fixing size of the grid to 10x10
This commit is contained in:
parent
517b60b7a7
commit
c4d21146a9
14
main.py
14
main.py
@ -2,15 +2,15 @@ import pygame
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
screen = pygame.display.set_mode((1280, 720))
|
screen = pygame.display.set_mode((980, 980))
|
||||||
c = (0, 150, 0)
|
c = (0, 150, 0)
|
||||||
|
|
||||||
|
|
||||||
def draw_grid():
|
def draw_grid():
|
||||||
for y in range(80, 720, 80): # horizontal lines
|
for y in range(80, 960, 80): # horizontal lines
|
||||||
pygame.draw.line(screen, c, (80, y), (1280 - 80, y), 1)
|
pygame.draw.line(screen, c, (80, y), (960 - 80, y), 1)
|
||||||
for x in range(80, 1280, 80): # vertical lines
|
for x in range(80, 960, 80): # vertical lines
|
||||||
pygame.draw.line(screen, c, (x, 80), (x, 720 - 80), 1)
|
pygame.draw.line(screen, c, (x, 80), (x, 960 - 80), 1)
|
||||||
|
|
||||||
|
|
||||||
class Wozek:
|
class Wozek:
|
||||||
@ -36,13 +36,13 @@ def main():
|
|||||||
elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
|
elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN:
|
elif event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN:
|
||||||
if wozek.y <= 600:
|
if wozek.y <= 800:
|
||||||
wozek.y += 80
|
wozek.y += 80
|
||||||
elif event.type == pygame.KEYDOWN and event.key == pygame.K_UP:
|
elif event.type == pygame.KEYDOWN and event.key == pygame.K_UP:
|
||||||
if wozek.y >= 100:
|
if wozek.y >= 100:
|
||||||
wozek.y -= 80
|
wozek.y -= 80
|
||||||
elif event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT:
|
elif event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT:
|
||||||
if wozek.x <= 1170:
|
if wozek.x <= 800:
|
||||||
wozek.x += 80
|
wozek.x += 80
|
||||||
elif event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT:
|
elif event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT:
|
||||||
if wozek.x >= 100:
|
if wozek.x >= 100:
|
||||||
|
Loading…
Reference in New Issue
Block a user