This commit is contained in:
s473609 2023-03-15 13:03:42 +01:00
commit 802d5f5b01
6 changed files with 94 additions and 0 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (pythonPro)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pythonPro.iml" filepath="$PROJECT_DIR$/.idea/pythonPro.iml" />
</modules>
</component>
</project>

10
.idea/pythonPro.iml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

58
main.py Normal file
View File

@ -0,0 +1,58 @@
import pygame
pygame.init()
screen_size = (600, 600)
screen = pygame.display.set_mode(screen_size)
square_size = 50
num_squares = screen_size[0] // square_size
squares = []
for i in range(num_squares):
row = []
for j in range(num_squares):
square_rect = pygame.Rect(j * square_size, i * square_size, square_size, square_size)
row.append(square_rect)
squares.append(row)
object_rect = pygame.Rect(0, 0, square_size, square_size)
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
if object_rect.top > 0:
object_rect.top -= square_size
elif event.key == pygame.K_DOWN:
if object_rect.bottom < screen_size[1]:
object_rect.top += square_size
elif event.key == pygame.K_LEFT:
if object_rect.left > 0:
object_rect.left -= square_size
elif event.key == pygame.K_RIGHT:
if object_rect.right < screen_size[0]:
object_rect.left += square_size
screen.fill((255, 255, 255))
for row in squares:
for square_rect in row:
pygame.draw.rect(screen, (0, 0, 0), square_rect, 1)
pygame.draw.rect(screen, (255, 0, 0), object_rect)
pygame.display.flip()