Code Structure
This commit is contained in:
parent
1ed6a272b8
commit
2516befe86
1
Interface/__init__.py
Normal file
1
Interface/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
from .interface import *
|
@ -3,15 +3,19 @@ import pygame
|
|||||||
BLACK = 0, 0, 0
|
BLACK = 0, 0, 0
|
||||||
WHITE = 255, 255, 255
|
WHITE = 255, 255, 255
|
||||||
|
|
||||||
|
|
||||||
def rect(screen, color, position_x, position_y, size_x, size_y):
|
def rect(screen, color, position_x, position_y, size_x, size_y):
|
||||||
pygame.draw.rect(screen, color, (position_x, position_y, size_x, size_y))
|
pygame.draw.rect(screen, color, (position_x, position_y, size_x, size_y))
|
||||||
|
|
||||||
|
|
||||||
def line(screen, color, x_1, y_1, x_2, y_2):
|
def line(screen, color, x_1, y_1, x_2, y_2):
|
||||||
pygame.draw.line(screen, color, (x_1, y_1), (x_2, y_2))
|
pygame.draw.line(screen, color, (x_1, y_1), (x_2, y_2))
|
||||||
|
|
||||||
|
|
||||||
def create_screen(size):
|
def create_screen(size):
|
||||||
return pygame.display.set_mode(size)
|
return pygame.display.set_mode(size)
|
||||||
|
|
||||||
|
|
||||||
def draw_board(screen, color, width, height, tiles_x, tiles_y):
|
def draw_board(screen, color, width, height, tiles_x, tiles_y):
|
||||||
tiles_width = width / tiles_x
|
tiles_width = width / tiles_x
|
||||||
tiles_height = height / tiles_y
|
tiles_height = height / tiles_y
|
||||||
@ -25,4 +29,3 @@ def draw_board(screen, color, width, height, tiles_x, tiles_y):
|
|||||||
for i in range(tiles_y-1):
|
for i in range(tiles_y-1):
|
||||||
line(screen, color, 0, temp_y, width, temp_y)
|
line(screen, color, 0, temp_y, width, temp_y)
|
||||||
temp_y += tiles_height
|
temp_y += tiles_height
|
||||||
|
|
||||||
|
21
Interface/interface.py
Normal file
21
Interface/interface.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import sys
|
||||||
|
import pygame
|
||||||
|
from .helpers import *
|
||||||
|
|
||||||
|
|
||||||
|
def initialize_interface(tiles_x, tiles_y):
|
||||||
|
size = width, height = 800, 800
|
||||||
|
screen = create_screen(size)
|
||||||
|
pygame.display.set_caption('Epic AI Vacuum Cleaner')
|
||||||
|
|
||||||
|
while True:
|
||||||
|
for event in pygame.event.get():
|
||||||
|
if event.type == pygame.QUIT:
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
screen.fill(BLACK)
|
||||||
|
# rect(screen, WHITE, 50,50,90,90)
|
||||||
|
|
||||||
|
draw_board(screen, WHITE, width, height, tiles_x, tiles_y)
|
||||||
|
|
||||||
|
pygame.display.flip()
|
@ -1,23 +0,0 @@
|
|||||||
import sys, pygame
|
|
||||||
from helpers import *
|
|
||||||
pygame.init()
|
|
||||||
|
|
||||||
size = width, height = 1000, 1000
|
|
||||||
screen = create_screen(size)
|
|
||||||
|
|
||||||
tiles_x, tiles_y = 10, 10
|
|
||||||
|
|
||||||
|
|
||||||
while True:
|
|
||||||
for event in pygame.event.get():
|
|
||||||
if event.type == pygame.QUIT: sys.exit()
|
|
||||||
|
|
||||||
|
|
||||||
screen.fill(BLACK)
|
|
||||||
# rect(screen, WHITE, 50,50,90,90)
|
|
||||||
|
|
||||||
draw_board(screen, WHITE, width, height, tiles_x, tiles_y)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pygame.display.flip()
|
|
Loading…
Reference in New Issue
Block a user