70 lines
1.3 KiB
Python
70 lines
1.3 KiB
Python
from module import COLORS
|
|
|
|
class Block:
|
|
id = ''
|
|
color = ''
|
|
flowable = False # 可流动
|
|
fallible = False # 可下坠
|
|
collision = True # 可以碰撞
|
|
|
|
def __init__(self, x: int, y: int):
|
|
self.x = x
|
|
self.y = y
|
|
|
|
def get_screen_x(self):
|
|
return self.x * 20
|
|
|
|
def get_screen_y(self):
|
|
return self.y * 20
|
|
|
|
|
|
class GrassBlock(Block):
|
|
id = 'grass'
|
|
color = COLORS.get(id)
|
|
|
|
def __init__(self, x: int, y: int):
|
|
super().__init__(x, y)
|
|
|
|
|
|
class DirtBlock(Block):
|
|
id = 'dirt'
|
|
color = COLORS.get(id)
|
|
|
|
def __init__(self, x: int, y: int):
|
|
super().__init__(x, y)
|
|
|
|
|
|
class SandBlock(Block):
|
|
id = 'sand'
|
|
color = COLORS.get(id)
|
|
flowable = True
|
|
|
|
def __init__(self, x: int, y: int):
|
|
super().__init__(x, y)
|
|
|
|
|
|
class StoneBlock(Block):
|
|
id = 'stone'
|
|
color = COLORS.get(id)
|
|
|
|
def __init__(self, x: int, y: int):
|
|
super().__init__(x, y)
|
|
|
|
|
|
class AirBlock(Block):
|
|
id = 'air'
|
|
color = COLORS.get(id)
|
|
collision = False
|
|
|
|
def __init__(self, x: int, y: int):
|
|
super().__init__(x, y)
|
|
|
|
|
|
class WaterBlock(Block):
|
|
id = 'water'
|
|
color = COLORS.get(id)
|
|
flowable = True
|
|
collision = False
|
|
|
|
def __init__(self, x: int, y: int):
|
|
super().__init__(x, y) |