feat(tractor): add method to get current tile
This commit is contained in:
parent
7de410c59a
commit
ff7e5c4b99
@ -1,6 +1,8 @@
|
||||
import pygame
|
||||
import os
|
||||
from dotenv import find_dotenv, load_dotenv
|
||||
from kb import ile_podlac
|
||||
from tile import Tile
|
||||
|
||||
class Tractor(pygame.sprite.Sprite):
|
||||
def __init__(self, field):
|
||||
@ -55,3 +57,12 @@ class Tractor(pygame.sprite.Sprite):
|
||||
y = self.rect.y // TILE_SIZE
|
||||
tile_type = self.field.tiles.sprites()[y * 16 + x].type
|
||||
print(f"The tractor is on a {tile_type} tile.")
|
||||
|
||||
def get_current_tile(self):
|
||||
load_dotenv(find_dotenv())
|
||||
TILE_SIZE = int(os.getenv("TILE_SIZE"))
|
||||
|
||||
x = self.rect.x // TILE_SIZE
|
||||
y = self.rect.y // TILE_SIZE
|
||||
current_tile = self.field.tiles.sprites()[y * 16 + x]
|
||||
return current_tile
|
||||
|
Loading…
Reference in New Issue
Block a user