repl.it
@MinecraftMrGabe/

parkour game

Pygame

I made a parkour game. it's fun if you ignore the physics

fork
loading
Files
  • main.py
  • electromagic railgun.png
  • graphics.py
  • grappling hook.png
  • hook.png
  • HV round.png
  • ideas
  • mission.py
  • New Piskel-1.png (3).png
  • nohup.out
  • output.txt
  • player_front.png
  • player_left.png
  • player_right.png
  • player_zipline.png
  • player.png
  • playerside.png
  • rope.png
  • rpg.png
  • trial.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import pygame
from pygame.locals import *
screen = pygame.display.set_mode((800,600))
clock = pygame.time.Clock()
sps = 1 #seconds per second. this will allow some stuff I've been thinking about
import mission
from mission import mouse
import trial
pygame.font.init()
buttons = pygame.sprite.Group()
clicked_button = None
class moose(pygame.sprite.Sprite):
  def __init__(self):
    pygame.sprite.Sprite.__init__(self)
    self.image = pygame.surface.Surface((1,1))
    self.rect = self.image.get_rect()
    self.clicking = False
Mouse = moose()
def updmouse():
  global Mouse
  pos = pygame.mouse.get_pos()
  Mouse.rect.x = pos[0]-0.5
  Mouse.rect.y = pos[1]-0.5
  btn = pygame.sprite.spritecollideany(Mouse,buttons)
  if btn!=None:
    btn.hovered = True
    for x in buttons.sprites():
      if x != btn:
        x.hovered = False
class button(pygame.sprite.Sprite):
  def __init__(self,id,text,color,pos,size):
    pygame.sprite.Sprite.__init__(self)
    self.id = id
    self.text = text
    self.color = color
    self.pos = pos
    self.size = size
    font = pygame.font.Font('freesansbold.ttf',int(size[1]*0.9))
    self.trxt = font.render(str(text),True,color)
    self.surf = pygame.surface.Surface(size)
    self.surf.blit(self.trxt,(self.size[0]//2-self.trxt.get_size()[0]//2,self.size[1]//2-self.trxt.get_size()[1]//2))
    self.image = self.surf
    self.rect = pygame.surface.Surface(size).get_rect()
    self.rect.x = self.pos[0]
    self.rect.y = self.pos[1]
    self.clicked = False
    self.hovered = False
    buttons.add(self)
  def update(self):
    if self.hovered:
      self.rect.x+=1
      
    self.clicked = Mouse.clicking and self.hovered
    if self.clicked:
      clicked_button = self
  def reset(self):
    self.hovered = False
  def draw(self):
    screen.blit(self.image,self.rect)
yeet = mission.npc((),screen,pygame.sprite.Group())
image = pygame.transform.scale(yeet.image,(400,400))
#button('msnbtn',"missions",(125,125,125),(0,0),(100,20))
#def button.click():
#  trial.play(yeet)
cam = mission.camera(0,0,screen)
menus = pygame.sprite.Group()
main_menu = mission.Menu('main menu',cam)
menus.add(main_menu)
main_menu.active = True
main_menu.show = True
main_menu.back_button.rect.y = -100
main_menu.start_button.rect.y = -100
main_menu.buttons.add(mission.button('Trial',(60,60,60),(100,100),(100,30),trial.cam,trial.play,main_menu))
def main():
  while True:
    mission.upd_mouse()
    for event in pygame.event.get():
      if event.type == MOUSEBUTTONDOWN:
        mission.mouse.clicking = True
      elif event.type == MOUSEBUTTONUP:
        mission.mouse.clicking = False
    screen.fill((255,255,255))
    menus.draw(screen)
    menus.update()
    screen.blit(image,(300,150))
    pygame.display.update()
    for x in buttons:
      x.reset()
    clock.tick(30)
    
main()