initial project structure, dummy background
This commit is contained in:
parent
2c650658c6
commit
3cbca8a3f1
25
event_interpreter.py
Normal file
25
event_interpreter.py
Normal 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
52
main.py
@ -1,6 +1,58 @@
|
|||||||
|
# libraries
|
||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
|
# other files of this project
|
||||||
|
import project_constants
|
||||||
|
import event_interpreter
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
|
||||||
pygame.init()
|
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
|
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
23
project_constants.py
Normal 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')
|
BIN
resources/assets/background.png
Normal file
BIN
resources/assets/background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 88 KiB |
Loading…
Reference in New Issue
Block a user