diff options
author | coolestdude1 <arielzamparini@gmail.com> | 2010-02-24 20:25:22 (GMT) |
---|---|---|
committer | coolestdude1 <arielzamparini@gmail.com> | 2010-02-24 20:25:22 (GMT) |
commit | 8b24b119282531bbdf651b5e747dbc9ad052291b (patch) | |
tree | 4a627b3c823de0a2a11db32f600e55f535a30f50 | |
parent | 3bc2155085bf183977e10ce37eb5debc24e005b3 (diff) |
added in a grid and a second block with m/ handling
-rw-r--r-- | blocku.py | 14 | ||||
-rw-r--r-- | data/Thumbs.db | bin | 8704 -> 11776 bytes | |||
-rw-r--r-- | data/grid.png | bin | 0 -> 617 bytes |
3 files changed, 9 insertions, 5 deletions
@@ -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 Binary files differindex 90215a3..5a1ee92 100644 --- a/data/Thumbs.db +++ b/data/Thumbs.db diff --git a/data/grid.png b/data/grid.png Binary files differnew file mode 100644 index 0000000..563c13f --- /dev/null +++ b/data/grid.png |