Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import play
- import pygame
- from random import randint
- play.set_backdrop("beige")
- death = play.new_box(color = "beige", width = 1000, height = 30, x = 0, y = -300)
- sea = play.new_image("seaside.jpg", size = 27.5, x = 0, y = 85)
- score_txt = play.new_text(words = 'Completion:', x=play.screen.right-160, y=play.screen.top-30, size=70)
- score = play.new_text(words = '0', x=play.screen.right-65, y=play.screen.top-30, size=70)
- percentage = play.new_text(words = '%', x=play.screen.right-30, y=play.screen.top-30, size=70)
- text = play.new_text(color = "grey", words='Tap W to jump, LEFT/RIGHT to move', x=0, y=play.screen.bottom+60, size=70)
- #player
- player = play.new_box(width = 20, height = 35, x = -380, y = 175, color = "beige", border_color = "brown", border_width = 2.5)
- #platforms
- platforms = []
- platform_1 = play.new_box(width = 150, height = 10, x = -350, y = 150, color = "brown")
- platforms.append(platform_1)
- platform_2 = play.new_box(width = 150, height = 10, x = 350, y = 150, color = "brown")
- platforms.append(platform_2)
- platform_3 = play.new_box(width = 150, height = 10, x = 0, y = 100, color = "brown")
- platforms.append(platform_3)
- platform_4 = play.new_box(width = 125, height = 10, x = -360, y = 105, angle = 45, color = "brown")
- platforms.append(platform_4)
- platform_5 = play.new_box(width = 125, height = 10, x = 360, y = 105, angle = -45, color = "brown")
- platforms.append(platform_5)
- platform_6 = play.new_box(width = 150, height = 10, x = -120, y = 0, color = "brown")
- platforms.append(platform_6)
- platform_7 = play.new_box(width = 150, height = 10, x = 120, y = 0, color = "brown")
- platforms.append(platform_7)
- #shells
- shells = []
- shell_1 = play.new_image(image = "shell-removebg-preview.png", size = 7.5, x = -120, y = 25)
- shells.append(shell_1)
- shell_2 = play.new_image(image = "shell-removebg-preview.png", size = 7.5, x = 0, y = 125)
- shells.append(shell_2)
- shell_3 = play.new_image(image = "shell-removebg-preview.png", size = 7.5, x = 120, y = 25)
- shells.append(shell_3)
- shell_4 = play.new_image(image = "shell-removebg-preview.png", size = 7.5, x = 300, y = 175)
- shells.append(shell_4)
- @play.when_program_starts
- def start():
- player.start_physics(can_move = True, stable = True, obeys_gravity = True, mass = 100, friction = 1.0, bounciness = 0.1)
- for platform in platforms:
- platform.start_physics(can_move = False, stable = True, obeys_gravity = False, mass = 10)
- @play.repeat_forever
- async def game():
- if play.key_is_pressed("a"):
- player.physics.x_speed = -10
- if play.key_is_pressed("d"):
- player.physics.x_speed = 10
- if play.key_is_pressed("w"):
- if player.is_touching(platform_1):
- player.physics.y_speed = 50
- elif player.is_touching(platform_2):
- player.physics.y_speed = 50
- elif player.is_touching(platform_3):
- player.physics.y_speed = 200
- elif player.is_touching(platform_6):
- player.physics.y_speed = 200
- elif player.is_touching(platform_7):
- player.physics.y_speed = 200
- else:
- player.physics.y_speed = 0
- #to collect shells
- for s in shells:
- if s.is_touching(player):
- s.hide()
- shells.remove(s)
- score.words = str(int(score.words) + 25)
- #losing check
- if player.is_touching(death):
- for s in shells:
- s.hide
- sea.hide()
- score.hide()
- score_txt.hide()
- percentage.hide()
- for i in platforms:
- i.hide()
- player.hide()
- for i in shells:
- i.hide()
- text.hide()
- lose = play.new_image(image = "pic.jpg", size = 200, x = 0, y = -50)
- lose_text = play.new_text(words = "YOU LOSE", color = "black", x = 0, y = 250, size = 200)
- await play.timer(3)
- quit()
- #win check
- if len(shells) == 0:
- await play.timer(3)
- for s in shells:
- s.hide
- sea.hide()
- score.hide()
- score_txt.hide()
- percentage.hide()
- for i in platforms:
- i.hide()
- player.hide()
- for i in shells:
- i.hide()
- text.hide()
- win = play.new_image(image = "image.jpg", size = 75)
- win_text = play.new_text(words = "WIN", color = "blue", x = -250, y = 200, size = 150)
- await play.timer(seconds=1/48)
- play.start_program()
Advertisement
Add Comment
Please, Sign In to add comment