Skip to content
Permalink
Browse files
Using spreadsheets
Using player/tiles spreadsheets and solved velocity bug  which made platforms move independly from each other.
  • Loading branch information
dacostag committed Apr 28, 2020
1 parent 858b8da commit 01e6fbdd63140c69cad07ef29b3c46ece340087c
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 23 deletions.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,174 @@
<TextureAtlas imagePath="sheet.png">
<SubTexture name="box.png" x="0" y="864" width="70" height="70"/>
<SubTexture name="boxAlt.png" x="0" y="792" width="70" height="70"/>
<SubTexture name="boxCoin.png" x="0" y="720" width="70" height="70"/>
<SubTexture name="boxCoinAlt.png" x="0" y="576" width="70" height="70"/>
<SubTexture name="boxCoinAlt_disabled.png" x="0" y="504" width="70" height="70"/>
<SubTexture name="boxCoin_disabled.png" x="0" y="648" width="70" height="70"/>
<SubTexture name="boxEmpty.png" x="0" y="432" width="70" height="70"/>
<SubTexture name="boxExplosive.png" x="0" y="360" width="70" height="70"/>
<SubTexture name="boxExplosiveAlt.png" x="0" y="216" width="70" height="70"/>
<SubTexture name="boxExplosive_disabled.png" x="0" y="288" width="70" height="70"/>
<SubTexture name="boxItem.png" x="0" y="144" width="70" height="70"/>
<SubTexture name="boxItemAlt.png" x="0" y="0" width="70" height="70"/>
<SubTexture name="boxItemAlt_disabled.png" x="432" y="432" width="70" height="70"/>
<SubTexture name="boxItem_disabled.png" x="0" y="72" width="70" height="70"/>
<SubTexture name="boxWarning.png" x="72" y="648" width="70" height="70"/>
<SubTexture name="brickWall.png" x="216" y="0" width="70" height="70"/>
<SubTexture name="bridge.png" x="216" y="72" width="70" height="70"/>
<SubTexture name="bridgeLogs.png" x="288" y="720" width="70" height="70"/>
<SubTexture name="castle.png" x="288" y="792" width="70" height="70"/>
<SubTexture name="castleCenter.png" x="504" y="288" width="70" height="70"/>
<SubTexture name="castleCenter_rounded.png" x="504" y="720" width="70" height="70"/>
<SubTexture name="castleCliffLeft.png" x="504" y="792" width="70" height="70"/>
<SubTexture name="castleCliffLeftAlt.png" x="648" y="720" width="70" height="70"/>
<SubTexture name="castleCliffRight.png" x="648" y="792" width="70" height="70"/>
<SubTexture name="castleCliffRightAlt.png" x="792" y="288" width="70" height="70"/>
<SubTexture name="castleHalf.png" x="792" y="360" width="70" height="70"/>
<SubTexture name="castleHalfLeft.png" x="432" y="720" width="70" height="70"/>
<SubTexture name="castleHalfMid.png" x="648" y="648" width="70" height="70"/>
<SubTexture name="castleHalfRight.png" x="792" y="648" width="70" height="70"/>
<SubTexture name="castleHillLeft.png" x="648" y="576" width="70" height="70"/>
<SubTexture name="castleHillLeft2.png" x="792" y="576" width="70" height="70"/>
<SubTexture name="castleHillRight.png" x="792" y="504" width="70" height="70"/>
<SubTexture name="castleHillRight2.png" x="792" y="432" width="70" height="70"/>
<SubTexture name="castleLedgeLeft.png" x="856" y="868" width="5" height="22"/>
<SubTexture name="castleLedgeRight.png" x="842" y="868" width="5" height="22"/>
<SubTexture name="castleLeft.png" x="792" y="216" width="70" height="70"/>
<SubTexture name="castleMid.png" x="792" y="144" width="70" height="70"/>
<SubTexture name="castleRight.png" x="792" y="72" width="70" height="70"/>
<SubTexture name="dirt.png" x="792" y="0" width="70" height="70"/>
<SubTexture name="dirtCenter.png" x="720" y="864" width="70" height="70"/>
<SubTexture name="dirtCenter_rounded.png" x="720" y="792" width="70" height="70"/>
<SubTexture name="dirtCliffLeft.png" x="720" y="720" width="70" height="70"/>
<SubTexture name="dirtCliffLeftAlt.png" x="720" y="648" width="70" height="70"/>
<SubTexture name="dirtCliffRight.png" x="720" y="576" width="70" height="70"/>
<SubTexture name="dirtCliffRightAlt.png" x="720" y="504" width="70" height="70"/>
<SubTexture name="dirtHalf.png" x="720" y="432" width="70" height="70"/>
<SubTexture name="dirtHalfLeft.png" x="720" y="360" width="70" height="70"/>
<SubTexture name="dirtHalfMid.png" x="720" y="288" width="70" height="70"/>
<SubTexture name="dirtHalfRight.png" x="720" y="216" width="70" height="70"/>
<SubTexture name="dirtHillLeft.png" x="720" y="144" width="70" height="70"/>
<SubTexture name="dirtHillLeft2.png" x="720" y="72" width="70" height="70"/>
<SubTexture name="dirtHillRight.png" x="720" y="0" width="70" height="70"/>
<SubTexture name="dirtHillRight2.png" x="648" y="864" width="70" height="70"/>
<SubTexture name="dirtLedgeLeft.png" x="842" y="892" width="5" height="18"/>
<SubTexture name="dirtLedgeRight.png" x="842" y="912" width="5" height="18"/>
<SubTexture name="dirtLeft.png" x="504" y="432" width="70" height="70"/>
<SubTexture name="dirtMid.png" x="504" y="360" width="70" height="70"/>
<SubTexture name="dirtRight.png" x="648" y="504" width="70" height="70"/>
<SubTexture name="door_closedMid.png" x="648" y="432" width="70" height="70"/>
<SubTexture name="door_closedTop.png" x="648" y="360" width="70" height="70"/>
<SubTexture name="door_openMid.png" x="648" y="288" width="70" height="70"/>
<SubTexture name="door_openTop.png" x="648" y="216" width="70" height="70"/>
<SubTexture name="fence.png" x="648" y="144" width="70" height="70"/>
<SubTexture name="fenceBroken.png" x="648" y="72" width="70" height="70"/>
<SubTexture name="grass.png" x="648" y="0" width="70" height="70"/>
<SubTexture name="grassCenter.png" x="576" y="864" width="70" height="70"/>
<SubTexture name="grassCenter_rounded.png" x="576" y="792" width="70" height="70"/>
<SubTexture name="grassCliffLeft.png" x="576" y="720" width="70" height="70"/>
<SubTexture name="grassCliffLeftAlt.png" x="576" y="648" width="70" height="70"/>
<SubTexture name="grassCliffRight.png" x="576" y="576" width="70" height="70"/>
<SubTexture name="grassCliffRightAlt.png" x="576" y="504" width="70" height="70"/>
<SubTexture name="grassHalf.png" x="576" y="432" width="70" height="70"/>
<SubTexture name="grassHalfLeft.png" x="576" y="360" width="70" height="70"/>
<SubTexture name="grassHalfMid.png" x="576" y="288" width="70" height="70"/>
<SubTexture name="grassHalfRight.png" x="576" y="216" width="70" height="70"/>
<SubTexture name="grassHillLeft.png" x="576" y="144" width="70" height="70"/>
<SubTexture name="grassHillLeft2.png" x="576" y="72" width="70" height="70"/>
<SubTexture name="grassHillRight.png" x="576" y="0" width="70" height="70"/>
<SubTexture name="grassHillRight2.png" x="504" y="864" width="70" height="70"/>
<SubTexture name="grassLedgeLeft.png" x="849" y="868" width="5" height="24"/>
<SubTexture name="grassLedgeRight.png" x="849" y="894" width="5" height="24"/>
<SubTexture name="grassLeft.png" x="504" y="648" width="70" height="70"/>
<SubTexture name="grassMid.png" x="504" y="576" width="70" height="70"/>
<SubTexture name="grassRight.png" x="504" y="504" width="70" height="70"/>
<SubTexture name="hill_large.png" x="842" y="720" width="48" height="146"/>
<SubTexture name="hill_largeAlt.png" x="864" y="0" width="48" height="146"/>
<SubTexture name="hill_small.png" x="792" y="828" width="48" height="106"/>
<SubTexture name="hill_smallAlt.png" x="792" y="720" width="48" height="106"/>
<SubTexture name="ladder_mid.png" x="504" y="144" width="70" height="70"/>
<SubTexture name="ladder_top.png" x="504" y="72" width="70" height="70"/>
<SubTexture name="liquidLava.png" x="504" y="0" width="70" height="70"/>
<SubTexture name="liquidLavaTop.png" x="432" y="864" width="70" height="70"/>
<SubTexture name="liquidLavaTop_mid.png" x="432" y="792" width="70" height="70"/>
<SubTexture name="liquidWater.png" x="504" y="216" width="70" height="70"/>
<SubTexture name="liquidWaterTop.png" x="432" y="648" width="70" height="70"/>
<SubTexture name="liquidWaterTop_mid.png" x="432" y="576" width="70" height="70"/>
<SubTexture name="lock_blue.png" x="432" y="504" width="70" height="70"/>
<SubTexture name="lock_green.png" x="72" y="576" width="70" height="70"/>
<SubTexture name="lock_red.png" x="432" y="360" width="70" height="70"/>
<SubTexture name="lock_yellow.png" x="432" y="288" width="70" height="70"/>
<SubTexture name="rockHillLeft.png" x="432" y="216" width="70" height="70"/>
<SubTexture name="rockHillRight.png" x="432" y="144" width="70" height="70"/>
<SubTexture name="ropeAttached.png" x="432" y="72" width="70" height="70"/>
<SubTexture name="ropeHorizontal.png" x="432" y="0" width="70" height="70"/>
<SubTexture name="ropeVertical.png" x="360" y="864" width="70" height="70"/>
<SubTexture name="sand.png" x="360" y="792" width="70" height="70"/>
<SubTexture name="sandCenter.png" x="576" y="864" width="70" height="70"/>
<SubTexture name="sandCenter_rounded.png" x="576" y="792" width="70" height="70"/>
<SubTexture name="sandCliffLeft.png" x="360" y="720" width="70" height="70"/>
<SubTexture name="sandCliffLeftAlt.png" x="360" y="648" width="70" height="70"/>
<SubTexture name="sandCliffRight.png" x="360" y="576" width="70" height="70"/>
<SubTexture name="sandCliffRightAlt.png" x="360" y="504" width="70" height="70"/>
<SubTexture name="sandHalf.png" x="360" y="432" width="70" height="70"/>
<SubTexture name="sandHalfLeft.png" x="360" y="360" width="70" height="70"/>
<SubTexture name="sandHalfMid.png" x="360" y="288" width="70" height="70"/>
<SubTexture name="sandHalfRight.png" x="360" y="216" width="70" height="70"/>
<SubTexture name="sandHillLeft.png" x="360" y="144" width="70" height="70"/>
<SubTexture name="sandHillLeft2.png" x="360" y="72" width="70" height="70"/>
<SubTexture name="sandHillRight.png" x="360" y="0" width="70" height="70"/>
<SubTexture name="sandHillRight2.png" x="288" y="864" width="70" height="70"/>
<SubTexture name="sandLedgeLeft.png" x="856" y="892" width="5" height="18"/>
<SubTexture name="sandLedgeRight.png" x="856" y="912" width="5" height="18"/>
<SubTexture name="sandLeft.png" x="288" y="648" width="70" height="70"/>
<SubTexture name="sandMid.png" x="288" y="576" width="70" height="70"/>
<SubTexture name="sandRight.png" x="288" y="504" width="70" height="70"/>
<SubTexture name="sign.png" x="288" y="432" width="70" height="70"/>
<SubTexture name="signExit.png" x="288" y="360" width="70" height="70"/>
<SubTexture name="signLeft.png" x="288" y="288" width="70" height="70"/>
<SubTexture name="signRight.png" x="288" y="216" width="70" height="70"/>
<SubTexture name="snow.png" x="288" y="144" width="70" height="70"/>
<SubTexture name="snowCenter.png" x="720" y="864" width="70" height="70"/>
<SubTexture name="snowCenter_rounded.png" x="288" y="72" width="70" height="70"/>
<SubTexture name="snowCliffLeft.png" x="288" y="0" width="70" height="70"/>
<SubTexture name="snowCliffLeftAlt.png" x="216" y="864" width="70" height="70"/>
<SubTexture name="snowCliffRight.png" x="216" y="792" width="70" height="70"/>
<SubTexture name="snowCliffRightAlt.png" x="216" y="720" width="70" height="70"/>
<SubTexture name="snowHalf.png" x="216" y="648" width="70" height="70"/>
<SubTexture name="snowHalfLeft.png" x="216" y="576" width="70" height="70"/>
<SubTexture name="snowHalfMid.png" x="216" y="504" width="70" height="70"/>
<SubTexture name="snowHalfRight.png" x="216" y="432" width="70" height="70"/>
<SubTexture name="snowHillLeft.png" x="216" y="360" width="70" height="70"/>
<SubTexture name="snowHillLeft2.png" x="216" y="288" width="70" height="70"/>
<SubTexture name="snowHillRight.png" x="216" y="216" width="70" height="70"/>
<SubTexture name="snowHillRight2.png" x="216" y="144" width="70" height="70"/>
<SubTexture name="snowLedgeLeft.png" x="863" y="868" width="5" height="18"/>
<SubTexture name="snowLedgeRight.png" x="863" y="888" width="5" height="18"/>
<SubTexture name="snowLeft.png" x="144" y="864" width="70" height="70"/>
<SubTexture name="snowMid.png" x="144" y="792" width="70" height="70"/>
<SubTexture name="snowRight.png" x="144" y="720" width="70" height="70"/>
<SubTexture name="stone.png" x="144" y="648" width="70" height="70"/>
<SubTexture name="stoneCenter.png" x="144" y="576" width="70" height="70"/>
<SubTexture name="stoneCenter_rounded.png" x="144" y="504" width="70" height="70"/>
<SubTexture name="stoneCliffLeft.png" x="144" y="432" width="70" height="70"/>
<SubTexture name="stoneCliffLeftAlt.png" x="144" y="360" width="70" height="70"/>
<SubTexture name="stoneCliffRight.png" x="144" y="288" width="70" height="70"/>
<SubTexture name="stoneCliffRightAlt.png" x="144" y="216" width="70" height="70"/>
<SubTexture name="stoneHalf.png" x="144" y="144" width="70" height="70"/>
<SubTexture name="stoneHalfLeft.png" x="144" y="72" width="70" height="70"/>
<SubTexture name="stoneHalfMid.png" x="144" y="0" width="70" height="70"/>
<SubTexture name="stoneHalfRight.png" x="72" y="864" width="70" height="70"/>
<SubTexture name="stoneHillLeft2.png" x="72" y="792" width="70" height="70"/>
<SubTexture name="stoneHillRight2.png" x="72" y="720" width="70" height="70"/>
<SubTexture name="stoneLedgeLeft.png" x="863" y="908" width="5" height="24"/>
<SubTexture name="stoneLedgeRight.png" x="864" y="148" width="5" height="24"/>
<SubTexture name="stoneLeft.png" x="72" y="504" width="70" height="70"/>
<SubTexture name="stoneMid.png" x="72" y="432" width="70" height="70"/>
<SubTexture name="stoneRight.png" x="72" y="360" width="70" height="70"/>
<SubTexture name="stoneWall.png" x="72" y="288" width="70" height="70"/>
<SubTexture name="tochLit.png" x="72" y="216" width="70" height="70"/>
<SubTexture name="tochLit2.png" x="72" y="144" width="70" height="70"/>
<SubTexture name="torch.png" x="72" y="72" width="70" height="70"/>
<SubTexture name="window.png" x="72" y="0" width="70" height="70"/>
</TextureAtlas>
15 main.py
@@ -6,6 +6,7 @@ from settings import *
from sprites import *
import os.path


