2021-06-25 16:13:52 +02:00
|
|
|
from gamedata.objects.base import BaseObject
|
|
|
|
|
|
|
|
class TilesetRenderer(BaseObject):
|
|
|
|
|
|
|
|
def __init__(self,x,y,game):
|
|
|
|
|
|
|
|
super().__init__(x,y,game)
|
|
|
|
|
|
|
|
self.tilew = 64
|
|
|
|
self.tileh = 64
|
|
|
|
|
2021-06-25 18:29:57 +02:00
|
|
|
self.solid = game.sprite_lib["solid.png"]
|
|
|
|
self.empty = game.sprite_lib["empty.png"]
|
2021-06-25 16:13:52 +02:00
|
|
|
|
|
|
|
self.collisiongrid = [
|
|
|
|
[0,0,0,0,0,0,0],
|
2021-06-25 18:29:57 +02:00
|
|
|
[1,0,0,0,1,0,0],
|
2021-06-25 16:13:52 +02:00
|
|
|
[1,1,0,0,0,0,0],
|
|
|
|
[1,1,0,0,0,0,0],
|
2021-06-25 18:57:40 +02:00
|
|
|
[1,1,0,1,0,1,1],
|
2021-06-25 16:13:52 +02:00
|
|
|
[1,1,0,1,1,1,0],
|
|
|
|
]
|
|
|
|
|
|
|
|
def draw(self):
|
|
|
|
|
|
|
|
for y in range(len(self.collisiongrid)):
|
|
|
|
for x in range(len(self.collisiongrid[y])):
|
|
|
|
|
|
|
|
data = self.collisiongrid[y][x]
|
2021-06-25 18:29:57 +02:00
|
|
|
sprites = [self.empty,self.solid]
|
|
|
|
self.game.window.blit(sprites[data],(self.rect[0]+x*self.tilew,self.rect[1]+y*self.tileh))
|