initial project structure, dummy background

This commit is contained in:
s452635 2021-03-11 00:47:14 +01:00
parent 2c650658c6
commit 60bf33f79e
4 changed files with 100 additions and 0 deletions

25
event_interpreter.py Normal file
View File

@ -0,0 +1,25 @@
import pygame
def interpret( event ):
# remove this after adding code
pass
# key press interpretation here
# add calls to sapper object's movement functions
# TODO : key press interpretation goes here
#
# TINY SAMPLE FROM MY PYGAME TEST
# (had trouble with figuring this out)
#
# # this part is true, when you press a key down
# # there's also a KEYUP for letting go
# if event.type == pygame.KEYDOWN:
#
# # this part is true, when a key u pressed down is the left arrow
# if event.key == pygame.K_LEFT:
# # here should be a call to sapper's movement function
#

52
main.py
View File

@ -1,6 +1,58 @@
# libraries
import pygame
# other files of this project
import project_constants
import event_interpreter
if __name__ == "__main__":
pygame.init()
pygame.display.set_caption(project_constants.V_NAME_OF_WINDOW)
# loading minefields
# TODO : call to a minefield loading function goes here
running = True
while running:
# ================ #
# === GRAPHICS === #
# ================ #
# background grid (fills frame with white, blits grid)
project_constants.SCREEN.fill((255, 255, 255))
project_constants.SCREEN.blit\
(
project_constants.ASSET_BACKGROUND,
(
project_constants.V_SCREEN_PADDING,
project_constants.V_SCREEN_PADDING
)
)
# tiles
# TODO : call to tile blitting function goes here
# mines
# TODO : call to a mine blitting function goes here
pygame.display.update()
# ============== #
# === EVENTS === #
# ============== #
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
else: event_interpreter.interpret( event )

23
project_constants.py Normal file
View File

@ -0,0 +1,23 @@
import pygame
# VARIABLE STARTS WITH ... IF IT'S
# V a value like a string or an int
# ASSET a png file (or other graphic format)
V_NAME_OF_WINDOW = "MineFusion TM"
V_TILE_SIZE = 60
V_GRID_VER_TILES = V_GRID_HOR_TILES = 10 # vertical, horizontal
V_SCREEN_PADDING = 10
SCREEN = pygame.display.set_mode\
(
(
V_TILE_SIZE * V_GRID_HOR_TILES + 2 * V_SCREEN_PADDING, # screen width
V_TILE_SIZE * V_GRID_HOR_TILES + 2 * V_SCREEN_PADDING # screen height
)
)
ASSET_BACKGROUND = pygame.image.load('resources/assets/background.png')

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB