summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-03-18 13:05:58 +0200
committerViljami Ilola <+@hix.fi>2024-03-18 13:05:58 +0200
commitb00fe8fe50392a75529864fe03399fa3a0976143 (patch)
tree4f61dbc5b771605984bb3c34d0b8a423c8a8c24c
parent8781f3b04dff7434d302f7606cdcb0d2c1523cf8 (diff)
internal resolution x10. get rid of rest get_sprites functions
-rw-r--r--src/sliceitoff/__main__.py8
-rw-r--r--src/sliceitoff/display/static.py4
-rw-r--r--src/sliceitoff/enemies/enemies.py11
-rw-r--r--src/sliceitoff/field/field.py3
-rw-r--r--src/sliceitoff/images/images.py2
-rw-r--r--src/sliceitoff/player/player.py12
-rw-r--r--src/sliceitoff/status/status.py4
7 files changed, 20 insertions, 24 deletions
diff --git a/src/sliceitoff/__main__.py b/src/sliceitoff/__main__.py
index 5fc766b..2da9aa8 100644
--- a/src/sliceitoff/__main__.py
+++ b/src/sliceitoff/__main__.py
@@ -35,15 +35,15 @@ def sliceitoff():
while True:
dt = clock.tick(60)
- for fun in (status, field):
+ for fun in (status, field, enemies):
fun.update(dt)
-
+
display.update(
[
status.sprites,
field.sprites,
- enemies.get_sprites(),
- player.get_sprites()
+ enemies.sprites,
+ player.sprites
])
if game.step():
diff --git a/src/sliceitoff/display/static.py b/src/sliceitoff/display/static.py
index 1678994..af1cc67 100644
--- a/src/sliceitoff/display/static.py
+++ b/src/sliceitoff/display/static.py
@@ -1,2 +1,2 @@
-INTERNAL_WIDTH = 40_000
-INTERNAL_HEIGHT = 30_000
+INTERNAL_WIDTH = 400_000
+INTERNAL_HEIGHT = 300_000
diff --git a/src/sliceitoff/enemies/enemies.py b/src/sliceitoff/enemies/enemies.py
index b0ac187..6a9fda4 100644
--- a/src/sliceitoff/enemies/enemies.py
+++ b/src/sliceitoff/enemies/enemies.py
@@ -56,8 +56,8 @@ class Enemies():
def emerge_enemies(self):
for _ in range(self.level * 1):
enemy = EnemyBall()
- enemy.set_position( (randrange(0,38_000), randrange(0,26_000)) )
- enemy.set_movement( (randrange(0,400)-200, randrange(0,400)-200) )
+ enemy.set_position( (randrange(0,380_000), randrange(0,260_000)) )
+ enemy.set_movement( (randrange(0,200)-100, randrange(0,200)-100) )
self.sprites.add(enemy)
def wall_hit(self, field, enemy):
@@ -70,8 +70,9 @@ class Enemies():
if ( enemy.rect.y + enemy.rect.h >= field.rect.y + field.rect.h ):
enemy.force_up()
- def get_sprites(self):
- self.sprites.update(move=1)
+ def update(self, dt):
+ """ Update sprites basis of dt. dt = milliseconds from last update """
+ self.sprites.update(move=dt)
for enemy in self.sprites:
for field in self.field.sprites:
if field.rect.contains(enemy):
@@ -80,5 +81,3 @@ class Enemies():
for field in self.field.sprites:
if field.rect.colliderect(enemy):
self.wall_hit(field, enemy)
-
- return self.sprites
diff --git a/src/sliceitoff/field/field.py b/src/sliceitoff/field/field.py
index a6084f1..979590e 100644
--- a/src/sliceitoff/field/field.py
+++ b/src/sliceitoff/field/field.py
@@ -16,7 +16,7 @@ class FieldSprite(pygame.sprite.Sprite):
class Field():
def __init__(self):
self.sprites = pygame.sprite.Group()
- self.sprites.add(FieldSprite( (0, 0, 40_000, 28_000) ))
+ self.sprites.add(FieldSprite( (0, 0, 400_000, 280_000) ))
def coordinates_inside_area(self, area, x, y) -> bool:
if x < area[0]:
@@ -68,5 +68,6 @@ class Field():
return Scaling.area_to_rect((ax, y2, aw, y3-y2))
def update(self, dt):
+ """ Update sprites basis of dt. dt = milliseconds from last update """
pass
\ No newline at end of file
diff --git a/src/sliceitoff/images/images.py b/src/sliceitoff/images/images.py
index 07a8bcd..7ae1f6d 100644
--- a/src/sliceitoff/images/images.py
+++ b/src/sliceitoff/images/images.py
@@ -20,7 +20,7 @@ class Images:
print(f"Loading images {name = }, {filename = }")
image = pygame.image.load(filename)
rgba = pygame.Surface.convert_alpha(image)
- scaled = pygame.transform.smoothscale_by(rgba, Scaling.factor)
+ scaled = pygame.transform.smoothscale_by(rgba, Scaling.factor*10)
__class__.surfaces[name] = scaled
return True
diff --git a/src/sliceitoff/player/player.py b/src/sliceitoff/player/player.py
index f383077..9870c50 100644
--- a/src/sliceitoff/player/player.py
+++ b/src/sliceitoff/player/player.py
@@ -17,7 +17,7 @@ class Player():
def __init__(self, field = None, enemies = None):
self.field = field
self.enemies = enemies
- self.position = (20_000, 14_000)
+ self.position = (200_000, 140_000)
self.direction = False
self.lazer = False
self.sprites = pygame.sprite.Group()
@@ -39,15 +39,15 @@ class Player():
self.position = Scaling.scale_to_internal(pos)
self.updated = True
- def get_sprites(self):
+ def update(self, dt):
+ """ Update sprites basis of dt. dt = milliseconds from last update """
if self.updated:
self.__update_sprites()
- return self.sprites
def fire_lazer(self):
# self.lazer = True
# self.updated = True
- hitbox = self.field.slice(self.position, self.direction, 450)
+ hitbox = self.field.slice(self.position, self.direction, 4_500)
if hitbox is not None:
for enemy in self.enemies.sprites:
if hitbox.colliderect(enemy.rect):
@@ -64,7 +64,3 @@ class Player():
if not self.lazer:
self.direction = not self.direction
self.updated = True
-
- def __del__(self):
- pass
- \ No newline at end of file
diff --git a/src/sliceitoff/status/status.py b/src/sliceitoff/status/status.py
index 5390299..4f2125a 100644
--- a/src/sliceitoff/status/status.py
+++ b/src/sliceitoff/status/status.py
@@ -26,9 +26,9 @@ class Status():
""" Update sprites basis of dt. dt = milliseconds from last update """
if self.updated:
self.sprites.empty()
- y = 28_000
+ y = 280_000
score_str="{:010d}".format(self.score)
- for letter, x in zip(score_str, range(30_000,40_000,1_000)):
+ for letter, x in zip(score_str, range(300_000,400_000,10_000)):
self.sprites.add(LetterSprite(
Images.surfaces[f"letter_{letter}"],
Scaling.scale_to_display((x,y)) ))