trashbin-rendering #23

Merged
s464843 merged 3 commits from trashbin-rendering into master 2022-05-10 12:08:35 +02:00
2 changed files with 2 additions and 27 deletions
Showing only changes of commit 45a3ff6711 - Show all commits

View File

@ -1,24 +0,0 @@
from settings import *
class Camera:
def __init__(self,width,height):
self.camera = pg.Rect(0,0, width, height)
self.width = width
self.height = height
def apply(self,entity):
return entity.rect.move(self.camera.topleft)
def apply_rect(self, rect):
return rect.move(self.camera.topleft)
def update(self,target):
x = -target.rect.x + int(WIDTH/2)
y = -target.rect.y + int(HEIGHT / 2)
# limit scrolling to map size
x = min(0, x) # left
y = min(0, y) # top
x = max(-(self.width - WIDTH), x) # right
y = max(-(self.height - HEIGHT), y) # bottom
self.camera = pg.Rect(x, y, self.width, self.height)

View File

@ -1,9 +1,8 @@
from enum import Enum from enum import Enum
from map import map_utils
from settings import * from settings import *
ROAD_TILE = 0
class Rotation(Enum): class Rotation(Enum):
UP = 0 UP = 0
RIGHT = 1 RIGHT = 1
@ -36,7 +35,7 @@ def get_neighbours(node, searched_list, array):
y = node.y + offset_y y = node.y + offset_y
# prevent out of map coords # prevent out of map coords
if (x >= 0 and x < MAP_WIDTH and y >= 0 and y < MAP_HEIGHT): if (x >= 0 and x < MAP_WIDTH and y >= 0 and y < MAP_HEIGHT):
if(array[y][x] == ROAD_TILE and (x, y) not in searched_list): if(map_utils.isRoadTile(array[y][x]) and (x, y) not in searched_list):
neighbour = Node(x, y, Rotation.NONE) neighbour = Node(x, y, Rotation.NONE)
neighbour.rotation = get_needed_rotation(node, neighbour) neighbour.rotation = get_needed_rotation(node, neighbour)
neighbours.append(neighbour) neighbours.append(neighbour)