48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
|
import pygame
|
||
|
|
||
|
import project_constants as const
|
||
|
|
||
|
|
||
|
# moved here from minefield
|
||
|
def calculate_screen_position(row, column):
|
||
|
|
||
|
coords = (
|
||
|
const.V_SCREEN_PADDING + const.V_TILE_SIZE * column,
|
||
|
const.V_SCREEN_PADDING + const.V_TILE_SIZE * row,
|
||
|
)
|
||
|
|
||
|
return coords
|
||
|
|
||
|
|
||
|
def display_sapper(sapper_x, sapper_y, sapper_dir):
|
||
|
|
||
|
sapper_screen_coords = calculate_screen_position(
|
||
|
sapper_x,
|
||
|
sapper_y
|
||
|
)
|
||
|
|
||
|
if sapper_dir == const.Direction.UP:
|
||
|
const.SCREEN.blit(
|
||
|
const.ASSET_SAPPER,
|
||
|
sapper_screen_coords
|
||
|
)
|
||
|
|
||
|
if sapper_dir == const.Direction.RIGHT:
|
||
|
const.SCREEN.blit(
|
||
|
pygame.transform.rotate(const.ASSET_SAPPER, 90),
|
||
|
sapper_screen_coords
|
||
|
)
|
||
|
|
||
|
if sapper_dir == const.Direction.DOWN:
|
||
|
const.SCREEN.blit(
|
||
|
pygame.transform.rotate(const.ASSET_SAPPER, 180),
|
||
|
sapper_screen_coords
|
||
|
)
|
||
|
|
||
|
if sapper_dir == const.Direction.LEFT:
|
||
|
const.SCREEN.blit(
|
||
|
pygame.transform.rotate(const.ASSET_SAPPER, 270),
|
||
|
sapper_screen_coords
|
||
|
)
|
||
|
|