initial commit
This commit is contained in:
commit
5a3ae08f61
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal 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
4
.idea/misc.xml
Normal 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 (pythonProject)" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal 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/pythonProject.iml" filepath="$PROJECT_DIR$/.idea/pythonProject.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
10
.idea/pythonProject.iml
Normal file
10
.idea/pythonProject.iml
Normal 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>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
85
main.py
Normal file
85
main.py
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
import pygame
|
||||||
|
|
||||||
|
|
||||||
|
class Field:
|
||||||
|
def __init__(self, isWet, thingOn):
|
||||||
|
self.isWet = isWet
|
||||||
|
self.thingOn = thingOn
|
||||||
|
|
||||||
|
|
||||||
|
class Player:
|
||||||
|
x = 0
|
||||||
|
y = 0
|
||||||
|
rotation = 0
|
||||||
|
|
||||||
|
|
||||||
|
T = [[Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)],
|
||||||
|
[Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)],
|
||||||
|
[Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)],
|
||||||
|
[Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)],
|
||||||
|
[Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)],
|
||||||
|
[Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)],
|
||||||
|
[Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)],
|
||||||
|
[Field(1, 0), Field(0, 0), Field(0, 1), Field(0, 2), Field(0, 3), Field(1, 0), Field(1, 0), Field(1, 0)]]
|
||||||
|
pygame.init()
|
||||||
|
|
||||||
|
player = Player()
|
||||||
|
|
||||||
|
screen = pygame.display.set_mode([500, 500])
|
||||||
|
|
||||||
|
running = True
|
||||||
|
clock = pygame.time.Clock()
|
||||||
|
while running:
|
||||||
|
for event in pygame.event.get():
|
||||||
|
if event.type == pygame.QUIT:
|
||||||
|
running = False
|
||||||
|
if event.type == pygame.KEYDOWN:
|
||||||
|
if event.key == pygame.K_LEFT:
|
||||||
|
if player.x > 0:
|
||||||
|
player.x = player.x - 1
|
||||||
|
if event.key ==pygame.K_UP:
|
||||||
|
if player.y > 0:
|
||||||
|
player.y = player.y - 1
|
||||||
|
if event.key ==pygame.K_RIGHT:
|
||||||
|
if player.x < 7:
|
||||||
|
player.x = player.x + 1
|
||||||
|
if event.key ==pygame.K_DOWN:
|
||||||
|
if player.y < 7:
|
||||||
|
player.y = player.y + 1
|
||||||
|
screen.fill((178, 255, 51))
|
||||||
|
img1 = pygame.image.load('1.png')
|
||||||
|
img2 = pygame.image.load('2.png')
|
||||||
|
img3 = pygame.image.load('3.png')
|
||||||
|
imgPlayer = pygame.image.load('player.png')
|
||||||
|
i = 0
|
||||||
|
while i < len(T):
|
||||||
|
j = 0
|
||||||
|
while j < len(T[i]):
|
||||||
|
color = (0, 0, 0)
|
||||||
|
if T[i][j].isWet == 0:
|
||||||
|
color = (160, 82, 45)
|
||||||
|
else:
|
||||||
|
color = (51, 25, 0)
|
||||||
|
pygame.draw.rect(screen, color, pygame.Rect(50 + 50 * i, 50 + 50 * j, 50, 50))
|
||||||
|
if T[i][j].thingOn==1:
|
||||||
|
screen.blit(img1, (50 + 50 * i, 50 + 50 * j))
|
||||||
|
if T[i][j].thingOn==2:
|
||||||
|
screen.blit(img2, (50 + 50 * i, 50 + 50 * j))
|
||||||
|
if T[i][j].thingOn==3:
|
||||||
|
screen.blit(img3, (50 + 50 * i, 50 + 50 * j))
|
||||||
|
j = j + 1
|
||||||
|
i = i + 1
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
while i < len(T)+1:
|
||||||
|
pygame.draw.line(screen, (0, 0, 0), (50 + i * 50, 50), (50 + i * 50, 50 + len(T) * 50),5)
|
||||||
|
pygame.draw.line(screen, (0, 0, 0), (50, 50 + i * 50), (50 + len(T) * 50, 50 + i * 50),5)
|
||||||
|
i = i + 1
|
||||||
|
tmpImg = pygame.transform.rotate(imgPlayer, player.rotation)
|
||||||
|
screen.blit(tmpImg, (55 + 50 * player.x, 55 + 50 * player.y))
|
||||||
|
pygame.display.flip()
|
||||||
|
# clock.tick(30)
|
||||||
|
|
||||||
|
# Done! Time to quit.
|
||||||
|
|
||||||
|
pygame.quit()
|
BIN
player.png
Normal file
BIN
player.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue
Block a user