Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # sorry for how much code this game hass!
- def level3():
- # ---------------------------------------------------------- transition
- white = (255, 255, 255)
- black = (0, 0, 0)
- # our window
- WINDOW_SIZE = (800,700)
- pygame.display.set_caption("new world")
- blacks = 0, 0, 0
- window = pygame.display.set_mode((WINDOW_SIZE), pygame.NOFRAME)
- class Circle:
- def __init__( self, color, x, y, radius, width ):
- self.color = color
- self.x = x
- self.y = y
- self.radius = radius
- self.width = width
- self.raw_width = width
- def draw( self, window ):
- pygame.draw.circle( window, self.color, ( self.x, self.y ), self.radius, self.width )
- def circleInTransition( self ):
- self.radius = max(WINDOW_SIZE)
- self.width = 0
- add = True
- speed = 13
- rnge = round(800 / speed)
- for i in range( rnge ):
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- sys.exit()
- self.width += speed
- if self.width > self.radius:
- self.width = self.radius
- circle.draw( window )
- pygame.display.update()
- self.width = self.radius - 50
- for i in range( 300 ):
- time.sleep(0.0001)
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- sys.exit()
- self.radius -= 2
- self.width -= 2
- if self.radius < 50:
- if self.width <= 0:
- self.radius = 50
- else:
- self.radius = 50
- if self.width < 1:
- self.width = 1
- break
- else:
- level3()
- #if self.width == 50:
- # self.width = 0
- circle.draw( window )
- pygame.display.update()
- pygame.display.update()
- def circleInTransition( self ):
- self.radius = max(WINDOW_SIZE)
- self.width = 0
- add = True
- speed = 13
- rnge = round(800 / speed)
- for i in range( rnge ):
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- sys.exit()
- self.width += speed
- if self.width > self.radius:
- self.width = self.radius
- circle.draw( window )
- pygame.display.update()
- self.width = self.radius - 50
- for i in range( 300 ):
- time.sleep(0.0001)
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- sys.exit()
- self.radius -= 2
- self.width -= 2
- if self.radius < 50:
- if self.width <= 0:
- self.radius = 50
- else:
- self.radius = 50
- if self.width < 1:
- self.width = 1
- break
- else:
- level3()
- #if self.width == 50:
- # self.width = 0
- circle.draw( window )
- pygame.display.update()
- pygame.display.update()
- def circleOutInInOut( self ):
- self.radius = max(WINDOW_SIZE)
- self.width = 0
- speed = 99
- playerman = player(340,465,50,50,white)
- rnge = round(800 / speed)
- for i in range( rnge ):
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- sys.exit()
- if self.width > self.radius:
- self.width = self.radius
- self.width += speed
- circle.draw( window )
- for i in range( 90 ):
- time.sleep(0.0001)
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- sys.exit()
- if self.width < 0:
- self.width = 0
- self.width -= 8
- for bg in bgs:
- bg.draw()
- playerman.draw()
- chef1.draw()
- chef2.draw()
- chef3.draw()
- for cheese in cheeses:
- cheese.draw()
- for obj in object_list:
- obj.draw()
- cheesemove()
- position()
- window.blit(healthba, (-1,0))
- # player health HHEHEHEHEHE
- hitbox = (5, 35 + 2, 31, 57)
- pygame.draw.rect(window, (167, 70, 47), (hitbox[0], hitbox[1] - 4, 170 - (5 * (10 - health)), 10)) # NEW
- pygame.draw.rect(window, (24, 10, 6), (hitbox[0], hitbox[1] - 25, 170 - (5 * (10 - health)), 10)) # NEW
- pygame.draw.rect(window, (54, 24, 16), (hitbox[0], hitbox[1] - 26, 170 - (5 * (10 - health)), 10)) # NEW
- pygame.draw.rect(window, (243, 130, 104), (hitbox[0], hitbox[1] - 25, 170 - (5 * (10 - health)), 10)) # NEW
- pygame.draw.rect(window, (221, 109, 83), (hitbox[0], hitbox[1] - 24, 170 - (5 * (10 - health)), 23)) # NEW
- pygame.draw.rect(window, (199, 84, 57), (hitbox[0], hitbox[1] - 20, 170 - (5 * (10 - health)), 20)) # NEWright = True
- hitbox2 = (5, 89 + 2, 31, 57)
- pygame.draw.rect(window, (13, 16, 17), (hitbox2[0], hitbox2[1] - 21, 170 - (5 * (10 - health2)), 20)) # NEW
- pygame.draw.rect(window, (146,236,244), (hitbox2[0], hitbox2[1] - 20, 170 - (5 * (10 - health2)), 20)) # NEW
- pygame.draw.rect(window, (95, 212, 231), (hitbox2[0], hitbox2[1] - 18, 170 - (5 * (10 - health2)), 20)) # NEW
- pygame.draw.rect(window, (13, 16, 17), (hitbox2[0], hitbox2[1] - 8, 170 - (5 * (10 - health2)), 15)) # NEW
- pygame.draw.rect(window, (57, 182, 214), (hitbox2[0], hitbox2[1] - 10, 170 - (5 * (10 - health2)), 20)) # NEW
- pygame.draw.rect(window, (114, 203, 226), (hitbox2[0], hitbox2[1] - 16, 170 - (5 * (10 - health2)), 20)) # NEW
- hitbox3 = (660, 50 + 2, 31, 57)
- pygame.draw.rect(window, (17,48,42,255), (hitbox3[0], hitbox3[1] - 21, 120 - (5 * (10 - health3)), 20)) # NEW
- pygame.draw.rect(window, (89,243,212,255), (hitbox3[0], hitbox3[1] - 20, 120 - (5 * (10 - health3)), 20)) # NEW
- pygame.draw.rect(window, (87,205,182,255), (hitbox3[0], hitbox3[1] - 18, 120 - (5 * (10 - health3)), 20)) # NEW
- pygame.draw.rect(window, (71,190,166,255), (hitbox3[0], hitbox3[1] - 8, 120 - (5 * (10 - health3)), 15)) # NEW
- pygame.draw.rect(window, (57,160,139,255), (hitbox3[0], hitbox3[1] - 10, 120 - (5 * (10 - health3)), 20)) # NEW
- pygame.draw.rect(window, (71,190,166,255), (hitbox3[0], hitbox3[1] - 16, 120 - (5 * (10 - health3)), 20)) # NEW
- window.blit(stat1, (0,0))
- window.blit(settingsm,(655,-100))
- circle.draw( window )
- pygame.display.update()
- pygame.display.update()
- # --------------------------------------------------- Transition
- global pause
- pause = False
- def quitgame():
- pygame.quit()
- def unpause():
- global pause
- pause = False
- jump = pygame.mixer.Sound('jump1.wav')
- jump.set_volume(0.1)
- hits = pygame.mixer.Sound('hit.flac')
- hits.set_volume(0.1)
- land = [pygame.mixer.Sound('jumpland (4).wav'),pygame.mixer.Sound("land.wav")]
- land[1].set_volume(0.1)
- land[0].set_volume(0.1)
- walk = [pygame.mixer.Sound('jumpland (4).wav'),pygame.mixer.Sound("jumpland (4).wav"),pygame.mixer.Sound("jumpland (4).wav")]
- walk[1].set_volume(0.05)
- # our player class LEVEL 3
- class player:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.idle = [pygame.image.load("grey_mouse/idle (" + str(i) + ").png").convert_alpha() for i in range(1, 21)]
- self.leftid = [pygame.image.load("grey_mouse/id (" + str(i) + ").png").convert_alpha() for i in range(1, 21)]
- self.Right = [pygame.image.load("grey_mouse/walk (" + str(i) + ").png").convert_alpha() for i in range(1, 9)]
- self.left = [pygame.image.load("grey_mouse/left (" + str(i) + ").png").convert_alpha() for i in range(1, 9)]
- self.jump = [pygame.image.load("grey_mouse/jump (6).png")]
- self.jump2 = [pygame.image.load("grey_mouse/jump 06.png").convert_alpha()]
- self.Push = [pygame.image.load("grey_mouse/ol" + str(i) + ".png").convert_alpha() for i in range(1, 9)]
- self.Push2 = [pygame.image.load("grey_mouse/olo (" + str(i) + ").png").convert_alpha() for i in range(1, 9)]
- self.att = [pygame.image.load("grey_mouse/oj" + str(i) + ".png").convert_alpha() for i in range(1, 9)]
- self.att2 = [pygame.image.load("grey_mouse/ojo (" + str(i) + ").png").convert_alpha() for i in range(1, 9)]
- self.snif = [pygame.image.load("grey_mouse/sni (" + str(i) + ").png").convert_alpha() for i in range(1, 19)]
- self.snife = [pygame.image.load("grey_mouse/snie (" + str(i) + ").png").convert_alpha() for i in range(1, 19)]
- self.death = [pygame.image.load("grey_mouse/dead (" + str(i) + ").png").convert_alpha() for i in range(1, 16)]
- self.death2 = [pygame.image.load("grey_mouse/dead2 (" + str(i) + ").png").convert_alpha() for i in range(1, 16)]
- repeat = jumpCountStart // 9
- self.jump = [self.jump[i // repeat] for i in range(len(self.jump) * repeat)]
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.fps = 60
- self.clock = pygame.time.Clock()
- self.next_frame_time = 0
- self.anim_index = 0
- self.time = 0
- self.isJump = False
- self.JumpCount = 10
- self.JumpCount = jumpCountStart
- self.direction = "att"
- self.direction = "att2"
- self.direction = "jump"
- self.direction = "jump2"
- self.direction = "Push2"
- self.direction = "snif"
- self.direction = "snif2"
- self.direction = "DEath"
- self.direction = "DEath2"
- self.direction = "Idle"
- self.direction = "right"
- self.direction = "left"
- self.direction = "leftid"
- self.speed = 1.9
- self.fall = 0
- def get_rect(self):
- self.rect.topleft = (self.x,self.y)
- return self.rect
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "Idle":
- self.clock.tick(self.fps)
- image_list = self.idle
- elif self.direction == "right":
- image_list = self.Right
- elif self.direction == "left":
- image_list = self.left
- elif self.direction == "leftid":
- image_list = self.leftid
- elif self.direction == "jump":
- image_list = self.jump
- elif self.direction == "jump2":
- image_list = self.jump2
- elif self.direction == "Push":
- image_list = self.Push
- elif self.direction == "Push2":
- image_list = self.Push2
- elif self.direction == "att":
- image_list = self.att
- elif self.direction == "att2":
- image_list = self.att2
- elif self.direction == "snif":
- image_list = self.snif
- elif self.direction == "DEath":
- image_list = self.death
- elif self.direction == "DEath2":
- image_list = self.death2
- elif self.direction == "snif2":
- image_list = self.snife
- time_now = pygame.time.get_ticks()
- if (time_now > self.next_frame_time):
- # Time until the next game
- inter_time_delay = 2000 // self.fps
- self.next_frame_time = time_now + inter_time_delay
- # Showing next frame
- self.anim_index += 1
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- player_image = image_list[self.anim_index]
- self.hitbox = (self.x, self.y + 30, 46,60)
- player_rect = player_image.get_rect(midbottom = self.get_rect().midbottom)
- window.blit(player_image, player_rect)
- # our player class LEVEL 2
- class lavaa:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.ws = [pygame.image.load("bob (" + str(i) + ").png").convert_alpha() for i in range(1, 13)]
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.fps = 60
- self.clock = pygame.time.Clock()
- self.next_frame_time = 0
- self.anim_index = 0
- self.direction = "ws"
- def get_rect(self):
- self.rect.topleft = (self.x,self.y)
- return self.rect
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "ws":
- self.clock.tick(self.fps)
- image_list = self.ws
- time_now = pygame.time.get_ticks()
- if (time_now > self.next_frame_time):
- # Time until the next game
- inter_time_delay = 3000 // self.fps
- self.next_frame_time = time_now + inter_time_delay
- # Showing next frame
- self.anim_index += 1
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- player_image = image_list[self.anim_index]
- player_rect = player_image.get_rect(center = self.get_rect().center)
- player_rect.centerx += 15
- player_rect.centery += -60
- window.blit(player_image, player_rect)
- pygame.draw.rect(window,self.color,self.rect)
- # our player class
- class lavaa2: # level 3
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.ws = [pygame.image.load("fliplava (" + str(i) + ").png").convert_alpha() for i in range(1, 13)]
- self.ws2 = [pygame.image.load("updownbob (" + str(i) + ").png").convert_alpha() for i in range(1, 13)]
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.fps = 60
- self.clock = pygame.time.Clock()
- self.next_frame_time = 0
- self.anim_index = 0
- self.direction = "ws"
- self.direction = "updownlava"
- def get_rect(self):
- self.rect.topleft = (self.x,self.y)
- return self.rect
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "ws":
- self.clock.tick(self.fps)
- image_list = self.ws
- if self.direction == "updownlava":
- self.clock.tick(self.fps)
- image_list = self.ws2
- time_now = pygame.time.get_ticks()
- if (time_now > self.next_frame_time):
- # Time until the next game
- inter_time_delay = 3000 // self.fps
- self.next_frame_time = time_now + inter_time_delay
- # Showing next frame
- self.anim_index += 1
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- player_image = image_list[self.anim_index]
- player_rect = player_image.get_rect(center = self.get_rect().center)
- player_rect.centerx += 15
- player_rect.centery += -60
- window.blit(player_image, player_rect)
- # our player class
- class puff:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.ws = [pygame.image.load("dark (" + str(i) + ").png").convert_alpha() for i in range(1, 20)]
- self.wss = [pygame.image.load("dark (" + str(i) + ").png").convert_alpha() for i in range(1,2)]
- self.darkside2 = [pygame.image.load("darkside (" + str(i) + ").png").convert_alpha() for i in range(1,20)]
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.fps = 60
- self.clock = pygame.time.Clock()
- self.next_frame_time = 0
- self.anim_index = 0
- self.direction = "ws"
- self.direction = "wss"
- self.direction = "darkside"
- self.show = False
- def get_rect(self):
- self.rect.topleft = (self.x,self.y)
- return self.rect
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.show:
- if self.direction == "ws":
- self.clock.tick(self.fps)
- image_list = self.ws
- if self.direction == "wss":
- self.clock.tick(self.fps)
- image_list = self.wss
- if self.direction == "darkside":
- self.clock.tick(self.fps)
- image_list = self.darkside2
- time_now = pygame.time.get_ticks()
- if (time_now > self.next_frame_time):
- # Time until the next game
- inter_time_delay = 5000 // self.fps
- self.next_frame_time = time_now + inter_time_delay
- # Showing next frame
- self.anim_index += 1
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- player_image = image_list[self.anim_index]
- player_rect = player_image.get_rect(center = self.get_rect().center)
- player_rect.centerx += 15
- player_rect.centery += -60
- window.blit(player_image, player_rect)
- white = 255,255,252
- puff1 = puff(580,400,50,50,white)
- # our player class
- class shot: # level 2
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.upshot = [pygame.image.load("rightshot (" + str(i) + ").png").convert_alpha() for i in range(1, 5)]
- self.downshot = [pygame.image.load("leftshot (" + str(i) + ").png").convert_alpha() for i in range(1, 5)]
- self.up = [pygame.image.load("upshot (" + str(i) + ").png").convert_alpha() for i in range(1, 5)]
- self.down = [pygame.image.load("downshot (" + str(i) + ").png").convert_alpha() for i in range(1, 5)]
- self.expod = [pygame.image.load("expod (" + str(i) + ").png").convert_alpha() for i in range(1, 10)]
- self.time = 0
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.fps = 60
- self.clock = pygame.time.Clock()
- self.next_frame_time = 0
- self.anim_index = 0
- self.direction = "right"
- self.direction = "left"
- self.direction = "upshot"
- self.direction = "downshot"
- self.direction = "expod"
- self.speed = 5
- def get_rect(self):
- self.rect.topleft = (self.x,self.y)
- return self.rect
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "right":
- self.clock.tick(self.fps)
- image_list = self.upshot
- elif self.direction == "left":
- self.clock.tick(self.fps)
- image_list = self.downshot
- if self.direction == "upshot":
- self.clock.tick(self.fps)
- image_list = self.up
- elif self.direction == "downshot":
- self.clock.tick(self.fps)
- image_list = self.down
- elif self.direction == "expod":
- self.clock.tick(self.fps)
- image_list = self.expod
- time_now = pygame.time.get_ticks()
- if (time_now > self.next_frame_time):
- # Time until the next game
- inter_time_delay = 3000 // self.fps
- self.next_frame_time = time_now + inter_time_delay
- # Showing next frame
- self.anim_index += 1
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- player_image = image_list[self.anim_index]
- player_rect = player_image.get_rect(center = self.get_rect().center)
- player_rect.centerx += 15
- player_rect.centery += 10
- window.blit(player_image, player_rect)
- # our health class player health class
- class health:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.upshot = [pygame.image.load("enemy/health (" + str(i) + ").png").convert_alpha() for i in range(1, 17)]
- self.time = 0
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.fps = 60
- self.clock = pygame.time.Clock()
- self.next_frame_time = 0
- self.anim_index = 0
- self.speed = 5
- self.direction = "up"
- self.hit = False
- def get_rect(self):
- self.rect.topleft = (self.x,self.y)
- return self.rect
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.hit:
- if self.direction == "up":
- self.clock.tick(self.fps)
- image_list = self.upshot
- time_now = pygame.time.get_ticks()
- if (time_now > self.next_frame_time):
- # Time until the next game
- inter_time_delay = 3000 // self.fps
- self.next_frame_time = time_now + inter_time_delay
- # Showing next frame
- self.anim_index += 1
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- player_image = image_list[self.anim_index]
- window.blit(player_image, self.rect)
- white = 255,255,255
- heart = health(200,200,50,50,white)
- heart2 = health(200,200,50,50,white)
- class punch:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.upshot = [pygame.image.load("pos (" + str(i) + ").png").convert_alpha() for i in range(1, 17)]
- self.time = 0
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.fps = 60
- self.clock = pygame.time.Clock()
- self.next_frame_time = 0
- self.anim_index = 0
- self.speed = 5
- self.direction = "up"
- self.hit = False
- def get_rect(self):
- self.rect.topleft = (self.x,self.y)
- return self.rect
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "up":
- self.clock.tick(self.fps)
- image_list = self.upshot
- time_now = pygame.time.get_ticks()
- if (time_now > self.next_frame_time):
- # Time until the next game
- inter_time_delay = 3000 // self.fps
- self.next_frame_time = time_now + inter_time_delay
- # Showing next frame
- self.anim_index += 1
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- player_image = image_list[self.anim_index]
- if self.hit:
- window.blit(player_image, self.rect)
- punch1 = punch(200,200,50,50,white)
- # ------------------------- our portal class
- class portal:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.upshot = [pygame.image.load("pur (" + str(i) + ").png").convert_alpha() for i in range(1, 16)]
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.fps = 60
- self.clock = pygame.time.Clock()
- self.next_frame_time = 0
- self.anim_index = 0
- self.direction = "down"
- self.direction = "up"
- self.speed = 5
- def get_rect(self):
- self.rect.topleft = (self.x,self.y)
- return self.rect
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "up":
- self.clock.tick(self.fps)
- image_list = self.upshot
- time_now = pygame.time.get_ticks()
- if (time_now > self.next_frame_time):
- # Time until the next game
- inter_time_delay = 3000 // self.fps
- self.next_frame_time = time_now + inter_time_delay
- # Showing next frame
- self.anim_index += 1
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- player_image = image_list[self.anim_index]
- player_rect = player_image.get_rect(center = self.get_rect().center)
- player_rect.centerx += 15
- player_rect.centery += -60
- window.blit(player_image, player_rect)
- portal1 = portal(2000,1150,50,50,white)
- #-------------------- portal class
- # our moving rope
- class rop:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.upshot = [pygame.image.load("rop (" + str(i) + ").png").convert_alpha() for i in range(1, 4)]
- self.nomove = [pygame.image.load("rop (" + str(i) + ").png").convert_alpha() for i in range(1, 2)]
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.fps = 60
- self.clock = pygame.time.Clock()
- self.next_frame_time = 0
- self.anim_index = 0
- self.direction = "nomove"
- self.direction = "up"
- self.speed = 5
- def get_rect(self):
- self.rect.topleft = (self.x,self.y)
- return self.rect
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "up":
- self.clock.tick(self.fps)
- image_list = self.upshot
- elif self.direction == "nomove":
- self.clock.tick(self.fps)
- image_list = self.nomove
- time_now = pygame.time.get_ticks()
- if (time_now > self.next_frame_time):
- # Time until the next game
- inter_time_delay = 3000 // self.fps
- self.next_frame_time = time_now + inter_time_delay
- # Showing next frame
- self.anim_index += 1
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- player_image = image_list[self.anim_index]
- window.blit(player_image, self.rect)
- white = 255, 255 ,255
- rop1 = rop(1370,850,50,50,white)
- class fire:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.upshot = [pygame.image.load("pngs/fire_bowl_hanging/fi (" + str(i) + ").png").convert_alpha() for i in range(1, 5)]
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.fps = 60
- self.clock = pygame.time.Clock()
- self.next_frame_time = 0
- self.anim_index = 0
- self.direction = "nomove"
- self.direction = "up"
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "up":
- self.clock.tick(self.fps)
- image_list = self.upshot
- time_now = pygame.time.get_ticks()
- if (time_now > self.next_frame_time):
- # Time until the next game
- inter_time_delay = 5000 // self.fps
- self.next_frame_time = time_now + inter_time_delay
- # Showing next frame
- self.anim_index += 1
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- player_image = image_list[self.anim_index]
- window.blit(player_image, self.rect)
- white = 255, 255 ,255
- #---------------------------------------- LEVEL 2
- fire1 = fire(280,541,50,50,white)
- fire2 = fire(370,541,50,50,white)
- fire3 = fire(150,810,50,50,white)
- fire4 = fire(230,810,50,50,white)
- fire5 = fire(420,938,50,50,white)
- fire6 = fire(510,938,50,50,white)
- fire7 = fire(1159,846,50,50,white)
- #----------------------------------------
- class bowl:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.upshot = [pygame.image.load("pngs/fire_bowl/fi (" + str(i) + ").png").convert_alpha() for i in range(1, 5)]
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.fps = 60
- self.clock = pygame.time.Clock()
- self.next_frame_time = 0
- self.anim_index = 0
- self.direction = "nomove"
- self.direction = "up"
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "up":
- self.clock.tick(self.fps)
- image_list = self.upshot
- time_now = pygame.time.get_ticks()
- if (time_now > self.next_frame_time):
- # Time until the next game
- inter_time_delay = 5000 // self.fps
- self.next_frame_time = time_now + inter_time_delay
- # Showing next frame
- self.anim_index += 1
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- player_image = image_list[self.anim_index]
- window.blit(player_image, self.rect)
- bigfire1 = bowl(90,100,50,50,white)
- bigfire2 = bowl(1360,360,50,50,white)
- # - enemy classes -------------------------------------------
- class rat:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.upshot = [pygame.image.load("enemy/walk (" + str(i) + ").png").convert_alpha() for i in range(1, 10)]
- self.idle = [pygame.image.load("enemy/standright (" + str(i) + ").png").convert_alpha() for i in range(1, 20)]
- self.id = [pygame.image.load("enemy/standleft (" + str(i) + ").png").convert_alpha() for i in range(1, 20)]
- self.move2 = [pygame.image.load("enemy/left (" + str(i) + ").png").convert_alpha() for i in range(1, 10)]
- self.att = [pygame.image.load("enemy/bit (" + str(i) + ").png").convert_alpha() for i in range(1, 10)]
- self.at = [pygame.image.load("enemy/bit2 (" + str(i) + ").png").convert_alpha() for i in range(1, 10)]
- self.die = [pygame.image.load("enemy/died.png").convert_alpha()]
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.fps = 60
- self.clock = pygame.time.Clock()
- self.next_frame_time = 0
- self.anim_index = 0
- self.time = 0
- self.direction = "move"
- self.direction = "move2"
- self.direction = "idle"
- self.direction = "att"
- self.direction = "at"
- self.direction = "id"
- self.direction = "die"
- self.speed = 1
- self.image = pygame.image.load("ratso.png").convert_alpha()
- self.image2 = pygame.image.load("ratso2.png").convert_alpha()
- self.font = pygame.font.Font("Gugi-Regular.ttf", 20)
- self.scoretext = self.font.render("Lv ??", True, (0, 0, 0))
- self.scorerect = self.scoretext.get_rect()
- self.scorerect.center = ((400,550))
- self.healthbar = (self.x + 17, self.y + 2, 31, 57)
- self.isJump = False
- self.jumpCount = 10
- self.isJump2 = False
- self.isJumpCount2 = 5
- self.hitbox2 = (self.x - 47, self.y + 11, 169, 52) # NEW
- self.hitbox = (self.x + 17, self.y + 11, 129, 52) # NEW
- self.hitbox3 = (self.x + 17, self.y + 2, 31, 57)
- self.health = 10
- def get_rect(self):
- self.rect.topleft = (self.x,self.y)
- return self.rect
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "move":
- self.clock.tick(self.fps)
- image_list = self.upshot
- elif self.direction == "idle":
- self.clock.tick(self.fps)
- image_list = self.idle
- elif self.direction == "id":
- self.clock.tick(self.fps)
- image_list = self.id
- elif self.direction == "move2":
- self.clock.tick(self.fps)
- image_list = self.move2
- elif self.direction == "att":
- self.clock.tick(self.fps)
- image_list = self.att
- elif self.direction == "at":
- self.clock.tick(self.fps)
- image_list = self.at
- elif self.direction == "die":
- image_list = self.die
- time_now = pygame.time.get_ticks()
- if (time_now > self.next_frame_time):
- # Time until the next game
- inter_time_delay = 2500 // self.fps
- self.next_frame_time = time_now + inter_time_delay
- # Showing next frame
- self.anim_index += 1
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- player_image = image_list[self.anim_index]
- self.hitbox = (self.x, self.y + 30, 46,60)
- # --------------------------------------------------------------------- center all of them
- player_rect = player_image.get_rect(midbottom = self.get_rect().midbottom)
- player_rect.centerx += 0
- player_rect.centery += -6
- window.blit(player_image, player_rect)
- # --------------------------------------------------------------------- center all of them
- self.hitbox2 = (self.x - 140, self.y - 22, 121, 40) # NEW
- self.hitbox = (self.x + 80, self.y - 22, 60, 40) # NEW
- # our enemy health bar
- pygame.draw.rect(window, (231, 76, 60), (self.x + 5, self.y - 45,59, 15)) # NEW
- pygame.draw.rect(window, (34, 153, 84), (self.x + 5, self.y - 45, 59 - (5 * (10 - self.health)), 15)) # NEW
- window.blit(self.scoretext,(self.x + 15,self.y - 45))
- def jump(self):
- # Check if mario is jumping and then execute the
- # jumping code.
- if self.isJump:
- if self.jumpCount >= -10:
- neg = 1
- if self.jumpCount < 0:
- neg = -1
- self.y -= self.jumpCount**2 * 0.1 * neg
- self.jumpCount -= 1
- else:
- self.isJump = False
- self.jumpCount = 10
- def jump2(self):
- # Check if mario is jumping and then execute the
- # jumping code.
- if self.isJump2:
- if self.isJumpCount2 >= -5:
- neg = 1
- if self.isJumpCount2 < 0:
- neg = -1
- self.y -= self.isJumpCount2**2 * 0.1 * neg
- self.isJumpCount2 -= 1
- else:
- self.isJump2 = False
- self.isJumpCount2 = 5
- rat1 = rat(610,1229,50,50,white) # level 2
- rats = [rat1]
- # - enemy classes -------------------------------------------------------------
- class collid: # collid 333333333333333333333333333
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- def get_rect(self):
- self.rect.topleft = (self.x,self.y)
- return self.rect
- def draw(self): # COLLID 2
- self.rect.topleft = (self.x,self.y)
- cos = (30,50,10)
- collid1 = collid(630,1098,320,50,white) # done
- collid11 = collid(630,260,320,830,white) # done
- collid2 = collid(80,988,20,450,white) # done
- collid02 = collid(1180,1226,50,10,white) # done
- collid3 = collid(860,537,990,10,white)
- crateco = collid(800,425,145,90,white)
- lever = collid(100,419,120,5,white)
- stopglitch = collid(100,419,120,5,white)
- top1 = collid(330,1255,50,10,cos) # done
- top5 = collid(540,1277,470,10,cos) # done
- top2 = collid(140,778,22170,10,white) # done
- top3 = collid(390,915,22170,10,white) # done
- top4 = collid(250,602,22170,10,white) # done
- top04 = collid(1090,816,22170,10,cos) # done
- collidmove = collid(1410,750,50,450,white) # level 2
- collidmove2 = collid(1400,790,50,450,white)
- collid4 = collid(1394,1276,459,10,white)
- collid5 = collid(1894,1210,259,10,white)
- collids = [top04,collid02,top5,top4,top3,collid2,collid3,crateco,collid4,lever,top1,top2,collid5,collid11]
- class crate:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.image = pygame.image.load("cr1.png").convert_alpha()
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.image,self.rect)
- crate1 = crate(1200,370,5,50,white)
- class end:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.image = pygame.image.load("atest.png").convert_alpha()
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.image,self.rect)
- class stopmove: # level 2
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- class text:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.font = pygame.font.Font("Alice.ttf", 20)
- self.scoretext = self.font.render("Push", True, (255,255,255))
- self.scorerect = self.scoretext.get_rect()
- self.scorerect.center = ((400,550))
- self.visible = False
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.scoretext,self.rect)
- class text2:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.font = pygame.font.Font("Alice.ttf", 20)
- self.scoretext = self.font.render("'F' Bring Conveyor Down", True, (255,255,255))
- self.scorerect = self.scoretext.get_rect()
- self.scorerect.center = ((400,550))
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.scoretext,self.rect)
- class text33:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.show = False
- self.rect = pygame.Rect(x,y,height,width)
- self.image = pygame.image.load("texto2.png").convert_alpha()
- self.font = pygame.font.Font("Alice.ttf", 50)
- self.scoretext = self.font.render("You Have Died.....", True, (255,255,255))
- self.scorerect = self.scoretext.get_rect()
- self.scorerect.center = ((400,550))
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.show:
- window.blit(self.image,self.rect)
- class text3:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- self.image = pygame.image.load("hit.png")
- self.hit = False
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.hit:
- window.blit(self.image,self.rect)
- red = 231, 76, 60
- hittext = text3(rat1.x,rat1.y,50,50,red)
- colors = 0,23,56
- colors2 = 0,123,56
- exit1 = button((colors),640,65,90,40, '')
- show1 = button((colors2),10,125,150,40, '')
- move_spot = button((colors),720,125,25,260, '')
- bar1 = button((colors),720,125,30,40, '')
- v1 = button((colors),720,125,30,40, '')
- v2 = button((colors),720,170,30,40, '')
- v3 = button((colors),720,190,30,40, '')
- v4 = button((colors),720,230,30,40, '')
- exit_game = button((colors),720,230,50,40, '')
- reset_game = button((colors),720,230,50,40, '')
- main_game = button((colors),720,230,50,40, '')
- switch_pause = button((colors),720,230,50,40, '')
- jump_sound = button((colors),720,230,50,40, '')
- land_sound = button((colors),720,230,50,40, '')
- add = 0
- # our switch
- files = ['swo (1).png', 'swo (2).png', 'swo (3).png']
- switches = [pygame.image.load(f) for f in files]
- current_switch = 1
- current_move = 1
- # Pause game
- new = ['switch_on_blue.png','switch_off.png']
- # our pause button score
- button1 = [pygame.image.load(n) for n in new]
- pause1 = 1
- unpause1 = 1
- # Rese Game
- new1 = ['switch_on_blue.png','switch_off.png']
- # our pause button score
- button11 = [pygame.image.load(n) for n in new1]
- pause11 = 1
- unpause11 = 1
- # Exit Game
- new11 = ['switch_on_blue.png','switch_off.png']
- # our pause button score
- button111 = [pygame.image.load(n) for n in new11]
- pause111 = 1
- unpause111 = 1
- # Main Game
- new111 = ['switch_on_blue.png','switch_off.png']
- # our pause button score
- button1111 = [pygame.image.load(n) for n in new111]
- pause1111 = 1
- unpause1111 = 1
- # Main Game
- new1111 = ['switch_on_blue.png','switch_off.png']
- # our pause button score
- button11111 = [pygame.image.load(n) for n in new1111]
- pause11111 = 1
- unpause11111 = 1
- # Main Game
- new11111 = ['switch_on_blue.png','switch_off.png']
- # our pause button score
- button111111 = [pygame.image.load(n) for n in new11111]
- pause111111 = 1
- unpause111111 = 1
- add = 0
- off = False
- def paused():
- switch_pause = button((colors),635,255,50,40, '')
- while pause:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- quit()
- if event.type == pygame.MOUSEBUTTONDOWN:
- pos = pygame.mouse.get_pos()
- if switch_pause.isOver(pos):
- unpause()
- clu.play()
- pygame.display.update()
- clock.tick(15)
- buttons = [exit1,show1,v1,v2,v3,v4,bar1,switch_pause,exit_game,reset_game,main_game,jump_sound,land_sound]
- bar11 = pygame.image.load("bar.png")
- text1 = text(1280,500,50,50,white)
- text22 = text2(1500,250,50,50,white)
- deathtext = text33(300,500,50,50,white)
- orange = (200,2,50)
- stopmove1 = stopmove(1587,400,180,80,orange)
- # if the player collids with this he should click w and the push animation should play
- pusho = stopmove(800,408,50,20,white)
- pusho2 = stopmove(800,408,50,20,white)
- lavaplays = stopmove(20,638,400,360,white) # level 2
- lavaplays2 = stopmove(80,958,600,360,white) # level 2
- lavaplays3 = stopmove(800,958,600,360,white) # level 2
- costo = 105,200,50
- text_show_collision = stopmove(567,400,50,50,white)
- text_show_collision2 = stopmove(1407,1100,190,150,costo)
- end1 = end(1155,-200,50,50,white)
- # speed lines when we push our rectangles
- linecolor = 127, 140, 141
- line1 = stopmove(crate1.x + 70,crate1.y + 70,50,1,linecolor)
- # projectile for my bullets # level 2
- shot1 = shot(15,700,50,50,cos)
- shot2 = shot(15,850,50,50,cos)
- shot3 = shot(180,1010,50,50,cos)
- shot4 = shot(450,1010,50,50,cos)
- shot5 = shot(1250,1010,50,50,cos)
- shot6 = shot(1050,1010,50,50,cos)
- shots = [shot1,shot2,shot3,shot4,shot5,shot6]
- # level2 lavas
- #------------------------------------- platforms classes # LLEVEL 3#3333333333333333333333333333333333333
- lava1 = lavaa(245,5550,150,50,white)
- lava2 = lavaa(445,5550,150,50,white)
- lava3 = lavaa(645,5550,150,50,white)
- #------------------------------------- updownlavas classes # LLEVEL 3#3333333333333333333333333333333333333
- updown1 = lavaa2(250,5550,150,50,white)
- updown2 = lavaa2(445,5550,150,50,white)
- updown3 = lavaa2(645,5550,150,50,white)
- updown4 = lavaa2(745,5550,150,50,white)
- lava4 = lavaa(-1000,1450,9150,50,white)
- lava5 = lavaa(980,1340,150,50,white)
- lava6 = lavaa(1150,1340,150,50,white)
- lava7 = lavaa(1250,1340,150,50,white)
- lava8 = lavaa2(195,5550,150,50,white)
- lava9 = lavaa2(195,5550,150,50,white)
- lava10 = lavaa2(195,5550,150,50,white)
- # sides
- lava11 = lavaa(1850,1310,150,50,white)
- lava12 = lavaa(2050,1310,150,50,white)
- collidsides = [lava8,lava9,lava10]
- collidbottom2 = [lava1,lava2,lava3,lava4,lava5,lava6,lava7,lava11,lava12]
- # downs
- updownlava = [updown1,updown2,updown3]
- lavas = [lava1,lava2,lava3,lava5,lava6,lava7,lava8,lava9,lava10,lava11,lava12,updown1,updown2,updown3]
- # ---------------- rat collisions
- rat11 = stopmove(570,1210,50,50,cos) # level 2
- rat22 = stopmove(960,1210,50,50,cos)
- # ---------------- rat collisions
- # our game fps
- fps = 60
- clock = pygame.time.Clock()
- text_timer = 0
- text_timer2 = 0
- particles = []
- playerman = player(360,330,50,50,white) # LEVEL 2
- lava = pygame.image.load("lava.png").convert_alpha()
- lava = pygame.transform.scale(lava,(lava.get_width()*2,lava.get_height()*2))
- # blit the rope
- # class background
- class bg: # level 3
- def __init__(self,x,y,height,width):
- self.x =x
- self.y = y
- self.height =height
- self.width = width
- self.test = pygame.image.load("level3bg.png").convert_alpha()
- self.rect = pygame.Rect(x,y,height,width)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.test,self.rect)
- bg2 = bg(-0,0,0,0) # level 3
- bg1 = bg(-80,-310,0,0)
- # our cheese class
- class cheese:
- def __init__(self,x,y,height,width,color):
- self.x =x
- self.y = y
- self.height =height
- self.width = width
- self.color = color
- self.time = 0
- self.test = pygame.image.load("grey_mouse/cheese.png").convert_alpha()
- self.rect = pygame.Rect(x,y,height,width)
- self.font = pygame.font.Font("Alice.ttf", 30)
- self.scoretext = self.font.render("R", True, (255, 255, 255))
- self.scorerect = self.scoretext.get_rect()
- self.show = False
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.test, self.rect)
- if self.show:
- window.blit(self.scoretext,(self.x + 10,self.y - 30))
- class chef:
- def __init__(self,x,y,height,width,color):
- self.x =x
- self.y = y
- self.height =height
- self.width = width
- self.color = color
- self.time = 0
- self.rect = pygame.Rect(x,y,height,width)
- self.ws = [pygame.image.load("grey_mouse/flo (" + str(i) + ").png").convert_alpha() for i in range(1, 15)]
- self.fps = 60
- self.clock = pygame.time.Clock()
- self.next_frame_time = 0
- self.anim_index = 0
- self.direction = "float"
- def get_rect(self):
- self.rect.topleft = (self.x,self.y)
- return self.rect
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "float":
- self.clock.tick(self.fps)
- image_list = self.ws
- time_now = pygame.time.get_ticks()
- if (time_now > self.next_frame_time):
- # Time until the next game
- inter_time_delay = 3000 // self.fps
- self.next_frame_time = time_now + inter_time_delay
- # Showing next frame
- self.anim_index += 1
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- player_image = image_list[self.anim_index]
- window.blit(player_image, (self.x + 40,self.y))
- # level 2
- chef1 = chef(105,650,50,130,white)
- cheese1 = cheese(155,650,90,90,white)
- chef2 = chef(405,780,50,190,white)
- cheese2 = cheese(455,780,90,90,white)
- chef3 = chef(1105,680,50,130,white)
- cheese3 = cheese(1155,680,90,90,white)
- chefs = [chef1,chef2,chef3]
- cheeses = [cheese1,cheese2,cheese3]
- class newbg: # level 3
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.image = pygame.image.load("level3.png").convert_alpha()
- self.rect = pygame.Rect(x,y,height,width)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.image,self.rect)
- level11 = newbg(-100,-350,0,0,white)
- bgs = [bg1]
- # our game objects in a list
- object_list = [
- lava11,lava12,fire7,collid1,stopglitch,puff1,text22,rat1,collidmove,collidmove2,lava1,lava2,lava3,lava4,lava5,lava6,lava7,lava8,lava9,lava10,updown1,updown2,updown3,updown4,text1,level11,lavaplays,lavaplays2,lavaplays3,rat11,rat22,hittext, heart,heart2,fire5,fire6,fire3,fire4,fire2,fire1,pusho,pusho2,stopmove1,
- text_show_collision,
- text_show_collision2,deathtext]
- # remember on gimp to scale the stats to 540
- stat = pygame.image.load("statbut.png").convert_alpha()
- stat1 = pygame.image.load("hel1.png").convert_alpha()
- stat11 = pygame.image.load("health1.png").convert_alpha()
- settingsm = pygame.image.load("hel3.png").convert_alpha()
- healthba = pygame.image.load("healthba.png").convert_alpha()
- health = 10
- hitbox = (200, 200 + 2, 31, 57)
- health2 = 10
- hitbox2 = (200, 200 + 2, 31, 57)
- health3 = 10
- hitbox3 = (200, 200 + 2, 31, 57)
- # ----------------------------------- game settings
- show_settings = False
- exit11 = False
- setbutton = pygame.image.load("setbutton.png").convert_alpha()
- bar11 = pygame.image.load("bar.png").convert_alpha()
- # class background
- class back:
- def __init__(self,x,y,height,width):
- self.x =x
- self.y = y
- self.height =height
- self.width = width
- self.test = pygame.image.load("set.png").convert_alpha()
- self.rect = pygame.Rect(x,y,height,width)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.test,self.rect)
- showtimer = 0
- showtimer2 = 0
- seti = back(230,-750,50,50)
- class particle:
- def __init__(self,x,y):
- self.x = x
- self.y = y
- self.x_vel = random.randrange(-10,13)//5
- self.y_vel = random.randrange(-10,-1)//5
- self.cheese = pygame.image.load("che1.png").convert_alpha()
- self.cheese = pygame.transform.scale(self.cheese,(self.cheese.get_width()//3,self.cheese.get_height()//3))
- self.lifetime = 0
- def draw(self,window):
- self.lifetime += 1
- if self.lifetime <30:
- self.x -= self.x_vel
- self.y -= self.y_vel
- window.blit(self.cheese,(self.x,self.y))
- class particle2:
- def __init__(self,x,y):
- self.x = x
- self.y = y
- self.x_vel = random.randrange(-10,13)//5
- self.y_vel = random.randrange(-10,-1)//5
- self.lifetime = 0
- def draw(self,window):
- self.lifetime += 1
- if self.lifetime <30:
- self.x -= self.x_vel
- self.y -= self.y_vel
- pygame.draw.circle(window,(153, 163, 164),(self.x,self.y),10)
- particles = []
- # ----------------------------------- game settings
- def cheesemove():
- cheese1.y = chef1.rect.top + math.cos(math.radians(cheese1.time)) * 40
- cheese1.time += 2.3
- if cheese1.time >= 360:
- cheese1.time = 0
- cheese2.y = chef2.rect.top + math.cos(math.radians(cheese2.time)) * 40
- cheese2.time += 2.3
- if cheese2.time >= 360:
- cheese2.time = 0
- cheese3.y = chef3.rect.top + math.cos(math.radians(cheese3.time)) * 40
- cheese3.time += 2.3
- if cheese3.time >= 360:
- cheese3.time = 0
- particless = []
- blito = True
- def redraw():
- for button in buttons:
- button.draw(window)
- for bg in bgs:
- bg.draw()
- collidmove2.draw()
- collidmove.draw()
- if blito:
- # our bullets
- for shot in shots:
- shot.draw()
- crate1.draw()
- portal1.draw()
- playerman.draw()
- if blito == False:
- for shot in shots:
- shot.draw()
- for particle2 in particless:
- particle2.draw(window)
- for cheese in cheeses:
- cheese.draw()
- for chef in chefs:
- chef.draw()
- swtich_image = switches[current_switch]
- display.blit(swtich_image, swtich_image.get_rect(midbottom = (collidmove.x + 190,collidmove.y + 440)))
- for obj in object_list:
- obj.draw()
- for collid in collids:
- collid.draw()
- display.blit(healthba, (-1,0))
- # player health HHEHEHEHEHE
- hitbox = (5, 35 + 2, 31, 57)
- pygame.draw.rect(window, (167, 70, 47), (hitbox[0], hitbox[1] - 4, 170 - (5 * (10 - health)), 10)) # NEW
- pygame.draw.rect(window, (24, 10, 6), (hitbox[0], hitbox[1] - 25, 170 - (5 * (10 - health)), 10)) # NEW
- pygame.draw.rect(window, (54, 24, 16), (hitbox[0], hitbox[1] - 26, 170 - (5 * (10 - health)), 10)) # NEW
- pygame.draw.rect(window, (243, 130, 104), (hitbox[0], hitbox[1] - 25, 170 - (5 * (10 - health)), 10)) # NEW
- pygame.draw.rect(window, (221, 109, 83), (hitbox[0], hitbox[1] - 24, 170 - (5 * (10 - health)), 23)) # NEW
- pygame.draw.rect(window, (199, 84, 57), (hitbox[0], hitbox[1] - 20, 170 - (5 * (10 - health)), 20)) # NEWright = True
- hitbox2 = (5, 89 + 2, 31, 57)
- pygame.draw.rect(window, (13, 16, 17), (hitbox2[0], hitbox2[1] - 21, 170 - (5 * (10 - health2)), 20)) # NEW
- pygame.draw.rect(window, (146,236,244), (hitbox2[0], hitbox2[1] - 20, 170 - (5 * (10 - health2)), 20)) # NEW
- pygame.draw.rect(window, (95, 212, 231), (hitbox2[0], hitbox2[1] - 18, 170 - (5 * (10 - health2)), 20)) # NEW
- pygame.draw.rect(window, (13, 16, 17), (hitbox2[0], hitbox2[1] - 8, 170 - (5 * (10 - health2)), 15)) # NEW
- pygame.draw.rect(window, (57, 182, 214), (hitbox2[0], hitbox2[1] - 10, 170 - (5 * (10 - health2)), 20)) # NEW
- pygame.draw.rect(window, (114, 203, 226), (hitbox2[0], hitbox2[1] - 16, 170 - (5 * (10 - health2)), 20)) # NEW
- hitbox3 = (660, 50 + 2, 31, 57)
- pygame.draw.rect(window, (17,48,42,255), (hitbox3[0], hitbox3[1] - 21, 120 - (5 * (10 - health3)), 20)) # NEW
- pygame.draw.rect(window, (89,243,212,255), (hitbox3[0], hitbox3[1] - 20, 120 - (5 * (10 - health3)), 20)) # NEW
- pygame.draw.rect(window, (87,205,182,255), (hitbox3[0], hitbox3[1] - 18, 120 - (5 * (10 - health3)), 20)) # NEW
- pygame.draw.rect(window, (71,190,166,255), (hitbox3[0], hitbox3[1] - 8, 120 - (5 * (10 - health3)), 15)) # NEW
- pygame.draw.rect(window, (57,160,139,255), (hitbox3[0], hitbox3[1] - 10, 120 - (5 * (10 - health3)), 20)) # NEW
- pygame.draw.rect(window, (71,190,166,255), (hitbox3[0], hitbox3[1] - 16, 120 - (5 * (10 - health3)), 20)) # NEW
- display.blit(settingsm,(655,-100))
- display.blit(stat1, (0,0))
- # ----------------------------------- game settings
- seti.draw()
- position = bar1.x,bar1.y
- window.blit(bar11,(position))
- # our bar imagead
- window.blit(bar11,(bar1.x - 5,bar1.y ))
- mew = button1[pause1]
- window.blit(mew, mew.get_rect(midbottom = (switch_pause.x + 18,switch_pause.y + 35)))
- mews = button11[pause11]
- window.blit(mews, mews.get_rect(midbottom = (exit_game.x + 18,exit_game.y + 38)))
- mewss = button111[pause111]
- window.blit(mewss, mewss.get_rect(midbottom = (reset_game.x + 18,reset_game.y + 36)))
- mewsss = button1111[pause1111]
- window.blit(mewsss, mewsss.get_rect(midbottom = (main_game.x + 18,main_game.y + 31)))
- mewssss = button11111[pause11111]
- window.blit(mewssss, mewssss.get_rect(midbottom = (jump_sound.x + 15,jump_sound.y + 35)))
- mewsssss = button111111[pause111111]
- window.blit(mewsssss, mewsssss.get_rect(midbottom = (land_sound.x + 15,land_sound.y + 35)))
- text_show_collision2.draw()
- pos = pygame.mouse.get_pos()
- for particle in particles:
- particle.draw(window)
- rop1.draw()
- for collid in collids:
- collid.draw()
- px,py = playerman.x,playerman.y
- if not playerman.direction == "DEath2" and not playerman.direction == "DEath":
- if playerman.get_rect().y > 510:
- scroll_offset = playerman.y - 510
- # scroll objects ...
- for obj in object_list:
- obj.y -= scroll_offset # change all of them to player x and y
- for shot in shots:
- shot.y -= scroll_offset
- for collid in collids:
- collid.y -= scroll_offset
- for bg in bgs:
- bg.y -= scroll_offset
- # ... and scroll player
- playerman.y -= scroll_offset
- py -= scroll_offset
- crate1.y -= scroll_offset
- for cheese in cheeses:
- cheese.y -= scroll_offset
- for chef in chefs:
- chef.y -= scroll_offset
- rop1.y -= scroll_offset
- portal1.y -= scroll_offset
- left = True
- stopmoving = True
- textup = True
- timer = 0
- attack = 0
- up1 = True
- up2 = True
- # our main loop
- move1 = False
- move2 = False
- switch1 = True
- switch2 = True
- switch3 = True
- in_spot = True
- in_spot2 = True
- circle = Circle( blacks, 400, 350, 50, 50 )
- # positioning script
- def position():
- if in_spot:
- bar1.y = seti.y + 210
- cheese2.x = chef2.x + 50
- cheese3.x = chef3.x + 50
- for lavaa in collidsides:
- if playerman.rect.colliderect(lavaa.rect):
- if playerman.direction == "DEath":
- puff1.x = playerman.x
- puff1.y = playerman.y
- puff1.direction = "darkside"
- for lavaa in collidbottom2:
- if playerman.rect.colliderect(lavaa.rect):
- if playerman.direction == "DEath":
- puff1.x = playerman.x
- puff1.y = playerman.y
- lever.x = rop1.x + 10
- lever.y = rop1.y + 202
- stopglitch.x = rop1.x + 10
- stopglitch.y = rop1.y + 200
- v1.y = seti.y + 220
- v2.y = seti.y + 290
- v3.y = seti.y + 350
- v4.y = seti.y + 430
- switch_pause.x = seti.x + 410
- switch_pause.y = seti.y + 358
- jump_sound.x = seti.x + 350
- jump_sound.y = seti.y + 459
- land_sound.x = seti.x + 350
- land_sound.y = seti.y + 530
- exit_game.x = seti.x + 410
- exit_game.y = seti.y + 299
- reset_game.x = seti.x + 410
- reset_game.y = seti.y + 259
- main_game.x = seti.x + 410
- main_game.y = seti.y + 219
- exit1.x = seti.x + 410
- exit1.y = seti.y + 160
- # the rect that our player will collid with and it will allow use to push
- pusho.x = crateco.x - 5
- pusho.y = crateco.y + 40
- # the rect that our player will collid with and it will allow use to push
- pusho2.x = crateco.x + 99
- pusho2.y = crateco.y + 50
- if not playerjump == False:
- if playerman.direction == "DEath" or playerman.direction == "DEath2":
- deathtext.x = playerman.x + 150
- deathtext.show = True
- # punch
- if playerman.direction == "att":
- punch1.x = playerman.x + 55
- punch1.y = playerman.y - 14
- if playerman.direction == "att2":
- punch1.x = playerman.x - 19
- punch1.y = playerman.y - 14
- # this scrolls our jumping hitbox with the player
- crateco.x = crate1.x + 20
- crateco.y = crate1.y + 66
- hittext.x = rat1.x - 100
- hittext.y = rat1.y - 150
- moving = True
- x = 10
- y = 10
- x_change = 0
- y_change = 0
- old_x = x
- old_y = y
- tons = 0
- pa = 0
- e_clicked = False
- hit = True
- # our rat timer
- move = True
- move2 = True
- move3 = True
- attack2 = 0
- move_timer = 0
- move_timer2 = 0
- rat1_attack = 0
- pos = pygame.mouse.get_pos()
- click = True
- trans = 0
- trano = True
- adds = False
- exiting = False
- ex = 0
- reseting = False
- res = 0
- # Runing the game/ the main loop
- if_f = False
- run = True
- poop = False
- lavap = True
- lavap2 = True
- pushtimer = 0
- clo = True
- o = True
- os = True
- oos = True
- pushvalue = True
- snif = 0
- r = False
- PUNCH = True
- puffs = 0
- playerjump = True
- death = 0
- deathscreen = True
- diescreen1 = True
- # treansition
- dead_screen = True
- # fire ball hit player
- # ---------- projectiles
- nothit = True
- poops = True
- nothit2 = True
- poops2 = True
- nothit3 = True
- poops3 = True
- # ------------ projectiles
- load = 0
- pufo = 0
- load_transition_screen = True
- damaging = 0
- right = True
- left = True
- #if cheese score
- cheesescore = 0
- # rat score
- ratscore = 1
- player_double_jump = True
- # shoot the proejctiles timer
- shoot = 0
- # the player will start movign
- move_player_timer = 0
- # this is to show the deathtext at player pos and then stop it
- screenshake = 0
- showpos = True
- while run:
- # Making game run with fps
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- run = False
- if event.type == pygame.KEYDOWN:
- if event.key == pygame.K_f:
- if playerman.rect.colliderect(text_show_collision2.rect):
- sw.play()
- if_f = True
- if current_switch == 0:
- current_move = 1
- elif current_switch == len(switches)-1:
- current_move = -1
- current_switch += current_move
- elif event.type == pygame.MOUSEBUTTONDOWN:
- pos = pygame.mouse.get_pos()
- if show1.isOver(pos):
- show_settings = True
- showtimer = 0
- show1.x = 999
- uis.play()
- if exit1.isOver(pos):
- exit11 = True
- showtimer2 = 0
- show1.x = 675
- kit.play()
- # pause
- if switch_pause.isOver(pos):
- if pause1 == 0:
- unpause1 = 1
- elif pause1 == len(new)-1:
- unpause1 = -1
- pause1 += unpause1
- adds = True
- clicks.play()
- # exit game button
- if exit_game.isOver(pos):
- exiting = True
- if pause11 == 0:
- unpause11 = 1
- elif pause11 == len(new1)-1:
- unpause11 = -1
- pause11 += unpause11
- clicks.play()
- # reset game button
- if reset_game.isOver(pos):
- uiss.play()
- reseting = True
- if pause111 == 0:
- unpause111 = 1
- elif pause111 == len(new11)-1:
- unpause111 = -1
- pause111 += unpause111
- clicks.play()
- # main_game game button
- if main_game.isOver(pos):
- if pause1111 == 0:
- unpause1111 = 1
- clu.play()
- elif pause1111 == len(new111)-1:
- clicks.play()
- unpause1111 = -1
- pause1111 += unpause1111
- # main_game game button
- if jump_sound.isOver(pos):
- if pause11111 == 0:
- unpause11111 = 1
- clu.play()
- elif pause11111 == len(new1111)-1:
- unpause11111 = -1
- clicks.play()
- jump.stop()
- pause11111 += unpause11111
- # main_game game button
- if land_sound.isOver(pos):
- if pause111111 == 0:
- unpause111111 = 1
- clu.play()
- elif pause111111 == len(new11111)-1:
- unpause111111 = -1
- clicks.play()
- pause111111 += unpause111111
- # --------------------------------------------------- BUTTON CONTRO
- # this is our bar1 the gray part that we will be able to move
- if move_spot.isOver(pos):
- if bar1.isOver(pos):
- in_spot = False
- click = True
- #time.sleep(0.2)
- if not move_spot.isOver(pos):
- if not bar1.isOver(pos):
- click = False
- # make our uprightlavas the direction
- for lavaa2 in updownlava:
- lavaa2.direction = "updownlava"
- for lavaa2 in collidsides:
- lavaa2.direction = "ws"
- if bar1.rect.colliderect(v1.rect):
- pygame.mixer.music.set_volume(0.3)
- if bar1.rect.colliderect(v2.rect):
- pygame.mixer.music.set_volume(0.8)
- if bar1.rect.colliderect(v3.rect):
- pygame.mixer.music.set_volume(0.6)
- if bar1.rect.colliderect(v4.rect):
- pygame.mixer.music.set_volume(0.1)
- if bar1.rect.bottom >= move_spot.rect.bottom:
- bar1.y = 360
- if click:
- pos = pygame.mouse.get_pos()
- click = pygame.mouse.get_pressed()
- bar1.y = pos[1]
- # draw them on our player x and y
- if playerman.rect.colliderect(collid1.rect):
- playerman.y += 4
- # ----------------------------- what happens if our player touches the projectile
- keepmoving = True
- if keepmoving:
- for one in range(len(shots)-1,-1,-1):
- if playerman.rect.colliderect(shots[one].rect):
- if health > -23:
- if damaging <= 100:
- damaging += 1
- blito = False
- health -= 0.1
- shots[one].direction = "expod"
- shots[one].x = playerman.x
- shots[one].y = playerman.y - 20
- else:
- del shots[one]
- damaging = 0
- heart2.hit = False
- else:
- playerman.direction = "DEath2"
- if showpos:
- playerman.isJump = True
- playerjump = False
- deathtext.x = playerman.x - 150
- deathtext.y = playerman.y - 150
- deathtext.show = True
- showpos = False
- if damaging == 5 or damaging == 20 or damaging == 40 or damaging == 60 or damaging == 90:
- damagesound.play()
- heart2.hit = True
- # what happens if thje palyer collids with the shot7
- if player_double_jump:
- if playerman.rect.colliderect(shot6.rect) and damaging == 20:
- playerman.isJump = True
- if playerman.rect.colliderect(shot5.rect):
- player_double_jump = False
- if playerman.rect.colliderect(shot1.rect):
- nothit = False
- if playerman.rect.colliderect(shot2.rect):
- poops = False
- if playerman.rect.colliderect(shot3.rect):
- nothit2 = False
- if playerman.rect.colliderect(shot4.rect):
- poops2 = False
- if playerman.rect.colliderect(shot5.rect):
- nothit3 = False
- if playerman.rect.colliderect(shot6.rect):
- poops3 = False
- # --------------------------------------------------- BUTTON CONTRO
- # load our main game when we click this button
- if pause1111 == 0:
- game_intro()
- # if the player falls out the map
- if playerman.rect.colliderect(lava4.rect):
- playerman.direction = "DEath"
- # our settings showing up
- if show_settings:
- if showtimer < 82:
- seti.y += 8
- showtimer += 1
- in_spot = True
- if bar1.rect.colliderect(v1.rect):
- bar1.y = v1.y
- in_spot = False
- if bar1.rect.colliderect(v2.rect):
- bar1.y = v2.y
- in_spot = False
- if bar1.rect.colliderect(v3.rect):
- bar1.y = v3.y
- in_spot = False
- if bar1.rect.colliderect(v4.rect):
- bar1.y = v4.y
- in_spot = False
- if exit11:
- if showtimer2 < 82:
- showtimer2 += 1
- seti.y -= 8
- if bar1.rect.colliderect(v1.rect):
- bar1.y = v1.y
- in_spot = False
- if bar1.rect.colliderect(v2.rect):
- bar1.y = v2.y
- in_spot = False
- if bar1.rect.colliderect(v3.rect):
- bar1.y = v3.y
- in_spot = False
- if bar1.rect.colliderect(v4.rect):
- bar1.y = v4.y
- in_spot = False
- # telling what to do when we say the word 'key'
- keys = pygame.key.get_pressed()
- #----------------- level 2 code
- if cheesescore == 3 and playerman.rect.colliderect(portal1.rect):
- reseting = True
- #---------------------------------------------------------- STAMINA CODE
- if keys[pygame.K_e]:
- e_clicked = True
- if e_clicked:
- tons += 1
- # ------------------------------------- play lava sound when collisions
- if playerman.rect.colliderect(lavaplays.rect):
- if lavap:
- La.play(-1)
- lavap = False
- if not playerman.rect.colliderect(lavaplays.rect):
- La.stop()
- lavap = True
- if playerman.rect.colliderect(lavaplays2.rect):
- if lavap2:
- La2.play(-1)
- lavap2 = False
- if not playerman.rect.colliderect(lavaplays2.rect):
- La2.stop()
- lavap2 = True
- # ------------------------------------------------- PAUSE
- if adds:
- if add < 5:
- add += 1
- else:
- pause = True
- paused()
- adds = False
- add = 0
- if exiting:
- if ex < 10:
- ex += 1
- else:
- pygame.quit()
- if reseting:
- if res < 10:
- res += 1
- else:
- circle.circleInTransition()
- # player death
- if adds == False:
- if pause1 == 0:
- if pause == False:
- pause1 = 1
- # player death
- if playerman.y == 1000:
- transition.play()
- circle.circleOutInInOut()
- load_transition_screen = False
- if load_transition_screen:
- transition.play()
- circle.circleOutInInOut()
- load_transition_screen = False
- if unpause111111 == 0:
- land[1].stop()
- land[0].stop()
- # Shortining playerman.x and playerman.y
- px,py = playerman.x,playerman.y
- move_right = keys[pygame.K_d] # change to d and the other one a
- move_left = keys[pygame.K_a]
- move_hit = False
- move_hit2 = False
- # ------------------------------------------------- PAUSE
- rat1.jump()
- rat1.jump2()
- for one in range(len(rats)-1,-1,-1):
- if hit:
- if tons > 10:
- if playerman.direction == "Idle":
- playerman.direction = "att"
- hits.play()
- if playerman.rect.colliderect(rats[one].rect):
- if rats[one].health > -2:
- rats[one].health -= 1
- random.choice(enemyhits).play()
- else:
- rats[one].direction = "die"
- heart.hit = False
- rats[one].isJump = True
- ratscore += 1
- print(ratscore)
- move3 = False
- move2 = False
- move = False
- if oos:
- die.play()
- oos = False
- if playerman.direction == "leftid":
- playerman.direction = "att2"
- hits.play()
- stopmoving = False
- if playerman.rect.colliderect(rats[one].rect):
- if rats[one].health > -2:
- rats[one].health -= 1
- random.choice(enemyhits).play()
- else:
- rats[one].direction = "die"
- heart.hit = False
- rats[one].isJump = True
- move3 = False
- move2 = False
- move = False
- if oos:
- die.play()
- oos = False
- move3 = False
- move2 = False
- move = False
- if playerman.rect.colliderect(rats[one].rect) and not rat1.rect.colliderect(rat11.rect) and not rat1.rect.colliderect(rat22.rect):
- if playerman.direction == "att" or rat1.direction == "att2":
- rat1.x += 2
- rat1.isJump2 = True
- if not playerman.direction == "DEath" and not playerman.direction == "DEath2":
- if playerman.rect.colliderect(rats[one].rect):
- move3 = False
- move2 = False
- move = False
- if health2 > -21:
- health2 -= 0.3
- else:
- if playerman.direction == "att":
- playerman.direction = "Idle"
- if playerman.direction == "att2":
- playerman.direction = "leftid"
- hit = False
- hittext.hit = False
- if tons > 30:
- tons = 0
- e_clicked = False
- if playerman.direction == "att":
- playerman.direction = "Idle"
- if playerman.direction == "att2":
- playerman.direction = "leftid"
- if playerman.direction == "att" or playerman.direction == "att2":
- punch1.hit = True
- if playerman.direction == "Idle" or playerman.direction == "leftid":
- punch1.hit = False
- if playerman.rect.colliderect(rat1.rect):
- if playerman.direction == "att" or playerman.direction == "att2":
- hittext.hit = True
- punch1.hit = True
- if playerman.direction == "Idle":
- hittext.hit = False
- punch1.hit = False
- if not playerman.rect.colliderect(rat1.rect):
- hittext.hit = False
- if hit == False:
- if health2 < 10:
- health2 += 0.2
- else:
- if keys[pygame.K_e]:
- hit = True
- #---------------------------------------------------------- STAMINA CODE
- # MOVE OUR text down if we click F
- if if_f:
- text22.y += 5
- if move:
- if move_timer < 300:
- move_timer += 1
- else:
- rat1.direction = "move2"
- rat1.x += 1
- if move2:
- if move_timer2 < 300:
- move_timer2 += 1
- else:
- rat1.direction = "move"
- rat1.x -= 1
- if rat1.rect.colliderect(rat11.rect) and not rat1.direction == "die":
- rat1.direction = "idle"
- move = True
- move2 = False
- move_timer2 = 0
- elif rat1.rect.colliderect(rat22.rect) and not rat1.direction == "die":
- rat1.direction = "id"
- move = False
- move2 = True
- move_timer = 0
- if not playerman.direction == "DEath" and not playerman.direction == "DEath2":
- if move3:
- if playerman.rect.colliderect(rat1.hitbox):
- rat1.x += 3
- rat1.direction = "move2"
- elif playerman.rect.colliderect(rat1.hitbox2):
- rat1.x -= 3
- rat1.direction = "move"
- if not playerman.direction == "DEath" and not playerman.direction == "DEath2":
- if rat1.direction == "move2":
- if playerman.rect.colliderect(rat1.rect):
- move = False
- move2 = False
- rat1.direction = "id"
- # our hurt on our player x and y
- heart.x = playerman.x + 10
- heart.y = playerman.y - 60
- heart2.x = playerman.x + 10
- heart2.y = playerman.y - 60
- if not playerman.rect.colliderect(rat1.rect) and not playerman.rect.colliderect(rat1.hitbox2) and not playerman.rect.colliderect(rat1.hitbox):
- heart.hit = False
- if not playerman.direction == "DEath" and not playerman.direction == "DEath2":
- if playerman.rect.colliderect(rat1.rect):
- if rat1.direction == "move2" or rat1.direction == "id" or rat1.direction == "at":
- if playerman.direction == "right" and not rat1.direction == "die":
- rat1.direction = "id"
- move = False
- move2 = False
- attack += 1
- if attack >= 50:
- if not rat1.direction == "die":
- rat1.direction = "at"
- heart.hit = True
- if o:
- if rat1.direction == "at" or "att":
- phit.play()
- o = False
- else:
- o = True
- heart.hit = False
- if attack > 70:
- rat1.direction = "id"
- attack = 0
- if not playerman.direction == "DEath" and not playerman.direction == "DEath2":
- if rat1.direction == "move":
- if playerman.rect.colliderect(rat1.rect):
- move = False
- move2 = False
- #- ---------------------------------- this is moving our player
- if rat1.direction == "at":
- move_hit = True
- if rat1.direction == "att":
- move_hit2 = True
- #- ---------------------------------- this is moving our player
- if not playerman.direction == "DEath" and not playerman.direction == "DEath2":
- if playerman.rect.colliderect(rat1.rect):
- move = False
- move2 = False
- if playerman.direction == "left" and not rat1.direction == "die" and playerman.rect.colliderect(rat1.hitbox):
- rat1.direction = "idle"
- if rat1.direction == "move" or rat1.direction == "idle" or rat1.direction == "att":
- attack2 += 1
- if attack2 >= 50:
- rat1.direction = "att"
- heart.hit = True
- if os:
- if rat1.direction == "at" or "att":
- phit.play()
- os = False
- else:
- os = True
- heart.hit = False
- if attack2 > 70:
- rat1.direction = "idle"
- attack2 = 0
- move_timer2 = 300
- if not playerman.rect.colliderect(rat1.rect) and not playerman.rect.colliderect(rat1.hitbox2) and not playerman.rect.colliderect(rat1.hitbox) and not rat1.rect.colliderect(rat11.rect):
- if not move and not move2:
- if rat1.direction == "move2" or rat1.direction == "id" or rat1.direction == "at":
- move2 = True
- move_timer = 300
- move_timer2 = 300
- rat1.direction = "move"
- elif rat1.direction == "move" or rat1.direction == "idle" or rat1.direction == "att":
- move = True
- move_timer2 = 300
- move_timer = 300
- rat1.direction = "move2"
- if playerman.direction == "DEath" or playerman.direction == "DEath2":
- if not move and not move2:
- if rat1.direction == "move2" or rat1.direction == "id" or rat1.direction == "at":
- move2 = True
- move_timer = 300
- move_timer2 = 300
- rat1.direction = "move"
- elif rat1.direction == "move" or rat1.direction == "idle" or rat1.direction == "att":
- move = True
- move_timer2 = 300
- move_timer = 300
- rat1.direction = "move2"
- if playerman.rect.colliderect(rat1.rect):
- if rat1.direction == "at" or rat1.direction == "att":
- if health > -23:
- health -= 0.1
- else:
- if playerman.direction == "left" or playerman.direction == "leftid":
- playerman.direction = "DEath2"
- playerjump = False
- deathtext.x = playerman.x - 100
- deathtext.y = playerman.y - 150
- else:
- playerman.direction = "DEath"
- deathtext.show = True
- playerjump = False
- deathtext.x = playerman.x - 100
- deathtext.y = playerman.y - 150
- if dead_screen:
- if playerman.direction == "DEath" or playerman.direction == "DEath2":
- if death < 160:
- death += 1
- else:
- reseting = True
- if deathscreen:
- uiss.play()
- deathscreen = False
- if death < 60:
- deathtext.y -= 5
- if diescreen1:
- diescreen.play()
- diescreen1 = False
- # --- -show the player death when in the lavaaa
- for lavaa in lavas:
- if playerman.get_rect().colliderect(lavaa.rect):
- showpos = False
- dead_screen = False
- health = -23
- playerman.direction = "DEath"
- puff1.direction = "ws"
- puff1.show = True
- deathtext.show = False
- if playerjump:
- evil.play()
- playerman.isJump = True
- playerjump = False
- deathtext.x = playerman.x - 150
- deathtext.y = playerman.y - 150
- if playerjump == False:
- if pufo < 65:
- pufo += 1
- else:
- puff1.show = False
- dead_screen = True
- deathtext.show = True
- # ------------------------------------------------------------------------------------------------- SO MUCH CODE AHHAHAHAHAHHA
- if not rat1.direction == "die":
- if not playerman.direction == "DEath" and not playerman.direction == "DEath2":
- if playerman.rect.colliderect(rat11.rect) and playerman.rect.colliderect(rat1.rect):
- move3 = False
- move2 = False
- move = False
- if not playerman.rect.colliderect(rat11.rect) and not playerman.rect.colliderect(rat1.rect):
- move3 = True
- if playerman.rect.colliderect(rat22.rect) and playerman.rect.colliderect(rat1.rect):
- move3 = False
- move2 = False
- move = False
- if not playerman.rect.colliderect(rat22.rect) and not playerman.rect.colliderect(rat1.rect):
- move3 = True
- # ------------------------------------------------------------------------------------------------- SO MUCH CODE AHHAHAHAHAHHA
- text2.visible = True
- if crateco.rect.colliderect(lava1.rect):
- crateco.y += 2
- if current_switch == 1:
- playerman.speed = 1.9
- con.stop()
- rop1.direction = "nomove"
- if current_switch == 2:
- if lever.rect.colliderect(collidmove.rect):
- rop1.direction = "up"
- rop1.y += playerman.speed
- if pushvalue:
- if playerman.rect.colliderect(text_show_collision2.rect):
- con.play()
- pushvalue = False
- if not playerman.rect.colliderect(text_show_collision2.rect):
- con.stop()
- pushvalue = True
- else:
- rop1.direction = "nomove"
- pushvalue = True
- con.stop()
- if current_switch == 0:
- if lever.rect.colliderect(collidmove2.rect):
- rop1.y -= playerman.speed
- rop1.direction = "up"
- if pushvalue:
- if playerman.rect.colliderect(collidmove2):
- con.play()
- pushvalue = False
- if not playerman.rect.colliderect(collidmove2):
- con.stop()
- pushvalue = True
- else:
- rop1.direction = "nomove"
- pushvalue = True
- con.stop()
- if playerman.rect.colliderect(stopglitch.rect):
- move_right = False
- move_left = False
- playerman.speed = 1.9
- # -------------- HOMEworkSSS
- # first one is music
- # second one is deportes
- # third one is bicicleta
- # forth one is un libro
- # is la tera
- #
- # screenshakey
- if shot4.rect.bottom >= lavaplays2.rect.bottom:
- screenshake = 30
- if screenshake > 0:
- screenshake -= 1
- render_offset = [0,0]
- if screenshake:
- render_offset[0] = random.randint(0, 8) - 4
- render_offset[1] = random.randint(0, 8) - 4
- position()
- # move our projectiles up and down
- # Making bird move left and right
- if nothit:
- shot1.x = lavaplays.rect.right - math.sin(math.radians(shot1.time)) * 400
- shot1.time += 1
- if shot1.time >= 180:
- shot1.time = 0
- if shot1.rect.right >= lavaplays.rect.right:
- shot1.direction = "left"
- if shot1.rect.left <= lavaplays.rect.left:
- shot1.direction = "right"
- if shot1.x <= lavaplays.rect.left:
- if playerman.rect.colliderect(lavaplays.rect):
- ball.play()# if the object y is >= 700 then change the direction and minus the y
- if shoot < 70:
- shoot += 1
- else:
- poop = True
- if poops:
- if poop:
- shot2.x = lavaplays.rect.right - math.sin(math.radians(shot2.time)) * 400
- shot2.time += 1
- if shot2.time >= 180:
- shot2.time = 0
- if shot2.rect.right >= lavaplays.rect.right:
- shot2.direction = "left"
- if shot2.rect.left <= lavaplays.rect.left:
- shot2.direction = "right"
- if shot2.x <= lavaplays.rect.left:
- if playerman.rect.colliderect(lavaplays.rect):
- ball.play()# if the object y is >= 700 then change the direction and minus the y
- # move our projectiles up and down
- # Making bird move left and right
- if nothit2:
- shot3.y = lavaplays2.rect.bottom - math.sin(math.radians(shot3.time)) * 400
- shot3.time += 1.5
- if shot3.time >= 180:
- shot3.time = 0
- if shot3.rect.top <= lavaplays2.rect.top:
- poop = True# if the object y is <= 200 then change the direction and add to the y
- shot3.direction = "downshot"
- if shot3.rect.bottom >= lavaplays2.rect.bottom:
- shot3.direction = "upshot"
- if shot3.y >= lavaplays2.rect.bottom:
- if playerman.rect.colliderect(lavaplays2.rect):
- ball.play()# if the object y is >= 700 then change the direction and minus the y
- if poops2:
- if poop:
- shot4.y = lavaplays2.rect.bottom - math.sin(math.radians(shot4.time)) * 400
- shot4.time += 1.5
- if shot4.time >= 180:
- shot4.time = 0
- if shot4.rect.top <= lavaplays2.rect.top: # if the object y is <= 200 then change the direction and add to the y
- shot4.direction = "downshot"
- if shot4.rect.bottom >= lavaplays2.rect.bottom:
- shot4.direction = "upshot"
- if shot4.y >= lavaplays2.rect.bottom:
- if playerman.rect.colliderect(lavaplays2.rect):
- ball.play()# if the object y is >= 700 then change the direction and minus the y
- # move our projectiles up and down
- # Making bird move left and right
- if nothit3:
- shot5.y = lavaplays3.rect.bottom - math.sin(math.radians(shot5.time)) * 400
- shot5.time += 1.5
- if shot5.time >= 180:
- shot5.time = 0
- if shot5.rect.top <= lavaplays3.rect.top:
- poop = True# if the object y is <= 200 then change the direction and add to the y
- shot5.direction = "downshot"
- if shot5.rect.bottom >= lavaplays2.rect.bottom:
- shot5.direction = "upshot"
- if shot5.y >= lavaplays3.rect.bottom:
- if playerman.rect.colliderect(lavaplays3.rect):
- ball.play()# if the object y is >= 700 then change the direction and minus the y
- if poops3:
- if poop:
- shot6.y = lavaplays3.rect.bottom - math.sin(math.radians(shot6.time)) * 400
- shot6.time += 1.5
- if shot6.time >= 180:
- shot6.time = 0
- if shot6.rect.top <= lavaplays3.rect.top: # if the object y is <= 200 then change the direction and add to the y
- shot6.direction = "downshot"
- if shot6.rect.bottom >= lavaplays3.rect.bottom:
- shot6.direction = "upshot"
- if shot6.y >= lavaplays3.rect.bottom:
- if playerman.rect.colliderect(lavaplays3.rect):
- ball.play()# if the object y is >= 700 then change the direction and minus the y
- if textup:
- if playerman.rect.colliderect(text_show_collision.rect):
- text_show_collision.x = playerman.x
- text_show_collision.y = playerman.y
- if text_timer < 100:
- text_timer += 1
- text1.y -= 1
- text1.visible = True
- #
- if PUNCH:
- if playerman.direction == "att" or playerman.direction == "att2":
- stopmoving = False
- elif not playerman.direction == "att" or playerman.direction == "att2":
- stopmoving = True
- if stopmoving:
- if playerman.rect.colliderect(pusho.rect):
- if keys[pygame.K_d]:
- playerman.direction = "Push"
- right = False
- left = False
- move_hit2 = False
- move_hit = False
- if text_timer2 < 250:
- text_timer2 += 1
- text1.y += 2
- crate1.x += 1
- for x in range(3):
- x, y = crate1.rect.center
- particless.append( particle2( crate1.x,crate1.y + 150 ) )
- else:
- playerman.direction = "Idle"
- right = True
- left = True
- if playerman.rect.colliderect(pusho2.rect):
- if keys[pygame.K_a]:
- playerman.direction = "Push2"
- right = False
- left = False
- move_hit2 = False
- move_hit = False
- if text_timer2 < 250:
- text_timer2 += 1
- text1.y += 2
- crate1.x -= 1
- for x in range(3):
- x, y = crate1.rect.center
- particless.append( particle2(crate1.x + 170 ,crate1.y + 150 ) )
- else:
- playerman.direction = "leftid"
- right = True
- left = True
- if not playerman.direction == "DEath" and not playerman.direction == "DEath2":
- if keys[pygame.K_SPACE]:
- if playerman.direction == "Push":
- playerman.direction = "Idle"
- if keys[pygame.K_SPACE]:
- if playerman.direction == "Push2":
- playerman.direction = "leftid"
- if crateco.rect.colliderect(stopmove1.rect):
- stopmoving = False
- PUNCH = False
- # telling what to do when we say the word 'key'
- keys = pygame.key.get_pressed()
- # Shortining playerman.x and playerman.y
- px,py = playerman.x,playerman.y
- # ------------------------------- PICK UP CHEESE\
- cheesemove()
- for one in range(len(chefs)-1,-1,-1):
- if playerman.rect.colliderect(chefs[one].rect):
- cheese1.show = True
- else:
- cheese1.show = False
- if keys[pygame.K_r]:
- r = True
- if r:
- if snif < 95:
- snif += 3
- if playerman.direction == "Idle":
- playerman.direction = "snif"
- if playerman.direction == "leftid":
- playerman.direction = "snif2"
- for x in range(1):
- for one in range(len(cheeses)-1,-1,-1):
- if playerman.rect.colliderect(cheeses[one].rect):
- x, y = cheeses[one].rect.center
- particles.append( particle(cheeses[one].x, cheeses[one].y ) )
- else:
- if playerman.direction == "snif":
- playerman.direction = "Idle"
- snif = 0
- r = False
- if playerman.direction == "snif2":
- playerman.direction = "leftid"
- snif = 0
- r = False
- for one in range(len(cheeses)-1,-1,-1):
- if playerman.rect.colliderect(cheeses[one].rect):
- coin.play()
- del cheeses[one]
- cheesescore += 1
- print(cheesescore)
- # ------------------------------- PICK UP CHEESE
- if playerman.direction == "right":
- playerman.direction = "Idle"
- if playerman.direction == "left":
- playerman.direction = "leftid"
- # ---------------------------- movement area
- if not playerman.direction == "DEath" and not playerman.direction == "DEath2":
- # player 'A' movment
- if keys[pygame.K_a]:
- for obj in object_list:
- obj.x += playerman.speed
- crate1.x += playerman.speed
- for shot in shots:
- shot.x += playerman.speed
- for collid in collids:
- collid.x += playerman.speed
- for bg in bgs:
- bg.x += playerman.speed
- if right:
- playerman.direction = "left"
- for cheese in cheeses:
- cheese.x += playerman.speed
- for chef in chefs:
- chef.x += playerman.speed
- rop1.x += playerman.speed
- portal1.x += playerman.speed
- # player 'D' movment
- elif keys[pygame.K_d]:
- for obj in object_list:
- obj.x -= playerman.speed
- for shot in shots:
- shot.x -= playerman.speed
- for collid in collids:
- collid.x -= playerman.speed
- for bg in bgs:
- bg.x -= playerman.speed
- if left:
- playerman.direction = "right"
- crate1.x -= playerman.speed
- for cheese in cheeses:
- cheese.x -= playerman.speed
- for chef in chefs:
- chef.x -= playerman.speed
- rop1.x -= playerman.speed
- portal1.x -= playerman.speed
- if not playerman.direction == "DEath" and not playerman.direction == "DEath2":
- if playerman.y < 50:
- for obj in object_list:
- obj.y += playerman.speed
- for shot in shots:
- shot.y += playerman.speed
- for collid in collids:
- collid.y += playerman.speed
- for bg in bgs:
- bg.y += playerman.speed
- crate1.y += playerman.speed
- for cheese in cheeses:
- cheese.y += playerman.speed
- for chef in chefs:
- chef.y += playerman.speed
- rop1.y += playerman.speed
- portal1.y += playerman.speed
- if not playerman.direction == "Death" and not playerman.direction == "DEath2":
- if keys[pygame.K_d]:
- if playerman.direction == "jump2":
- playerman.direction = "jump"
- if keys[pygame.K_a]:
- if playerman.direction == "jump":
- playerman.direction = "jump2"
- platform_rect_list = [p.get_rect() for p in collids]
- player_rect = playerman.get_rect()
- player_rect.topleft = (px, py)
- playerman.y = py
- if player_rect.collidelist(platform_rect_list) < 0:
- playerman.x = px
- if not playerman.direction == "DEath" and not playerman.direction == "DEath2":
- if move_right:
- for obj in object_list:
- obj.x -= playerman.speed
- for shot in shots:
- shot.x -= playerman.speed
- for collid in collids:
- collid.x -= playerman.speed
- for bg in bgs:
- bg.x -= playerman.speed
- crate1.x -= playerman.speed
- for cheese in cheeses:
- cheese.x -= playerman.speed
- for chef in chefs:
- chef.x -= playerman.speed
- rop1.x -= playerman.speed
- portal1.x -= playerman.speed
- if move_left:
- for obj in object_list:
- obj.x += playerman.speed
- for shot in shots:
- shot.x += playerman.speed
- for collid in collids:
- collid.x += playerman.speed
- crate1.x += playerman.speed
- for bg in bgs:
- bg.x += playerman.speed
- for cheese in cheeses:
- cheese.x += playerman.speed
- for chef in chefs:
- chef.x += playerman.speed
- rop1.x += playerman.speed
- portal1.x += playerman.speed
- if move_hit:
- for obj in object_list:
- obj.x -= 0.5
- for shot in shots:
- shot.x -= 0.5
- for collid in collids:
- collid.x -= 0.5
- crate1.x -= 0.5
- for bg in bgs:
- bg.x -= 0.5
- portal1.x -= 0.5
- for cheese in cheeses:
- cheese.x -= 0.5
- for chef in chefs:
- chef.x -= 0.5
- rop1.x -= 0.5
- if move_hit2:
- for obj in object_list:
- obj.x += 0.5
- for shot in shots:
- shot.x += 0.5
- for collid in collids:
- collid.x += 0.5
- crate1.x += 0.5
- for bg in bgs:
- bg.x += 0.5
- for cheese in cheeses:
- cheese.x += 0.5
- for chef in chefs:
- chef.x += 0.5
- portal1.x += 0.5
- rop1.x += 0.5
- if load_transition_screen == False:
- if move_player_timer < 20:
- move_player_timer += 1
- else:
- platform_rect_list = [p.get_rect() for p in collids] # get_rect()
- player_rect = playerman.get_rect()
- player_rect.topleft = (px, py)
- playerman.y = py
- cI = player_rect.collidelist(platform_rect_list)
- if cI >= 0:
- # undo movement of platforms dependent on the direction and intersection distance
- dx = 0
- if move_right:
- dx = platform_rect_list[cI].left - player_rect.right
- if move_left:
- dx = platform_rect_list[cI].right - player_rect.left
- if move_hit:
- dx = platform_rect_list[cI].left - player_rect.right
- if move_hit2:
- dx = platform_rect_list[cI].right - player_rect.left
- for collid in collids:
- collid.x -= dx
- collid.get_rect()
- for obj in object_list:
- obj.x -= dx
- for shot in shots:
- shot.x -= dx
- crate1.x -= dx
- for bg in bgs:
- bg.x -= dx
- for cheese in cheeses:
- cheese.x -= dx
- for chef in chefs:
- chef.x -= dx
- portal1.x -= dx
- rop1.x -= dx
- if not playerman.isJump:
- playerman.y += playerman.fall
- playerman.fall += 0.8
- playerman.isJump = False
- # For player to get on top of platform
- collide = False
- for collid in collids:
- if playerman.get_rect().colliderect(collid.rect):
- collide = True
- playerman.JumpCount = 10
- right = True
- left = True
- playerman.y = collid.rect.top - playerman.height
- if playerman.rect.right > collid.rect.left and playerman.rect.left < collid.rect.left - playerman.width:
- playerman.x = collid.rect.left - playerman.width
- if playerman.rect.left < collid.rect.right and playerman.rect.right > collid.rect.right + playerman.width:
- playerman.x = collid.rect.right
- if playerman.direction == "jump":
- playerman.direction = "Idle"
- if unpause111111 == 1:
- land[1].play()
- land[0].play()
- if playerman.direction == "jump2":
- playerman.direction = "leftid"
- if unpause111111 == 1:
- land[1].play()
- land[0].play()
- if collide:
- playerman.isJump = False
- playerman.fall = 1
- # Player jumping
- if not playerman.direction == "DEath" and not playerman.direction == "DEath2":
- if collide:
- if keys[pygame.K_SPACE]:
- playerman.isJump = True
- right = False
- left = False
- if unpause11111 == 1:
- jump.play()
- playerman.fall = 0
- ## playerman.isJump = False <-- omit this line. already False
- # What will happen when player jumps
- else:
- collideBottom = False
- for collid in collids:
- if (playerman.get_rect().colliderect(collid.rect) and
- playerman.y + playerman.height > collid.rect.bottom):
- collideBottom = True
- playerman.y = collid.rect.bottom
- break
- if not collideBottom and playerman.JumpCount >= 0:
- playerman.y -= (playerman.JumpCount*abs(playerman.JumpCount))*0.3
- playerman.JumpCount -= 1
- if playerman.direction == "right" or playerman.direction == "Idle":
- playerman.direction = "jump"
- if playerman.direction == "left" or playerman.direction == "leftid":
- playerman.direction = "jump2"
- else:
- playerman.isJump = False
- playerman.JumpCount = 10
- # redrawing the window
- redraw()
- window.blit(window,(render_offset))
- # updating the game
- pygame.display.update()
- # quiting the game
- pygame.quit()
- unpause()
Add Comment
Please, Sign In to add comment