Skip to content

Commit dd5e118

Browse files
PeanutbutterWarriorPeanutbutterWarrior
PeanutbutterWarrior
authored and
PeanutbutterWarrior
committed
Fix Formatting
1 parent d09842f commit dd5e118

19 files changed

+90
-93
lines changed

classes/Camera.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from classes.Maths import vec2D
1+
from classes.Maths import Vec2D
22

33

44
class Camera:
55
def __init__(self, pos, entity):
6-
self.pos = vec2D(pos.x, pos.y)
6+
self.pos = Vec2D(pos.x, pos.y)
77
self.entity = entity
88
self.x = self.pos.x * 32
99
self.y = self.pos.y * 32

classes/Collider.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def checkY(self):
5252
self.entity.vel.y = 0
5353
# reset jump on bottom
5454
if self.entity.traits is not None:
55-
if "jumpTrait" in self.entity.traits:
56-
self.entity.traits["jumpTrait"].reset()
55+
if "JumpTrait" in self.entity.traits:
56+
self.entity.traits["JumpTrait"].reset()
5757
if "bounceTrait" in self.entity.traits:
5858
self.entity.traits["bounceTrait"].reset()
5959
if self.entity.vel.y < 0:

classes/Font.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def loadFont(self):
2424
row,
2525
2,
2626
colorkey=pygame.color.Color(0, 0, 0),
27-
xTileSize = 8,
28-
yTileSize = 8
27+
xTileSize=8,
28+
yTileSize=8
2929
)
3030
}
3131
)

classes/GaussianBlur.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import pygame
22
from scipy.ndimage.filters import *
33

4+
45
class GaussianBlur:
5-
def __init__(self,kernelsize=7):
6+
def __init__(self, kernelsize=7):
67
self.kernel_size = kernelsize
78

89
def filter(self, srfc, xpos, ypos, width, height):
9-
nSrfc = pygame.Surface((width,height))
10+
nSrfc = pygame.Surface((width, height))
1011
pxa = pygame.surfarray.array3d(srfc)
11-
blurred = gaussian_filter(pxa,sigma=(self.kernel_size, self.kernel_size, 0))
12+
blurred = gaussian_filter(pxa, sigma=(self.kernel_size, self.kernel_size, 0))
1213
pygame.surfarray.blit_array(nSrfc, blurred)
1314
del pxa
1415
return nSrfc

classes/Input.py

+12-19
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ def checkForKeyboardInput(self):
1919
pressedKeys = pygame.key.get_pressed()
2020

2121
if pressedKeys[K_LEFT] or pressedKeys[K_h] and not pressedKeys[K_RIGHT]:
22-
self.entity.traits["goTrait"].direction = -1
22+
self.entity.traits["GoTrait"].direction = -1
2323
elif pressedKeys[K_RIGHT] or pressedKeys[K_l] and not pressedKeys[K_LEFT]:
24-
self.entity.traits["goTrait"].direction = 1
24+
self.entity.traits["GoTrait"].direction = 1
2525
else:
26-
self.entity.traits['goTrait'].direction = 0
26+
self.entity.traits['GoTrait'].direction = 0
2727

2828
isJumping = pressedKeys[K_SPACE] or pressedKeys[K_UP] or pressedKeys[K_k]
29-
self.entity.traits['jumpTrait'].jump(isJumping)
29+
self.entity.traits['JumpTrait'].jump(isJumping)
3030

31-
self.entity.traits['goTrait'].boost = pressedKeys[K_LSHIFT]
31+
self.entity.traits['GoTrait'].boost = pressedKeys[K_LSHIFT]
3232

33-
def checkForMouseInput(self,events):
33+
def checkForMouseInput(self, events):
3434
mouseX, mouseY = pygame.mouse.get_pos()
3535
if self.isRightMouseButtonPressed(events):
3636
self.entity.levelObj.addKoopa(
@@ -44,7 +44,7 @@ def checkForMouseInput(self,events):
4444
mouseX / 32 - self.entity.camera.pos.x, mouseY / 32
4545
)
4646

47-
def checkForQuitAndRestartInputEvents(self,events):
47+
def checkForQuitAndRestartInputEvents(self, events):
4848
for event in events:
4949
if event.type == pygame.QUIT:
5050
pygame.quit()
@@ -55,20 +55,13 @@ def checkForQuitAndRestartInputEvents(self,events):
5555
self.entity.pauseObj.createBackgroundBlur()
5656

