2021-04-17 15:29:36 +02:00
|
|
|
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(
|
2021-04-17 19:56:34 +02:00
|
|
|
pygame.transform.rotate(const.ASSET_SAPPER, 270),
|
2021-04-17 15:29:36 +02:00
|
|
|
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(
|
2021-04-17 19:56:34 +02:00
|
|
|
pygame.transform.rotate(const.ASSET_SAPPER, 90),
|
2021-04-17 15:29:36 +02:00
|
|
|
sapper_screen_coords
|
|
|
|
)
|
|
|
|
|