diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/game.iml b/.idea/game.iml
new file mode 100644
index 0000000..8b8c395
--- /dev/null
+++ b/.idea/game.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..302b49b
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..ffbc64a
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/game.py b/game.py
index e753032..f64763a 100644
--- a/game.py
+++ b/game.py
@@ -14,7 +14,7 @@
#You were importing all widgets anyway, and there was an unknown error.
class Game(object):
- print "Setting global Game params."
+ print("Setting global Game params.")
# Game parameters
BG_TILE_IMG = 'images/wood2.png'
BUTTON_BGIMG = 'images/x.png'
@@ -28,7 +28,7 @@ class Game(object):
def __init__(self):
pygame.init()
- print "Pygame started."
+ print("Pygame started.")
#set up screen and background
self.screen = pygame.display.set_mode(
@@ -38,7 +38,7 @@ def __init__(self):
#Drawing a handy MessageBoard widget
#Can use these for any text.
- print "Configuring tboard MessageBoard params."
+ print("Configuring tboard MessageBoard params.")
self.tboard_text = ['This is a test.']
self.tboard_x = 120
self.tboard_y = 120
@@ -49,93 +49,93 @@ def __init__(self):
self.tboard = MessageBoard(self.screen,
rect=self.tboard_rect,
bgcolor=self.tboard_bgcolor,
- border_width=4,
+ border_width=4,
border_color=pygame.Color('black'),
text=self.tboard_text,
padding=5,
font=('comic sans', 18),
font_color=pygame.Color('yellow'))
- print "Moving on to buttons..."
-
- self.button_bgimgs = ['images/x.png']
- #self.button_width = self.button_bgimgs[0].get_width()
- #self.button_height = self.button_bgimgs[0].get_height()
-
- #hopefully this will draw the button -15 pixels from the right end, +15 from the top
- #(hopefully giving us a nice X)
- # should be replaced in the future with a method that returns the coords for an x button
- # in whatever corner we want.
- #self.button_rect = Rect(self.tboard_width, self.tboard_y-15, self.button_width, self.button_height)
- self.button = Button(self.screen,
- pos=vec2d(self.tboard_width, self.tboard_y-15),
- btntype='Close',
- imgnames=self.button_bgimgs,
- attached=self.tboard)
-
- print "Created close button."
-
- self.togglebtn_bgimgs = ['images/toggle1.png', 'images/toggle2.png']
-
- self.togglebtn = Button(self.screen,
- pos=vec2d(250, 250),
- btntype='Toggle',
- imgnames=self.togglebtn_bgimgs,
- attached="",
- text="Toggle",
- textcolor=(255,255,255))
-
- print "Created toggle button."
-
- self.clockImg = Images(self.screen,
- 'images/clock.png',
- pos=vec2d(430,0))
-
- self.hand = Images(self.screen,
- 'images/secondHand.png',
- pos=vec2d(505,15),
- imgtype='Spinner')
-
- self.textTest = textEntry(self.screen,
- pos=vec2d(0, self.SCREEN_HEIGHT-50),
- size=vec2d(self.SCREEN_WIDTH,50))
-
- self.floater = movingRect(self.screen,
- pos=vec2d(self.SCREEN_WIDTH/2, 0),
- speed=vec2d(0,5))
-
- self.moveImg = movingImg(self.screen,
- "images/toggle1.png",
- pos=vec2d(0,self.SCREEN_HEIGHT*3/4),
- speed=vec2d(5, 0))
-
- self.ball = circles(self.screen,
- pos=vec2d(25,25),
- radius = 25)
-
- self.buttons = [self.togglebtn]
- self.textEntries = [self.textTest]
-
- self.world = [self.button, self.togglebtn, self.clockImg, self.hand, self.textTest, self.moveImg, self.floater, self.ball]
-
- self.clock = pygame.time.Clock()
- self.paused = False
-
- #spawning entities
-
- #Setting up gamefield
- #need a method for dynamically figuring out how many rows/columns we need based on
- #the spacing we want and field size. Using some constants for now.
- self.grid_nrows = 30
- self.grid_ncols = 30
-
- self.field_rect = pygame.Rect(0, 0, self.SCREEN_WIDTH, self.SCREEN_HEIGHT)
-
- self.options = dict(debug=True,
- draw_grid=False)
-
- print "Done setting game options, exiting Game init."
-
+ print("Moving on to buttons...")
+
+ self.button_bgimgs = ['images/x.png']
+ #self.button_width = self.button_bgimgs[0].get_width()
+ #self.button_height = self.button_bgimgs[0].get_height()
+
+ #hopefully this will draw the button -15 pixels from the right end, +15 from the top
+ #(hopefully giving us a nice X)
+ # should be replaced in the future with a method that returns the coords for an x button
+ # in whatever corner we want.
+ #self.button_rect = Rect(self.tboard_width, self.tboard_y-15, self.button_width, self.button_height)
+ self.button = Button(self.screen,
+ pos=vec2d(self.tboard_width, self.tboard_y-15),
+ btntype='Close',
+ imgnames=self.button_bgimgs,
+ attached=self.tboard)
+
+ print("Created close button.")
+
+ self.togglebtn_bgimgs = ['images/toggle1.png', 'images/toggle2.png']
+
+ self.togglebtn = Button(self.screen,
+ pos=vec2d(250, 250),
+ btntype='Toggle',
+ imgnames=self.togglebtn_bgimgs,
+ attached="",
+ text="Toggle",
+ textcolor=(255,255,255))
+
+ print("Created toggle button.")
+
+ self.clockImg = Images(self.screen,
+ 'images/clock.png',
+ pos=vec2d(430,0))
+
+ self.hand = Images(self.screen,
+ 'images/secondHand.png',
+ pos=vec2d(505,15),
+ imgtype='Spinner')
+
+ self.textTest = textEntry(self.screen,
+ pos=vec2d(0, self.SCREEN_HEIGHT-50),
+ size=vec2d(self.SCREEN_WIDTH,50))
+
+ self.floater = movingRect(self.screen,
+ pos=vec2d(self.SCREEN_WIDTH/2, 0),
+ speed=vec2d(0,5))
+
+ self.moveImg = movingImg(self.screen,
+ "images/toggle1.png",
+ pos=vec2d(0,self.SCREEN_HEIGHT*3/4),
+ speed=vec2d(5, 0))
+
+ self.ball = circles(self.screen,
+ pos=vec2d(25,25),
+ radius = 25)
+
+ self.buttons = [self.togglebtn]
+ self.textEntries = [self.textTest]
+
+ self.world = [self.button, self.togglebtn, self.clockImg, self.hand, self.textTest, self.moveImg, self.floater, self.ball]
+
+ self.clock = pygame.time.Clock()
+ self.paused = False
+
+ #spawning entities
+
+ #Setting up gamefield
+ #need a method for dynamically figuring out how many rows/columns we need based on
+ #the spacing we want and field size. Using some constants for now.
+ self.grid_nrows = 30
+ self.grid_ncols = 30
+
+ self.field_rect = pygame.Rect(0, 0, self.SCREEN_WIDTH, self.SCREEN_HEIGHT)
+
+ self.options = dict(debug=True,
+ draw_grid=False)
+
+ print("Done setting game options, exiting Game init.")
+
def xy2coord(self, pos):
""" Convert a (x, y) pair to a (nrow, ncol) coordinate
"""
@@ -190,14 +190,14 @@ def draw(self):
#decide if we should draw grid.
if self.options['draw_grid']:
self.draw_grid()
-
+
self.tboard.draw()
-
- for obj in self.world:
- obj.draw()
+
+ for obj in self.world:
+ obj.draw()
def run(self):
- print "Beginning run sequence."
+ print("Beginning run sequence.")
# The main game loop
#
while True:
@@ -215,30 +215,30 @@ def run(self):
if self.time_passed > 100:
continue
- active = False
- for entry in self.textEntries:
- if entry.clicked:
- active = True
+ active = False
+ for entry in self.textEntries:
+ if entry.clicked:
+ active = True
#Event loop. In-game control is routed through here
#Will probably need something more robust soon.
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- self.quit()
- elif event.type == pygame.KEYDOWN and not active:
- if event.key == pygame.K_SPACE:
- self.paused = not self.paused
- elif event.key == pygame.K_g:
- #toggle draw grid
- self.options['draw_grid'] = not self.options['draw_grid']
- elif (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1):
- for button in self.buttons:
- button.mouse_click_event(event.pos)
- for entry in self.textEntries:
- entry.mouse_click_event(event.pos)
+ for event in pygame.event.get():
+ if event.type == pygame.QUIT:
+ self.quit()
+ elif event.type == pygame.KEYDOWN and not active:
+ if event.key == pygame.K_SPACE:
+ self.paused = not self.paused
+ elif event.key == pygame.K_g:
+ # toggle draw grid
+ self.options['draw_grid'] = not self.options['draw_grid']
+ elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
+ for button in self.buttons:
+ button.mouse_click_event(event.pos)
+ for entry in self.textEntries:
+ entry.mouse_click_event(event.pos)
- #pass temporarily disabled, don't think it does anything
+ #pass temporarily disabled, don't think it does anything
- #entity events here.
+ #entity events here.
#update hud, counters, score, anything like that here
if not self.paused:
@@ -258,7 +258,7 @@ def quit(self):
if __name__ == "__main__":
- print "Creating game object..."
+ print("Creating game object...")
game = Game()
- print "Done. Starting run method"
+ print("Done. Starting run method")
game.run()