added the .py files and the *temporary* sprite assets
12
.idea/inspectionProfiles/Project_Default.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoredErrors">
|
||||||
|
<list>
|
||||||
|
<option value="N802" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
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>
|
7
.idea/misc.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="JavaScriptSettings">
|
||||||
|
<option name="languageLevel" value="ES6" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
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/untitled.iml" filepath="$PROJECT_DIR$/.idea/untitled.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/projet-dino-club_info.iml
Normal 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>
|
8
.idea/untitled.iml
Normal 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>
|
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>
|
BIN
bg.jpg
Normal file
After Width: | Height: | Size: 349 KiB |
BIN
ground.png
Normal file
After Width: | Height: | Size: 99 KiB |
BIN
obs10.png
Normal file
After Width: | Height: | Size: 153 B |
BIN
obs20.png
Normal file
After Width: | Height: | Size: 167 B |
BIN
obs30.png
Normal file
After Width: | Height: | Size: 176 B |
BIN
obs40.png
Normal file
After Width: | Height: | Size: 183 B |
BIN
obs50.png
Normal file
After Width: | Height: | Size: 202 B |
BIN
obs60.png
Normal file
After Width: | Height: | Size: 206 B |
BIN
obs70.png
Normal file
After Width: | Height: | Size: 209 B |
16
setup.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
from cx_Freeze import setup, Executable
|
||||||
|
base = None
|
||||||
|
executables = [Executable("tests.py", base=base)]
|
||||||
|
packages = ["idna", "random", "pygame"]
|
||||||
|
options = {
|
||||||
|
'build_exe': {
|
||||||
|
'packages':packages,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
setup(
|
||||||
|
name = "dino à 2 balles",
|
||||||
|
options = options,
|
||||||
|
version = "1.0",
|
||||||
|
description = 'FC ça passe',
|
||||||
|
executables = executables
|
||||||
|
)
|
147
tests.py
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
import pygame
|
||||||
|
import random
|
||||||
|
pygame.init()
|
||||||
|
pygame.font.init()
|
||||||
|
|
||||||
|
win = pygame.display.set_mode((500, 500))
|
||||||
|
pygame.display.set_caption("test")
|
||||||
|
bigFont = pygame.font.SysFont('Impact', 50)
|
||||||
|
smallFont = pygame.font.SysFont('Impact', 35)
|
||||||
|
|
||||||
|
|
||||||
|
posGround = 405
|
||||||
|
posPlayer = 40
|
||||||
|
|
||||||
|
|
||||||
|
posy = posGround -64
|
||||||
|
|
||||||
|
jumpCount = 21
|
||||||
|
walkCount = 0
|
||||||
|
bgCount = 0
|
||||||
|
groundCount =0
|
||||||
|
jump = False
|
||||||
|
|
||||||
|
|
||||||
|
class Obstacle:
|
||||||
|
def __init__(self, position, width):
|
||||||
|
self.position = position
|
||||||
|
self.width = width
|
||||||
|
|
||||||
|
|
||||||
|
obs1 = Obstacle(600, random.randrange(10, 70, 10))
|
||||||
|
obs2 = Obstacle(1000, random.randrange(10, 70, 10))
|
||||||
|
obs3 = Obstacle(1400, random.randrange(10, 70, 10))
|
||||||
|
obs4 = Obstacle(2000, random.randrange(10, 70, 10))
|
||||||
|
obs5 = Obstacle(2200, random.randrange(10, 70, 10))
|
||||||
|
obs6 = Obstacle(2600, random.randrange(10, 70, 10))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def jumpHeight(count):
|
||||||
|
return (-0.02*count*count+8)*20
|
||||||
|
|
||||||
|
|
||||||
|
walkSprite = [pygame.image.load('walk1.png'), pygame.image.load('walk2.png'), pygame.image.load('walk3.png'), pygame.image.load('walk4.png'), pygame.image.load('walk5.png'), pygame.image.load('walk6.png')]
|
||||||
|
obstacleSprite =[pygame.image.load('obs10.png'), pygame.image.load('obs20.png'), pygame.image.load('obs30.png'), pygame.image.load('obs40.png'), pygame.image.load('obs50.png'), pygame.image.load('obs60.png'), pygame.image.load('obs70.png')]
|
||||||
|
bg = pygame.image.load('bg.jpg')
|
||||||
|
ground = pygame.image.load('ground.png')
|
||||||
|
|
||||||
|
|
||||||
|
program_Running = True
|
||||||
|
game_Running = True
|
||||||
|
|
||||||
|
while program_Running:
|
||||||
|
while game_Running:
|
||||||
|
print('yay')
|
||||||
|
pygame.time.delay(int(1000/60))
|
||||||
|
obstacles = [obs1, obs2, obs3, obs4, obs5, obs6]
|
||||||
|
|
||||||
|
for event in pygame.event.get():
|
||||||
|
if event.type == pygame.QUIT:
|
||||||
|
game_Running = False
|
||||||
|
program_Running = False
|
||||||
|
|
||||||
|
key = pygame.key.get_pressed()
|
||||||
|
if key[pygame.K_SPACE] and jumpCount == 21:
|
||||||
|
jump = True
|
||||||
|
jumpCount = -20
|
||||||
|
|
||||||
|
if jump and jumpCount <= 20:
|
||||||
|
posy = posGround - int(jumpHeight(jumpCount)) - 64
|
||||||
|
jumpCount += 1
|
||||||
|
|
||||||
|
for i in range(0, 6):
|
||||||
|
if abs(obstacles[i].position - posPlayer)<obstacles[i].width/2:
|
||||||
|
if posy > posGround -64 -50:
|
||||||
|
game_Running = False
|
||||||
|
|
||||||
|
win.fill((0, 0, 0))
|
||||||
|
win.blit(bg, (0+int(bgCount/3), 0))
|
||||||
|
win.blit(ground, (groundCount, posGround))
|
||||||
|
win.blit(walkSprite[(walkCount % 18)//3], (posPlayer, posy))
|
||||||
|
|
||||||
|
for i in range(0, 6):
|
||||||
|
if obstacles[i].position < 500:
|
||||||
|
if obstacles[i].width == 10:
|
||||||
|
win.blit(obstacleSprite[0], (obstacles[i].position, posGround-50))
|
||||||
|
elif obstacles[i].width == 20:
|
||||||
|
win.blit(obstacleSprite[1], (obstacles[i].position, posGround-50))
|
||||||
|
elif obstacles[i].width == 30:
|
||||||
|
win.blit(obstacleSprite[2], (obstacles[i].position, posGround-50))
|
||||||
|
elif obstacles[i].width == 40:
|
||||||
|
win.blit(obstacleSprite[3], (obstacles[i].position, posGround-50))
|
||||||
|
elif obstacles[i].width == 50:
|
||||||
|
win.blit(obstacleSprite[4], (obstacles[i].position, posGround-50))
|
||||||
|
elif obstacles[i].width == 60:
|
||||||
|
win.blit(obstacleSprite[5], (obstacles[i].position, posGround-50))
|
||||||
|
elif obstacles[i].width == 70:
|
||||||
|
win.blit(obstacleSprite[6], (obstacles[i].position, posGround-50))
|
||||||
|
obstacles[i].position -= 5
|
||||||
|
|
||||||
|
|
||||||
|
if obstacles[i].position < -1 * obstacles[i].width:
|
||||||
|
obstacles[i].width = random.randrange(10, 70, 10)
|
||||||
|
obstacles[i].position = 2400
|
||||||
|
print(i, ": position: ", obstacles[i].position)
|
||||||
|
|
||||||
|
pygame.display.update()
|
||||||
|
|
||||||
|
walkCount += 1
|
||||||
|
groundCount -= 5
|
||||||
|
if groundCount <= -641:
|
||||||
|
groundCount = 0
|
||||||
|
lostText = bigFont.render('YOU LOST', False, (255, 0, 0))
|
||||||
|
lostText2 = smallFont.render("Press Spacebar to replay", False, (255, 0, 0))
|
||||||
|
win.fill((0, 0, 0))
|
||||||
|
win.blit(lostText, (150, 150))
|
||||||
|
win.blit(lostText2, (75, 250))
|
||||||
|
pygame.display.update()
|
||||||
|
|
||||||
|
for event in pygame.event.get():
|
||||||
|
if event.type == pygame.QUIT:
|
||||||
|
program_Running = False
|
||||||
|
|
||||||
|
|
||||||
|
key = pygame.key.get_pressed()
|
||||||
|
if key[pygame.K_SPACE]:
|
||||||
|
|
||||||
|
game_Running = True
|
||||||
|
|
||||||
|
# reseting every variable:
|
||||||
|
|
||||||
|
posy = posGround - 64
|
||||||
|
|
||||||
|
jumpCount = 21
|
||||||
|
walkCount = 0
|
||||||
|
bgCount = 0
|
||||||
|
groundCount = 0
|
||||||
|
jump = False
|
||||||
|
|
||||||
|
obs1 = Obstacle(600, random.randrange(10, 70, 10))
|
||||||
|
obs2 = Obstacle(1000, random.randrange(10, 70, 10))
|
||||||
|
obs3 = Obstacle(1400, random.randrange(10, 70, 10))
|
||||||
|
obs4 = Obstacle(2000, random.randrange(10, 70, 10))
|
||||||
|
obs5 = Obstacle(2200, random.randrange(10, 70, 10))
|
||||||
|
obs6 = Obstacle(2600, random.randrange(10, 70, 10))
|
||||||
|
|
||||||
|
|
BIN
walk1.png
Normal file
After Width: | Height: | Size: 693 B |
BIN
walk2.png
Normal file
After Width: | Height: | Size: 739 B |
BIN
walk3.png
Normal file
After Width: | Height: | Size: 650 B |
BIN
walk4.png
Normal file
After Width: | Height: | Size: 670 B |
BIN
walk5.png
Normal file
After Width: | Height: | Size: 712 B |
BIN
walk6.png
Normal file
After Width: | Height: | Size: 1.1 KiB |