The following works with both under python 3.4.0, etc, as above, though the
SDL2 version is slow.

import sys
import pygame
# or import pygame_sdl2 as pygame
pygame.init()

window_size = width, height = (800, 600)
speed = [5, 5]
background = (255, 144, 0) #colour. red, green and blue.

screen = pygame.display.set_mode(window_size)

ball = pygame.image.load("ball.gif")
ballrect = ball.get_rect()

keep_going = True

try: #get ready to deal with any problems
  while keep_going:
    for event in pygame.event.get():
      if event.type == pygame.QUIT:
        keep_going = False #exit the loop

    ballrect = ballrect.move(speed)
    if ballrect.left < 0 or ballrect.right > width:
      speed[0] = -speed[0]
    if ballrect.top < 0 or ballrect.bottom > height:
      speed[1] = -speed[1]

    screen.fill(background)
    screen.blit(ball, ballrect)
    pygame.display.flip()
except:
  raise #show what went wrong
finally:
  pygame.display.quit() #close the window


On 6 April 2015 at 19:15, Russell Jones <russell.jo...@gmail.com> wrote:

> I just installed it under 3.4.0 on Ubuntu 14.04 in a VE with "pip install
> hg+https://bitbucket.org/pygame/pygame"; though I've not tested the build
> beyond importing the module. Are you using Homebrew or MacPorts at all?
> MacPorts has 1.9.1 as py27-game. I don't know about the status of the
> module in Homebrew. If you're happy to experiment, you might try
> pygame-sdl2 by Tom Rothamel et al at https://github.com/renpy/pygame_sdl2
> I'm trying it now. I used pyvenv-3.4 --system-site-packages py340ve and
> "pip install --upgrade cython ; pip install --upgrade
> git+https://github.com/renpy/pygame_sdl2.git"; Again, no testing beyond
> importing the module.
>
> If you try the SDL2 version and are using MacPorts, note this problem
> https://trac.macports.org/ticket/42406 which seems to be a general thing
> with the MP GCCs. I'm not sure why they don't patch GCC to include
> /opt/local/lib in the compiler library path by default.
>
> Russell
>
> On 6 April 2015 at 19:02, Eryn Wells <e...@erynwells.me> wrote:
>
>> OS X 10.10.2, and Python 2.7 I think. I'm away from the machine I was
>> trying to install on earlier. I was trying to install in a virtualenv.
>> Is that supported? And last I checked, Pygame was 2.x only. Is that
>> still true?
>>
>> On Mon, Apr 6, 2015 at 10:48 AM, Russell Jones <russell.jo...@gmail.com>
>> wrote:
>> > I am, yes. There's a(n old) version here:
>> >
>> http://web.archive.org/web/20140227121133/http://www.pygame.org/install.html
>> >
>> > What OS and Python version are you using?
>> >
>> > Russell
>> >
>> > On 6 April 2015 at 17:07, Eryn Wells <e...@erynwells.me> wrote:
>> >>
>> >> Hi all,
>> >>
>> >> I've been trying to find information about how to install Pygame. I'm
>> >> getting a 404 error when I try to access the install documentation at
>> >> http://www.pygame.org/install.html . Is anyone else seeing  this?
>> >>
>> >> Thanks!
>> >> Eryn
>> >
>> >
>>
>
>

Reply via email to