Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- import math
- pygame.init()
- #------------------------------------------------- start screen
- def startscreen():
- window.fill(0,0,0)
- # ---------- MUSIC SECTION
- pygame.mixer.init()
- music = pygame.mixer.music.load("backgroundsong.wav")
- pygame.mixer.music.play(-1)
- # shooting sound
- shootsound = pygame.mixer.Sound("shootsound.wav")
- # hit the ice bergs sound
- icesound = pygame.mixer.Sound("shoot.wav")
- # hurt sound
- hurtsound = pygame.mixer.Sound("hite.wav")
- # jumpsound
- jumpsound = pygame.mixer.Sound("sjump.wav")
- #coin sound
- coinsound = pygame.mixer.Sound("coinssound.wav")
- # enemy hit sound
- hitesound = pygame.mixer.Sound("h.wav")
- # enemy death sound
- deathsound = pygame.mixer.Sound("death.wav")
- # health gain
- healthsound = pygame.mixer.Sound("pw.wav")
- # walking sound
- icesound = pygame.mixer.Sound("ices.wav")
- # ---------------------------------
- # window
- window = pygame.display.set_mode((800,800))
- pygame.display.set_caption("new World")
- #
- # error bloccks
- erblock = pygame.image.load("error.png")
- # trees images
- treo = pygame.image.load("tree.png")
- # mountains
- mounto = pygame.image.load("mount.png")
- # platform images
- blocks = pygame.image.load("block.png")
- # coins image
- heart = pygame.image.load("heart.png")
- # heart image
- heartingss = pygame.image.load("health.png")
- # define the shooting sound for the player ------------------------
- #---------------------------------------------
- # window
- window = pygame.display.set_mode((800,800))
- pygame.display.set_caption("new World")
- #
- # error bloccks
- erblock = pygame.image.load("error.png")
- # trees images
- treo = pygame.image.load("tree.png")
- # mountains
- mounto = pygame.image.load("mount.png")
- # platform images
- blocks = pygame.image.load("block.png")
- # coins image
- heart = pygame.image.load("heart.png")
- # heart image
- heartingss = pygame.image.load("health.png")
- # background
- bg = pygame.image.load("bg.png")
- # ice mountains
- ice = pygame.image.load("ice1.png")
- #
- icyy = pygame.image.load("ice2.png")
- # player projectiles
- slash = pygame.image.load("heart.png")
- # space bar key
- spi = [
- pygame.image.load("j1.png"),
- pygame.image.load("j2.png")]
- standingright = [pygame.image.load("d1.png"),
- pygame.image.load("d2.png"),
- pygame.image.load("d3.png"),
- pygame.image.load("d4.png"),
- pygame.image.load("d5.png"),
- pygame.image.load("d6.png"),
- pygame.image.load("d7.png"),
- pygame.image.load("d8.png"),
- pygame.image.load("d9.png"),
- pygame.image.load("d10.png"),
- pygame.image.load("d11.png"),
- pygame.image.load("d12.png"),
- pygame.image.load("d13.png"),
- pygame.image.load("d14.png"),
- pygame.image.load("d15.png")]
- standingleft =[pygame.image.load("s1.png"),
- pygame.image.load("s2.png"),
- pygame.image.load("s3.png"),
- pygame.image.load("s4.png"),
- pygame.image.load("s5.png"),
- pygame.image.load("s6.png"),
- pygame.image.load("s7.png"),
- pygame.image.load("s8.png"),
- pygame.image.load("s9.png"),
- pygame.image.load("s10.png"),
- pygame.image.load("s11.png"),
- pygame.image.load("s12.png"),
- pygame.image.load("s13.png"),
- pygame.image.load("s14.png"),
- pygame.image.load("s15.png")]
- rights = [pygame.image.load("L1.png"),
- pygame.image.load("L2.png"),
- pygame.image.load("L3.png"),
- pygame.image.load("L4.png"),
- pygame.image.load("L5.png"),
- pygame.image.load("L6.png"),
- pygame.image.load("L7.png"),
- pygame.image.load("L8.png"),
- pygame.image.load("L9.png"),
- pygame.image.load("L10.png"),
- pygame.image.load("L11.png"),
- pygame.image.load("L12.png"),
- pygame.image.load("L13.png"),
- pygame.image.load("L14.png"),
- pygame.image.load("L15.png")]
- lefts = [pygame.image.load("e1.png"),
- pygame.image.load("e2.png"),
- pygame.image.load("e3.png"),
- pygame.image.load("e4.png"),
- pygame.image.load("e5.png"),
- pygame.image.load("e6.png"),
- pygame.image.load("e7.png"),
- pygame.image.load("e8.png"),
- pygame.image.load("e9.png"),
- pygame.image.load("e10.png"),
- pygame.image.load("e11.png"),
- pygame.image.load("e12.png"),
- pygame.image.load("e13.png"),
- pygame.image.load("e14.png"),
- pygame.image.load("e15.png")]
- games = [pygame.image.load("key1.png"),
- pygame.image.load("key2.png"),
- pygame.image.load("key3.png"),
- pygame.image.load("key4.png"),
- pygame.image.load("key5.png"),
- pygame.image.load("key6.png"),
- pygame.image.load("key7.png")]
- # trees
- tree = pygame.image.load("treo.png")
- # bushes
- bushes = pygame.image.load("bush.png")
- #
- class tree:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.errors = pygame.image.load("treo.png")
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.errors,self.rect)
- black = (0,0,0)
- tree1 = tree(150,300,60,60,black)
- trees = [tree1]
- class bush:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.errors = pygame.image.load("bush.png")
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.errors,self.rect)
- bush1 = bush(-987210,-87510,100,100,black)
- bushes = [bush1]
- # erro block class
- class error:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.erblock = pygame.image.load("error.png")
- self.color = color
- self.rect = pygame.Rect(x,y,height,width)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- player_rect = erblock.get_rect(center = self.rect.center)
- player_rect.centerx += 20 # 10 is just an example
- player_rect.centery += -20 # 15 is just an example
- window.blit(self.erblock,self.rect)
- white = (255,255,255)
- error1 = error(-60,504,50,50,white)
- errors = [error1]
- platformGroup = pygame.sprite.Group
- platformList = []
- level = ["p ",
- "p ",
- "p ",
- "p ",
- "p ",
- "p ",
- "p ",
- "p ",
- "p ",
- "p ",
- " ",]
- for iy, row in enumerate(level):
- for ix, col in enumerate(row):
- if col == "p":
- new_platforms = error(-60, iy*70, 50,60,(255,255,255))
- errors.append(new_platforms)
- # my players class
- # player class
- class player:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.color = color
- self.height = height
- self.width = width
- self.speed = 5
- self.isJump = False
- self.JumpCount = 10
- self.fall = 0
- #hit box
- self.hitbox = (self.x + 20, self.y, 28, 60)
- self.stand = pygame.image.load("stands.png")
- self.rights = [pygame.image.load("L1.png"),
- pygame.image.load("L2.png"),
- pygame.image.load("L3.png"),
- pygame.image.load("L4.png"),
- pygame.image.load("L5.png"),
- pygame.image.load("L6.png"),
- pygame.image.load("L7.png"),
- pygame.image.load("L8.png"),
- pygame.image.load("L9.png"),
- pygame.image.load("L10.png"),
- pygame.image.load("L11.png"),
- pygame.image.load("L12.png"),
- pygame.image.load("L13.png"),
- pygame.image.load("L14.png"),
- pygame.image.load("L15.png")]
- self.lefts = [pygame.image.load("e1.png"),
- pygame.image.load("e2.png"),
- pygame.image.load("e3.png"),
- pygame.image.load("e4.png"),
- pygame.image.load("e5.png"),
- pygame.image.load("e6.png"),
- pygame.image.load("e7.png"),
- pygame.image.load("e8.png"),
- pygame.image.load("e9.png"),
- pygame.image.load("e10.png"),
- pygame.image.load("e11.png"),
- pygame.image.load("e12.png"),
- pygame.image.load("e13.png"),
- pygame.image.load("e14.png"),
- pygame.image.load("e15.png")]
- self.standingright = [pygame.image.load("d1.png"),
- pygame.image.load("d2.png"),
- pygame.image.load("d3.png"),
- pygame.image.load("d4.png"),
- pygame.image.load("d5.png"),
- pygame.image.load("d6.png"),
- pygame.image.load("d7.png"),
- pygame.image.load("d8.png"),
- pygame.image.load("d9.png"),
- pygame.image.load("d10.png"),
- pygame.image.load("d11.png"),
- pygame.image.load("d12.png"),
- pygame.image.load("d13.png"),
- pygame.image.load("d14.png"),
- pygame.image.load("d15.png")]
- self.standingleft =[pygame.image.load("s1.png"),
- pygame.image.load("s2.png"),
- pygame.image.load("s3.png"),
- pygame.image.load("s4.png"),
- pygame.image.load("s5.png"),
- pygame.image.load("s6.png"),
- pygame.image.load("s7.png"),
- pygame.image.load("s8.png"),
- pygame.image.load("s9.png"),
- pygame.image.load("s10.png"),
- pygame.image.load("s11.png"),
- pygame.image.load("s12.png"),
- pygame.image.load("s13.png"),
- pygame.image.load("s14.png"),
- pygame.image.load("s15.png")]
- self.rights = [pygame.transform.scale(image,(image.get_width()//5,image.get_height()//5)) for image in self.rights]
- self.lefts = [pygame.transform.scale(image,(image.get_width()//5,image.get_height()//5)) for image in self.lefts]
- self.standingright = [pygame.transform.scale(image,(image.get_width()//5,image.get_height()//5)) for image in self.standingright]
- self.standingleft = [pygame.transform.scale(image,(image.get_width()//5,image.get_height()//5)) for image in self.standingleft]
- self.bo_index = 0
- self.anim_index = 0
- self.stans_index = 0
- self.direction = "right"
- self.direction = "left"
- self.direction = "standright"
- self.direction = "standleft"
- self.health = 10
- self.hitbox = (self.x + -30, self.y + 0, 31, 57)
- # playerman hitbox
- self.hits = (self.x + 20, self.y, 28,60)
- self.rect = pygame.rect = pygame.Rect(self.x,self.y,width, height)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "right":
- image_list = self.rights
- elif self.direction == "standright":
- image_list = self.standingright
- elif self.direction == "left":
- image_list = self.lefts
- else:
- image_list = self.standingleft
- if self.anim_index >= len(image_list):
- self.anim_index = 0
- player_image = image_list[self.anim_index]
- self.anim_index += 1
- player_rect = player_image.get_rect(center = self.rect.center)
- player_rect.centerx += 20 # 10 is just an example
- player_rect.centery += -20 # 15 is just an example
- window.blit(player_image, player_rect)
- self.hits = (self.x + 20, self.y, 28,60)
- pygame.draw.rect(window, (255,0,0), (self.hitbox[0], self.hitbox[1] - 60, 80, 10)) # NEW
- pygame.draw.rect(window, (0,255,0), (self.hitbox[0], self.hitbox[1] - 60, 80 - (5 * (10 - self.health)), 10))
- self.hitbox = (self.x + -30, self.y + 0, 31, 57)
- # health icon
- heat = pygame.image.load("health.png")
- # player icon
- icon = pygame.image.load("icon.png")
- # floor platforms class
- class platform:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.blocks = pygame.image.load("block.png")
- self.rect = pygame.Rect(x,y,height,width)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.blocks,self.rect)
- # trees class
- class icess:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.icyy = pygame.image.load("ice2.png")
- self.icyy = pygame.transform.scale(self.icyy,(self.icyy.get_width()-44,self.icyy.get_height()-44))
- self.rect = pygame.Rect(x,y,height,width)
- self.hitbox = (self.x + 5, self.y + 1, 10, 72)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- player_rect = icyy.get_rect(center = self.rect.center)
- player_rect.centerx += 0 # 10 is just an example
- player_rect.centery += -50 # 15 is just an example
- window.blit(icyy, player_rect)
- self.hitbox = (self.x + 5, self.y + 1, 10, 72)
- black = (0,0,0)
- ice1 = icess(255450,16540,50434,134320,black)
- icing = [ice1]
- #
- class dice:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.ice = pygame.image.load("ice1.png")
- self.ice = pygame.transform.scale(self.ice,(self.ice.get_width()-44,self.ice.get_height()-44))
- self.rect = pygame.Rect(x,y,height,width)
- # the hitbox our projectiles will be colliding with
- self.hitbox = (self.x + 0, self.y + 1, 10, 72)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- player_rect = ice.get_rect(center = self.rect.center)
- player_rect.centerx += -14 # 10 is just an example
- player_rect.centery += -15 # 15 is just an example
- window.blit(ice, player_rect)
- # hit box our projectile will be colliding with
- self.hitbox = (self.x + 0, self.y + 1, 10, 72)
- black = (0,0,0)
- ice2 = dice(254550,494540,10,30,black)
- dicing = [ice2]
- # keys left right up[ down
- class Snow:
- def __init__(self, x, y, height, width, color):
- self.color = color
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.games = [
- pygame.image.load("key1.png"),
- pygame.image.load("key2.png"),
- pygame.image.load("key3.png"),
- pygame.image.load("key4.png"),
- pygame.image.load("key5.png"),
- pygame.image.load("key6.png"),
- pygame.image.load("key7.png")
- ]
- self.anim_index = 0
- self.direction = "idk"
- self.rect = pygame.Rect(x,y,height,width)
- self.delay = 150
- self.next_frame = pygame.time.get_ticks() + self.delay
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "idk":
- window.blit(self.games[self.anim_index], self.rect)
- if pygame.time.get_ticks() >= self.next_frame:
- self.next_frame = pygame.time.get_ticks() + self.delay
- self.anim_index += 1
- if self.anim_index == len(self.games):
- self.anim_index = 0
- black = (0,0,)
- snow1 = Snow(340,550,50,150,black)
- snowing = [snow1]
- # space bar key
- class spie:
- def __init__(self,x,y,height,width,color):
- self.color = color
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.spi = [
- pygame.image.load("j1.png"),
- pygame.image.load("j2.png")]
- self.anim_index = 0
- self.direction = "so"
- self.rect = pygame.Rect(x,y,height,width)
- self.delay = 150
- self.next_frame = pygame.time.get_ticks() + self.delay
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "so":
- window.blit(self.spi[self.anim_index], self.rect)
- if pygame.time.get_ticks() >= self.next_frame:
- self.next_frame = pygame.time.get_ticks() + self.delay
- self.anim_index += 1
- if self.anim_index == len(self.spi):
- self.anim_index = 0
- black = (0,0,)
- spie1 = spie(10,640,50,150,black)
- spies = [spie1]
- # coins class
- class coin:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.heart = pygame.image.load("heart.png")
- 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)
- player_rect = heart.get_rect(center = self.rect.center)
- player_rect.centerx += 0 # 10 is just an example
- player_rect.centery += 0 # 15 is just an example
- window.blit(heart, player_rect)
- # bullet class
- class projectile(object):
- def __init__(self, x, y, dirx, diry, color):
- self.x = x
- self.y = y
- self.dirx = dirx
- self.diry = diry
- self.slash = pygame.image.load("heart.png")
- self.rect = self.slash.get_rect()
- self.rect.topleft = ( self.x, self.y )
- self.speed = 10
- self.color = color
- def move(self):
- self.x += self.dirx * self.speed
- self.y += self.diry * self.speed
- def draw(self, window):
- self.rect.topleft = (round(self.x), round(self.y))
- window.blit(self.slash,self.rect)
- sigh = pygame.image.load("alert.png")
- class alrt:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.sigh = pygame.image.load("alert.png")
- self.sigh = pygame.transform.scale(self.sigh,(self.sigh.get_width()*3,self.sigh.get_height()*3))
- 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)
- player_rect = sigh.get_rect(center = self.rect.center)
- player_rect.centerx += 10 # 10 is just an example
- player_rect.centery += -15 # 15 is just an example
- window.blit(self.sigh,self.rect)
- black = (0,0,0)
- alert1 = alrt(170,370,50,50,black)
- alerting = [alert1]
- # exit image
- exits = pygame.image.load("exit.png")
- class exi:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.color = color
- self.height = height
- self.width = width
- self.exits = pygame.image.load("exit.png")
- self.exits = pygame.transform.scale(self.exits,(self.exits.get_width()*3,self.exits.get_height()*3))
- self.rect = pygame.Rect(x,y,height,width)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.exits,self.rect)
- # define the text class
- black = (0,0,0)
- exit1 = exi(160,140,40,40,black)
- exiting = [exit1]
- # text imgae
- te = pygame.image.load("text.png")
- # text class
- class texto:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.te = pygame.image.load("text.png")
- self.te = pygame.transform.scale(self.te,(self.te.get_width()-20,self.te.get_height()-20))
- self.rect = pygame.Rect(x,y,height,width)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.te,self.rect)
- pygame.draw.rect(window,self.color,self.rect)
- # define text class
- black = (0,0,0)
- text1 = texto(50,100,50,50,black)
- texting = [text1]
- # house image
- housee = pygame.image.load("house.png")
- # house
- class house:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y =y
- self.height = height
- self.width = width
- self.color = color
- self.housee = pygame.image.load("house.png")
- self.rect = pygame.Rect(x,y,height,width)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.housee,self.rect)
- # define the house class
- white = (255,255,255)
- house1 = house(50,290,60,60,white)
- housing = [house1]
- # player image
- man = [pygame.image.load("i1.png"),
- pygame.image.load("i1.png"),
- pygame.image.load("i2.png"),
- pygame.image.load("i3.png"),
- pygame.image.load("i4.png"),
- pygame.image.load("i5.png"),
- pygame.image.load("i6.png"),
- pygame.image.load("i7.png"),
- pygame.image.load("i8.png"),
- pygame.image.load("i9.png"),
- pygame.image.load("i10.png"),
- pygame.image.load("i11.png"),
- pygame.image.load("i12.png"),
- pygame.image.load("i13.png"),
- pygame.image.load("i14.png"),
- pygame.image.load("i15.png")]
- # player villager
- class villager:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.man =[
- pygame.image.load("i1.png"),
- pygame.image.load("i1.png"),
- pygame.image.load("i2.png"),
- pygame.image.load("i3.png"),
- pygame.image.load("i4.png"),
- pygame.image.load("i5.png"),
- pygame.image.load("i6.png"),
- pygame.image.load("i7.png"),
- pygame.image.load("i8.png"),
- pygame.image.load("i9.png"),
- pygame.image.load("i10.png"),
- pygame.image.load("i11.png"),
- pygame.image.load("i12.png"),
- pygame.image.load("i13.png"),
- pygame.image.load("i14.png"),
- pygame.image.load("i15.png")]
- self.direction = "so"
- self.anim_index = 0
- self.so_index = 0
- self.man = [pygame.transform.scale(image,(image.get_width()//5,image.get_height()//5)) for image in self.man]
- self.rect = pygame.Rect(x,y,height,width)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- if self.direction == "so":
- window.blit(self.man[self.anim_index], self.rect)
- self.anim_index += 1
- if self.anim_index == len(self.man):
- self.anim_index = 0
- # image of the sigh
- sighimage = pygame.image.load("sigh.png")
- # level 1 sigh class
- class sign:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.color = color
- self.height = height
- self.width = width
- self.sighimage = pygame.image.load("sigh.png")
- self.sighimage = pygame.transform.scale(self.sighimage,(self.sighimage.get_width()-10,self.sighimage.get_height()-10))
- self.rect = pygame.Rect(x,y,height,width)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.sighimage,self.rect)
- # define level 1 sighn
- black = (0,0,0)
- sighn1 = sign(-33,300,50,50,black)
- signs = [sighn1]
- # enemy animations
- esleft = [pygame.image.load("esleft1.png"),
- pygame.image.load("esleft1.png"),
- pygame.image.load("esleft2.png"),
- pygame.image.load("esleft3.png"),
- pygame.image.load("esleft4.png"),
- pygame.image.load("esleft5.png"),
- pygame.image.load("esleft6.png"),
- pygame.image.load("esleft7.png"),
- pygame.image.load("esleft8.png"),
- pygame.image.load("esleft9.png"),
- pygame.image.load("esleft10.png"),
- pygame.image.load("esleft11.png"),
- pygame.image.load("esleft12.png"),
- pygame.image.load("esleft13.png"),
- pygame.image.load("esleft14.png"),
- pygame.image.load("esleft15.png"),
- pygame.image.load("esleft16.png"),
- pygame.image.load("esleft17.png"),
- ]
- esright = [pygame.image.load("esright1.png"),
- pygame.image.load("esright1.png"),
- pygame.image.load("esright2.png"),
- pygame.image.load("esright3.png"),
- pygame.image.load("esright4.png"),
- pygame.image.load("esright5.png"),
- pygame.image.load("esright6.png"),
- pygame.image.load("esright7.png"),
- pygame.image.load("esright8.png"),
- pygame.image.load("esright9.png"),
- pygame.image.load("esright10.png"),
- pygame.image.load("esright11.png"),
- pygame.image.load("esright12.png"),
- pygame.image.load("esright13.png"),
- pygame.image.load("esright14.png"),
- pygame.image.load("esright15.png"),
- pygame.image.load("esright16.png"),
- pygame.image.load("esright17.png"),
- ]
- class enemys:
- def __init__(self,x,y,height,width,end):
- self.x = x
- self.y =y
- self.esright = [pygame.image.load("esright1.png"),
- pygame.image.load("esright1.png"),
- pygame.image.load("esright2.png"),
- pygame.image.load("esright3.png"),
- pygame.image.load("esright4.png"),
- pygame.image.load("esright5.png"),
- pygame.image.load("esright6.png"),
- pygame.image.load("esright7.png"),
- pygame.image.load("esright8.png"),
- pygame.image.load("esright9.png"),
- pygame.image.load("esright10.png"),
- pygame.image.load("esright11.png"),
- pygame.image.load("esright12.png"),
- pygame.image.load("esright13.png"),
- pygame.image.load("esright14.png"),
- pygame.image.load("esright15.png"),
- pygame.image.load("esright16.png"),
- pygame.image.load("esright17.png"),
- ]
- self.esleft = [pygame.image.load("esleft1.png"),
- pygame.image.load("esleft1.png"),
- pygame.image.load("esleft2.png"),
- pygame.image.load("esleft3.png"),
- pygame.image.load("esleft4.png"),
- pygame.image.load("esleft5.png"),
- pygame.image.load("esleft6.png"),
- pygame.image.load("esleft7.png"),
- pygame.image.load("esleft8.png"),
- pygame.image.load("esleft9.png"),
- pygame.image.load("esleft10.png"),
- pygame.image.load("esleft11.png"),
- pygame.image.load("esleft12.png"),
- pygame.image.load("esleft13.png"),
- pygame.image.load("esleft14.png"),
- pygame.image.load("esleft15.png"),
- pygame.image.load("esleft16.png"),
- pygame.image.load("esleft17.png"),
- ]
- self.esright = [pygame.transform.scale(image,(image.get_width()//3,image.get_height()//3)) for image in self.esright]
- self.esleft = [pygame.transform.scale(image,(image.get_width()//3,image.get_height()//3)) for image in self.esleft]
- self.height = height
- self.width = width
- self.anim_index = 0
- self.distance = 80
- self.speed = 8
- self.vel = 3
- self.path = [x,end]
- self.Walking_index = 0
- self.hitbox = (self.x + 17, self.y + 2, 31, 57)
- self.rect = pygame.Rect(x,y,height,width)
- COOLDOWN = 30
- # enemys health
- self.health = 10
- self.visible = True
- # this makes the enemy move right and left
- def draw(self,window):
- self.move()
- if self.Walking_index + 1 >= 33:
- self.Walking_index = 0
- if self.vel > 0:
- window.blit(self.esright[self.Walking_index//3], (self.x,self.y))
- self.Walking_index += 1
- else:
- window.blit(self.esleft[self.Walking_index//3], (self.x,self.y))
- self.Walking_index += 1
- # this moves the enemy left and right
- def move(self):
- if self.visible:
- if self.vel > 0:
- if self.x + self.vel < self.path[1]:
- self.x += self.vel
- else:
- self.vel = self.vel * -1
- self.Walking_index = 0
- else:
- if self.x - self.vel > self.path[0]:
- self.x += self.vel
- else:
- self.vel = self.vel * -1
- self.Walking_index = 0
- # the hit box for the enemy the health
- pygame.draw.rect(window, (255,0,0), (self.hitbox[0], self.hitbox[1] - 20, 70, 10)) # NEW
- pygame.draw.rect(window, (0,255,0), (self.hitbox[0], self.hitbox[1] - 20, 70 - (5 * (10 - self.health)), 10))
- self.hitbox = (self.x + 47, self.y + 31, 50, 72)
- # THIS PART MAKES the enemy not scroll with the player
- def scroll(self,sx, sy):
- self.x += sx
- self.y += sy
- self.path[0] += sx
- self.path[1] += sx
- #-----------------------------------------------------------------------------------------------------
- smallice = pygame.image.load("fals.png")
- class smallice:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.smallice = pygame.image.load("fals.png")
- self.smallice = pygame.transform.scale(self.smallice,(self.smallice.get_width()-2,self.smallice.get_height()-2))
- self.rect = pygame.Rect(x,y,height,width)
- self.hits = (self.x + 20, self.y, 28,60)
- self.health = 10
- # the hitbox our projectiles will be colliding with
- self.hitbox = (self.x + 0, self.y + 1, 10, 72)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- player_rect = self.smallice.get_rect(center = self.rect.center)
- player_rect.centerx += 0 # 10 is just an example
- player_rect.centery += 70 # 15 is just an example
- window.blit(self.smallice, player_rect)
- self.hits = (self.x + 20, self.y, 28,60)
- pygame.draw.rect(window, (255,0,0), (self.hitbox[0], self.hitbox[1] - 60, 50, 10)) # NEW
- pygame.draw.rect(window, (0,255,0), (self.hitbox[0], self.hitbox[1] - 60, 50 - (5 * (10 - self.health)), 10))
- self.hitbox = (self.x + -20, self.y + 30, 31, 57)
- # define the small ices
- black = (0,0,0)
- smallice1 = smallice(550,215,20,20,black)
- smallice2 = smallice(750,215,20,20,black)
- smallice3 = smallice(950,215,20,20,black)
- smallice4 = smallice(1110,215,20,20,black)
- small = [smallice1]
- smalls = [smallice2]
- smallss = [smallice3]
- smallsss = [smallice4]
- # enemys bullets
- littleice = pygame.image.load("littleboy.png")
- class Bullet(object):
- def __init__(self, x, y,color):
- self.x = x
- self.y = y
- self.littleice = pygame.image.load("littleboy.png")
- self.hitbox = self.littleice.get_rect()
- self.rect = self.littleice.get_rect()
- self.rect.topleft = (self.x,self.y)
- self.speed = 10
- self.color = color
- self.hitbox = (self.x + 57, self.y + 33, 29, 52) # NEW
- def draw(self, window):
- self.rect.topleft = (self.x,self.y)
- player_rect = self.littleice.get_rect(center = self.rect.center)
- player_rect.centerx += 0 # 10 is just an example
- player_rect.centery += 0 # 15 is just an example
- window.blit(self.littleice, player_rect)
- self.hitbox = (self.x + 97, self.y + 33, 10, 10) # NEW
- window.blit(self.littleice,self.rect)
- #---------------------------------------------------------------------------------------------
- # position image
- thisispos = pygame.image.load("poslol.png")
- # poisiton class health UP
- class pos5:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.thisispos = pygame.image.load("poslol.png")
- self.thisispos = pygame.transform.scale(self.thisispos,(self.thisispos.get_width()//8,self.thisispos.get_height()//8))
- self.rect = pygame.Rect(x,y,height,width)
- # the hitbox our projectiles will be colliding with
- self.hitbox = (self.x + 0, self.y + 1, 10, 72)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- player_rect = self.thisispos.get_rect(center = self.rect.center)
- player_rect.centerx += -10 # 10 is just an example
- player_rect.centery += 29 # 15 is just an example
- window.blit(self.thisispos, player_rect)
- self.hitbox = (self.x + -20, self.y + 30, 21, 67)
- # define the pos class
- black = (0,0,0)
- pos1 = pos5(950,390,50,50,black)
- poses = [pos1]
- # enemy icon image
- enemyi = pygame.image.load("ei.png")
- # enemy icon class
- class enemyicon:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y = y
- self.height = height
- self.width = width
- self.color = color
- self.enemyi = pygame.image.load("ei.png")
- self.rect = pygame.Rect(x,y,height,width)
- self.enemyi = pygame.transform.scale(self.enemyi,(self.enemyi.get_width()//3,self.enemyi.get_height()//3))
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.enemyi,self.rect)
- # hurt image
- hurts = [pygame.image.load("HURT1.png"),
- pygame.image.load("HURT2.png"),
- pygame.image.load("HURT3.png"),
- pygame.image.load("HURT4.png")]
- def hurt():
- delay = 105
- next_frame = pygame.time.get_ticks() + delay
- if pygame.time.get_ticks() >= next_frame:
- next_frame = pygame.time.get_ticks() + delay
- hurts = [pygame.image.load("HURT1.png"),
- pygame.image.load("HURT2.png"),
- pygame.image.load("HURT3.png"),
- pygame.image.load("HURT4.png")]
- # define enemy icon class
- black = (0,0,0)
- enemyi1 = enemyicon(0,70,50,50,black)
- enemyicons = [enemyi1]
- # define the enemy class
- black = (0,0,0)
- enemys1 = enemys(400,399,104,64,500)
- enemys2 = enemys(650,399,104,64,900)
- enemying = [enemys1]
- enemyings = [enemys2]
- # define the villager class
- red = (255,255,0)
- villager1 = villager(150,400,20,20,red)
- villaging = [villager1]
- black = (0,0,0)
- white = (255,255,255)
- green = (0,255,0)
- #_------
- # colors
- White = (255,255,255)
- Black = ((0,0,0))
- Yellow = ((231,253,0))
- # frames per second
- FPS = 60
- clock = pygame.time.Clock()
- # define player class
- playerman = player(50,450,30,30,Black)
- # coins
- coin1 = coin(340,450,30,30, Yellow)
- coin2 = coin(370,450,30,30, Yellow)
- coin3 = coin(370,420,30,30, Yellow)
- coin4 = coin(340,420,30,30, Yellow)
- coin5 = coin(480,450,30,30, Yellow)
- coin6 = coin(530,450,30,30, Yellow)
- Coins_list = [coin1,coin2,coin3,coin4,coin5,coin6]
- # enemy base
- # define platforms class
- plat = platform(-1000,500,6310,20,White)
- platforms = [plat]
- platformGroup = pygame.sprite.Group
- platformList = []
- level = [" ",
- " t ",
- " to to to ",
- "p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p ",
- " ",
- " ",
- " " ,
- " b b b b b b b p ",
- " s s s s ",
- " b b b ",
- "p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p p ",]
- for iy, row in enumerate(level):
- for ix, col in enumerate(row):
- if col == "p":
- new_platforms = platform(ix*10, iy*50, 10,10,(255,255,255))
- platforms.append(new_platforms)
- for iy, row in enumerate(level):
- for ix, col in enumerate(row):
- if col == "s":
- new_platforms = dice(ix*30, iy*50, 10,250,(255,255,255))
- dicing.append(new_platforms)
- for iy, row in enumerate(level):
- for ix, col in enumerate(row):
- if col == "t":
- new_platforms = icess(ix*30, iy*110, 10,10,(255,255,255))
- icing.append(new_platforms)
- for iy, row in enumerate(level):
- for ix, cols in enumerate(row):
- if cols == "b":
- new_platforms = bush(ix*20, iy*15, 10,10,(255,255,255))
- bushes.append(new_platforms)
- for iy, row in enumerate(level):
- for ix, cols in enumerate(row):
- if cols == "o":
- new_platforms = tree(ix*20, iy* -20, 10,10,(255,255,255))
- trees.append(new_platforms)
- # enemy -5 def function call the function under the enemy thing when you hit it
- def minusenemyhealthtext():
- font1 = pygame.font.SysFont('BLOODY.tff', 100)
- stext = font1.render('-5', 1, (255,0,0))
- window.blit(stext, (450 - (stext.get_width()/2),300))
- pygame.display.update()
- # this function ads +5 when ever we drink or health potion
- def plushealth():
- font2 = pygame.font.SysFont('comicsans', 100)
- sstext = font2.render('+5', 1, (0,255,0))
- window.blit(sstext, (450 - (sstext.get_width()/2),200))
- pygame.display.update()
- # coin scoring
- font = pygame.font.Font('times.ttf',29)
- score = 0
- text = font.render("Hearts = " + str(score), True, (255,255,255))
- textRect = text.get_rect()
- textRect.center = ((80,70))
- #-------------------------------- enemy shoots left and right
- shotsright = pygame.image.load("shooting2.png")
- shotsleft = pygame.image.load("shooting1.png")
- class enemyshoot:
- def __init__(self,x,y,height,width,color):
- self.x = x
- self.y =y
- self.height = height
- self.width = width
- self.color = color
- self.shootsright = pygame.image.load("shooting2.png")
- self.shotsleft = pygame.image.load("shooting1.png")
- self.shootsright = pygame.transform.scale(self.shootsright,(self.shootsright.get_width()//3,self.shootsright.get_height()//3))
- self.shotsleft = pygame.transform.scale(self.shotsleft,(self.shotsleft.get_width()//3,self.shotsleft.get_height()//3))
- self.rect = pygame.Rect(x,y,height,width)
- self.health = 10
- self.hitbox = (self.x + -20, self.y + 30, 31, 57)
- def draw(self):
- self.rect.topleft = (self.x,self.y)
- window.blit(self.shootsright,self.rect)
- self.hits = (self.x + 20, self.y, 28,60)
- pygame.draw.rect(window, (255,0,0), (self.hitbox[0], self.hitbox[1] - 60, 50, 10)) # NEW
- pygame.draw.rect(window, (0,255,0), (self.hitbox[0], self.hitbox[1] - 60, 50 - (5 * (10 - self.health)), 10))
- self.hitbox = (self.x + 60, self.y + 80, 81, 87)
- black = (0,0,0)
- enemyshoots1 = enemyshoot(1100,240,100,100,black)
- enemyshooting = [enemyshoots1]
- #------------------------------------------------------------------------------
- # enemys bullets
- ksud = pygame.image.load("heart.png")
- class Bools(object):
- def __init__(self, x, y,color):
- self.x = x
- self.y = y
- self.ksud = pygame.image.load("heart.png")
- self.hitbox = self.ksud.get_rect()
- self.rect = self.ksud.get_rect()
- self.rect.topleft = (self.x,self.y)
- self.speed = 10
- self.color = color
- self.hitbox = (self.x + 57, self.y + 33, 29, 52) # NEW
- def draw(self, window):
- self.rect.topleft = (self.x,self.y)
- player_rect = self.ksud.get_rect(center = self.rect.center)
- player_rect.centerx += 0 # 10 is just an example
- player_rect.centery += 0 # 15 is just an example
- window.blit(self.ksud, player_rect)
- self.hitbox = (self.x + 97, self.y + 33, 10, 10) # NEW
- window.blit(self.ksud,self.rect)
- #------------------------------------------------------------------------------
- # varabile for image text sighns
- # main game loop
- shootsright = []
- bullets = []
- bulls = []
- bullss = []
- bullsss = []
- bullssss = []
- runninggame = True
- while runninggame:
- clock.tick(FPS)
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- runninggame = False
- # -------- shoot the bullets when you click your mouse
- if event.type == pygame.MOUSEBUTTONDOWN:
- # this is for the bullets
- if len(bullets) < 2:
- shootsound.play()
- start_x, start_y = playerman.x+playerman.width//2, playerman.y + playerman.height-54
- mouse_x, mouse_y = event.pos
- dir_x, dir_y = mouse_x - start_x, mouse_y - start_y
- distance = math.sqrt(dir_x**2 + dir_y**2)
- if distance > 0:
- new_bullet = projectile(start_x, start_y, dir_x/distance, dir_y/distance, (0,0,0))
- bullets.append(new_bullet)
- # this is displaying the bullets for the player
- for bullet in bullets[:]:
- bullet.move()
- if bullet.x < 0 or bullet.x > 900 or bullet.y < 0 or bullet.y > 900:
- bullets.pop(bullets.index(bullet))
- #--------------------------------------------------------------------------------------------------------- enemys
- # enemys 1
- for bullet in bullets:
- if bullet.rect.colliderect(enemys2.hitbox):
- if enemys2.health > -5:
- enemys2.health -= 1
- bullets.pop(bullets.index(bullet))
- hitesound.play()
- # this function calss the -5 text appearing and dispearing on my screen
- minusenemyhealthtext()
- else:
- for oe in range(len(enemyings)-1,-1,-1):
- deathsound.play()
- del enemyings[oe]
- # enemys 2
- for bullet in bullets:
- if bullet.rect.colliderect(enemys1.hitbox):
- if enemys1.health > -5:
- enemys1.health -= 1
- bullets.pop(bullets.index(bullet))
- hitesound.play()
- # this function calss the -5 text appearing and dispearing on my screen
- minusenemyhealthtext()
- else:
- for one in range(len(enemying)-1,-1,-1):
- deathsound.play()
- del enemying[one]
- #---------------------------------------------------------------------------------------------------------
- # if collides with the sharp tiles
- for bullet in bullets:
- for icess in icing:
- if bullet.rect.colliderect(icess.hitbox):
- bullets.pop(bullets.index(bullet))
- icesound.play()
- print("YO YOU COLLIDED THAT SHIT")
- for bullet in bullets:
- for dice in dicing:
- if bullet.rect.colliderect(dice.hitbox):
- bullets.pop(bullets.index(bullet))
- icesound.play()
- print("yo fam you collided with that sharp thing")
- # health players
- for dice in dicing:
- if playerman.rect.colliderect(dice.hitbox):
- hurtsound.play()
- if playerman.health > -6:
- playerman.health -= 1
- playerman.x = 10
- else:
- print("cant delete him")
- for pos5 in poses:
- if playerman.rect.colliderect(pos5.hitbox):
- healthsound.play()
- playerman.health += 5
- del poses[one]
- # this function loads +5 for the player
- plushealth()
- # ----------------------------------------------------------------------------
- # collision between the ices
- for bullet in bullets:
- for bull in bulls:
- for smallice in small:
- if bullet.rect.colliderect(smallice.rect):
- icesound.play()
- if smallice.health > 1:
- smallice.health -= 1
- else:
- del small[one]
- if bull.y < 1050 and bull.y > 2160:
- print("by by mfs")
- # collision between the ices
- for bullet in bullets:
- for firstb in bullss:
- for smallice in smalls:
- if bullet.rect.colliderect(smallice.rect):
- icesound.play()
- if smallice.health > 1:
- smallice.health -= 1
- else:
- del smalls[one]
- if firstb.y < 1050 and firstb.y > 2160:
- print("by by mfs")
- # collision between the ices
- for bullet in bullets:
- for secondb in bullsss:
- for smallice in smallss:
- if bullet.rect.colliderect(smallice.rect):
- icesound.play()
- if smallice.health > 1:
- smallice.health -= 1
- else:
- del smallss[one]
- if secondb.y < 1050 and secondb.y > 2160:
- print("by by mfs")
- # collision between the ices
- for bullet in bullets:
- for thirdb in bullssss:
- for smallice in smallsss:
- if bullet.rect.colliderect(smallice.rect):
- icesound.play()
- if smallice.health > 1:
- smallice.health -= 1
- else:
- del smallsss[one]
- if thirdb.y < 1050 and thirdb.y > 2160:
- print("by by mfs")
- # ----------------------------------------------------------------------------
- # collision between the ices
- #Poping bullets from list
- for bull in bulls:
- if playerman.rect.colliderect(bull.hitbox):
- playerman.health -=1
- bulls.pop(bulls.index(bull))
- for firstb in bullss:
- if playerman.rect.colliderect(firstb.hitbox):
- playerman.health -=1
- bullss.pop(bullss.index(firstb))
- for secondb in bullsss:
- if playerman.rect.colliderect(secondb.hitbox):
- playerman.health -=1
- bullsss.pop(bullsss.index(secondb))
- for thirdb in bullssss:
- if playerman.rect.colliderect(thirdb.hitbox):
- playerman.health -=1
- bullssss.pop(bullssss.index(thirdb))
- #---------------------------------------------------------------------------------------------------------------------------------------------
- # projectile class for each of the bullets
- for bull in bulls:
- if bull.y < 550 and bull.y > 0:
- bull.y += 4
- else:
- bulls.pop(bulls.index(bull))
- if len(bulls) < 1:
- bulls.append(Bullet(round(smallice1.x+smallice1.width-107),round(smallice1.y + smallice1.height-50),(0,0,0)))
- for firstb in bullss:
- if firstb.y < 550 and bull.y > 0:
- firstb.y += 5
- else:
- bullss.pop(bullss.index(firstb))
- if len(bullss) < 1:
- bullss.append(Bullet(round(smallice2.x+smallice2.width-107),round(smallice2.y + smallice2.height-50),(0,0,0)))
- for secondb in bullsss:
- if secondb.y < 550 and secondb.y > 0:
- secondb.y += 6
- else:
- bullsss.pop(bullsss.index(secondb))
- if len(bullsss) < 1:
- bullsss.append(Bullet(round(smallice3.x+smallice3.width-107),round(smallice3.y + smallice3.height-50),(0,0,0)))
- for thirdb in bullssss:
- if thirdb.y < 550 and thirdb.y > 0:
- thirdb.y += 7
- else:
- bullssss.pop(bullssss.index(thirdb))
- if len(bullssss) < 1:
- bullssss.append(Bullet(round(smallice4.x+smallice4.width-107),round(smallice4.y + smallice4.height-50),(0,0,0)))
- for shootss in shootsright:
- if shootss.x < 500 and shootss.x > 0:
- shootss.x += 7
- else:
- shootsright.pop(shootsright.index(shootss))
- if len(shootsright) < 1:
- shootsright.append(Bools(round(enemyshoots1.x+enemyshoots1.width-107),round(enemyshoots1.y + enemyshoots1.height-50),(0,0,0)))
- # projectile class for each of the bullets
- #---------------------------------------------------------------------------------------------------------------------------------------------
- keys = pygame.key.get_pressed()
- # Jump and Collisions
- # camera left and right movement
- if playerman.y < 250:
- playerman.y += 1
- for platform in platforms:
- platform.y += playerman.speed
- for coin in Coins_list:
- coin.y += playerman.speed
- for error in errors:
- error.y += playerman.speed
- for dice in dicing:
- dice.y += playerman.speed
- for icess in icing:
- icess.y += playerman.speed
- for bush in bushes:
- bush.y += playerman.speed
- for spie in spies:
- spie.y += playerman.speed
- for Snow in snowing:
- Snow.y += playerman.speed
- for alrt in alerting:
- alrt.y += playerman.speed
- for villager in villaging:
- villager.y += playerman.speed
- for house in housing:
- house.y += playerman.speed
- for tree in trees:
- tree.y += playerman.speed
- for sign in signs:
- sign.y += playerman.speed
- for pos5 in poses:
- pos5.y += playerman.speed
- for smallice in small:
- smallice.y += playerman.speed
- for enemyshoot in enemyshooting:
- enemyshoot.y += playerman.speed
- #--------------------------------------------------------
- # bullets for ice falling camera control
- for bull in bulls:
- bull.y += playerman.speed
- for firstb in bullss:
- firstb.y += playerman.speed
- for secondb in bullsss:
- secondb.y += playerman.speed
- for thirdb in bullssss:
- thirdb.y += playerman.speed
- #----------------------------------------------
- # the ice fallings camera cdontrol
- for smallice in smalls:
- smallice.y += playerman.speed
- for smallice in smallss:
- smallice.y += playerman.speed
- for smallice in smallsss:
- smallice.y += playerman.speed
- #----------------------------------------------
- for enemys in enemying:
- enemys.scroll(0,+ playerman.speed)
- for enemys in enemyings:
- enemys.scroll(0,+ playerman.speed)
- for shootss in shootsright:
- shootss.y += playerman.speed
- # camera up movement:
- if playerman.y > 500:
- playerman.y -= playerman.fall
- for platform in platforms:
- platform.y -= playerman.fall
- for coin in Coins_list:
- coin.y -= playerman.fall
- for error in errors:
- error.y -= playerman.fall
- for dice in dicing:
- dice.y -= playerman.fall
- for icess in icing:
- icess.y -= playerman.fall
- for bush in bushes:
- bush.y -= playerman.fall
- for spie in spies:
- spie.y -= playerman.fall
- for Snow in snowing:
- Snow.y -= playerman.fall
- for villager in villaging:
- villager.y -= playerman.fall
- for house in housing:
- house.y -= playerman.fall
- for alrt in alerting:
- alrt.y -= playerman.fall
- for tree in trees:
- tree.y -= playerman.fall
- for sign in signs:
- sign.y -= playerman.fall
- for pos5 in poses:
- pos5.y -= playerman.fall
- for enemyshoot in enemyshooting:
- enemyshoot.y -= playerman.fall
- #----------------------------------------------
- for smallice in small:
- smallice.y -= playerman.fall
- for smallice in smalls:
- smallice.y -= playerman.fall
- for smallice in smallss:
- smallice.y -= playerman.fall
- for smallice in smallsss:
- smallice.y -= playerman.fall
- #----------------------------------------------
- # camera controlf for falling ice
- for bull in bulls:
- bull.y -= playerman.fall
- for firstb in bullss:
- firstb.y -= playerman.fall
- for secondb in bullsss:
- secondb.y -= playerman.fall
- for thirdb in bullssss:
- thirdb.y -= playerman.fall
- #----------------------------------------------
- for enemys in enemying:
- enemys.scroll(0, -playerman.fall)
- for enemys in enemyings:
- enemys.scroll(0, -playerman.fall)
- for shootss in shootsright:
- shootss.y -= playerman.fall
- keys = pygame.key.get_pressed()
- # key binds for the player
- if keys[pygame.K_a]:
- playerman.x -= playerman.speed
- playerman.direction = "left"
- # camera controll for left
- if playerman.x < 100:
- playerman.x += playerman.speed
- for platform in platforms:
- platform.x += playerman.speed
- for coin in Coins_list:
- coin.x += playerman.speed
- for error in errors:
- error.x += playerman.speed
- for dice in dicing:
- dice.x += playerman.speed
- for icess in icing:
- icess.x += playerman.speed
- for bush in bushes:
- bush.x += playerman.speed
- for spie in spies:
- spie.x += playerman.speed
- for Snow in snowing:
- Snow.x += playerman.speed
- for villager in villaging:
- villager.x += playerman.speed
- for house in housing:
- house.x += playerman.speed
- for alrt in alerting:
- alrt.x += playerman.speed
- for tree in trees:
- tree.x += playerman.speed
- for sign in signs:
- sign.x += playerman.speed
- for pos5 in poses:
- pos5.x += playerman.speed
- for enemyshoot in enemyshooting:
- enemyshoot.x += playerman.speed
- for shootss in shootsright:
- shootss.x += playerman.speed
- #----------------------------------------------
- # the ice fallings camera cdontrol
- for smallice in small:
- smallice.x += playerman.speed
- for smallice in smalls:
- smallice.x += playerman.speed
- for smallice in smallss:
- smallice.x += playerman.speed
- for smallice in smallsss:
- smallice.x += playerman.speed
- #----------------------------------------------
- for bull in bulls:
- bull.x += playerman.speed
- for firstb in bullss:
- firstb.x += playerman.speed
- for secondb in bullsss:
- secondb.x += playerman.speed
- for thirdb in bullssss:
- thirdb.x += playerman.speed
- #----------------------------------------------
- for enemys in enemying:
- enemys.scroll(playerman.speed,0)
- for enemys in enemyings:
- enemys.scroll(playerman.speed,0)
- elif keys[pygame.K_d]:
- playerman.x += playerman.speed
- playerman.direction = "right"
- # camera for right:
- if playerman.x > 400:
- playerman.x -= playerman.speed
- for platform in platforms:
- platform.x -= playerman.speed
- for coin in Coins_list:
- coin.x -= playerman.speed
- for error in errors:
- error.x -= playerman.speed
- for dice in dicing:
- dice.x -= playerman.speed
- for icess in icing:
- icess.x -= playerman.speed
- for bush in bushes:
- bush.x -= playerman.speed
- for spie in spies:
- spie.x -= playerman.speed
- for Snow in snowing:
- Snow.x -= playerman.speed
- for villager in villaging:
- villager.x -= playerman.speed
- for house in housing:
- house.x -= playerman.speed
- for alrt in alerting:
- alrt.x -= playerman.speed
- for tree in trees:
- tree.x -= playerman.speed
- for sign in signs:
- sign.x -= playerman.speed
- for pos5 in poses:
- pos5.x -= playerman.speed
- for enemyshoot in enemyshooting:
- enemyshoot.x -= playerman.speed
- for shootss in shootsright:
- shootss.x -= playerman.speed
- #----------------------------------------------
- # the ice fallings camera cdontrol
- for smallice in small:
- smallice.x -= playerman.speed
- for smallice in smalls:
- smallice.x -= playerman.speed
- for smallice in smallss:
- smallice.x -= playerman.speed
- for smallice in smallsss:
- smallice.x -= playerman.speed
- #----------------------------------------------
- #----------------------------------------------
- for bull in bulls:
- bull.x -= playerman.speed
- for firstb in bullss:
- firstb.x -= playerman.speed
- for secondb in bullsss:
- secondb.x -= playerman.speed
- for thirdb in bullssss:
- thirdb.x -= playerman.speed
- #----------------------------------------------
- for enemys in enemying:
- enemys.scroll(-playerman.speed, 0)
- for enemys in enemyings:
- enemys.scroll(-playerman.speed, 0)
- else:
- if playerman.direction == "right":
- playerman.direction = "standright"
- else:
- if playerman.direction == "left":
- playerman.direction = "standleft"
- if not playerman.isJump:
- playerman.y += playerman.fall
- playerman.fall += 1
- collide = False
- playerman.isJump = False
- for platform in platforms:
- if playerman.rect.colliderect(platform.rect):
- collide = True
- isJump = False
- playerman.y = platform.rect.top - playerman.height + 1
- if playerman.rect.right > platform.rect.left and playerman.rect.left < platform.rect.left - playerman.width:
- playerman.x = platform.rect.left - playerman.width
- if playerman.rect.left < platform.rect.right and playerman.rect.right > platform.rect.right + playerman.width:
- playerman.x = platform.rect.right
- for one in range(len(Coins_list)-1,-1,-1):
- if playerman.rect.colliderect(Coins_list[one].rect):
- coinsound.play()
- del Coins_list[one]
- score += 1
- text = font.render("Hearts = " + str(score), True, (255,255,255))
- textRect.center = ((80,70))
- if collide:
- if keys[pygame.K_SPACE]:
- jumpsound.play()
- playerman.isJump = True
- playerman.fall = 0
- else:
- if playerman.JumpCount >= 0:
- playerman.y -= (playerman.JumpCount*abs(playerman.JumpCount))*0.3
- playerman.JumpCount -= 1
- else:
- playerman.isJump = False
- playerman.JumpCount = 10
- # display the player and the screen
- window.fill((106, 237, 249))
- window.blit(bg,(0,0))
- for pos5 in poses:
- pos5.draw()
- for spie in spies:
- spie.draw()
- for tree in trees:
- tree.draw()
- for bush in bushes:
- bush.draw()
- for icess in icing:
- icess.draw()
- for dice in dicing:
- dice.draw()
- for Snow in snowing:
- Snow.draw()
- for sign in signs:
- sign.draw()
- for error in errors:
- error.draw()
- for house in housing:
- house.draw()
- playerman.draw()
- for coin in Coins_list:
- coin.draw()
- for platform in platforms:
- platform.draw()
- for enemys in enemying:
- enemys.draw(window)
- for enemys in enemyings:
- enemys.draw(window)
- for villager in villaging:
- villager.draw()
- for enemyicon in enemyicons:
- enemyicon.draw()
- for alrt in alerting:
- alrt.draw()
- # draw the falling icy
- for smallice in small:
- smallice.draw()
- for smallice in smalls:
- smallice.draw()
- for smallice in smallss:
- smallice.draw()
- for smallice in smallsss:
- smallice.draw()
- #---------------------------------------
- # draw the falling bullets
- for bull in bulls:
- bull.draw(window)
- for firstb in bullss:
- firstb.draw(window)
- for secondb in bullsss:
- secondb.draw(window)
- for thirdb in bullssss:
- thirdb.draw(window)
- for enemyshoot in enemyshooting:
- enemyshoot.draw()
- #---------------------------------------
- for bullet in bullets:
- bullet.draw(window)
- for shootss in shootsright:
- shootss.draw(window)
- window.blit(text,textRect)
- pygame.display.update()
- pygame.quit()
Add Comment
Please, Sign In to add comment