I think I broke something
This commit is contained in:
@@ -10,6 +10,10 @@ import random
|
|||||||
class Cloud(pygame.sprite.Sprite):
|
class Cloud(pygame.sprite.Sprite):
|
||||||
def __init__(self, mainGameClass, cloudType):
|
def __init__(self, mainGameClass, cloudType):
|
||||||
pygame.sprite.Sprite.__init__(self)
|
pygame.sprite.Sprite.__init__(self)
|
||||||
|
|
||||||
|
self.type = cloudType
|
||||||
|
self.mainGameClass = mainGameClass
|
||||||
|
|
||||||
self.image = pygame.Surface((random.randint(150, 350),
|
self.image = pygame.Surface((random.randint(150, 350),
|
||||||
random.randint(50, 150)))
|
random.randint(50, 150)))
|
||||||
|
|
||||||
@@ -18,11 +22,10 @@ class Cloud(pygame.sprite.Sprite):
|
|||||||
|
|
||||||
self.rect = self.image.get_rect()
|
self.rect = self.image.get_rect()
|
||||||
self.rect.center = (
|
self.rect.center = (
|
||||||
mainGameClass.getScreenWidth() + self.rect.width,
|
self.mainGameClass.getScreenWidth() + self.rect.width,
|
||||||
mainGameClass.getScreenHeight()/2 - random.randint(100,
|
self.mainGameClass.getScreenHeight()/2 - random.randint(100,
|
||||||
mainGameClass.getScreenHeight()/2-100) + 50*(2-cloudType)
|
self.mainGameClass.getScreenHeight()/2-100) + 50*(2-cloudType)
|
||||||
)
|
)
|
||||||
self.speed = cloudType*mainGameClass.getGameSpeed() / 6
|
|
||||||
|
|
||||||
self.__doubleX = float(self.rect.x)
|
self.__doubleX = float(self.rect.x)
|
||||||
|
|
||||||
@@ -31,5 +34,5 @@ class Cloud(pygame.sprite.Sprite):
|
|||||||
if (self.rect.x < -self.rect.width):
|
if (self.rect.x < -self.rect.width):
|
||||||
self.kill()
|
self.kill()
|
||||||
|
|
||||||
self.__doubleX -= self.speed
|
self.__doubleX -= self.type*self.mainGameClass.getGameSpeed() / 6
|
||||||
self.rect.x = self.__doubleX
|
self.rect.x = self.__doubleX
|
||||||
|
|||||||
+4
-6
@@ -40,15 +40,15 @@ class Drakora():
|
|||||||
|
|
||||||
|
|
||||||
def speedUp(self):
|
def speedUp(self):
|
||||||
self.__gameSpeed *= 2
|
self.__gameSpeed += 1.5
|
||||||
|
|
||||||
|
|
||||||
def speedDown(self):
|
def speedDown(self):
|
||||||
if self.__gameSpeed > 2: self.__gameSpeed /= 2
|
if self.__gameSpeed > 1.5: self.__gameSpeed -= 1.5
|
||||||
|
|
||||||
|
|
||||||
def speedReset(self):
|
def speedReset(self):
|
||||||
self.__gameSpeed = 2
|
self.__gameSpeed = 1.5
|
||||||
|
|
||||||
|
|
||||||
def addScore(self, score):
|
def addScore(self, score):
|
||||||
@@ -78,7 +78,7 @@ class Drakora():
|
|||||||
|
|
||||||
if self.player: self.player.kill()
|
if self.player: self.player.kill()
|
||||||
|
|
||||||
self.player = Player()
|
self.player = Player(self)
|
||||||
self.players.add(self.player)
|
self.players.add(self.player)
|
||||||
|
|
||||||
self.__score = 0
|
self.__score = 0
|
||||||
@@ -278,8 +278,6 @@ class Drakora():
|
|||||||
|
|
||||||
|
|
||||||
def logic(self):
|
def logic(self):
|
||||||
self.player.updateSpeed(self.__gameSpeed)
|
|
||||||
|
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
self.player.control(event)
|
self.player.control(event)
|
||||||
self.endSceen.control(event)
|
self.endSceen.control(event)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class Enemy(pygame.sprite.Sprite):
|
|||||||
def __init__(self, mainGameClass):
|
def __init__(self, mainGameClass):
|
||||||
pygame.sprite.Sprite.__init__(self)
|
pygame.sprite.Sprite.__init__(self)
|
||||||
|
|
||||||
self.thisGame = mainGameClass
|
self.mainGameClass = mainGameClass
|
||||||
|
|
||||||
self.height = (mainGameClass.getScreenHeight()
|
self.height = (mainGameClass.getScreenHeight()
|
||||||
- mainGameClass.getFloorHeight())
|
- mainGameClass.getFloorHeight())
|
||||||
@@ -26,9 +26,10 @@ class Enemy(pygame.sprite.Sprite):
|
|||||||
def update(self):
|
def update(self):
|
||||||
if (self.rect.x < -self.rect.width):
|
if (self.rect.x < -self.rect.width):
|
||||||
self.kill()
|
self.kill()
|
||||||
self.thisGame.addScore(1)
|
self.mainGameClass.addScore(1)
|
||||||
|
else:
|
||||||
|
self.doubleX -= self.speed
|
||||||
|
self.rect.x = self.doubleX
|
||||||
|
|
||||||
self.rect.x -= self.speed
|
for i in self.collisionBoxes:
|
||||||
|
i.setX(self.rect.x)
|
||||||
for i in self.collisionBoxes:
|
|
||||||
i.setX(self.rect.x)
|
|
||||||
|
|||||||
+7
-3
@@ -42,17 +42,21 @@ class FlyingEnemy(Enemy):
|
|||||||
self.rect.center = (mainGameClass.getScreenWidth() + self.rect.width,
|
self.rect.center = (mainGameClass.getScreenWidth() + self.rect.width,
|
||||||
self.height)
|
self.height)
|
||||||
|
|
||||||
collision = CollisionBox(2, 0, self.rect.w - 28, self.rect.h - 8, self.rect.center)
|
self.doubleX = float(self.rect.x)
|
||||||
|
|
||||||
|
collision = CollisionBox(2, 0, self.rect.w - 28,
|
||||||
|
self.rect.h - 8, self.rect.center)
|
||||||
self.collisionBoxes.add(collision)
|
self.collisionBoxes.add(collision)
|
||||||
|
|
||||||
self.speed = self.thisGame.getGameSpeed()*2
|
self.speed = self.mainGameClass.getGameSpeed()*2
|
||||||
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
super().update()
|
super().update()
|
||||||
|
|
||||||
self.updateCount += 1
|
self.updateCount += 1
|
||||||
if self.updateCount >= 22 - math.log2(self.thisGame.getGameSpeed()) * 2:
|
if self.updateCount >= 22 - math.log2(
|
||||||
|
self.mainGameClass.getGameSpeed()) * 2:
|
||||||
self.currentImage += 1
|
self.currentImage += 1
|
||||||
if self.currentImage >= len(FlyingEnemy.images):
|
if self.currentImage >= len(FlyingEnemy.images):
|
||||||
self.currentImage = 0
|
self.currentImage = 0
|
||||||
|
|||||||
@@ -81,9 +81,11 @@ class Player(pygame.sprite.Sprite):
|
|||||||
def getCollisionBoxes(self):
|
def getCollisionBoxes(self):
|
||||||
return self.collisionBoxes
|
return self.collisionBoxes
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, mainGameClass):
|
||||||
pygame.sprite.Sprite.__init__(self)
|
pygame.sprite.Sprite.__init__(self)
|
||||||
|
|
||||||
|
self.mainGameClass = mainGameClass
|
||||||
|
|
||||||
self.currentWalkImage = 0
|
self.currentWalkImage = 0
|
||||||
self.currentUpImage = 0
|
self.currentUpImage = 0
|
||||||
self.currentDownImage = 0
|
self.currentDownImage = 0
|
||||||
@@ -102,7 +104,6 @@ class Player(pygame.sprite.Sprite):
|
|||||||
self.isDownCrouch = False
|
self.isDownCrouch = False
|
||||||
self.buttonsJump = (pygame.K_UP, pygame.K_SPACE,)
|
self.buttonsJump = (pygame.K_UP, pygame.K_SPACE,)
|
||||||
self.buttonsCrouch = (pygame.K_DOWN,)
|
self.buttonsCrouch = (pygame.K_DOWN,)
|
||||||
self.gameSpeed = 1
|
|
||||||
self.updateCount = 0
|
self.updateCount = 0
|
||||||
|
|
||||||
self.collisionBoxes = pygame.sprite.Group()
|
self.collisionBoxes = pygame.sprite.Group()
|
||||||
@@ -114,6 +115,8 @@ class Player(pygame.sprite.Sprite):
|
|||||||
collision = CollisionBox(0, 35, 25, 40, self.rect.center)
|
collision = CollisionBox(0, 35, 25, 40, self.rect.center)
|
||||||
self.collisionBoxes.add(collision)
|
self.collisionBoxes.add(collision)
|
||||||
|
|
||||||
|
self.__doubleY = float(self.rect.x)
|
||||||
|
|
||||||
|
|
||||||
def crouch(self):
|
def crouch(self):
|
||||||
if not self.isCrouching:
|
if not self.isCrouching:
|
||||||
@@ -132,8 +135,6 @@ class Player(pygame.sprite.Sprite):
|
|||||||
for i in self.collisionBoxes:
|
for i in self.collisionBoxes:
|
||||||
i.rect.y += 32
|
i.rect.y += 32
|
||||||
|
|
||||||
def updateSpeed(self, newGameSpeed):
|
|
||||||
self.gameSpeed = newGameSpeed
|
|
||||||
|
|
||||||
def control(self, event):
|
def control(self, event):
|
||||||
if event.type == pygame.KEYDOWN:
|
if event.type == pygame.KEYDOWN:
|
||||||
@@ -171,17 +172,19 @@ class Player(pygame.sprite.Sprite):
|
|||||||
elif self.isCrouching:
|
elif self.isCrouching:
|
||||||
self.standup()
|
self.standup()
|
||||||
|
|
||||||
|
gameSpeed = self.mainGameClass.getGameSpeed()
|
||||||
|
|
||||||
if self.isJumping:
|
if self.isJumping:
|
||||||
if self.gameSpeed <= 2: maxHoverCount = 30
|
if gameSpeed <= 2: maxHoverCount = 30
|
||||||
elif self.gameSpeed <= 4: maxHoverCount = 23
|
elif gameSpeed <= 4: maxHoverCount = 23
|
||||||
elif self.gameSpeed <= 8: maxHoverCount = 16
|
elif gameSpeed <= 8: maxHoverCount = 16
|
||||||
elif self.gameSpeed <= 16: maxHoverCount = 9
|
elif gameSpeed <= 16: maxHoverCount = 9
|
||||||
elif self.gameSpeed <= 32: maxHoverCount = 5
|
elif gameSpeed <= 32: maxHoverCount = 5
|
||||||
elif self.gameSpeed <= 64: maxHoverCount = 2
|
elif gameSpeed <= 64: maxHoverCount = 2
|
||||||
else: maxHoverCount = 1
|
else: maxHoverCount = 1
|
||||||
|
|
||||||
if self.isDownJump and self.hoverCount < maxHoverCount:
|
if self.isDownJump and self.hoverCount < maxHoverCount:
|
||||||
self.speed -= self.gameSpeed/8 * (
|
self.speed -= gameSpeed/8 * (
|
||||||
(math.cos(2*math.pi*self.hoverCount/
|
(math.cos(2*math.pi*self.hoverCount/
|
||||||
(2*maxHoverCount))+1)/2.5 + 0.2
|
(2*maxHoverCount))+1)/2.5 + 0.2
|
||||||
)
|
)
|
||||||
@@ -189,14 +192,15 @@ class Player(pygame.sprite.Sprite):
|
|||||||
else:
|
else:
|
||||||
self.isJumping = False
|
self.isJumping = False
|
||||||
else:
|
else:
|
||||||
self.speed += 0.07 * self.gameSpeed
|
self.speed += 0.07 * gameSpeed
|
||||||
|
|
||||||
self.rect.y += self.speed
|
self.__doubleY += self.speed
|
||||||
|
self.rect.y = self.__doubleY
|
||||||
|
|
||||||
for i in self.collisionBoxes:
|
for collisionBox in self.collisionBoxes:
|
||||||
i.setY(self.rect.y)
|
collisionBox.setY(self.rect.y)
|
||||||
|
|
||||||
if self.updateCount >= 22 - math.log2(self.gameSpeed) * 2:
|
if self.updateCount >= 22 - math.log2(gameSpeed) * 2:
|
||||||
if self.isOnFloor:
|
if self.isOnFloor:
|
||||||
if self.isCrouching:
|
if self.isCrouching:
|
||||||
self.currentCrouchImage += 1
|
self.currentCrouchImage += 1
|
||||||
|
|||||||
+5
-2
@@ -158,7 +158,10 @@ class StandingEnemy(Enemy):
|
|||||||
self.rect.center = (mainGameClass.getScreenWidth() + self.rect.width,
|
self.rect.center = (mainGameClass.getScreenWidth() + self.rect.width,
|
||||||
self.height)
|
self.height)
|
||||||
|
|
||||||
collision = CollisionBox(9, 3, self.rect.w - 18, self.rect.h - 6, self.rect.center)
|
self.doubleX = float(self.rect.x)
|
||||||
|
|
||||||
|
collision = CollisionBox(9, 3, self.rect.w - 18,
|
||||||
|
self.rect.h - 6, self.rect.center)
|
||||||
self.collisionBoxes.add(collision)
|
self.collisionBoxes.add(collision)
|
||||||
|
|
||||||
self.speed = self.thisGame.getGameSpeed()
|
self.speed = self.mainGameClass.getGameSpeed()
|
||||||
|
|||||||
@@ -5,3 +5,4 @@ Cheater 1000 0.01
|
|||||||
New-Kolya 2 15.20
|
New-Kolya 2 15.20
|
||||||
1 1 10.02
|
1 1 10.02
|
||||||
RUSlan 29 82.42
|
RUSlan 29 82.42
|
||||||
|
Player 0 5.58
|
||||||
|
|||||||
Reference in New Issue
Block a user