added simple pyGame field interface

This commit is contained in:
Роман Юдешко 2023-03-12 16:50:42 +01:00
parent 9df72a0f98
commit 98784d7e4f
8 changed files with 73 additions and 0 deletions

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

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

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.9" 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/SztIn_gr.234798.iml" filepath="$PROJECT_DIR$/.idea/SztIn_gr.234798.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

38
field.py Normal file
View File

@ -0,0 +1,38 @@
import pygame
pygame.init()
BLUE = (46, 34, 240)
WHITE = (255, 255, 255)
W = 600
H = 400
sc = pygame.display.set_mode((W, H))
pygame.display.set_caption("Pole i ciągnik")
pygame.display.set_icon(pygame.image.load("icon.png"))
clock = pygame.time.Clock()
FPS = 60
x = W // 2
y = H // 2
speed = 20
flRunning = True
while flRunning:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
flRunning = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
x -= speed
elif event.key == pygame.K_RIGHT:
x += speed
elif event.key == pygame.K_DOWN:
y += speed
elif event.key == pygame.K_UP:
y -= speed
sc.fill(WHITE)
pygame.draw.rect(sc, BLUE, (x, y, 20, 20))
pygame.display.update()
clock.tick(FPS)

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB