Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/test/TestGame.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/TestGame.py')
-rwxr-xr-xtest/TestGame.py35
1 files changed, 18 insertions, 17 deletions
diff --git a/test/TestGame.py b/test/TestGame.py
index d9dbc2e..223c675 100755
--- a/test/TestGame.py
+++ b/test/TestGame.py
@@ -2,6 +2,7 @@
import pygame
import gtk
+
class TestGame:
def __init__(self):
# Set up a clock for managing the frame rate.
@@ -14,7 +15,7 @@ class TestGame:
self.vy = 0
self.paused = False
-
+
def set_paused(self, paused):
self.paused = paused
@@ -25,11 +26,11 @@ class TestGame:
# Called to load the state of the game from the Journal.
def read_file(self, file_path):
pass
-
+
# The main game loop.
def run(self):
- self.running = True
-
+ self.running = True
+
screen = pygame.display.get_surface()
while self.running:
@@ -43,40 +44,40 @@ class TestGame:
return
elif event.type == pygame.VIDEORESIZE:
pygame.display.set_mode(event.size, pygame.RESIZABLE)
-
+
# Move the ball
if not self.paused:
self.x += self.vx
if self.x > screen.get_width() + 100:
self.x = -100
-
+
self.y += self.vy
if self.y > screen.get_height() - 100:
self.y = screen.get_height() - 100
self.vy = -self.vy
-
- self.vy += 5;
-
+
+ self.vy += 5
+
# Clear Display
- screen.fill((255,255,255)) #255 for white
+ screen.fill((255, 255, 255)) # 255 for white
# Draw the ball
- pygame.draw.circle(screen, (255,0,0), (self.x, self.y), 100)
-
+ pygame.draw.circle(screen, (255, 0, 0), (self.x, self.y), 100)
+
# Flip Display
- pygame.display.flip()
-
+ pygame.display.flip()
+
# Try to stay at 30 FPS
self.clock.tick(30)
+
# This function is called when the game is run directly from the command line:
-# ./TestGame.py
+# ./TestGame.py
def main():
pygame.init()
pygame.display.set_mode((0, 0), pygame.RESIZABLE)
- game = TestGame()
+ game = TestGame()
game.run()
if __name__ == '__main__':
main()
-