69 lines
1.9 KiB
Python
69 lines
1.9 KiB
Python
# libraries
|
|
import pygame
|
|
from pyglet.gl import * # for blocky textures
|
|
|
|
# other files of this project
|
|
import project_constants
|
|
import minefield as mf
|
|
|
|
|
|
def main():
|
|
pygame.init()
|
|
pygame.display.set_caption(project_constants.V_NAME_OF_WINDOW)
|
|
|
|
# for blocky textures
|
|
glEnable(GL_TEXTURE_2D)
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
|
|
|
|
# create an instance of Minefield, pass necessary data
|
|
minefield = mf.Minefield(project_constants.MAP_RANDOM_10x10)
|
|
|
|
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
|
|
)
|
|
)
|
|
|
|
# draw tiles and mines
|
|
minefield.draw(project_constants.SCREEN)
|
|
pygame.display.update()
|
|
|
|
# ============== #
|
|
# === EVENTS === #
|
|
# ============== #
|
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
|
running = False
|
|
|
|
# else: event_interpreter.interpret( event )
|
|
# Assigning all input from keyboard as variables into an array
|
|
keys = pygame.key.get_pressed()
|
|
|
|
# Depending on what key we press, the agent will move in that direction
|
|
# DISCRETION : The only keys that are available are arrow keys
|
|
if keys[pygame.K_RIGHT]:
|
|
minefield.go_right()
|
|
elif keys[pygame.K_LEFT]:
|
|
minefield.go_left()
|
|
elif keys[pygame.K_UP]:
|
|
minefield.go_up()
|
|
elif keys[pygame.K_DOWN]:
|
|
minefield.go_down()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|