class Game:
def __init__(self):
# initialize game window, etc
@@ -26,8 +27,8 @@ class Game:
def load_data(self):
self.dir = os.path.dirname(__file__)
img_dir = os.path.join(self.dir, 'img')
self.spritesheet = SpriteSheet(os.path.join(img_dir, player_spritesheet))

self.spritesheet1 = SpriteSheet(os.path.join(img_dir, spritesheet1))
self.spritesheet2 = SpriteSheet(os.path.join(img_dir, spritesheet2))

def new(self):
# starts a new game not a new program
@@ -37,7 +38,7 @@ class Game:
self.player = Player(self)
self.all_sprites.add(self.player)
for plat in platform_list:
p = Platform(*plat)
p = Platform(self, *plat)
self.all_sprites.add(p)
self.platforms.add(p)
self.run()
@@ -62,18 +63,18 @@ class Game:
self.player.vel.y = 0

# if player reaches 3/4 of width of the screen
if self.player.rect.x >= (width * 0.75):
if self.player.rect.x >= (width * 0.6):
self.player.pos.x -= abs(self.player.vel.x)
for plat in self.platforms:
plat.rect.x -= self.player.vel.x
# if player reaches goes left screen moves left 1/10
if self.player.rect.x <= (width * 0.1):
if self.player.rect.x <= (width * 0.2):
self.player.pos.x += abs(self.player.vel.x)
for plat in self.platforms:
plat.rect.x -= self.player.vel.x

