Add tile cost
This commit is contained in:
parent
4ceaf4904b
commit
89ad35bdf9
BIN
assets/atlas.png
BIN
assets/atlas.png
Binary file not shown.
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 14 KiB |
@ -1,9 +1,5 @@
|
||||
import random
|
||||
|
||||
|
||||
class Tile:
|
||||
origins = [(0, 0), (32, 0), (64, 0), (96, 0)]
|
||||
|
||||
def __init__(self, origin=(0, 0)):
|
||||
self.origin = random.choice(Tile.origins)
|
||||
def __init__(self, origin, cost):
|
||||
self.origin = origin
|
||||
self.cost = cost
|
||||
self.image = None
|
||||
|
19
survival/tile_generator.py
Normal file
19
survival/tile_generator.py
Normal file
@ -0,0 +1,19 @@
|
||||
import random
|
||||
|
||||
from survival.tile import Tile
|
||||
|
||||
|
||||
class TileGenerator:
|
||||
templates = [
|
||||
[(0, 0), 1], # Grass 1
|
||||
[(32, 0), 1], # Grass 2
|
||||
[(64, 0), 1], # Grass 3
|
||||
[(96, 0), 1], # Grass 4
|
||||
[(64, 64), 2], # Sand
|
||||
[(96, 64), 2], # Poddle
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def get_random_tile():
|
||||
template = random.choice(TileGenerator.templates)
|
||||
return Tile(template[0], template[1])
|
@ -1,12 +1,12 @@
|
||||
from survival.image import Image
|
||||
from survival.tile import Tile
|
||||
from survival.tile_generator import TileGenerator
|
||||
|
||||
|
||||
class TileLayer:
|
||||
def __init__(self, width, height):
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.tiles = [[Tile() for x in range(self.width)] for y in range(self.height)]
|
||||
self.tiles = [[TileGenerator.get_random_tile() for x in range(self.width)] for y in range(self.height)]
|
||||
self.image = Image('atlas.png')
|
||||
|
||||
def draw(self, camera, visible_area):
|
||||
|
Loading…
Reference in New Issue
Block a user