feat: added basic 2d grid

This commit is contained in:
korzepadawid 2022-03-04 16:45:30 +01:00
parent aa4baf8afe
commit bed39e9c44
3 changed files with 38 additions and 11 deletions

2
.gitignore vendored
View File

@ -149,4 +149,4 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear # and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ .idea/

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# 🏰 WMICraft

39
main.py
View File

@ -1,18 +1,43 @@
import pygame import pygame
# game init
pygame.init() pygame.init()
# screen size GAME_TITLE = 'WMICraft'
pygame.display.set_mode((800, 800)) WINDOW_HEIGHT = 900
WINDOW_WIDTH = 900
GRID_CELL_PADDING = 3
GRID_CELL_WIDTH = 42
GRID_CELL_HEIGHT = 42
GREEN = (0, 255, 0)
# title and icon screen = pygame.display.set_mode((WINDOW_HEIGHT, WINDOW_WIDTH))
pygame.display.set_caption('WMICraft') pygame.display.set_caption(GAME_TITLE)
icon = pygame.image.load('resources/icons/sword.png') icon = pygame.image.load('resources/icons/sword.png')
pygame.display.set_icon(icon) pygame.display.set_icon(icon)
running = True
while running: def draw_grid():
for row in range(20):
for column in range(20):
box_rect = [(GRID_CELL_PADDING + GRID_CELL_WIDTH) * column + GRID_CELL_PADDING,
(GRID_CELL_PADDING + GRID_CELL_HEIGHT) * row + GRID_CELL_PADDING,
GRID_CELL_WIDTH,
GRID_CELL_HEIGHT]
pygame.draw.rect(screen, GREEN, box_rect)
def main():
running = True
while running:
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
draw_grid()
pygame.display.update()
pygame.quit()
if __name__ == '__main__':
main()