trashbin-rendering #23
@ -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)
|
@ -1,9 +1,8 @@
|
||||
from enum import Enum
|
||||
|
||||
from map import map_utils
|
||||
from settings import *
|
||||
|
||||
ROAD_TILE = 0
|
||||
|
||||
class Rotation(Enum):
|
||||
UP = 0
|
||||
RIGHT = 1
|
||||
@ -36,7 +35,7 @@ def get_neighbours(node, searched_list, array):
|
||||
y = node.y + offset_y
|
||||
# prevent out of map coords
|
||||
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.rotation = get_needed_rotation(node, neighbour)
|
||||
neighbours.append(neighbour)
|
||||
|
Loading…
Reference in New Issue
Block a user