From 8b24b119282531bbdf651b5e747dbc9ad052291b Mon Sep 17 00:00:00 2001 From: coolestdude1 Date: Wed, 24 Feb 2010 20:25:22 +0000 Subject: added in a grid and a second block with m/ handling --- diff --git a/blocku.py b/blocku.py index 2152057..b5fb014 100644 --- a/blocku.py +++ b/blocku.py @@ -57,10 +57,10 @@ class Block(pygame.sprite.Sprite): east='' south='' west='' - def __init__(self, n='', e='', s='', w=''): + def __init__(self, n='', e='', s='', w='', x='', y=''): pygame.sprite.Sprite.__init__(self, self.containers) self.image = self.images[0].copy() - self.rect = pygame.Rect(200,200,64,64) + self.rect = pygame.Rect(x,y,64,64) self.font = pygame.font.Font(None, 20) self.font.set_italic(1) self.color = Color('blue') @@ -187,7 +187,8 @@ class Game: #main blocku code structs blocks = pygame.sprite.Group() Block.containers = blocks,spriteBatch - aBlock = Block(1,2,3,4) + aBlock = Block(1,2,3,4,200,200) + bBlock = Block(5,6,7,8,300,300) global debugText debugText = '' @@ -201,7 +202,7 @@ class Game: keyDown = False # it is important to note that like xna the origin is 0,0 # the top left of the current window - # print is trace in console + # print is trace in console # and increases as you go down and to the right # pygame has a collision detector under pygame.sprite.spritecollide(group,group,dokill) # this will return a list of colliders, dokill will remove the colliders from the parrent group if true @@ -252,7 +253,10 @@ class Game: debugText = 'holding mouse button 1' if aBlock.rect.collidepoint(x,y): aBlock.grab(mouse.get_pos()) - debugText += 'grabed the block' + debugText += 'grabed aBlock' + elif bBlock.rect.collidepoint(x,y): + bBlock.grab(mouse.get_pos()) + debugText += 'grabed bBlock' else: debugText = '' # note random here is random.random() diff --git a/data/Thumbs.db b/data/Thumbs.db index 90215a3..5a1ee92 100644 --- a/data/Thumbs.db +++ b/data/Thumbs.db Binary files differ diff --git a/data/grid.png b/data/grid.png new file mode 100644 index 0000000..563c13f --- /dev/null +++ b/data/grid.png Binary files differ -- cgit v0.9.1