Browse Source

fixed serveral bugs

JSON-implementation
Max Lange 7 years ago
parent
commit
dcba5843ff
  1. 4
      src/game_data.py
  2. 10
      src/objects.py
  3. 2
      src/player.py

4
src/game_data.py

@ -9,7 +9,7 @@ from . import sounds
from . import objects
def save(self, name):
def save(name):
name = name.encode("utf-8")
# removes invalid characters
@ -57,7 +57,7 @@ def save(self, name):
json.dump(data, settings_file, indent=12)
def load(self, name):
def load(name):
"""Load savegame"""
try:

10
src/objects.py

@ -171,6 +171,8 @@ class target():
self.pos_y -= self.explosion.getRect().h / 2.0
self.explosion.play()
self.gothit = True
while self.explosion.state in ["stopped", "paused"]:
self.explosion.play()
def blit(self):
"""Blits target and explosion"""
@ -259,13 +261,13 @@ class warp_station():
settings.right = False
while test_collide():
if settings.player.pos.center[0] < self.pos.center[0]:
settings.player.move_ip(-20, 0)
settings.player.move_abs(-20, 0)
else:
settings.player.move_ip(20, 0)
settings.player.move_abs(20, 0)
if settings.player.pos.center[1] < self.pos.center[1]:
settings.player.move_ip(0, -20)
settings.player.move_abs(0, -20)
else:
settings.player.move_ip(0, 20)
settings.player.move_abs(0, 20)
playerpos = settings.player.pos
def blit(self):

2
src/player.py

@ -70,7 +70,7 @@ class player():
if self.rotation == 315:
self.img = self.playeruple
def move_pix_ip(self, addx, addy):
def move_abs(self, addx, addy):
#lint:disable
self.rel_x = (self.pos.x + addx) / float(settings.screenx_current)
self.rel_y = (self.pos.y + addy) / float(settings.screeny_current)

Loading…
Cancel
Save