1294 lines
62 KiB
Python
1294 lines
62 KiB
Python
from typing import Dict
|
|
import pygame, random, time, sys
|
|
from ffpyplayer.player import MediaPlayer
|
|
import numpy as np
|
|
from pygame import sndarray
|
|
|
|
pygame.init()
|
|
pygame.mixer.pre_init(buffer=1500)
|
|
pygame.mixer.init()
|
|
#all the variables
|
|
pw, ph = 43, 60
|
|
displaysize, playersize = (640,480), (pw,ph)
|
|
game_surface = pygame.Surface((640, 480))
|
|
map = pygame.Surface((640, 480))
|
|
level = 1
|
|
angle = 0
|
|
escapecounter = 0
|
|
dialognum = 1
|
|
battlemodestart = False
|
|
battlemode = False
|
|
defaultborders = True
|
|
BX, BY = 0, 0
|
|
playerX, playerY = 250, 250
|
|
oldX, oldY = playerX, playerY
|
|
playerXc, playerYc = 0, 0
|
|
camera_x = playerX - 640 // 2
|
|
randomblock = pygame.Surface((100, 100))
|
|
randomblock.fill((0, 0, 255))
|
|
playeractive = False
|
|
floweytalking = False
|
|
floweypissed = False
|
|
blocks = [
|
|
(0, 312, 75, 200),
|
|
(0, 355, 120, 200),
|
|
(0, 398, 165, 200),
|
|
(0, 0, 120, 88),
|
|
(480, 0, 165, 88),
|
|
(550, 0, 1000, 245),
|
|
(478, 360, 1000, 100),
|
|
(440, 400, 100, 100)
|
|
#(x, y, w, h)
|
|
#(420, 400, 100, 100)
|
|
]
|
|
selectormenu = False
|
|
GOBACKONLY = False
|
|
goingblack = 0
|
|
animation_delay = 10
|
|
startdelay = 0
|
|
player_sprites = [
|
|
pygame.transform.scale(pygame.image.load('players1.png'), playersize),
|
|
pygame.transform.scale(pygame.image.load('players2.png'), playersize),
|
|
pygame.transform.scale(pygame.image.load('players3.png'), playersize),
|
|
pygame.transform.scale(pygame.image.load('playerb1.png'), playersize),
|
|
pygame.transform.scale(pygame.image.load('playerb2.png'), playersize),
|
|
pygame.transform.scale(pygame.image.load('playerb3.png'), playersize),
|
|
pygame.transform.scale(pygame.image.load('playerr1.png'), playersize),
|
|
pygame.transform.scale(pygame.image.load('playerr2.png'), playersize),
|
|
pygame.transform.scale(pygame.image.load('playerl1.png'), playersize),
|
|
pygame.transform.scale(pygame.image.load('playerl2.png'), playersize),
|
|
]
|
|
player_soul = pygame.transform.scale(pygame.image.load('soul.png'), (16,16))
|
|
rect_surf = pygame.transform.scale(pygame.image.load('pellet.png'), (20,10))
|
|
monstersize = (108, 124)
|
|
Flowey02 = pygame.transform.scale(pygame.image.load("Flowey02.png"), monstersize)
|
|
Flowey01 = pygame.transform.scale(pygame.image.load("Flowey01.png"), monstersize)
|
|
current_music = None
|
|
dialogue = pygame.transform.scale(pygame.image.load('dialogue.png'), (580,180))
|
|
escapping = False
|
|
last_surf = None # keep last drawn frame
|
|
fullscreen = False
|
|
inmenu = False
|
|
x_start = None
|
|
fontsize = 32
|
|
char, color = None, "white"
|
|
dialogue_text = ""
|
|
letters_shown = 0 # start with nothing shown
|
|
floweygoofy = False
|
|
xkey, ykey = 1, 1
|
|
pelletx, pellety = 300, 30
|
|
pelletxr1 = 200
|
|
pelletxr2 = 250
|
|
pelletyr3 = 350
|
|
pelletyr4 = 400
|
|
font = pygame.font.Font("determination.ttf", fontsize).render(char, True, color)
|
|
#things that will be in save files
|
|
hp, maxhp = 20, 20
|
|
LV = 1
|
|
level = 1
|
|
playername = ""
|
|
current_run = "neutral"
|
|
#all the pygame setups and shit
|
|
clock = pygame.time.Clock()
|
|
screen = pygame.display.set_mode(displaysize)
|
|
player = player_sprites[0]
|
|
#player_rect = player.get_rect()
|
|
start_time = time.time() # wall clock start
|
|
iconpng = pygame.image.load('icon.png')
|
|
iconpng = pygame.transform.scale(iconpng, (32,32))
|
|
#intro
|
|
video = MediaPlayer("intro.mkv")
|
|
game_option = 1
|
|
blip_channel = pygame.mixer.Channel(5)
|
|
blip_variants = [
|
|
pygame.mixer.Sound("blip.ogg"),
|
|
pygame.mixer.Sound("scaryblip.wav")
|
|
]
|
|
def play_letter_blip(num):
|
|
sound = blip_variants[num]
|
|
blip_channel.play(sound)
|
|
|
|
|
|
def play_music(filename, loop=-1):
|
|
"""
|
|
Switch music without blocking.
|
|
The old track fades out in the background while the new one starts instantly.
|
|
"""
|
|
global current_music
|
|
|
|
if current_music == filename:
|
|
return # same track, do nothing
|
|
if filename == "stop":
|
|
pygame.mixer.music.stop()
|
|
current_music = None
|
|
if filename != "stop":
|
|
# Start new track immediately
|
|
pygame.mixer.music.load(filename)
|
|
pygame.mixer.music.play(loop)
|
|
current_music = filename
|
|
|
|
#defines borders
|
|
def def_borders(x,y, b1, b2, b3, b4):
|
|
if x < b1:
|
|
x = oldX
|
|
elif y > b2:
|
|
y = oldY
|
|
if x > b3:
|
|
x = oldX
|
|
elif y < b4:
|
|
y = oldY
|
|
return x, y
|
|
|
|
def check_collision(x1, y1, w1, h1, x2, y2, w2, h2):
|
|
"""
|
|
Returns True if the two rectangles overlap.
|
|
Works like pygame.Rect.colliderect.
|
|
|
|
x1, y1 = top-left of first rectangle
|
|
w1, h1 = width/height of first rectangle
|
|
x2, y2 = top-left of second rectangle
|
|
w2, h2 = width/height of second rectangle
|
|
"""
|
|
return (x1 < x2 + w2 and
|
|
x1 + w1 > x2 and
|
|
y1 < y2 + h2 and
|
|
y1 + h1 > y2)
|
|
|
|
def draw_text(text, color, pos, fontsize, space_width=10, letter_spacing=0, line_spacing=5, shake_amount=0, select=False, xkeyboard=1, ykeyboard=1, surface=game_surface):
|
|
"""
|
|
Draws text to game_surface with:
|
|
- '\n' converted to new lines
|
|
- custom space width
|
|
- adjustable spacing between letters
|
|
- shaking effect
|
|
- optional selection highlight based on xkeyboard/ykeyboard
|
|
"""
|
|
# convert color names to RGB
|
|
colors = {
|
|
"black" : (0,0,0),
|
|
"white": (255,255,255),
|
|
"red": (255,0,0),
|
|
"green": (0,255,0),
|
|
"blue": (0,0,255),
|
|
"yellow": (255,255,0)
|
|
}
|
|
color = colors.get(color, (255,255,255))
|
|
|
|
font = pygame.font.Font("determination.ttf", fontsize)
|
|
x_start, y = pos
|
|
|
|
row = 1
|
|
for line in text.split("\n"):
|
|
x = x_start
|
|
col = 1
|
|
for char in line:
|
|
if char == " ":
|
|
x += space_width
|
|
col += 1
|
|
continue
|
|
|
|
# if select mode is on, highlight the letter at (xkeyboard, ykeyboard)
|
|
if select and col == xkeyboard and row == ykeyboard:
|
|
char_color = colors.get("yellow")
|
|
else:
|
|
char_color = color
|
|
|
|
char_surf = font.render(char, True, char_color)
|
|
|
|
shake_x = random.uniform(-shake_amount, shake_amount)
|
|
shake_y = random.uniform(-shake_amount, shake_amount)
|
|
surface.blit(char_surf, (x + shake_x, y + shake_y))
|
|
x += char_surf.get_width() + letter_spacing
|
|
col += 1
|
|
y += font.get_linesize() + line_spacing
|
|
row += 1
|
|
|
|
dialogue_text = "* Howdy!\n* I'm FLOWEY.\n* FLOWEY the FLOWER!"
|
|
letters_shown = 0
|
|
last_tick = pygame.time.get_ticks()
|
|
delay_ms = 40 # reveal speed (ms per character)
|
|
|
|
def draw_dialogue_text(
|
|
text,
|
|
color,
|
|
pos,
|
|
fontsize,
|
|
letters_shown,
|
|
surface,
|
|
space_width=10,
|
|
letter_spacing=0,
|
|
line_spacing=5,
|
|
shake_amount=0,
|
|
debug=False,
|
|
num=0
|
|
):
|
|
"""
|
|
Draw up to `letters_shown` characters of `text` onto `surface`.
|
|
pos is relative to the top-left of `surface`.
|
|
Returns how many characters were drawn (useful for debugging).
|
|
"""
|
|
colors = {
|
|
"black" : (0,0,0),
|
|
"white": (255,255,255),
|
|
"red": (255,0,0),
|
|
"green": (0,255,0),
|
|
"blue": (0,0,255),
|
|
"yellow": (255,255,0)
|
|
}
|
|
fg = colors.get(color, color if isinstance(color, tuple) else (255,255,255))
|
|
|
|
font = pygame.font.Font("determination.ttf", fontsize)
|
|
x_start, y = pos
|
|
|
|
drawn = 0
|
|
# iterate line-by-line so '\n' is respected
|
|
for line in text.split("\n"):
|
|
x = x_start
|
|
for ch in line:
|
|
if drawn >= letters_shown:
|
|
return drawn
|
|
if ch == " ":
|
|
x += space_width
|
|
drawn += 1
|
|
continue
|
|
|
|
ch_surf = font.render(ch, True, fg)
|
|
shake_x = random.uniform(-shake_amount, shake_amount)
|
|
shake_y = random.uniform(-shake_amount, shake_amount)
|
|
dest_x = x + shake_x
|
|
dest_y = y + shake_y
|
|
|
|
surface.blit(ch_surf, (dest_x, dest_y))
|
|
if ch not in " \n" and not blip_channel.get_busy():
|
|
if len(dialogue_text) > letters_shown-1:
|
|
play_letter_blip(num)
|
|
if debug:
|
|
# draw a small rect showing the glyph area (visible overlay)
|
|
pygame.draw.rect(surface, (255,0,0), pygame.Rect(int(dest_x), int(dest_y),
|
|
ch_surf.get_width(), ch_surf.get_height()), 1)
|
|
|
|
x += ch_surf.get_width() + letter_spacing
|
|
drawn += 1
|
|
# move to next line. use font.get_linesize if available
|
|
try:
|
|
line_h = font.get_linesize()
|
|
except Exception:
|
|
line_h = fontsize
|
|
y += line_h + line_spacing
|
|
|
|
return drawn
|
|
|
|
|
|
|
|
|
|
#all the music
|
|
start_menu_mus = "mus_menu0.ogg"
|
|
|
|
pygame.display.set_caption("UNDERTALE", icontitle="Inspired by Toby Fox <3")
|
|
pygame.display.set_icon(iconpng)
|
|
paused = False
|
|
running = True
|
|
while running == True:
|
|
#print(pygame.time.get_ticks())
|
|
oldX, oldY = playerX, playerY
|
|
playerY += playerYc*3
|
|
playerX += playerXc*3
|
|
if not battlemode:
|
|
if playerYc > 0:
|
|
startdelay += 1
|
|
if startdelay > animation_delay:
|
|
if player == player_sprites[0]:
|
|
player = player_sprites[1]
|
|
elif player == player_sprites[1]:
|
|
player = player_sprites[2]
|
|
else:
|
|
player = player_sprites[0]
|
|
startdelay = 0
|
|
elif playerYc < 0:
|
|
startdelay += 1
|
|
if startdelay > animation_delay:
|
|
if player == player_sprites[3]:
|
|
player = player_sprites[4]
|
|
elif player == player_sprites[4]:
|
|
player = player_sprites[5]
|
|
else:
|
|
player = player_sprites[3]
|
|
startdelay = 0
|
|
elif playerXc > 0:
|
|
startdelay += 1
|
|
if startdelay > animation_delay:
|
|
if player == player_sprites[6]:
|
|
player = player_sprites[7]
|
|
else:
|
|
player = player_sprites[6]
|
|
startdelay = 0
|
|
elif playerXc < 0:
|
|
startdelay += 1
|
|
if startdelay > animation_delay:
|
|
if player == player_sprites[8]:
|
|
player = player_sprites[9]
|
|
else:
|
|
player = player_sprites[8]
|
|
startdelay = 0
|
|
window_size = screen.get_size()
|
|
scale = min(window_size[0] / (640,480)[0], window_size[1] / (640,480)[1])
|
|
new_size = (int((640,480)[0] * scale), int((640,480)[1] * scale))
|
|
scaled_surface = pygame.transform.scale(game_surface, new_size)
|
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
|
running = False
|
|
if event.type == pygame.KEYDOWN:
|
|
if event.key == pygame.K_z or event.key == pygame.K_RETURN:
|
|
if level == 1 or level == 1.5:
|
|
video.close_player()
|
|
level = 2
|
|
elif level == 2:
|
|
if game_option == 1:
|
|
level = 3
|
|
else:
|
|
level = 2.5
|
|
game_option = 1
|
|
elif level == 2.5:
|
|
if game_option == 1:
|
|
level = 2
|
|
elif level == 3:
|
|
if len(playername) < 6:
|
|
if ykey == 1:
|
|
if xkey == 1:
|
|
playername += "A"
|
|
elif xkey == 3:
|
|
playername += "B"
|
|
elif xkey == 5:
|
|
playername += "C"
|
|
elif xkey == 7:
|
|
playername += "D"
|
|
elif xkey == 9:
|
|
playername += "E"
|
|
elif xkey == 11:
|
|
playername += "F"
|
|
elif xkey == 13:
|
|
playername += "G"
|
|
elif ykey == 2:
|
|
if xkey == 1:
|
|
playername += "H"
|
|
elif xkey == 3:
|
|
playername += "I"
|
|
elif xkey == 5:
|
|
playername += "J"
|
|
elif xkey == 7:
|
|
playername += "K"
|
|
elif xkey == 9:
|
|
playername += "L"
|
|
elif xkey == 11:
|
|
playername += "M"
|
|
elif xkey == 13:
|
|
playername += "N"
|
|
elif ykey == 3:
|
|
if xkey == 1:
|
|
playername += "O"
|
|
elif xkey == 3:
|
|
playername += "P"
|
|
elif xkey == 5:
|
|
playername += "Q"
|
|
elif xkey == 7:
|
|
playername += "R"
|
|
elif xkey == 9:
|
|
playername += "S"
|
|
elif xkey == 11:
|
|
playername += "T"
|
|
elif xkey == 13:
|
|
playername += "U"
|
|
elif ykey == 4:
|
|
if xkey == 1:
|
|
playername += "V"
|
|
elif xkey == 3:
|
|
playername += "W"
|
|
elif xkey == 5:
|
|
playername += "X"
|
|
elif xkey == 7:
|
|
playername += "Y"
|
|
elif xkey == 9:
|
|
playername += "Z"
|
|
if ykey == 5:
|
|
if xkey == 1:
|
|
playername += "a"
|
|
elif xkey == 3:
|
|
playername += "b"
|
|
elif xkey == 5:
|
|
playername += "c"
|
|
elif xkey == 7:
|
|
playername += "d"
|
|
elif xkey == 9:
|
|
playername += "e"
|
|
elif xkey == 11:
|
|
playername += "f"
|
|
elif xkey == 13:
|
|
playername += "g"
|
|
elif ykey == 6:
|
|
if xkey == 1:
|
|
playername += "h"
|
|
elif xkey == 3:
|
|
playername += "i"
|
|
elif xkey == 5:
|
|
playername += "j"
|
|
elif xkey == 7:
|
|
playername += "k"
|
|
elif xkey == 9:
|
|
playername += "l"
|
|
elif xkey == 11:
|
|
playername += "m"
|
|
elif xkey == 13:
|
|
playername += "n"
|
|
elif ykey == 7:
|
|
if xkey == 1:
|
|
playername += "o"
|
|
elif xkey == 3:
|
|
playername += "p"
|
|
elif xkey == 5:
|
|
playername += "q"
|
|
elif xkey == 7:
|
|
playername += "r"
|
|
elif xkey == 9:
|
|
playername += "s"
|
|
elif xkey == 11:
|
|
playername += "t"
|
|
elif xkey == 13:
|
|
playername += "u"
|
|
elif ykey == 8:
|
|
if xkey == 1:
|
|
playername += "v"
|
|
elif xkey == 3:
|
|
playername += "w"
|
|
elif xkey == 5:
|
|
playername += "x"
|
|
elif xkey == 7:
|
|
playername += "y"
|
|
elif xkey == 9:
|
|
playername += "z"
|
|
if ykey == 9:
|
|
if xkey == 5:
|
|
if playername != "":
|
|
playername = playername[:-1]
|
|
elif xkey == 9:
|
|
if playername != "":
|
|
level = 3.5
|
|
xkey, ykey = 1, 1
|
|
elif level == 3.5:
|
|
if GOBACKONLY:
|
|
GOBACKONLY, level = False, 3
|
|
else:
|
|
if xkey == 1:
|
|
level = 3
|
|
xkey, ykey = 9, 9
|
|
elif xkey == 2:
|
|
level = 3.75
|
|
elif level == 5:
|
|
if floweytalking:
|
|
if len(dialogue_text) > letters_shown:
|
|
letters_shown = len(dialogue_text)
|
|
else:
|
|
if dialognum < 8:
|
|
if not battlemode:
|
|
dialogue = pygame.transform.scale(pygame.image.load('dialogue.png'), (580,180))
|
|
letters_shown = 0
|
|
dialognum += 1
|
|
elif level == 6:
|
|
if floweytalking:
|
|
if len(dialogue_text) > letters_shown:
|
|
letters_shown = len(dialogue_text)
|
|
else:
|
|
if dialognum < 20:
|
|
if not battlemode:
|
|
dialogue = pygame.transform.scale(pygame.image.load('dialogue.png'), (580,180))
|
|
if dialognum == 7 or dialognum == 11 or dialognum == 14:
|
|
pass
|
|
else:
|
|
if dialognum != 15:
|
|
letters_shown = 0
|
|
dialognum += 1
|
|
if event.key == pygame.K_F4:
|
|
if not fullscreen:
|
|
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
|
|
fullscreen = True
|
|
else:
|
|
screen = pygame.display.set_mode(displaysize)
|
|
fullscreen = False
|
|
|
|
if event.key == pygame.K_ESCAPE:
|
|
escapping = True
|
|
|
|
if event.key == pygame.K_SPACE:
|
|
print("playerX="+str(playerX)+", playerY="+str(playerY)+"\nmouse pos: "+str(pygame.mouse.get_pos()))
|
|
|
|
if event.key == pygame.K_LEFT or event.key == pygame.K_a:
|
|
#if randomblock not in player.colliderect():
|
|
if not inmenu:
|
|
if playeractive:
|
|
playerXc = -1
|
|
startdelay = animation_delay
|
|
else:
|
|
if selectormenu:
|
|
if level == 3:
|
|
if (xkey, ykey) != (1, 1):
|
|
xkey -= 1
|
|
if xkey < 1 and ykey != 1 and ykey != 9:
|
|
xkey = 13
|
|
ykey += -1
|
|
if ykey < 8.5:
|
|
if xkey % 2 == 0:
|
|
xkey -= 1
|
|
else:
|
|
if xkey == 8:
|
|
xkey = 5
|
|
elif xkey == 4:
|
|
xkey = 1
|
|
elif xkey == 0:
|
|
xkey = 9
|
|
elif level == 3.5:
|
|
if not GOBACKONLY:
|
|
if xkey != 1:
|
|
xkey = 1
|
|
else:
|
|
xkey = 2
|
|
|
|
else:
|
|
xkey -= 1
|
|
print(str(xkey))
|
|
|
|
if event.key == pygame.K_RIGHT or event.key == pygame.K_d:
|
|
if not inmenu:
|
|
if playeractive:
|
|
playerXc = 1
|
|
startdelay = animation_delay
|
|
else:
|
|
if selectormenu:
|
|
if level == 3:
|
|
if ykey < 8.5:
|
|
xkey += 1
|
|
if xkey % 2 == 0:
|
|
xkey += 1
|
|
else:
|
|
if xkey == 1:
|
|
xkey = 5
|
|
elif xkey == 5:
|
|
xkey = 9
|
|
elif xkey == 9:
|
|
xkey = 1
|
|
elif level == 3.5:
|
|
if not GOBACKONLY:
|
|
if xkey != 2:
|
|
xkey = 2
|
|
else:
|
|
xkey = 1
|
|
|
|
print(str(xkey))
|
|
|
|
if event.key == pygame.K_UP or event.key == pygame.K_w:
|
|
#print(game_option)
|
|
if not inmenu:
|
|
if playeractive:
|
|
playerYc = -1
|
|
startdelay = animation_delay
|
|
else:
|
|
if selectormenu:
|
|
if ykey > 1:
|
|
ykey -= 1
|
|
else:
|
|
if game_option > 1:
|
|
game_option -= 1
|
|
print(str(ykey))
|
|
if event.key == pygame.K_DOWN or event.key == pygame.K_s:
|
|
#print(game_option)
|
|
if not inmenu:
|
|
if playeractive:
|
|
playerYc = 1
|
|
startdelay = animation_delay
|
|
else:
|
|
if selectormenu:
|
|
ykey +=1
|
|
if ykey > 8.5 and ykey != 10:
|
|
if xkey == 2 or xkey == 3 or xkey == 4:
|
|
xkey = 1
|
|
elif xkey == 6 or xkey == 7 or xkey == 8 or xkey == 9:
|
|
xkey = 5
|
|
else:
|
|
if xkey != 1 and xkey != 5 and xkey != 9:
|
|
xkey = 9
|
|
else:
|
|
game_option += 1
|
|
print(str(ykey))
|
|
|
|
|
|
print("posx="+str(xkey)+" posy="+str(ykey))
|
|
if event.type == pygame.KEYUP:
|
|
|
|
if event.key == pygame.K_ESCAPE:
|
|
escapecounter = 0
|
|
escapping = False
|
|
|
|
if event.key == pygame.K_LEFT or event.key == pygame.K_a:
|
|
if not battlemode:
|
|
player = player_sprites[8]
|
|
playerXc = 0
|
|
|
|
if event.key == pygame.K_RIGHT or event.key == pygame.K_d:
|
|
if not battlemode:
|
|
player = player_sprites[6]
|
|
playerXc = 0
|
|
|
|
if event.key == pygame.K_UP or event.key == pygame.K_w:
|
|
if not battlemode:
|
|
player = player_sprites[3]
|
|
playerYc = 0
|
|
|
|
if event.key == pygame.K_DOWN or event.key == pygame.K_s:
|
|
if not battlemode:
|
|
player = player_sprites[0]
|
|
playerYc = 0
|
|
|
|
if defaultborders:
|
|
playerX, playerY = def_borders(playerX, playerY, 0, 420, 600, 0)
|
|
for bx, by, bw, bh in blocks:
|
|
if check_collision(playerX, playerY, pw, ph, bx, by, bw, bh):
|
|
playerX, playerY = oldX, oldY
|
|
break # stop checking after first collision
|
|
game_surface.fill((0, 0, 0))
|
|
if level == 1:
|
|
inmenu = True
|
|
play_music("stop")
|
|
frame, val = video.get_frame() # get next frame (or None)
|
|
if frame is not None:
|
|
img, t = frame
|
|
last_surf = pygame.image.frombuffer(img.to_bytearray()[0], img.get_size(), 'RGB')
|
|
# always draw last frame, even if no new frame
|
|
clock.tick(30)
|
|
if last_surf:
|
|
game_surface.blit(last_surf, (0, 0))
|
|
if val == 'eof':
|
|
level = 1.5
|
|
elif level == 1.5:
|
|
game_surface.blit(last_surf, (0, 0))
|
|
elif level == 2:
|
|
inmenu = True
|
|
play_music(start_menu_mus)
|
|
if game_option == 1:
|
|
game_surface.blit(pygame.transform.scale(pygame.image.load("instructions.png"), (640, 480)), (0,0))
|
|
elif game_option == 2:
|
|
game_surface.blit(pygame.transform.scale(pygame.image.load("instructions2.png"), (640, 480)), (0,0))
|
|
else:
|
|
game_surface.blit(pygame.transform.scale(pygame.image.load("instructions2.png"), (640, 480)), (0,0))
|
|
game_option = 2
|
|
elif level == 2.5:
|
|
play_music(start_menu_mus)
|
|
if game_option == 1:
|
|
game_surface.blit(pygame.transform.scale(pygame.image.load("settings1.png"), (640, 480)), (0,0))
|
|
elif game_option == 2:
|
|
game_surface.blit(pygame.transform.scale(pygame.image.load("settings2.png"), (640, 480)), (0,0))
|
|
else:
|
|
game_surface.blit(pygame.transform.scale(pygame.image.load("settings2.png"), (640, 480)), (0,0))
|
|
game_option = 2
|
|
elif level == 3:
|
|
play_music(start_menu_mus)
|
|
selectormenu = True
|
|
draw_text("Name the fallen human.","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (275, 111), 32, letter_spacing=-0.6)
|
|
if playername.lower() == "gaster":
|
|
selectormenu = False
|
|
inmenu = False
|
|
level = 1
|
|
video = MediaPlayer("intro.mkv")
|
|
playername = ""
|
|
if xkey > 13 and ykey < 9:
|
|
xkey = 1
|
|
ykey += 1
|
|
if ykey < 5:
|
|
if ykey == 4:
|
|
if xkey > 9:
|
|
xkey = 1
|
|
ykey += 1
|
|
draw_text("A B C D E F G\nH I J K L M N\nO P Q R S T U\nV W X Y Z", "white", (120, 150), 34, space_width=47, letter_spacing=0, line_spacing=-7, shake_amount=0.135, select=True, xkeyboard=xkey, ykeyboard=ykey)
|
|
draw_text("a b c d e f g\nh i j k l m n\no p q r s t u\nv w x y z", "white", (120, 276), 34, space_width=47, letter_spacing=0, line_spacing=-7, shake_amount=0.135)
|
|
draw_text("Quit", "white", (120, 405), 34, letter_spacing=-0.6)
|
|
draw_text("Backspace", "white", (253, 405), 34, letter_spacing=-0.6)
|
|
draw_text("Done", "white", (465, 405), 34, letter_spacing=-0.6)
|
|
elif 4 < ykey < 9:
|
|
if ykey == 8:
|
|
if xkey > 9:
|
|
xkey = 9
|
|
draw_text("A B C D E F G\nH I J K L M N\nO P Q R S T U\nV W X Y Z", "white", (120, 150), 34, space_width=47, letter_spacing=0, line_spacing=-7, shake_amount=0.135)
|
|
draw_text("a b c d e f g\nh i j k l m n\no p q r s t u\nv w x y z", "white", (120, 276), 34, space_width=47, letter_spacing=0, line_spacing=-7, shake_amount=0.135, select=True, xkeyboard=xkey, ykeyboard=ykey-4)
|
|
draw_text("Quit", "white", (120, 405), 34, letter_spacing=-0.6)
|
|
draw_text("Backspace", "white", (253, 405), 34, letter_spacing=-0.6)
|
|
draw_text("Done", "white", (465, 405), 34, letter_spacing=-0.6)
|
|
elif ykey > 8:
|
|
draw_text("A B C D E F G\nH I J K L M N\nO P Q R S T U\nV W X Y Z", "white", (120, 150), 34, space_width=47, letter_spacing=0, line_spacing=-7, shake_amount=0.135)
|
|
draw_text("a b c d e f g\nh i j k l m n\no p q r s t u\nv w x y z", "white", (120, 276), 34, space_width=47, letter_spacing=0, line_spacing=-7, shake_amount=0.135)
|
|
if ykey > 9:
|
|
ykey = 1
|
|
draw_text("Quit", "white", (120, 405), 34, letter_spacing=-0.6)
|
|
draw_text("Backspace", "white", (253, 405), 34, letter_spacing=-0.6)
|
|
draw_text("Done", "white", (465, 405), 34, letter_spacing=-0.6)
|
|
if xkey == 1:
|
|
draw_text("Quit", "yellow", (120, 405), 34, letter_spacing=-0.6)
|
|
draw_text("Backspace", "white", (253, 405), 34, letter_spacing=-0.6)
|
|
draw_text("Done", "white", (465, 405), 34, letter_spacing=-0.6)
|
|
elif xkey == 5:
|
|
draw_text("Quit", "white", (120, 405), 34, letter_spacing=-0.6)
|
|
draw_text("Backspace", "yellow", (253, 405), 34, letter_spacing=-0.6)
|
|
draw_text("Done", "white", (465, 405), 34, letter_spacing=-0.6)
|
|
elif xkey == 9:
|
|
draw_text("Quit", "white", (120, 405), 34, letter_spacing=-0.6)
|
|
draw_text("Backspace", "white", (253, 405), 34, letter_spacing=-0.6)
|
|
draw_text("Done", "yellow", (465, 405), 34, letter_spacing=-0.6)
|
|
elif xkey < 1:
|
|
xkey = 9
|
|
else:
|
|
xkey = 1
|
|
else:
|
|
ykey = 9
|
|
increasinglybig = 32
|
|
elif level == 3.5:
|
|
play_music(start_menu_mus)
|
|
if GOBACKONLY:
|
|
draw_text("Go back", "yellow", (120, 405), 34, letter_spacing=-0.6)
|
|
if playername.lower() == "sans":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
GOBACKONLY = True
|
|
draw_text("nope.","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "alphys":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
GOBACKONLY = True
|
|
draw_text("D-don't do that.","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "asgore":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
GOBACKONLY = True
|
|
draw_text("You cannot.","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "asriel":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
GOBACKONLY = True
|
|
draw_text("...","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "flowey":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
GOBACKONLY = True
|
|
draw_text("I already CHOSE\nthat name.","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "toriel":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
GOBACKONLY = True
|
|
draw_text("I think you should\nthink of your own\nname, my child.","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "undyne":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
GOBACKONLY = True
|
|
draw_text("Get your OWN name!","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
else:
|
|
if xkey == 1:
|
|
draw_text("No", "yellow", (120, 405), 34, letter_spacing=-0.6)
|
|
draw_text("Yes", "white", (465, 405), 34, letter_spacing=-0.6)
|
|
elif xkey == 2:
|
|
draw_text("No", "white", (120, 405), 34, letter_spacing=-0.6)
|
|
draw_text("Yes", "yellow", (465, 405), 34, letter_spacing=-0.6)
|
|
if playername.lower() == "frisk":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("WARNING: This name will\nmake your life hell.\nProceed anyway?","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
elif playername.lower() == "murder" or playername.lower() == "mercy ":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("That's a little on-\nthe-nose, isn't it...?" ,"white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "aaaaaa":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("Not very creative...?","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "aaron":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("Is this name correct? ;)","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "alphy":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("Uh.... OK?","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "catty":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("Bratty! Bratty!\nThat's MY name!","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "bratty":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("Like, OK I guess.","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "bpants":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("You are really scraping the\nbottom of the barrel.","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "chara":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("the true name.","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "gerson":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("Wah ha ha! Why not?","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "jerry":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("Jerry.","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "metta" or playername.lower() == "mett" or playername.lower() == "mtt":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("OOOOH!!! ARE YOU\nPROMOTING MY BRAND?","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "napsta" or playername.lower() == "blooky":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("........\n(They are powerless to\nstop you.)","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "papyru":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("I'LL ALLOW IT!!!!","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "shyren":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("...?","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "temmie":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("hOI!","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
elif playername.lower() == "woshua":
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("Clean name.","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
else:
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text("Is this name correct?","white", (170, 60), 32, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
|
|
|
|
|
|
#game_surface.blit(pygame.font.Font("determination.ttf", 32).render("Name the fallen human.", True, (255, 255, 255)), (181, 70))
|
|
elif level == 3.75:
|
|
play_music("mus_cymbal.ogg")
|
|
game_surface.fill((goingblack, goingblack, goingblack)) # black borders
|
|
if increasinglybig < 107:
|
|
increasinglybig += 0.28
|
|
draw_text(playername, "white", (float(275-increasinglybig*1.5/2+random.uniform(-0.8, 0.8)), float(111+increasinglybig*1.2+random.uniform(-1.5, 1.5))), int(increasinglybig), letter_spacing=-0.6)
|
|
if goingblack < 255:
|
|
goingblack += 0.65
|
|
else:
|
|
inmenu, selectormenu, playeractive = False, False, True
|
|
map = pygame.Surface((1400, 480))
|
|
map.blit(pygame.transform.scale(pygame.image.load("startingroom.png"), (1400, 480)), (0,0))
|
|
defaultborders = False
|
|
level = 4
|
|
playerX, playerY = 285, 205
|
|
player = player_sprites[0]
|
|
play_music("stop")
|
|
elif level == 4:
|
|
camera_x = playerX - 640 // 2
|
|
if camera_x < 0:
|
|
camera_x = 0
|
|
elif camera_x > 1400 - 640:
|
|
camera_x = 1400 - 640
|
|
# draw the visible slice of the map
|
|
game_surface.blit(map, (0, 0), (camera_x, 0, 640, 480))
|
|
# draw the player at the correct position
|
|
player_screen_x = playerX - camera_x
|
|
game_surface.blit(player, (player_screen_x, playerY))
|
|
if playerX > 1205 and playerY < 250:
|
|
blocks.clear()
|
|
player = player_sprites[3]
|
|
map = pygame.Surface((640, 480))
|
|
customtimer = 0
|
|
print("Before reset:", playerX, playerY)
|
|
playerX, playerY = 300, 405
|
|
print("After reset:", playerX, playerY)
|
|
level = 5
|
|
else:
|
|
playerX, playerY = def_borders(playerX, playerY,40,382,1315,45)
|
|
elif level == 5:
|
|
playerX, playerY = def_borders(playerX, playerY, 231, 420, 360, 0)
|
|
|
|
# draw the visible slice of the map
|
|
#print(customtimer)
|
|
if floweytalking:
|
|
playeractive = False
|
|
play_music("mus_flowey.ogg")
|
|
customtimer += 1
|
|
if 20 > customtimer:
|
|
map.blit(pygame.transform.scale(pygame.image.load("floweyroom2.png"), (640, 480)), (0,0))
|
|
dialogue.blit(Flowey02, (30,30))
|
|
elif 20 < customtimer < 40:
|
|
map.blit(pygame.transform.scale(pygame.image.load("floweyroom.png"), (640, 480)), (0,0))
|
|
dialogue.blit(Flowey01, (30,30))
|
|
elif customtimer > 40:
|
|
customtimer = 0
|
|
map.blit(pygame.transform.scale(pygame.image.load("floweyroom2.png"), (640, 480)), (0,0))
|
|
dialogue.blit(Flowey02, (30,30))
|
|
else:
|
|
map.blit(pygame.transform.scale(pygame.image.load("floweyroom.png"), (640, 480)), (0,0))
|
|
dialogue.blit(Flowey01, (30,30))
|
|
|
|
|
|
letters_shown += 1
|
|
# safely play blip
|
|
index = min(int(letters_shown)-1, len(dialogue_text)-1) # cap at last character
|
|
#if int(letters_shown) > 0 and dialogue_text[index] not in " \n":
|
|
# if letters_shown+1 < len(dialogue_text):
|
|
# generate_blip(frequency=random.randint(600,605), duration_ms=60, volume=0.4).play()
|
|
|
|
print(letters_shown)
|
|
if dialognum < 7:
|
|
game_surface.blit(map, (0, 0))
|
|
game_surface.blit(dialogue, (25,0))
|
|
draw_dialogue_text(dialogue_text, "white", (150, 30), 36, letters_shown, dialogue,
|
|
space_width=10, letter_spacing=-1, line_spacing=2, shake_amount=0, debug=False, num=0)
|
|
# draw the player at the correct position
|
|
game_surface.blit(player_sprites[3], (playerX, playerY))
|
|
if dialognum == 1:
|
|
dialogue_text = "* Howdy!\n* I'm FLOWEY.\n* FLOWEY the FLOWER!"
|
|
#draw_dialogue_text(dialogue_text, "white", (40, 380), 24, letters_shown, surface=dialogue)
|
|
elif dialognum == 2:
|
|
dialogue_text = "* Hmmm..."
|
|
elif dialognum == 3:
|
|
dialogue_text = "* You're new to the\nUNDERGROUND, aren'tcha?"
|
|
elif dialognum == 4:
|
|
dialogue_text = "* Golly, you must be\nso confused."
|
|
elif dialognum == 5:
|
|
dialogue_text = "* Someone ought to teach\nyou how things work\naround here!"
|
|
elif dialognum == 6:
|
|
dialogue_text = "* Ready? Here we go!"
|
|
else:
|
|
battlemodestart = True
|
|
level = 6
|
|
customtimer = 0
|
|
dialognum = 1
|
|
pygame.mixer.Sound("encounter.ogg").play()
|
|
|
|
|
|
elif not floweytalking:
|
|
map.blit(pygame.transform.scale(pygame.image.load("floweyroom.png"), (640, 480)), (0,0))
|
|
if playerY < 301:
|
|
dialognum = 1
|
|
floweytalking = True
|
|
playeractive = False
|
|
playerYc, playerXc = 0, 0
|
|
elif playerY > 408:
|
|
defaultborders = False
|
|
level = 4
|
|
playerX, playerY = 1257, 260
|
|
camera_x = playerX - 640 // 2
|
|
if camera_x < 0:
|
|
camera_x = 0
|
|
elif camera_x > 1400 - 640:
|
|
camera_x = 1400 - 640
|
|
blocks = [
|
|
(0, 312, 75, 200),
|
|
(0, 355, 120, 200),
|
|
(0, 398, 165, 200),
|
|
(0, 0, 120, 88),
|
|
(480, 0, 165, 88),
|
|
(550, 0, 1000, 245),
|
|
(478, 360, 1000, 100),
|
|
(440, 400, 100, 100)
|
|
#(x, y, w, h)
|
|
#(420, 400, 100, 100)
|
|
]
|
|
player = player_sprites[0]
|
|
inmenu, selectormenu, playeractive = False, False, True
|
|
map = pygame.Surface((1400, 480))
|
|
map.blit(pygame.transform.scale(pygame.image.load("startingroom.png"), (1400, 480)), (0,0))
|
|
game_surface.blit(map, (0, 0))
|
|
# draw the player at the correct position
|
|
game_surface.blit(player, (playerX, playerY))
|
|
elif level == 6:
|
|
#left,down,right,up
|
|
if battlemode:
|
|
playerX,playerY = def_borders(playerX,playerY,230,370,370,230)
|
|
pygame.draw.rect(game_surface, (0, 0, 0), pygame.Rect(225, 225, 166, 166))
|
|
pygame.draw.rect(game_surface, (255, 255, 255), pygame.Rect(225, 225, 166, 166), 3)
|
|
draw_text("LV "+str(LV), "white", (200, 400), 34, space_width=4.5, letter_spacing=-0.6)
|
|
draw_text(str(hp)+"/"+str(maxhp), "white", (345, 400), 34, space_width=4.5, letter_spacing=-0.6)
|
|
|
|
if floweytalking:
|
|
letters_shown += 1
|
|
# safely play blip
|
|
index = min(int(letters_shown)-1, len(dialogue_text)-1) # cap at last character
|
|
if dialognum == 1:
|
|
pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 100))
|
|
dialogue_text = "See that heart?\nThat is your SOUL,\nthe very culmination\nof your being!"
|
|
elif dialognum == 2:
|
|
pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 100))
|
|
dialogue_text = "Your SOUL starts off\nweak, but can grow\nstrong if you gain\na lot of LV."
|
|
elif dialognum == 3:
|
|
pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 72))
|
|
dialogue_text = "What's LV stand for?\nWhy, LOVE, of\ncourse!"
|
|
elif dialognum == 4:
|
|
pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 48))
|
|
dialogue_text = "You want some LOVE,\ndon't you?"
|
|
elif dialognum == 5:
|
|
pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 48))
|
|
dialogue_text = "Don't worry, I'll\nshare some with you!"
|
|
elif dialognum == 6:
|
|
floweygoofy = True
|
|
dialogue_text = ""
|
|
game_surface.blit(pygame.transform.scale(pygame.image.load('Flowey_goofy.png'), monstersize), (255, 85))
|
|
#draw_dialogue_text(dialogue_text, "white", (40, 380), 24, letters_shown, surface=dialogue)
|
|
elif dialognum == 8:
|
|
pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 72))
|
|
dialogue_text = "Down here, LOVE\nis shared\nthrough..."
|
|
elif dialognum == 9:
|
|
angle += 8
|
|
#game_surface.blit(pygame.transform.rotate(pygame.Surface((1, 2), pygame.SRCALPHA).fill((255, 255, 255)) or pygame.Surface((1, 2), pygame.SRCALPHA), angle), (250, 40))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletxr1, pellety+50))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletxr2, pellety+25))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletx, pellety))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletyr3, pellety+25))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletyr4, pellety+50))
|
|
#game_surface.blit(pygame.transform.rotate(pygame.Surface((10, 20)).fill((255, 255, 255)), angle), (250, 40))
|
|
#game_surface.blit(pygame.transform.rotate(pygame.Surface((10, 20)).fill((255, 255, 255)), angle), (275, 30))
|
|
#game_surface.blit(pygame.transform.rotate(pygame.Surface((10, 20)).fill((255, 255, 255)), angle), (300, 20))
|
|
#game_surface.blit(pygame.transform.rotate(pygame.Surface((10, 20)).fill((255, 255, 255)), angle), (325, 30))
|
|
#game_surface.blit(pygame.transform.rotate(pygame.Surface((10, 20)).fill((255, 255, 255)), angle), (350, 40))
|
|
Flowey02 = pygame.transform.scale(pygame.image.load("Flowey02m.png"), monstersize)
|
|
Flowey01 = pygame.transform.scale(pygame.image.load("Flowey01m.png"), monstersize)
|
|
pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 72))
|
|
dialogue_text = "Little white...\n\"friendliness\npellets.\""
|
|
elif dialognum == 10:
|
|
angle += 8
|
|
Flowey02 = pygame.transform.scale(pygame.image.load("Flowey02.png"), monstersize)
|
|
Flowey01 = pygame.transform.scale(pygame.image.load("Flowey01.png"), monstersize)
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletxr1, pellety+50))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletxr2, pellety+25))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletx, pellety))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletyr3, pellety+25))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletyr4, pellety+50))
|
|
pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 24))
|
|
dialogue_text = "Are you ready?"
|
|
elif dialognum == 11:
|
|
angle += 8
|
|
#rect_surf = pygame.Surface((10, 20), pygame.SRCALPHA)
|
|
#rect_surf.fill((255, 255, 255))
|
|
pellety += 3
|
|
pelletxr1 += 0.8
|
|
pelletxr2 += 0.5
|
|
pelletyr3 -= 0.5
|
|
pelletyr4 -= 0.8
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletxr1, pellety+50))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletxr2, pellety+25))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletx, pellety))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletyr3, pellety+25))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletyr4, pellety+50))
|
|
pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 72))
|
|
dialogue_text = "Move around!\nGet as many as\nyou can!"
|
|
floweypellets = [
|
|
(pelletxr1, pellety+50, 20, 10),
|
|
(pelletxr2, pellety+25, 20, 10),
|
|
(pelletx, pellety, 20, 10),
|
|
(pelletyr3, pellety+25, 20, 10),
|
|
(pelletyr4, pellety+50, 20, 10)
|
|
]
|
|
if pellety > 800:
|
|
dialognum = 12
|
|
letters_shown = 0
|
|
elif dialognum == 12:
|
|
pelletx, pellety = 300, 30
|
|
pelletxr1 = 200
|
|
pelletxr2 = 250
|
|
pelletyr3 = 350
|
|
pelletyr4 = 400
|
|
Flowey01, Flowey02 = pygame.transform.scale(pygame.image.load("Floweywinky.png"), monstersize), pygame.transform.scale(pygame.image.load("Floweywinky.png"), monstersize)
|
|
pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 48))
|
|
dialogue_text = "Hey buddy,\nyou missed them."
|
|
elif dialognum == 13:
|
|
pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 48))
|
|
dialogue_text = "Let's try again,\nokay?"
|
|
elif dialognum == 14:
|
|
Flowey01, Flowey02 = pygame.transform.scale(pygame.image.load("Flowey01.png"), monstersize), pygame.transform.scale(pygame.image.load("Flowey01.png"), monstersize)
|
|
angle += 8
|
|
#rect_surf = pygame.Surface((10, 20), pygame.SRCALPHA)
|
|
#rect_surf.fill((255, 255, 255))
|
|
pellety += 3
|
|
pelletxr1 += 1
|
|
pelletxr2 += 0.7
|
|
pelletyr3 -= 0.7
|
|
pelletyr4 -= 1
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletxr1, pellety+50))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletxr2, pellety+25))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletx, pellety))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletyr3, pellety+25))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletyr4, pellety+50))
|
|
#pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 72))
|
|
dialogue_text = ""
|
|
if 800 > pellety > 480:
|
|
Flowey01, Flowey02 = pygame.transform.scale(pygame.image.load("Floweypissed01.png"), monstersize), pygame.transform.scale(pygame.image.load("Floweypissed01.png"), monstersize)
|
|
if pellety > 800:
|
|
Flowey01, Flowey02 = pygame.transform.scale(pygame.image.load("Floweypissed01.png"), monstersize), pygame.transform.scale(pygame.image.load("Floweypissed01.png"), monstersize)
|
|
dialognum = 15
|
|
letters_shown = 0
|
|
elif dialognum == 15:
|
|
pelletx, pellety = 300, 30
|
|
pelletxr1 = 200
|
|
pelletxr2 = 250
|
|
pelletyr3 = 350
|
|
pelletyr4 = 400
|
|
Flowey01, Flowey02 = pygame.transform.scale(pygame.image.load("Floweypissed01.png"), monstersize), pygame.transform.scale(pygame.image.load("Floweypissed01.png"), monstersize)
|
|
pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 100))
|
|
dialogue_text = "Is this a joke?\nAre you braindead?\nRUN. INTO. THE.\nBULLETS!!!"
|
|
elif dialognum == 16:
|
|
Flowey01, Flowey02 = pygame.transform.scale(pygame.image.load("Flowey01.png"), monstersize), pygame.transform.scale(pygame.image.load("Flowey01.png"), monstersize)
|
|
angle += 8
|
|
#rect_surf = pygame.Surface((10, 20), pygame.SRCALPHA)
|
|
#rect_surf.fill((255, 255, 255))
|
|
pellety += 3
|
|
pelletxr1 += 1.1
|
|
pelletxr2 += 0.75
|
|
pelletyr3 -= 0.75
|
|
pelletyr4 -= 1.1
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletxr1, pellety+50))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletxr2, pellety+25))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletx, pellety))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletyr3, pellety+25))
|
|
game_surface.blit(pygame.transform.rotate(rect_surf, angle), (pelletyr4, pellety+50))
|
|
if pellety < 480:
|
|
pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 100))
|
|
dialogue_text = "Is this a joke?\nAre you braindead?\nRUN. INTO. THE.\nfriendliness pellets"
|
|
elif 800 > pellety > 480:
|
|
dialogue_text = ""
|
|
if 800 > pellety:
|
|
Flowey01, Flowey02 = pygame.transform.scale(pygame.image.load("Floweypissed02.png"), monstersize), pygame.transform.scale(pygame.image.load("Floweypissed03.png"), monstersize)
|
|
dialognum = 17
|
|
floweypissed = True
|
|
letters_shown = 0
|
|
play_music("stop")
|
|
elif dialognum == 17:
|
|
if floweypissed:
|
|
pygame.draw.rect(game_surface, (255, 255, 255), (400, 100, 200, 72))
|
|
dialogue_text = "You know what's\ngoing on here,\ndon't you?"
|
|
|
|
|
|
|
|
if 18 > dialognum > 10:
|
|
for bx, by, bw, bh in floweypellets:
|
|
if check_collision(playerX, playerY, pw, ph, bx, by, bw, bh):
|
|
hp = 1
|
|
letters_shown = 0
|
|
dialognum = 17
|
|
floweypissed = False
|
|
break
|
|
|
|
if floweygoofy:
|
|
game_surface.blit(pygame.transform.scale(pygame.image.load('Flowey_goofy.png'), monstersize), (255, 85))
|
|
if customtimer < 175:
|
|
angle += 5
|
|
game_surface.blit(pygame.transform.rotate(pygame.transform.scale(pygame.image.load("star.png"), (10, 10)), angle), (370, 100))
|
|
else:
|
|
letters_shown = 0
|
|
dialognum = 8
|
|
floweygoofy = False
|
|
|
|
|
|
if dialognum < 16:
|
|
play_music("mus_flowey.ogg")
|
|
customtimer += 1
|
|
if not floweygoofy:
|
|
if 20 > customtimer:
|
|
game_surface.blit(Flowey02, (255, 85))
|
|
elif 20 < customtimer < 40:
|
|
game_surface.blit(Flowey01, (255, 85))
|
|
elif customtimer > 40:
|
|
customtimer = 0
|
|
game_surface.blit(Flowey02, (255, 85))
|
|
else:
|
|
game_surface.blit(Flowey01, (255, 85))
|
|
|
|
game_surface.blit(player, (playerX, playerY))
|
|
if dialognum < 17:
|
|
draw_dialogue_text(dialogue_text, "black", (400, 100), 20, letters_shown, game_surface,
|
|
space_width=10, letter_spacing=-1, line_spacing=2, shake_amount=0, debug=False, num=0)
|
|
else:
|
|
draw_dialogue_text(dialogue_text, "black", (400, 100), 20, letters_shown, game_surface,
|
|
space_width=10, letter_spacing=-1, line_spacing=2, shake_amount=0.25, debug=False, num=1)
|
|
|
|
|
|
if battlemodestart:
|
|
playeractive = True
|
|
playerX, playerY = BX, BY
|
|
playerX, playerY = 300, 300
|
|
defaultborders = False
|
|
game_surface.blit(player, (playerX, playerY))
|
|
customtimer += 1
|
|
if 75 > customtimer > 33:
|
|
player = player_soul
|
|
elif customtimer > 75:
|
|
battlemodestart = False
|
|
battlemode = True
|
|
#print(str(dialognum)+" "+str(letters_shown))
|
|
if level != 1:
|
|
clock.tick(75)
|
|
|
|
|
|
if escapping:
|
|
game_surface.blit(pygame.transform.scale(pygame.image.load("quitting.png"), (90, 20)), (0,0))
|
|
print(str(escapecounter))
|
|
escapecounter += 1
|
|
if escapecounter > 15:
|
|
sys.exit()
|
|
x = (window_size[0] - new_size[0]) // 2
|
|
y = (window_size[1] - new_size[1]) // 2
|
|
if level != 3.75:
|
|
screen.fill((0, 0, 0)) # black borders
|
|
screen.blit(scaled_surface, (x, y))
|
|
pygame.display.flip()
|
|
pygame.display.update()
|