5757
def isLeftMouseButtonPressed(self, events):
58-
return self.checkMouse(events,1)
59-
60-
58+
return self.checkMouse(events, 1)
6159

6260
def isRightMouseButtonPressed(self, events):
63-
return self.checkMouse(events,3)
64-
61+
return self.checkMouse(events, 3)
6562

6663
def checkMouse(self, events, button):
6764
for e in events:
68-
if e.type == pygame.MOUSEBUTTONUP:
69-
if e.button == button:
70-
return True
71-
else:
72-
return False
73-
74-
65+
if e.type == pygame.MOUSEBUTTONUP and e.button == button:
66+
return True
67+
return False

classes/Level.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
from classes.Sprites import Sprites
55
from classes.Tile import Tile
66
from entities.Coin import Coin
7+
from entities.CoinBrick import CoinBrick
78
from entities.Goomba import Goomba
89
from entities.Koopa import Koopa
910
from entities.RandomBox import RandomBox
10-
from entities.CoinBrick import CoinBrick
11+
1112

1213
class Level:
1314
def __init__(self, screen, sound, dashboard):
@@ -111,7 +112,7 @@ def addCloudSprite(self, x, y):
111112

112113
def addPipeSprite(self, x, y, length=2):
113114
try:
114-
# add Pipe Head
115+
# add pipe head
115116
self.level[y][x] = Tile(
116117
self.sprites.spriteCollection.get("pipeL"),
117118
pygame.Rect(x * 32, y * 32, 32, 32),
@@ -120,7 +121,7 @@ def addPipeSprite(self, x, y, length=2):
120121
self.sprites.spriteCollection.get("pipeR"),
121122
pygame.Rect((x + 1) * 32, y * 32, 32, 32),
122123
)
123-
# add pipe Body
124+
# add pipe body
124125
for i in range(1, length + 20):
125126
self.level[y + i][x] = Tile(
126127
self.sprites.spriteCollection.get("pipe2L"),

classes/Maths.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class vec2D:
1+
class Vec2D:
22
def __init__(self, x=0, y=0):
33
self.x = x
44
self.y = y

classes/Menu.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self, screen, dashboard, level, sound):
3535
0, 150, 2, colorkey=[255, 0, 220], ignoreTileSize=True
3636
)
3737
self.menu_dot2 = self.spritesheet.image_at(
38-
20, 150, 2, colorkey=[255, 0, 220], ignoreTileSize=True
38+
20, 150, 2, colorkey=[255, 0, 220], ignoreTileSize=True
3939
)
4040
self.loadSettings("./settings.json")
4141

@@ -98,7 +98,7 @@ def drawMenu(self):
9898
self.dashboard.drawText("SETTINGS", 180, 320, 24)
9999
self.dashboard.drawText("EXIT", 180, 360, 24)
100100

