diff options
author | Alan Aguiar <alanjas@hotmail.com> | 2013-08-11 22:46:17 (GMT) |
---|---|---|
committer | Alan Aguiar <alanjas@hotmail.com> | 2013-08-11 22:46:17 (GMT) |
commit | e7973f02f5509a975f44360de9cd82c6a04f991b (patch) | |
tree | c1f912e8aafd24f795ec07fd3e10b0082d91894f /src | |
parent | e52c589d7edda351b0d61145df2a692c02dbbcc5 (diff) |
some improves in hall view
Diffstat (limited to 'src')
-rwxr-xr-x | src/api/Button.py | 4 | ||||
-rwxr-xr-x | src/api/Sprite.py | 29 | ||||
-rw-r--r-- | src/assets/images/hall/A1-Pasillo-2.png | bin | 0 -> 855490 bytes | |||
-rw-r--r-- | src/assets/images/hall/A1-Pasillo-3.png | bin | 0 -> 851658 bytes | |||
-rw-r--r-- | src/assets/images/hall/A1-Pasillo-4.png | bin | 0 -> 875316 bytes | |||
-rw-r--r-- | src/assets/images/hall/A1-Pasillo-5.png | bin | 0 -> 852463 bytes | |||
-rw-r--r-- | src/assets/images/hall/A1-Pasillo-6.png | bin | 0 -> 856951 bytes | |||
-rw-r--r-- | src/assets/images/hall/arrow.png | bin | 0 -> 3170 bytes | |||
-rw-r--r-- | src/game/BoyHall.py | 14 | ||||
-rw-r--r-- | src/game/HallState.py | 61 |
10 files changed, 76 insertions, 32 deletions
diff --git a/src/api/Button.py b/src/api/Button.py index f78cda2..c16855f 100755 --- a/src/api/Button.py +++ b/src/api/Button.py @@ -33,12 +33,12 @@ class CButton(CLabel): def update(self):
CLabel.update(self)
- self.mclicked = False
-
#TODO: Make a CMouse class and check for isPressed() and click().
#check for mouse input
+ self.mclicked = False
+
if CMouse().firstPress():
if self.rect.collidepoint(CMouse().getPos()):
print("first press in button")
diff --git a/src/api/Sprite.py b/src/api/Sprite.py index 6cfa895..6cd48be 100755 --- a/src/api/Sprite.py +++ b/src/api/Sprite.py @@ -91,7 +91,10 @@ class CSprite(pygame.sprite.Sprite): # Angle of rotation in degrees of the sprite image (usually the same as mAngle).
self.mRotation = 0
- self.pressed = False
+ #self.pressed = False
+ self.mactive = False
+ self.mclicked = False
+
self.states = {}
self.currentState = "default"
@@ -150,6 +153,22 @@ class CSprite(pygame.sprite.Sprite): self.mPos.add(self.mVel)
self.calculatePositionWithOffset()
+
+ self.mclicked = False
+
+ if CMouse().firstPress():
+ if self.rect.collidepoint(CMouse().getPos()):
+ #print("first press in button")
+ self.mactive = True
+
+ #check for mouse release
+ if self.mactive == True:
+ if CMouse().release():
+ self.mactive = False
+ if self.rect.collidepoint(CMouse().getPos()):
+ #print("release in button")
+ self.mclicked = True
+
#---------------------------------------------------------------------------
# updateLogic().
@@ -417,12 +436,13 @@ class CSprite(pygame.sprite.Sprite): """ Boolean function. Returns True only if mouse
is pressed and released over sprite
"""
- released = False
+ """released = False
if self.pressed:
if (not CMouse().pressed()):
if self.rect.collidepoint(CMouse().getPos()):
released = True
- return released
+ return released"""
+ return self.mclicked
def collidesWith(self, target):
""" boolean function. Returns True if the sprite
@@ -440,8 +460,7 @@ class CSprite(pygame.sprite.Sprite): returns result of collision check (sprite from group
that was hit or None)
"""
- collision = pygame.sprite.spritecollideany(self, target)
- return collision
+ return pygame.sprite.spritecollideany(self, target)
def distanceTo(self, point):
""" returns distance to any point in pixels
diff --git a/src/assets/images/hall/A1-Pasillo-2.png b/src/assets/images/hall/A1-Pasillo-2.png Binary files differnew file mode 100644 index 0000000..929674a --- /dev/null +++ b/src/assets/images/hall/A1-Pasillo-2.png diff --git a/src/assets/images/hall/A1-Pasillo-3.png b/src/assets/images/hall/A1-Pasillo-3.png Binary files differnew file mode 100644 index 0000000..44c55ee --- /dev/null +++ b/src/assets/images/hall/A1-Pasillo-3.png diff --git a/src/assets/images/hall/A1-Pasillo-4.png b/src/assets/images/hall/A1-Pasillo-4.png Binary files differnew file mode 100644 index 0000000..e6663ab --- /dev/null +++ b/src/assets/images/hall/A1-Pasillo-4.png diff --git a/src/assets/images/hall/A1-Pasillo-5.png b/src/assets/images/hall/A1-Pasillo-5.png Binary files differnew file mode 100644 index 0000000..49873c7 --- /dev/null +++ b/src/assets/images/hall/A1-Pasillo-5.png diff --git a/src/assets/images/hall/A1-Pasillo-6.png b/src/assets/images/hall/A1-Pasillo-6.png Binary files differnew file mode 100644 index 0000000..fc9bde0 --- /dev/null +++ b/src/assets/images/hall/A1-Pasillo-6.png diff --git a/src/assets/images/hall/arrow.png b/src/assets/images/hall/arrow.png Binary files differnew file mode 100644 index 0000000..eca31dd --- /dev/null +++ b/src/assets/images/hall/arrow.png diff --git a/src/game/BoyHall.py b/src/game/BoyHall.py index 0b37586..7720909 100644 --- a/src/game/BoyHall.py +++ b/src/game/BoyHall.py @@ -51,6 +51,8 @@ class CBoyHall(CSprite): mDestX = 0 mDestY = 0 + mLastSense = 1 + def __init__(self): CSprite.__init__(self) @@ -93,7 +95,7 @@ class CBoyHall(CSprite): self.setXY(aOrigin.getX(), aOrigin.getY()) def set_destine(self, aDestine): - self.mDest = aDestine + self.mDest = aDestine def update(self): @@ -114,8 +116,7 @@ class CBoyHall(CSprite): return if (self.mAnim.frameHasChanged()): - f = self.mAnim.getCurrentFrame() - self.setImage(self.mFrameImage[f]) + self.setImage(self.mFrameImage[self.mAnim.getCurrentFrame()]) elif (self.mState == self.STATE_STALE): if CMouse().firstPress(): @@ -138,7 +139,10 @@ class CBoyHall(CSprite): if (aState == self.STATE_STALE): self.setVelXY(0, 0) - self.setImage(self.mFrameImage[1]) + if self.mLastSense == 0: + self.setImage(self.mFrameImage[4]) + else: + self.setImage(self.mFrameImage[1]) self.mAnim.init(1, 3, False) print 'set stale' @@ -158,9 +162,11 @@ class CBoyHall(CSprite): if x < 0: self.setImage(self.mFrameImage[3]) self.mAnim.init(6, 3, True, 3) + self.mLastSense = 0 else: self.setImage(self.mFrameImage[0]) self.mAnim.init(3, 3, True, 0) + self.mLastSense = 1 print 'set walk' self.mState = aState diff --git a/src/game/HallState.py b/src/game/HallState.py index 9d4908a..94f586e 100644 --- a/src/game/HallState.py +++ b/src/game/HallState.py @@ -31,7 +31,8 @@ import pygame class CHallState(CGameState): - mBackground = None + mBackground = None + mBackgroundList = [] mInstructions = None #mX = 10 mButtonBack = None @@ -40,7 +41,7 @@ class CHallState(CGameState): mArea1 = None - mFrameDoor0101 = [] + #mFrameDoor0101 = [] AREA1_POLYGON = [(402,94), (961,94), (961,631), (402,631)] @@ -64,34 +65,37 @@ class CHallState(CGameState): self.mButtonBack.set_text("Volver") #_('BACK Credits') CGame().addChild(self.mButtonBack) - self.mBackground = CImage.loadImage('assets/images/hall/A1-Pasillo-1.png', False) - CGame().setBackground(self.mBackground) + self.mBackgroundList.append(CImage.loadImage('assets/images/hall/A1-Pasillo-1.png', False)) + self.mBackgroundList.append(CImage.loadImage('assets/images/hall/A1-Pasillo-2.png', False)) + self.mBackgroundList.append(CImage.loadImage('assets/images/hall/A1-Pasillo-3.png', False)) + self.mBackgroundList.append(CImage.loadImage('assets/images/hall/A1-Pasillo-4.png', False)) + self.mBackgroundList.append(CImage.loadImage('assets/images/hall/A1-Pasillo-5.png', False)) + self.mBackgroundList.append(CImage.loadImage('assets/images/hall/A1-Pasillo-6.png', False)) + + CGame().setBackground(self.mBackgroundList[self.mCurrentSelectedArea]) self.mDoor = CSprite() self.mDoor.setXY(400, 50) - self.mFrameImageDoor = Image.loadImage('assets/images/hall/A1-puerta-resaltada.png', True) + self.mFrameImageDoor = Image.loadImage('assets/images/hall/A1-puerta-resaltada.png') self.mDoor.setImage(self.mFrameImageDoor) self.mDoorIs = False + + self.mLeftArrow = CSprite() + self.mLeftArrow.setXY(10, 400) + self.mImageLeftArrow = Image.loadImage('assets/images/hall/arrow.png') + self.mLeftArrow.setImage(self.mImageLeftArrow) + CGame().addChild(self.mLeftArrow) + + self.mRightArrow = CSprite() + self.mRightArrow.setXY(1060, 400) + self.mImageRightArrow = pygame.transform.flip(self.mImageLeftArrow, True, False) + self.mRightArrow.setImage(self.mImageRightArrow) + CGame().addChild(self.mRightArrow) self.mPlayer = CBoyHall() CGame().addChild(self.mPlayer) - """self.mText = CMultiLabel() - self.mText.textLines = [ - "dlkjfkljflk dslkdsj dsl", - "lkjdkldjdslk dslkdjd ", - "sadsakjd salkdjsa.", - "", - "dsalkjd ksajdlksjd lsk" - "dskldsjfkjd f d."] - - self.mText.size = (400, 300) - self.mText.fgColor = (0xFF, 0xFF, 0xFF) - self.mText.bgColor = (0, 0, 0) - self.mText.center = (320, 200) - self.mText.createImage() - CGame().addChild(self.mText)""" def update(self): #print "menu update" @@ -103,7 +107,22 @@ class CHallState(CGameState): CGame().setState(ms) return - if (CMath.pointInsidePolygon(CMouse().getX(), CMouse().getY(), self.AREA1_POLYGON)): + elif self.mLeftArrow.clicked(): + print 'previous game' + self.mCurrentSelectedArea = self.mCurrentSelectedArea - 1 + CGame().setBackground(self.mBackgroundList[self.mCurrentSelectedArea]) + self.mPlayer.mDestX = 1000 + self.mPlayer.setXY(1400, 500) + #self.mPlayer.setState(1) + + elif self.mRightArrow.clicked(): + print 'next game' + self.mCurrentSelectedArea = self.mCurrentSelectedArea + 1 + CGame().setBackground(self.mBackgroundList[self.mCurrentSelectedArea]) + self.mPlayer.mDestX = 200 + self.mPlayer.setXY(-200, 500) + + elif (CMath.pointInsidePolygon(CMouse().getX(), CMouse().getY(), self.AREA1_POLYGON)): if not(self.mDoorIs): CGame().addChild(self.mDoor) self.mDoorIs = True |