summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-03-24 12:32:42 +0200
committerViljami Ilola <+@hix.fi>2024-03-24 12:32:42 +0200
commit749d47df38540342a7fe19029284b8115b03574a (patch)
treedbcc6c9a67644b7f73a00885cbafe8cb14dee3dd
parentc22159dfb5abda283d76248b474098cc2110935c (diff)
scoring
-rw-r--r--src/sliceitoff/assets/fonts.lst3
-rw-r--r--src/sliceitoff/enemies/enemies.py4
-rw-r--r--src/sliceitoff/field/field.py1
-rw-r--r--src/sliceitoff/game/gameplay.py2
-rw-r--r--src/sliceitoff/player/player.py16
-rw-r--r--src/sliceitoff/screens/levelup.py20
-rw-r--r--src/sliceitoff/stats/stats.py21
-rw-r--r--src/sliceitoff/status/status.py15
8 files changed, 58 insertions, 24 deletions
diff --git a/src/sliceitoff/assets/fonts.lst b/src/sliceitoff/assets/fonts.lst
index 4a57f92..0fb62b5 100644
--- a/src/sliceitoff/assets/fonts.lst
+++ b/src/sliceitoff/assets/fonts.lst
@@ -3,6 +3,5 @@ deco assets gnufonts UTIL GNUFONTS DECO.FNT
8x8 assets gnufonts UTIL GNUFONTS 8X8.FNT
8x14 assets gnufonts UTIL GNUFONTS 8X14.FNT
computer assets gnufonts UTIL GNUFONTS COMPUTER.FNT
-breeze assets gnufonts UTIL GNUFONTS BREEZE.FNT
-scott assets gnufonts UTIL GNUFONTS SCOTT.FNT
+standard assets gnufonts UTIL GNUFONTS STANDARD.FNT
hearst assets gnufonts UTIL GNUFONTS HEARST.FNT \ No newline at end of file
diff --git a/src/sliceitoff/enemies/enemies.py b/src/sliceitoff/enemies/enemies.py
index 7bf5efa..b1c415d 100644
--- a/src/sliceitoff/enemies/enemies.py
+++ b/src/sliceitoff/enemies/enemies.py
@@ -42,7 +42,7 @@ class EnemySprite(pygame.sprite.Sprite):
class EnemyBall(EnemySprite):
def __init__(self):
super().__init__()
- letter = Fonts.fonts['8x8'].get(2).subsurface((0,0,8,8))
+ letter = Fonts.fonts['8x8'].get(randrange(1,3)).subsurface((0,0,8,8))
colored = letter.fill( "black", special_flags = pygame.BLEND_RGBA_MULT)
self.image = pygame.transform.scale_by(letter, 1_000 * Scaling.factor)
self.update()
@@ -51,7 +51,7 @@ class EnemyBall(EnemySprite):
class Enemies(pygame.sprite.Group):
def __init__(self, field = None):
super().__init__()
- for _ in range(3 + (Stats.level-1) * 2):
+ for _ in range(Stats.enemies):
enemy = EnemyBall()
enemy.set_position( (randrange(0,300_000), randrange(0,200_000)) )
enemy.set_movement( (randrange(0,200)-100, randrange(0,200)-100) )
diff --git a/src/sliceitoff/field/field.py b/src/sliceitoff/field/field.py
index f1a2086..82391d6 100644
--- a/src/sliceitoff/field/field.py
+++ b/src/sliceitoff/field/field.py
@@ -152,3 +152,4 @@ class Field(pygame.sprite.LayeredUpdates):
else:
self.explode(field.area)
field.remove(self)
+ Stats.field_count=len(self.active_sprites())
diff --git a/src/sliceitoff/game/gameplay.py b/src/sliceitoff/game/gameplay.py
index 6869cbb..e1f17ab 100644
--- a/src/sliceitoff/game/gameplay.py
+++ b/src/sliceitoff/game/gameplay.py
@@ -21,7 +21,7 @@ class Gameplay:
zap_sprite = self.field.slice(
self.player.position,
self.player.direction,
- 4_500)
+ 4_000)
if not zap_sprite:
return False
if pygame.sprite.spritecollideany(zap_sprite, self.enemies):
diff --git a/src/sliceitoff/player/player.py b/src/sliceitoff/player/player.py
index c062f1c..9235dc3 100644
--- a/src/sliceitoff/player/player.py
+++ b/src/sliceitoff/player/player.py
@@ -1,8 +1,10 @@
import os
import pygame
+from random import randrange
+
from display import Scaling
-from images import Images
+from images import Fonts
DEBUG = os.getenv("DEBUG")
@@ -21,9 +23,17 @@ class Player(pygame.sprite.LayeredUpdates):
def __init__(self):
super().__init__()
self.position = (0,0)
- self.direction = True
+ self.direction = False
self.lazer = False
- image = Images.surfaces['player_00']
+ image = pygame.Surface((8,26), pygame.SRCALPHA)
+ for color, y, ch in (
+ ("red",0,0x18),
+ ("red",13,0x19),
+ ("blue",6,0x09)):
+ ch = Fonts.fonts['standard'].get(ch)
+ ch.fill( color, special_flags = pygame.BLEND_RGBA_MULT)
+ image.blit(ch,(0,y))
+ image = pygame.transform.scale_by(image, 1_200 * Scaling.factor)
self.add(PlayerSprite(image), layer = 0)
image = pygame.transform.rotate(image, 90)
self.add(PlayerSprite(image), layer = 1)
diff --git a/src/sliceitoff/screens/levelup.py b/src/sliceitoff/screens/levelup.py
index 0a0468b..6b4003f 100644
--- a/src/sliceitoff/screens/levelup.py
+++ b/src/sliceitoff/screens/levelup.py
@@ -2,18 +2,28 @@ from text import TextPage
from stats import Stats
def levelup_screen():
+ (
+ total_bonus,
+ level_bonus,
+ life_bonus,
+ time_bonus,
+ area_bonus,
+ herd_bonus) = Stats.calc_bonus()
text = (
" LEVEL UP BONUS!\n"
" ===============\n"
"\n"
- f"Level{Stats.level*3000:7d}pts\n"
- f"Time{Stats.bonus:8d}pts\n"
+ f"Level{Stats.level:3d}\x12{level_bonus:9d}pts\n"
+ f"Lives{Stats.lives:3d}\x03{life_bonus:9d}pts\n"
+ f"Time{int(Stats.bonus/1000):4d}\x0e{time_bonus:9d}pts\n"
+ f"Area{int(Stats.percent):4d}\xfe{area_bonus:9d}pts\n"
+ f"Herd{Stats.enemies-Stats.field_count:4d}\x0f{herd_bonus:9d}pts\n"
f"\n"
- f"Total{Stats.level*3000+Stats.bonus:7d}pts")
+ f"Bonus{total_bonus:13d}pts\n")
return TextPage(
text,
- font = 'hearst',
+ font = 'lcd',
size = (12_000, 24_000),
- grid = (14_000, 24_000),
+ grid = (14_000, 20_000),
pos = (12_000, 6_000) )
diff --git a/src/sliceitoff/stats/stats.py b/src/sliceitoff/stats/stats.py
index 80cd347..4024e53 100644
--- a/src/sliceitoff/stats/stats.py
+++ b/src/sliceitoff/stats/stats.py
@@ -3,7 +3,9 @@ class Stats:
level = 0
bonus = 0
lives = 0
+ enemies = 0
percent = 0
+ field_count = 0
bgcolor = (64,0,0,255)
bordercolor = (0,0,0,255)
@@ -14,20 +16,33 @@ class Stats:
__class__.bonus = 20_000
__class__.lives = 3
__class__.percent = 100
+ __class__.field_count = 1
+ __class__.enemies = 3
@staticmethod
def level_up():
- __class__.score += __class__.level * 3_000
- __class__.score += __class__.level * __class__.bonus
+ __class__.score += __class__.calc_bonus()[0]
__class__.bonus = 20_000
__class__.percent = 100
+ __class__.field_count = 1
__class__.level += 1
+ __class__.enemies = 3 + (__class__.level - 1) * 2
@staticmethod
def lose_life():
__class__.lives -= 1
return not __class__.lives
-
+
+ @staticmethod
+ def calc_bonus():
+ level = __class__.level * 3_000
+ life = __class__.lives * 1_000
+ time = __class__.level * __class__.bonus
+ area = __class__.level * int(max(20-__class__.percent,0) * 1_000)
+ herd = (__class__.enemies - __class__.field_count) * 1_000
+ total = level + area + time + life + herd
+ return total, level, life, time, area, herd
+
@staticmethod
def update_bonus(dt):
__class__.bonus = max(0, __class__.bonus - dt)
diff --git a/src/sliceitoff/status/status.py b/src/sliceitoff/status/status.py
index cacc84a..ea93b88 100644
--- a/src/sliceitoff/status/status.py
+++ b/src/sliceitoff/status/status.py
@@ -12,17 +12,16 @@ class Status(pygame.sprite.Group):
""" Rebuilds statusline if needed """
super().update(**kwargs)
score_str = (
- "\x12{:1d} \x03{:1d} \x0e{:02d} \xfe{:02d} "
- "\x0f{:08d}").format(
- Stats.level,
- Stats.lives,
- Stats.bonus // 1000,
- 99 if Stats.percent == 100 else int(Stats.percent),
- Stats.score)
+ f"\x12{Stats.level:<2d}"
+ f"\x03{Stats.lives:<2d}"
+ f"\x0e{Stats.bonus // 1000:<3d}"
+ f"\xfe{99 if Stats.percent == 100 else int(Stats.percent):<3d}"
+ f"\x0f{Stats.enemies-Stats.field_count:<3d}"
+ f"{Stats.score:08d}")
if self.old_srt != score_str:
self.empty()
self.add( TextPage(
score_str,
- pos = (0, 220_000),
+ pos = (2_000, 220_000),
size = (12_000, 0),
font = 'lcd') )