Updated cheat system. Code rework
This commit is contained in:
+12
-13
@@ -140,15 +140,10 @@ class Drakora():
|
||||
self.fontMessage = pygame.font.Font(self.font, 56)
|
||||
self.fontGodmode = pygame.font.Font(self.font, 12)
|
||||
|
||||
self.charKeys = {
|
||||
pygame.K_a:'a', pygame.K_b:'b', pygame.K_c:'c', pygame.K_d:'d',
|
||||
pygame.K_e:'e', pygame.K_f:'f', pygame.K_g:'g', pygame.K_h:'h',
|
||||
pygame.K_i:'i', pygame.K_j:'j', pygame.K_k:'k', pygame.K_l:'l',
|
||||
pygame.K_m:'m', pygame.K_n:'n', pygame.K_o:'o', pygame.K_p:'p',
|
||||
pygame.K_q:'q', pygame.K_r:'r', pygame.K_s:'s', pygame.K_t:'t',
|
||||
pygame.K_u:'u', pygame.K_v:'v', pygame.K_w:'w', pygame.K_x:'x',
|
||||
pygame.K_y:'y', pygame.K_z:'z',
|
||||
}
|
||||
self.charKeys = tuple(
|
||||
pygame.key.key_code(chr(i)) for i in range(ord("a"), ord("z"))
|
||||
)
|
||||
|
||||
self.pressedKeys = deque(maxlen=10)
|
||||
self.isPressedKeysUpdated = True
|
||||
|
||||
@@ -169,7 +164,6 @@ class Drakora():
|
||||
|
||||
|
||||
def render(self):
|
||||
# self.screen.fill((102, 153, 255))
|
||||
self.background.draw(self.screen)
|
||||
for cloudGroup in self.cloudGroups: cloudGroup.draw(self.screen)
|
||||
self.enemies.draw(self.screen)
|
||||
@@ -179,7 +173,7 @@ class Drakora():
|
||||
if self.drawBoxes:
|
||||
for player in self.players:
|
||||
for collision in self.player.getCollisionBoxes():
|
||||
pygame.draw.rect(self.screen, (255, 0, 0), collision.rect, 1)
|
||||
pygame.draw.rect(self.screen, (255, 0, 0), collision.rect,1)
|
||||
for enemy in self.enemies:
|
||||
pygame.draw.rect(self.screen, (255, 0, 0), enemy.rect, 1)
|
||||
for floor in self.floors:
|
||||
@@ -225,6 +219,10 @@ class Drakora():
|
||||
self.fontGodmode, (255, 255, 255),
|
||||
(self.getScreenWidth()/2,60))
|
||||
|
||||
self.renderText(''.join(self.pressedKeys),
|
||||
self.fontGodmode, (255, 255, 255),
|
||||
(self.getScreenWidth()/2,80))
|
||||
|
||||
pygame.display.flip()
|
||||
|
||||
|
||||
@@ -242,7 +240,8 @@ class Drakora():
|
||||
|
||||
|
||||
def collideCheck(self):
|
||||
if sum([1 if pygame.sprite.spritecollideany(i, self.enemies) else 0 for i in self.player.getCollisionBoxes()]):
|
||||
if sum([1 if pygame.sprite.spritecollideany(i, self.enemies) else 0
|
||||
for i in self.player.getCollisionBoxes()]):
|
||||
if not self.isGodmode: self.isGameOver = True
|
||||
|
||||
if self.player.isOnFloor:
|
||||
@@ -299,7 +298,7 @@ class Drakora():
|
||||
|
||||
elif event.type == pygame.KEYUP:
|
||||
if event.key in self.charKeys:
|
||||
self.pressedKeys.append(self.charKeys[event.key])
|
||||
self.pressedKeys.append(pygame.key.name(event.key))
|
||||
self.isPressedKeysUpdated = True
|
||||
|
||||
self.doCheats()
|
||||
|
||||
Reference in New Issue
Block a user