Skip to content

Commit

Permalink
im sam and im a dummyhead
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoodspeed committed Apr 30, 2012
1 parent f89cd32 commit 0870d5a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions core/collisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ def collisionCheck(game,player,level):
if player.sprite.doorChange:
for door, player in groupcollide(level.doors, player, False, False).items():
game.nextLevel = door.nextLevel
door.open()
game.changing = True

13 changes: 7 additions & 6 deletions core/level.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def clean(self):
if not self.cleaned:
self.cleaned = True
self.image = self.cleanImage




## Tilesheet class
class TileSheet(object):
Expand All @@ -82,8 +81,8 @@ def render(self, data):
solidTileGroup = Group()
dirtyTileGroup = Group()
doorGroup = Group()


doorImage = self.tilemap.get(DOOR)
openImage = self.tilemap.get(OPENDOOR)
# Loop through the .lvl file
for y, row in enumerate(data):
tileOffset = 0
Expand All @@ -102,10 +101,12 @@ def render(self, data):
tile = DirtyTile(tileImage, cleanImage, x*self.w-tileOffset, y*self.h, cell) # We need to assign a secondary image here where it says tileImage the second time that will display when it's cleaned
dirtyTileGroup.add(tile)
else:
if cell == "o": # o = door
if cell == DOOR: # o = door
nextLevel = row[x+1]
door = Door(nextLevel, (x*self.w-tileOffset, y*self.h))
door = Door(nextLevel, (x*self.w-tileOffset, y*self.h),doorImage,openImage)
doorGroup.add(door)


tile = Tile(tileImage, isSolid, x*self.w-tileOffset, y*self.h, cell)
if isSolid:
solidTileGroup.add(tile)
Expand Down
7 changes: 6 additions & 1 deletion core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
".": (192,96),
"&": (32,32),
"o": (0,0),
"D": (50,55),
",": (69,69),
"CLEAN1": (96,96)
"CLEAN1": (96,96),
"OPENDOOR": (40,40)
}
TILE_SOLIDS = [ ".",
"&",
Expand All @@ -24,6 +26,9 @@

DIRTY_TILES_CLEAN = {",": "CLEAN1"}

DOOR = "o"
OPENDOOR = "D"

### PLAYER
PLAYER_SIZE = PLY_W, PLY_H = T_W, T_H*2.2
PLAYER_START = PLAYER_START_X, PLAYER_START_Y = 100, 504
Expand Down
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def on_keydown(self, event):
self.mel = True
elif event.key == K_UP and not self.player.doorChange:
self.player.doorChange = True

elif event.key == K_DOWN:
self.player.cleaning = True
self.player.cleaningSlowdown = CLEAN_SLOWDOWN
Expand Down
12 changes: 8 additions & 4 deletions world/door.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@


class Door(Sprite):
def __init__(self, nextLevel, loc):
def __init__(self, nextLevel, loc,image,openImage):
Sprite.__init__(self)
self.rect = Rect(loc, TILE_SIZE)
self.image = Surface(self.rect.size)
draw.rect(self.image, (255,0,255), self.image.get_rect()) ## REPLACE THIS WITH AN IMAGE
self.openImage = openImage

self.image = image
self.rect = self.image.get_rect()
self.rect.topleft = loc
self.nextLevel = nextLevel

def draw(self, surface):
surface.blit(self.image, (self.rect.topleft))
def open(self):
self.image = self.openImage

0 comments on commit 0870d5a

Please sign in to comment.