Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcoolestdude1 <arielzamparini@gmail.com>2010-02-18 11:28:03 (GMT)
committer coolestdude1 <arielzamparini@gmail.com>2010-02-18 11:28:03 (GMT)
commitd1060817004a0039676fbbfbdc493e40603db014 (patch)
tree9d9d327ccff6198d488833bafa6e546327e3d878
parente6270fe585a7a6fdbefe5d9c58ff2d902b4013b0 (diff)
added in broken rotation to the block press space to break
-rw-r--r--blocku.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/blocku.py b/blocku.py
index 1343bb1..5ccf4ac 100644
--- a/blocku.py
+++ b/blocku.py
@@ -67,8 +67,10 @@ class Block(pygame.sprite.Sprite):
self.west = west
def update(self):
+ #keep the block on the screen
self.rect = self.rect.clamp(SCREENRECT)
# game logic here for snapping to grid ...?
+ # when the block is snapped to the grid clamp the rect there
def move(self, direction):
# up = 0, right = 1, down = 2, left = 3
if direction == 0:
@@ -79,14 +81,19 @@ class Block(pygame.sprite.Sprite):
self.rect.move_ip(0,KEYBOARDMOVESPEED)
if direction == 3:
self.rect.move_ip(-KEYBOARDMOVESPEED,0)
- #keep the block on the screen
+
def grab(self, pos):
x, y = pos;
#print x , y
#print self.rect.left, self.rect.top
#self.rect = self.rect.move(x, y)
+ #remember the offset here is 32 as this will center the mouse in our 64pixel image
self.rect.left = x-32
self.rect.top = y-32
+ def rotate(self, angle):
+ global debugText
+ debugText = 'trying to rotate'
+ self.image = pygame.transform.rotate(self.image,angle)
class Puzzle:
def __init__(self):
@@ -170,9 +177,11 @@ class Game:
Block.containers = blocks,spriteBatch
aBlock = Block()
+ global debugText
+ debugText = ''
#see if there is a sprite font
if pygame.font:
- spriteBatch.add(Text(''))
+ spriteBatch.add(Text('Drawing call test '))
spriteBatch.add(mouseUpdate())
# it is important to note that like xna the origin is 0,0
@@ -215,13 +224,19 @@ class Game:
aBlock.move(2)
if keystate[K_LEFT]:
aBlock.move(3)
-
+ if keystate[K_SPACE]:
+ aBlock.rotate(3)
+
#for block in blocks:
x, y = mouse.get_pos()
- #blockx, blocky = block.rect
+
if event.get_grab():
+ debugText = 'holding mouse button 1'
if aBlock.rect.collidepoint(x,y):
aBlock.grab(mouse.get_pos())
+ debugText += 'grabed the block'
+ else:
+ debugText = ''
# note random here is random.random()
# note foreach here is for object in
@@ -234,7 +249,7 @@ class Game:
class Text(pygame.sprite.Sprite):
text = ''
- def __init__(self,txt):
+ def __init__(self,txt=''):
pygame.sprite.Sprite.__init__(self)
self.font = pygame.font.Font(None, 20)
self.font.set_italic(1)
@@ -244,7 +259,8 @@ class Text(pygame.sprite.Sprite):
self.text = txt
def update(self):
- msg = 'Drawing call test ' + self.text
+ global debugText
+ msg = self.text + debugText
self.image = self.font.render(msg, 0, self.color)
class mouseUpdate(pygame.sprite.Sprite):