reformated code to meet PEP 8 standards
This commit is contained in:
parent
a61e1c03b3
commit
691fcb1ca9
30
main.py
30
main.py
@ -1,18 +1,13 @@
|
|||||||
# libraries
|
# libraries
|
||||||
import pygame
|
import pygame
|
||||||
from pyglet.gl import * # for blocky textures
|
from pyglet.gl import * # for blocky textures
|
||||||
|
|
||||||
# other files of this project
|
# other files of this project
|
||||||
import project_constants
|
import project_constants
|
||||||
import event_interpreter
|
|
||||||
import minefield as mf
|
import minefield as mf
|
||||||
import json_generator
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
pygame.display.set_caption(project_constants.V_NAME_OF_WINDOW)
|
pygame.display.set_caption(project_constants.V_NAME_OF_WINDOW)
|
||||||
|
|
||||||
@ -26,15 +21,13 @@ def main():
|
|||||||
running = True
|
running = True
|
||||||
while running:
|
while running:
|
||||||
|
|
||||||
|
# ================ #
|
||||||
# ================ #
|
# === GRAPHICS === #
|
||||||
# === GRAPHICS === #
|
# ================ #
|
||||||
# ================ #
|
|
||||||
|
|
||||||
# background grid (fills frame with white, blits grid)
|
# background grid (fills frame with white, blits grid)
|
||||||
project_constants.SCREEN.fill((255, 255, 255))
|
project_constants.SCREEN.fill((255, 255, 255))
|
||||||
project_constants.SCREEN.blit\
|
project_constants.SCREEN.blit(
|
||||||
(
|
|
||||||
project_constants.ASSET_BACKGROUND,
|
project_constants.ASSET_BACKGROUND,
|
||||||
(
|
(
|
||||||
project_constants.V_SCREEN_PADDING,
|
project_constants.V_SCREEN_PADDING,
|
||||||
@ -46,21 +39,19 @@ def main():
|
|||||||
minefield.draw(project_constants.SCREEN)
|
minefield.draw(project_constants.SCREEN)
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
|
|
||||||
|
# ============== #
|
||||||
|
# === EVENTS === #
|
||||||
# ============== #
|
# ============== #
|
||||||
# === EVENTS === #
|
|
||||||
# ============== #
|
|
||||||
|
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
|
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
running = False
|
running = False
|
||||||
|
|
||||||
# else: event_interpreter.interpret( event )
|
# else: event_interpreter.interpret( event )
|
||||||
# Assigning all input from keyboard as variables into an array
|
# Assigning all input from keyboard as variables into an array
|
||||||
keys = pygame.key.get_pressed()
|
keys = pygame.key.get_pressed()
|
||||||
|
|
||||||
# Depending on what key we press, the agent will move in that direction
|
# Depending on what key we press, the agent will move in that direction
|
||||||
# DISCRETION : The only keys that are available are arrow keys
|
# DISCRETION : The only keys that are available are arrow keys
|
||||||
if keys[pygame.K_RIGHT]:
|
if keys[pygame.K_RIGHT]:
|
||||||
@ -72,5 +63,6 @@ def main():
|
|||||||
elif keys[pygame.K_DOWN]:
|
elif keys[pygame.K_DOWN]:
|
||||||
minefield.go_down()
|
minefield.go_down()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import pygame
|
import pygame
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
# VARIABLE STARTS WITH ... IF IT'S
|
# VARIABLE STARTS WITH ... IF IT'S
|
||||||
# V a value like a string or an int
|
# V a value like a string or an int
|
||||||
# STRUCT a list or other structure of values
|
# STRUCT a list or other structure of values
|
||||||
@ -9,7 +8,6 @@ import os
|
|||||||
# MAP a JSON map file
|
# MAP a JSON map file
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ================= #
|
# ================= #
|
||||||
# === VARIABLES === #
|
# === VARIABLES === #
|
||||||
# ================= #
|
# ================= #
|
||||||
@ -18,20 +16,18 @@ V_NAME_OF_WINDOW = "MineFusion TM"
|
|||||||
ASSETS_DIR = os.path.join("resources", "assets")
|
ASSETS_DIR = os.path.join("resources", "assets")
|
||||||
|
|
||||||
V_TILE_SIZE = 60
|
V_TILE_SIZE = 60
|
||||||
V_GRID_VER_TILES = V_GRID_HOR_TILES = 10 # vertical, horizontal
|
V_GRID_VER_TILES = V_GRID_HOR_TILES = 10 # vertical, horizontal
|
||||||
V_SCREEN_PADDING = 10
|
V_SCREEN_PADDING = 10
|
||||||
V_MINEFIELD_HEIGHT = V_TILE_SIZE * V_GRID_VER_TILES
|
V_MINEFIELD_HEIGHT = V_TILE_SIZE * V_GRID_VER_TILES
|
||||||
V_MINEFIELD_WIDTH = V_TILE_SIZE * V_GRID_HOR_TILES
|
V_MINEFIELD_WIDTH = V_TILE_SIZE * V_GRID_HOR_TILES
|
||||||
|
|
||||||
SCREEN = pygame.display.set_mode\
|
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 width
|
||||||
V_TILE_SIZE * V_GRID_HOR_TILES + 2 * V_SCREEN_PADDING # screen height
|
V_TILE_SIZE * V_GRID_HOR_TILES + 2 * V_SCREEN_PADDING # screen height
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# =============== #
|
# =============== #
|
||||||
# === STRUCTS === #
|
# === STRUCTS === #
|
||||||
# =============== #
|
# =============== #
|
||||||
@ -44,86 +40,71 @@ STRUCT_MINE_TYPES = ['A', 'B', 'F', 'K']
|
|||||||
# ============== #
|
# ============== #
|
||||||
MAP_RANDOM_10x10 = os.path.join("resources", "minefields", "firstmap.json")
|
MAP_RANDOM_10x10 = os.path.join("resources", "minefields", "firstmap.json")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ============== #
|
# ============== #
|
||||||
# === ASSETS === #
|
# === ASSETS === #
|
||||||
# ============== #
|
# ============== #
|
||||||
|
|
||||||
ASSET_BACKGROUND = pygame.transform.scale\
|
ASSET_BACKGROUND = pygame.transform.scale(
|
||||||
(
|
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "new_grid.png")),
|
pygame.image.load(os.path.join(ASSETS_DIR, "new_grid.png")),
|
||||||
(V_MINEFIELD_WIDTH, V_MINEFIELD_WIDTH)
|
(V_MINEFIELD_WIDTH, V_MINEFIELD_WIDTH)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_SAPPER = pygame.transform.scale\
|
ASSET_SAPPER = pygame.transform.scale(
|
||||||
(
|
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "sapper.png")),
|
pygame.image.load(os.path.join(ASSETS_DIR, "sapper.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_MINE_A = pygame.transform.scale\
|
ASSET_MINE_A = pygame.transform.scale(
|
||||||
(
|
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "mine_a.png")),
|
pygame.image.load(os.path.join(ASSETS_DIR, "mine_a.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_MINE_B = pygame.transform.scale\
|
ASSET_MINE_B = pygame.transform.scale(
|
||||||
(
|
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "mine_b.png")),
|
pygame.image.load(os.path.join(ASSETS_DIR, "mine_b.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_MINE_F = pygame.transform.scale\
|
ASSET_MINE_F = pygame.transform.scale(
|
||||||
(
|
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "mine_f.png")),
|
pygame.image.load(os.path.join(ASSETS_DIR, "mine_f.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_MINE_K = pygame.transform.scale\
|
ASSET_MINE_K = pygame.transform.scale(
|
||||||
(
|
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "mine_k.png")),
|
pygame.image.load(os.path.join(ASSETS_DIR, "mine_k.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_TILE_ORANGE = pygame.transform.scale\
|
ASSET_TILE_ORANGE = pygame.transform.scale(
|
||||||
(
|
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "tile_orange.png")),
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_orange.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_TILE_RED = pygame.transform.scale\
|
ASSET_TILE_RED = pygame.transform.scale(
|
||||||
(
|
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "tile_red.png")),
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_red.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_TILE_BLUE = pygame.transform.scale\
|
ASSET_TILE_BLUE = pygame.transform.scale(
|
||||||
(
|
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "tile_blue.png")),
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_blue.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_TILE_PURPLE = pygame.transform.scale\
|
ASSET_TILE_PURPLE = pygame.transform.scale(
|
||||||
(
|
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "tile_purple.png")),
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_purple.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_TILE_GREEN = pygame.transform.scale\
|
ASSET_TILE_GREEN = pygame.transform.scale(
|
||||||
(
|
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "tile_green.png")),
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_green.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_TILE_YELLOW = pygame.transform.scale\
|
ASSET_TILE_YELLOW = pygame.transform.scale(
|
||||||
(
|
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "tile_yellow.png")),
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_yellow.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
|
||||||
ASSET_TILE_WHITE = pygame.transform.scale\
|
ASSET_TILE_WHITE = pygame.transform.scale(
|
||||||
(
|
|
||||||
pygame.image.load(os.path.join(ASSETS_DIR, "tile_white.png")),
|
pygame.image.load(os.path.join(ASSETS_DIR, "tile_white.png")),
|
||||||
(V_TILE_SIZE, V_TILE_SIZE)
|
(V_TILE_SIZE, V_TILE_SIZE)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user