101-
def drawMenuBackground(self,withBanner=True):
101+
def drawMenuBackground(self, withBanner=True):
102102
for y in range(0, 13):
103103
for x in range(0, 20):
104104
self.screen.blit(
@@ -111,7 +111,7 @@ def drawMenuBackground(self,withBanner=True):
111111
self.level.sprites.spriteCollection.get("ground").image,
112112
(x * 32, y * 32),
113113
)
114-
if(withBanner):
114+
if withBanner:
115115
self.screen.blit(self.menu_banner, (150, 80))
116116
self.screen.blit(
117117
self.level.sprites.spriteCollection.get("mario_idle").image,
@@ -132,7 +132,7 @@ def drawMenuBackground(self,withBanner=True):
132132
self.screen.blit(
133133
self.level.sprites.spriteCollection.get("bush_3").image, (18 * 32, 12 * 32)
134134
)
135-
self.screen.blit(self.level.sprites.spriteCollection.get("goomba-1").image,(18.5*32,12*32))
135+
self.screen.blit(self.level.sprites.spriteCollection.get("goomba-1").image, (18.5*32, 12*32))
136136

137137
def drawSettings(self):
138138
self.drawDot()
@@ -154,28 +154,28 @@ def chooseLevel(self):
154154
self.levelNames = self.loadLevelNames()
155155
self.drawLevelChooser()
156156

157-
def drawBorder(self,x,y,width,height,color,thickness):
158-
pygame.draw.rect(self.screen,color,(x,y,width,thickness))
159-
pygame.draw.rect(self.screen,color,(x,y+width,width,thickness))
160-
pygame.draw.rect(self.screen,color,(x,y,thickness,width))
161-
pygame.draw.rect(self.screen,color,(x+width,y,thickness,width+thickness))
157+
def drawBorder(self, x, y, width, height, color, thickness):
158+
pygame.draw.rect(self.screen, color, (x, y, width, thickness))
159+
pygame.draw.rect(self.screen, color, (x, y+width, width, thickness))
160+
pygame.draw.rect(self.screen, color, (x, y, thickness, width))
161+
pygame.draw.rect(self.screen, color, (x+width, y, thickness, width+thickness))
162162

163163
def drawLevelChooser(self):
164164
j = 0
165165
offset = 75
166166
textOffset = 90
167167
for i, levelName in enumerate(self.loadLevelNames()):
168168
if self.currSelectedLevel == i+1:
169-
color = (255,255,255)
169+
color = (255, 255, 255)
170170
else:
171-
color = (150,150,150)
171+
color = (150, 150, 150)
172172
if i < 3:
173-
self.dashboard.drawText(levelName,175*i+textOffset,100,12)
174-
self.drawBorder(175*i+offset,55,125,75,color,5)
173+
self.dashboard.drawText(levelName, 175*i+textOffset, 100, 12)
174+
self.drawBorder(175*i+offset, 55, 125, 75, color, 5)
175175
else:
176-
self.dashboard.drawText(levelName,175*j+textOffset,250,12)
177-
self.drawBorder(175*j+offset,210,125,75,color,5)
178-
j+=1
176+
self.dashboard.drawText(levelName, 175*j+textOffset, 250, 12)
177+
self.drawBorder(175*j+offset, 210, 125, 75, color, 5)
178+
j += 1
179179

180180
def loadLevelNames(self):
181181
files = []

classes/Pause.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ def __init__(self, screen, entity, dashboard):
1616
0, 150, 2, colorkey=[255, 0, 220], ignoreTileSize=True
1717
)
1818
self.gray_dot = self.spritesheet.image_at(
19-
20, 150, 2, colorkey=[255, 0, 220], ignoreTileSize=True
19+
20, 150, 2, colorkey=[255, 0, 220], ignoreTileSize=True
2020
)
2121

2222
def update(self):
23-
self.screen.blit(self.pause_srfc,(0,0))
23+
self.screen.blit(self.pause_srfc, (0, 0))
2424
self.dashboard.drawText("PAUSED", 120, 160, 68)
2525
self.dashboard.drawText("CONTINUE", 150, 280, 32)
2626
self.dashboard.drawText("BACK TO MENU", 150, 320, 32)

classes/Spritesheet.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pygame
22

3+
34
class Spritesheet(object):
45
def __init__(self, filename):
56
try:

compile.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from distutils.core import setup
22

3-
import py2exe, glob
3+
import py2exe
4+
import glob
45

56
setup(
67
# this is the file that is run when you start the game from the command line.

entities/EntityBase.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import pygame
22

3-
from classes.Maths import vec2D
3+
from classes.Maths import Vec2D
44

55

66
class EntityBase(object):
77
def __init__(self, x, y, gravity):
8-
self.vel = vec2D()
8+
self.vel = Vec2D()
99
self.rect = pygame.Rect(x * 32, y * 32, 32, 32)
1010
self.gravity = gravity
1111
self.traits = None
@@ -14,10 +14,10 @@ def __init__(self, x, y, gravity):
1414
self.timer = 0
1515
self.type = ""
1616
self.onGround = False
17-
self.obeygravity = True
17+
self.obeyGravity = True
1818

1919
def applyGravity(self):
20-
if self.obeygravity:
20+
if self.obeyGravity:
2121
self.vel.y += self.gravity
2222

2323
def updateTraits(self):
@@ -28,7 +28,7 @@ def updateTraits(self):
2828
pass
2929

3030
def getPosIndex(self):
31-
return vec2D(int(self.rect.x / 32), int(self.rect.y / 32))
31+
return Vec2D(int(self.rect.x / 32), int(self.rect.y / 32))
3232

3333
def getPosIndexAsFloat(self):
34-
return vec2D(self.rect.x / 32.0, self.rect.y / 32.0)
34+
return Vec2D(self.rect.x / 32.0, self.rect.y / 32.0)

entities/Goomba.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from classes.Animation import Animation
2-
from classes.Maths import vec2D
3-
from entities.EntityBase import EntityBase
4-
from traits.leftrightwalk import LeftRightWalkTrait
52
from classes.Collider import Collider
63
from classes.EntityCollider import EntityCollider
4+
from classes.Maths import Vec2D
5+
from entities.EntityBase import EntityBase
6+
from traits.leftrightwalk import LeftRightWalkTrait
7+
78

89
class Goomba(EntityBase):
910
def __init__(self, screen, spriteColl, x, y, level, sound):
@@ -23,6 +24,7 @@ def __init__(self, screen, spriteColl, x, y, level, sound):
2324
self.EntityCollider = EntityCollider(self)
2425
self.levelObj = level
2526
self.sound = sound
27+
self.textPos = Vec2D(0, 0)
2628

2729
def update(self, camera):
2830
if self.alive:
@@ -54,7 +56,7 @@ def drawFlatGoomba(self, camera):
5456
)
5557

