Added coins

This commit is contained in:
2026-10-10 15:28:42 +02:00
parent 9030146ec8
commit 10a3d93821
7 changed files with 59 additions and 8 deletions
+2
View File
@@ -1,9 +1,11 @@
from .stoneBlock import StoneBlock
from .spawnPointBlock import SpawnPointBlock
from .finishBlock import FinishBlock
from .coinBlock import CoinBlock
BLOCKS = [
StoneBlock,
SpawnPointBlock,
FinishBlock,
CoinBlock
]
+28
View File
@@ -0,0 +1,28 @@
import os
from game.blocks.block import Block
from game.gameState import GameState
class CoinBlock(Block):
def __init__(self):
self.collected = False
@property
def character(self):
return '°'
@property
def type(self):
return 'coin'
@property
def solid(self):
return False
def on_collision(self, gameState: GameState):
if not self.collected:
gameState.add_coin()
self.collected = True
def to_string(self):
return " " if self.collected else "🪙" + (" " if os.getenv("SHOW_EXTRA_EMOJI_SPACES", "false").lower() == "true" else "")