diff --git a/event_interpreter.py b/event_interpreter.py new file mode 100644 index 0000000..b272cf9 --- /dev/null +++ b/event_interpreter.py @@ -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 +# diff --git a/main.py b/main.py index 4ab9620..8196614 100644 --- a/main.py +++ b/main.py @@ -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 ) diff --git a/project_constants.py b/project_constants.py new file mode 100644 index 0000000..9a48563 --- /dev/null +++ b/project_constants.py @@ -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') \ No newline at end of file diff --git a/resources/assets/background.png b/resources/assets/background.png new file mode 100644 index 0000000..70f15f7 Binary files /dev/null and b/resources/assets/background.png differ diff --git a/resources/minefields/there's_a_file_here_'cause_I_cannot_commit_an_empty_directory b/resources/minefields/there's_a_file_here_'cause_I_cannot_commit_an_empty_directory new file mode 100644 index 0000000..e69de29