diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..06bb031 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6649a8c --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..aeb7613 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/projet-dino-club_info.iml b/.idea/projet-dino-club_info.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/projet-dino-club_info.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/untitled.iml b/.idea/untitled.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/untitled.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/bg.jpg b/bg.jpg new file mode 100644 index 0000000..8870293 Binary files /dev/null and b/bg.jpg differ diff --git a/ground.png b/ground.png new file mode 100644 index 0000000..9880a44 Binary files /dev/null and b/ground.png differ diff --git a/obs10.png b/obs10.png new file mode 100644 index 0000000..00fc918 Binary files /dev/null and b/obs10.png differ diff --git a/obs20.png b/obs20.png new file mode 100644 index 0000000..8c4953a Binary files /dev/null and b/obs20.png differ diff --git a/obs30.png b/obs30.png new file mode 100644 index 0000000..5fbb791 Binary files /dev/null and b/obs30.png differ diff --git a/obs40.png b/obs40.png new file mode 100644 index 0000000..b72c326 Binary files /dev/null and b/obs40.png differ diff --git a/obs50.png b/obs50.png new file mode 100644 index 0000000..1e17bcf Binary files /dev/null and b/obs50.png differ diff --git a/obs60.png b/obs60.png new file mode 100644 index 0000000..f20fd40 Binary files /dev/null and b/obs60.png differ diff --git a/obs70.png b/obs70.png new file mode 100644 index 0000000..57bcc88 Binary files /dev/null and b/obs70.png differ diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f1f602a --- /dev/null +++ b/setup.py @@ -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 +) \ No newline at end of file diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..d208716 --- /dev/null +++ b/tests.py @@ -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) 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)) + + diff --git a/walk1.png b/walk1.png new file mode 100644 index 0000000..1dd2b59 Binary files /dev/null and b/walk1.png differ diff --git a/walk2.png b/walk2.png new file mode 100644 index 0000000..3b372d3 Binary files /dev/null and b/walk2.png differ diff --git a/walk3.png b/walk3.png new file mode 100644 index 0000000..ae84d90 Binary files /dev/null and b/walk3.png differ diff --git a/walk4.png b/walk4.png new file mode 100644 index 0000000..5b87ad1 Binary files /dev/null and b/walk4.png differ diff --git a/walk5.png b/walk5.png new file mode 100644 index 0000000..40640a3 Binary files /dev/null and b/walk5.png differ diff --git a/walk6.png b/walk6.png new file mode 100644 index 0000000..1c1577e Binary files /dev/null and b/walk6.png differ