Simple plateformer game playing
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
from .stoneBlock import StoneBlock
|
||||
from .spawnPointBlock import SpawnPointBlock
|
||||
from .finishBlock import FinishBlock
|
||||
|
||||
BLOCKS = [
|
||||
StoneBlock,
|
||||
SpawnPointBlock,
|
||||
FinishBlock,
|
||||
]
|
||||
@@ -0,0 +1,31 @@
|
||||
from abc import abstractmethod
|
||||
|
||||
from game.gameState import GameState
|
||||
|
||||
class Block:
|
||||
@property
|
||||
@abstractmethod
|
||||
def character(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def type(self):
|
||||
pass
|
||||
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def solid(self):
|
||||
pass
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def on_collision(self, gameState: GameState):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def to_string(self):
|
||||
pass
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
from game.blocks.block import Block
|
||||
from game.gameState import GameState
|
||||
|
||||
class FinishBlock(Block):
|
||||
@property
|
||||
def character(self):
|
||||
return 'E'
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return 'finish'
|
||||
|
||||
@property
|
||||
def solid(self):
|
||||
return False
|
||||
|
||||
def on_collision(self, gameState: GameState):
|
||||
gameState.set_stop_game(True)
|
||||
gameState.set_game_won(True)
|
||||
|
||||
def to_string(self):
|
||||
return "🏁"
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
from game.blocks.block import Block
|
||||
from game.gameState import GameState
|
||||
|
||||
class SpawnPointBlock(Block):
|
||||
@property
|
||||
def character(self):
|
||||
return 'S'
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return 'spawn_point'
|
||||
|
||||
@property
|
||||
def solid(self):
|
||||
return False
|
||||
|
||||
def on_collision(self, gameState: GameState):
|
||||
pass
|
||||
|
||||
def to_string(self):
|
||||
return "🚩"
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
from game.blocks.block import Block
|
||||
from game.gameState import GameState
|
||||
|
||||
class StoneBlock(Block):
|
||||
@property
|
||||
def character(self):
|
||||
return '#'
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return 'stone'
|
||||
|
||||
@property
|
||||
def solid(self):
|
||||
return True
|
||||
|
||||
def on_collision(self, gameState: GameState):
|
||||
# Stone blocks are solid, so the player cannot move through them.
|
||||
pass
|
||||
|
||||
def to_string(self):
|
||||
return "⬛"
|
||||
Reference in New Issue
Block a user