# Die, by falling of the screen
if self.player.rect.bottom > height:
if self.player.rect.bottom > height + 20:
for sprite in self.all_sprites:
sprite.rect.y -= max(self.player.vel.y, 10)
self.playing = False
@@ -129,8 +130,6 @@ class Game:
if event.type == pygame.KEYUP:
waiting = False



def draw_text(self, text, size, color, x, y):
font = pygame.font.Font(self.font_name, size)
text_surface = font.render(text, True, color)
@@ -6,7 +6,8 @@ height = 425
fps = 30
basic_font = 'courier new.ttf'
textX, textY = 10, 10
player_spritesheet = "p2_spritesheet.png"
spritesheet1 = "p2_spritesheet.png"
spritesheet2 = "tiles_spritesheet.png"

title = "You should be in quarantine!"
# setup game assets (images/sounds)
@@ -24,9 +25,9 @@ player_jump = 15

# Starting platforms

# X Y WIDTH HEIGTH
platform_list = [(0, 220, 40, height),
(0, height - 40, width * 3, 40),
(width / 2, 250, 60, 20),
(90, height - 300, 115, 20)]
# X Y
platform_list = [(0, 220),
(0, 425),
(800 / 2, 250),
(90, 425 - 300)]

0 comments on commit 01e6fbd

Please sign in to comment.