5658
def setPointsTextStartPosition(self, x, y):
57-
self.textPos = vec2D(x, y)
59+
self.textPos = Vec2D(x, y)
5860

5961
def movePointsTextUpAndDraw(self, camera):
6062
self.textPos.y += -0.5

entities/Item.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from copy import copy
22

33
from classes.Dashboard import Dashboard
4-
from classes.Maths import vec2D
4+
from classes.Maths import Vec2D
55

66

77
class Item(Dashboard):
88
def __init__(self, collection, screen, x, y):
99
super(Item, self).__init__("./img/font.png", 8, screen)
10-
self.ItemPos = vec2D(x, y)
11-
self.itemVel = vec2D(0, 0)
10+
self.ItemPos = Vec2D(x, y)
11+
self.itemVel = Vec2D(0, 0)
1212
self.screen = screen
1313
self.coin_animation = copy(collection.get("coin-item").animation)
1414
self.sound_played = False

entities/Koopa.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import pygame
22

33
from classes.Animation import Animation
4-
from classes.Maths import vec2D
5-
from entities.EntityBase import EntityBase
6-
from traits.leftrightwalk import LeftRightWalkTrait
74
from classes.Collider import Collider
85
from classes.EntityCollider import EntityCollider
6+
from classes.Maths import Vec2D
7+
from entities.EntityBase import EntityBase
8+
from traits.leftrightwalk import LeftRightWalkTrait
99

1010

1111
class Koopa(EntityBase):
@@ -30,15 +30,15 @@ def __init__(self, screen, spriteColl, x, y, level, sound):
3030
self.sound = sound
3131

3232
def update(self, camera):
33-
if self.alive == True:
33+
if self.alive:
3434
self.updateAlive(camera)
3535
self.checkEntityCollision()
3636
elif self.alive == "sleeping":
3737
self.sleepingInShell(camera)
3838
self.checkEntityCollision()
3939
elif self.alive == "shellBouncing":
4040
self.shellBouncing(camera)
41-
elif self.alive == False:
41+
elif not self.alive:
4242
self.die(camera)
4343

4444
def drawKoopa(self, camera):
@@ -61,10 +61,10 @@ def shellBouncing(self, camera):
6161

6262
def die(self, camera):
6363
if self.timer == 0:
64-
self.textPos = vec2D(self.rect.x + 3, self.rect.y - 32)
64+
self.textPos = Vec2D(self.rect.x + 3, self.rect.y - 32)
6565
if self.timer < self.timeAfterDeath:
6666
self.textPos.y += -0.5
67-
self.textPos = vec2D(self.rect.x + 3, self.rect.y - 32)
67+
self.textPos = Vec2D(self.rect.x + 3, self.rect.y - 32)
6868
self.dashboard.drawText("100", self.textPos.x + camera.x, self.textPos.y, 8)
6969
self.vel.y -= 0.5
7070
self.rect.y += self.vel.y
@@ -113,4 +113,4 @@ def checkEntityCollision(self):
113113
def _onCollisionWithMob(self, mob, collisionState):
114114
if collisionState.isColliding and mob.alive == "shellBouncing":
115115
self.alive = False
116-
self.sound.play_sfx(self.sound.brick_bump)
116+
self.sound.play_sfx(self.sound.brick_bump)

0 commit comments

Comments
 (0)