def display(img, pos): Const.gameDisplay.fill(Const.white) Const.gameDisplay.blit(images.background2, [Const.lead_x,Const.lead_y]) if pos == False: Const.gameDisplay.blit(img, [Const.width/4, Const.height/4]) Const.gameDisplay.blit(images.mage, [Const.lead_x+200,Const.lead_y]) Const.gameDisplay.blit(images.wizard, [Const.lead_x-300,Const.lead_y+200]) Const.gameDisplay.blit(images.killer, [Const.lead_x+300,Const.lead_y-100]) if pos == True: Const.gameDisplay.blit(img, [Const.width/4, Const.height/4]) Const.gameDisplay.blit(images.background, [0, 0]) message_to_screen(("x:"+str(-Const.lead_x)+"y:"+str(Const.lead_y)), Const.black, [0,0], 50) health_bar() pygame.display.update()
def text_box(msg): pygame.draw.rect(Const.gameDisplay, Const.black, [(Const.width/4)-100, Const.height/4, 550, 50]) message_to_screen(msg, Const.white, [(Const.width/4)-100, Const.height/4], 50) pygame.display.update() Const.counter = False while Const.counter == False: for event in pygame.event.get(): if event.type==pygame.QUIT: pygame.quit() quit() elif event.type==pygame.KEYDOWN: if event.key==pygame.K_x: Const.counter = True break
def Display(N1, N2, N3, N4, img, full): Const.gameDisplay.blit(img, [0, 0]) Const.gameDisplay.blit(images.rat, [150, 100]) pygame.draw.rect(Const.gameDisplay, Const.green, [237, 11, N1, 12]) pygame.draw.rect(Const.gameDisplay, Const.lawn_green, [237, 11, N1, 4]) pygame.draw.rect(Const.gameDisplay, Const.green, [236, 12, 1, 10]) pygame.draw.rect(Const.gameDisplay, Const.lawn_green, [236, 12, N1, 2]) pygame.draw.rect(Const.gameDisplay, Const.green, [235, 13, 1, 8]) pygame.draw.rect(Const.gameDisplay, Const.green, [234, 14, 1, 6]) pygame.draw.rect(Const.gameDisplay, Const.green, [54, 494, N2, 14]) pygame.draw.rect(Const.gameDisplay, Const.lawn_green, [54, 494, N2, 3]) message_to_screen(str(N4), Const.black, [89, 494], 20) message_to_screen(str(N3), Const.black, [370, 11], 20) if Const.percent == 294 and full == 1: pygame.draw.rect(Const.gameDisplay, Const.green, [531, 12, 1, 10]) pygame.draw.rect(Const.gameDisplay, Const.lawn_green, [531, 12, 1, 3]) pygame.draw.rect(Const.gameDisplay, Const.green, [532, 13, 1, 8]) pygame.draw.rect(Const.gameDisplay, Const.lawn_green, [532, 13, 1, 1]) pygame.draw.rect(Const.gameDisplay, Const.green, [533, 14, 1, 6]) pygame.display.update() time.sleep(0.05)
def title_menu(): counter = 1 while counter == 1: for event in pygame.event.get(): if event.type==pygame.QUIT: pygame.quit() quit() mouse = pygame.mouse.get_pos() if (200+Const.shapeW) > mouse[0] > Const.shapeW and 149 > mouse[1] > 50: pygame.draw.rect(Const.gameDisplay, Const.light_grey, [Const.shapeW, 50, 200, 99]) message_to_screen("START", Const.black, [Const.shapeW+40, 80], 50) pygame.display.update(Const.shapeW+40, 80, 25, 50) if event.type==MOUSEBUTTONDOWN: pygame.draw.rect(Const.gameDisplay, Const.grey, [Const.shapeW, 50, 200, 99]) message_to_screen("START", Const.black, [Const.shapeW+40, 80], 50) pygame.display.update(Const.shapeW+40, 80, 25, 50) time.sleep(0.1) pygame.draw.rect(Const.gameDisplay, Const.light_grey, [Const.shapeW, 50, 200, 99]) message_to_screen("START", Const.black, [Const.shapeW+40, 80], 50) pygame.display.update(Const.shapeW+40, 80, 25, 50) time.sleep(0.1) counter = 0 cutscenes() else: pygame.draw.rect(Const.gameDisplay, Const.white, [Const.shapeW, 50, 200, 99]) message_to_screen("START", Const.black, [Const.shapeW+40, 80], 50) pygame.display.update(Const.shapeW+40, 80, 25, 50) mouse = pygame.mouse.get_pos() if (200+Const.shapeW) > mouse[0] > Const.shapeW and 273 > mouse[1] > 174: pygame.draw.rect(Const.gameDisplay, Const.light_grey, [Const.shapeW, 174, 200, 99]) message_to_screen("QUIT", Const.black, [Const.shapeW+40, 204], 50) pygame.display.update(Const.shapeW+40, 204, 25, 50) if event.type==MOUSEBUTTONDOWN: pygame.draw.rect(Const.gameDisplay, Const.grey, [Const.shapeW, 174, 200, 99]) message_to_screen("QUIT", Const.black, [Const.shapeW+40, 204], 50) pygame.display.update(Const.shapeW+40, 204, 25, 50) time.sleep(0.1) pygame.draw.rect(Const.gameDisplay, Const.light_grey, [Const.shapeW, 174, 200, 99]) message_to_screen("QUIT", Const.black, [Const.shapeW+40, 204], 50) pygame.display.update(Const.shapeW+40, 204, 25, 50) time.sleep(0.1) pygame.quit() quit() else: pygame.draw.rect(Const.gameDisplay, Const.white, [Const.shapeW, 174, 200, 99]) message_to_screen("QUIT", Const.black, [Const.shapeW+40, 204], 50) pygame.display.update(Const.shapeW+40, 204, 25, 50) mouse = pygame.mouse.get_pos() if (200+Const.shapeW) > mouse[0] > Const.shapeW and 397 > mouse[1] > 298: pygame.draw.rect(Const.gameDisplay, Const.light_grey, [Const.shapeW, 298, 200, 99]) message_to_screen("LOAD", Const.black, [Const.shapeW+40, 327], 50) pygame.display.update(Const.shapeW+40, 327, 25, 50) if event.type==MOUSEBUTTONDOWN: pygame.draw.rect(Const.gameDisplay, Const.grey, [Const.shapeW, 298, 200, 99]) message_to_screen("LOAD", Const.black, [Const.shapeW+40, 327], 50) pygame.display.update(Const.shapeW+40, 327, 25, 50) time.sleep(0.1) pygame.draw.rect(Const.gameDisplay, Const.light_grey, [Const.shapeW, 298, 200, 99]) message_to_screen("LOAD", Const.black, [Const.shapeW+40, 327], 50) pygame.display.update(Const.shapeW+40, 327, 25, 50) time.sleep(0.1) try: Const.load = True load() gameLoop() except: pass else: pygame.draw.rect(Const.gameDisplay, Const.white, [Const.shapeW, 298, 200, 99]) message_to_screen("LOAD", Const.black, [Const.shapeW+40, 327], 50) pygame.display.update(Const.shapeW+40, 327, 25, 50)
def action(): Display(Const.percent, Const.percent2 , rat.rat_health, player.player_health, images.b1, 1) rat.rat_ExpGain = rat.rat_health * 10 Const.dmg = player.player_attack / rat.rat_health while Const.Exit == 0: pygame.display.update() for event in pygame.event.get(): if event.type==pygame.QUIT: pygame.quit() quit() elif event.type==pygame.KEYDOWN: if event.key==pygame.K_x: animation(images.b4) Const.Exit = 1 Const.percent = 294.0 message_to_screen("you ran away", Const.black, [200, 250], 25) rat.rat_health = float(random.randrange(100, 170, 10)) pygame.display.update() time.sleep(1) if event.key==pygame.K_v: animation(images.b3) Const.gameDisplay.blit(images.ability , [192, 144]) pygame.display.update() while Const.commands == 0: for event in pygame.event.get(): if event.type==pygame.QUIT: pygame.quit() quit() elif event.type==pygame.KEYDOWN: if event.key==pygame.K_v: Const.commands = 1 Const.commands = 0 Display(Const.percent, Const.percent2 , rat.rat_health, player.player_health, images.b1, 1) if event.key==pygame.K_z: inventory_images_list = [images.inventory, images.inventory2, images.inventory3, images.inventory4, images.inventory5, images.inventory6, images.inventory7, images.inventory8] animation(images.b5) Const.gameDisplay.blit(images.inventory , [192, 144]) pygame.display.update() Num = 0 Num2 = 0 Num3 = 0 while Const.commands == 0: for event in pygame.event.get(): if event.type==pygame.QUIT: pygame.quit() quit() elif event.type==pygame.KEYDOWN: if event.key==pygame.K_z: Const.commands = 1 elif event.key==pygame.K_LEFT: if Num == 0: Num = 7 else: Num -= 1 Const.gameDisplay.blit(inventory_images_list[Num] , [192, 144]) pygame.display.update() elif event.key==pygame.K_RIGHT: if Num == 7: Num = 0 else: Num += 1 Const.gameDisplay.blit(inventory_images_list[Num] , [192, 144]) pygame.display.update() elif event.key==pygame.K_v: Const.gameDisplay.blit(images.temp , [196+(Num2*48), 237+(Num3*48)]) pygame.display.update() elif event.key==pygame.K_x: if Num2 == 7: Num2 = 0 else: Num2 += 1 elif event.key==pygame.K_y: if Num3 == 3: Num3 = 0 else: Num3 += 1 Const.commands = 0 Display(Const.percent, Const.percent2 , rat.rat_health, player.player_health, images.b1, 1) elif event.key==pygame.K_c: if rat.rat_health >= player.player_attack: animation(images.b2) health("rat") Display(Const.percent, Const.percent2 , rat.rat_health, player.player_health, images.b1, 1) elif player.player_attack > rat.rat_health > 0: health("rat") rat.rat_health = 0 Const.percent = 0 Display(Const.percent, Const.percent2 , rat.rat_health, player.player_health, images.b1, 0) if rat.rat_health <= 0: Const.percent = 0 Display(Const.percent, Const.percent2 , rat.rat_health, player.player_health, images.b1, 0) pygame.display.update() Const.Exp += rat.rat_ExpGain Const.percent = 294.0 message_to_screen("you win + "+str(rat.rat_ExpGain)+" EXP", Const.black, [200, 250], 25) pygame.display.update() time.sleep(0.5) rat.rat_health = float(random.randrange(100.0, 170.0, 10.0)) Const.Exit = 1 if Const.Exp >= Const.limit: if player.Level < 50: player.Level_show += 1.0 player.Level += 1 Const.Exp -= Const.limit Const.limit += Const.limit*0.1 Const.percent2 = 110.0 player.player_health = 100.0 * player.Level_show player.player_attack = 50.0 * player.Level_show Const.gameDisplay.fill(Const.black) message_to_screen("congratulations ", Const.white, [Const.width/2.25, Const.height/1.75], 25) message_to_screen("you are now level "+str(player.Level)+"!", Const.white, [Const.width/2.25, Const.height/2], 25) pygame.display.update() time.sleep(0.5) break if Const.Exit != 1: health("player") Display(Const.percent, Const.percent2 , rat.rat_health, player.player_health, images.b1, 1) if player.player_health == 0: Const.gameDisplay.fill(Const.blue) message_to_screen("you lose", Const.white, [Const.width/2.25, Const.height/1.75], 25) time.sleep(2) pygame.display.update() pygame.quit() quit()