made some work on the intro so far so good ig

This commit is contained in:
Martin Dvořák 2026-06-07 00:53:37 +02:00
commit f316adc74c
7 changed files with 96 additions and 13 deletions

View file

@ -23,4 +23,6 @@ You control the people to your liking, just be aware, it can turn against you!
Here I will list all the external resources I will use, most likely, fonts. I make most of my assets by my own. Here I will list all the external resources I will use, most likely, fonts. I make most of my assets by my own.
Alright so I think its fair to state I stole some code from my last minijam project at https://git.dvorakmortonxd.dev/dvorakmortonxd/revival-inc , however I dont know if this counts as external resource since, I am literally the one who wrote it. Alright so I think its fair to state I stole some code from my last minijam project at https://git.dvorakmortonxd.dev/dvorakmortonxd/revival-inc , however I dont know if this counts as external resource since, I am literally the one who wrote it.
FONT: https://fontenddev.com/fonts/kiwi-soda/ FONT: https://fontenddev.com/fonts/kiwi-soda/
MENU THEME: you may not believe it but it is an edited (paulstretched) version of https://freesound.org/people/justin3am/sounds/403106/
BLIP SOUND EFFECT: https://freesound.org/people/danieldouch/sounds/466556/

BIN
blip.wav Normal file

Binary file not shown.

View file

@ -1,8 +1,18 @@
from render import load_sprite # this makes it so our function for rendering sprites from sprites.png is available in here from render import load_sprite # this makes it so our function for rendering sprites from sprites.png is available in here
import pygame import pygame
tickd = 0
def level1(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, mouse, click, big_text, level, tick, slightfont): # the function for our first level, ignore the unused variables here, you can use them when you edit it dialognum = 0
screen.blit(load_sprite(sheet, 0, 0, 56, 35, 912, 576), (0, 0)) # this renders a button I made in the sprites.png, its purely for visual purposes so it doesnt matter where you click rn DIALOGTEXT = "UNDEFINED"
def level1(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, mouse, click, big_text, level, tick, slightfont, pygamemixer): # the function for our first level, ignore the unused variables here, you can use them when you edit it
global tickd
tickd += 1
screen.blit(load_sprite(sheet, 0, 0, 57, 36, 912, 576), (0, 0)) # this renders a button I made in the sprites.png, its purely for visual purposes so it doesnt matter where you click rn
if tickd in range(100,110) or tickd in range(120,130) or tickd in range(300,310) or tickd in range(320,330):
overlay = pygame.Surface(screen.get_size(), pygame.SRCALPHA)
overlay.fill((255, 255, 255, 18))
screen.blit(overlay, (0, 0))
elif tickd > 450:
tickd = 0
mainmenu_text = slightfont.render("THE DESTROYER OF CITIES", True, (210, 210, 210)) mainmenu_text = slightfont.render("THE DESTROYER OF CITIES", True, (210, 210, 210))
playb_collision = pygame.Rect(315, 200, 285, 105) playb_collision = pygame.Rect(315, 200, 285, 105)
exitb_collision = pygame.Rect(315, 350, 285, 105) exitb_collision = pygame.Rect(315, 350, 285, 105)
@ -10,6 +20,8 @@ def level1(screen, sheet, screen_width, screen_height, lastclickpos, basicfont,
screen.blit(load_sprite(sheet, 57, 7, 19, 7, 285, 105), (315, 200)) screen.blit(load_sprite(sheet, 57, 7, 19, 7, 285, 105), (315, 200))
play_text = basicfont.render("Play", True, (0,0,0)) play_text = basicfont.render("Play", True, (0,0,0))
if click: if click:
tickd = 0
pygamemixer.stop()
level = 2 level = 2
else: else:
screen.blit(load_sprite(sheet, 57, 0, 19, 7, 285, 105), (315, 200)) screen.blit(load_sprite(sheet, 57, 0, 19, 7, 285, 105), (315, 200))
@ -28,6 +40,67 @@ def level1(screen, sheet, screen_width, screen_height, lastclickpos, basicfont,
screen.blit(exit_text, (414, 380)) screen.blit(exit_text, (414, 380))
screen.blit(mainmenu_text, (45, 65)) screen.blit(mainmenu_text, (45, 65))
return level # this returns the change we made to the level so that it updates in main.py return level # this returns the change we made to the level so that it updates in main.py
def level2(screen, sheet, lastclickpos, basicfont, mouse, click, level): # function for level 2 def level2(blip, screen, sheet, screen_width, screen_height, lastclickpos, basicfont, mouse, click, big_text, level, tick, slightfont, pygamemixer): # the function for our first level, ignore the unused variables here, you can use them when you edit it
print("ur done") # prints out "ur done" global tickd, dialognum, DIALOGTEXT
if dialognum != 9:
tickd += 1
if tickd == 59:
pygame.mixer.Sound.play(blip)
if tickd in range(60,501):
if tickd < 315:
transparency = (tickd-60, tickd-60, tickd-60)
else:
transparency = (255,255,255)
if dialognum == 0:
DIALOGTEXT = "Where am I..."
if dialognum == 1:
DIALOGTEXT = "What am I doing here?!"
if dialognum == 2:
DIALOGTEXT = "Why can't I remember anything?"
if dialognum == 3:
DIALOGTEXT = ". . ."
if dialognum == 4:
DIALOGTEXT = "Wait."
if dialognum == 5:
DIALOGTEXT = "Those aren't my hands."
if dialognum == 6:
DIALOGTEXT = ". . ."
if dialognum == 7:
DIALOGTEXT = ""
screen.blit(load_sprite(sheet, 0, 37, 57,36, 912, 576), (0,0))
screen.blit(load_sprite(sheet,57,15,8,25, 80, 250), (660, 290))
screen.blit(load_sprite(sheet, 65, 14, 54, 12, 162, 36), (720, 295))
if dialognum == 8:
DIALOGTEXT = "Oh..."
screen.blit(load_sprite(sheet, 0, 37, 57,36, 912, 576), (0,0))
screen.blit(load_sprite(sheet,57,15,8,25, 80, 250), (660, 290))
screen.blit(load_sprite(sheet, 65, 14, 54, 12, 162, 36), (720, 295))
dialog_square = pygame.surface.Surface((800, 68), pygame.SRCALPHA)
dialog_square.fill((0, 0, 0))
screen.blit(dialog_square, (56, 500))
if dialognum == 9:
DIALOGTEXT = "Press <H> to hide your parasite"
screen.blit(load_sprite(sheet, 0, 37, 57,36, 912, 576), (0,0))
screen.blit(load_sprite(sheet,57,15,8,25, 80, 250), (660, 290))
screen.blit(load_sprite(sheet, 65, 14, 54, 12, 162, 36), (720, 295))
dialog_square = pygame.surface.Surface((800, 68), pygame.SRCALPHA)
dialog_square.fill((0, 0, 0))
screen.blit(dialog_square, (56, 500))
dialog = basicfont.render(DIALOGTEXT, True, transparency)
if len(DIALOGTEXT) < 16:
DX = 456-len(DIALOGTEXT)*9
else:
DX = 456-len(DIALOGTEXT)*10
if dialognum < 7:
DY = 230
else:
DY = 510
screen.blit(dialog, (DX,DY))
if tickd > 500:
dialognum += 1
if dialognum > 6:
screen.blit(load_sprite(sheet, 0, 37, 57, 36, 912, 576), (0, 0))
if dialognum != 7:
pygame.mixer.Sound.play(blip)
tickd = 60
return level # returns the current level set return level # returns the current level set

22
main.py
View file

@ -4,17 +4,22 @@ import pygame, levels # Imports the pygame library and our own levels.py we made
window_fps = 60 # the frames per second, this decides how fast the main loop runs per second window_fps = 60 # the frames per second, this decides how fast the main loop runs per second
def main(fps=window_fps): # the main function def main(fps=window_fps): # the main function
pygame.init() # initalizes pygame pygame.init() # initializes pygame
pygame.mixer.init()
pygame.mixer.music.load('theme.wav')
pygame.mixer.music.play(-1,0,2000)
blip = pygame.mixer.Sound('blip.wav')
tick = 0 tick = 0
screen_width = 912 # the screen width screen_width = 912 # the screen width
screen_height = 576 # the screen height screen_height = 576 # the screen height
# THE SCREEN IS 19:12 RATIO # THE SCREEN IS 19:12 RATIO
title = "The Destroyer of Cities" # the title of the window obviously title = "The Destroyer of Cities" # the title of the window obviously
lastclickpos = [0, 0] # last position that was clicked, this changes every time you click somewhere on the game window lastclickpos = [0, 0] # last position that was clicked, this changes every time you click somewhere on the game window
screen = pygame.display.set_mode((screen_width, screen_height)) # this initalizes the display with the screen_width and screen_height variables screen = pygame.display.set_mode((screen_width, screen_height)) # this initializes the display with the screen_width and screen_height variables
pygame.display.set_caption(title) # this actually sets the title of the window from the title variable pygame.display.set_caption(title) # this actually sets the title of the window from the title variable
basicfont = pygame.font.Font('KiwiSoda.ttf', 50) # this sets a basic font for now, we can change this to anything later on basicfont = pygame.font.Font('KiwiSoda.ttf', 50) # this sets a basic font for now, we can change this to anything later on
bigfont = pygame.font.Font('KiwiSoda.ttf', 80) bigfont = pygame.font.Font('KiwiSoda.ttf', 80)
sysfont = pygame.font.SysFont('', 30)
slightly_smaller_than_bigfont = pygame.font.Font('KiwiSoda.ttf', 70) slightly_smaller_than_bigfont = pygame.font.Font('KiwiSoda.ttf', 70)
smallfont = pygame.font.Font('KiwiSoda.ttf', 30) smallfont = pygame.font.Font('KiwiSoda.ttf', 30)
clock = pygame.time.Clock() # this is used to control the fps of the game if you scroll down the code a bit clock = pygame.time.Clock() # this is used to control the fps of the game if you scroll down the code a bit
@ -28,8 +33,11 @@ def main(fps=window_fps): # the main function
if event.type == pygame.QUIT: # what happens when you click the X button on the window if event.type == pygame.QUIT: # what happens when you click the X button on the window
running = False # poof running = False # poof
if event.type == pygame.KEYDOWN: # what happens when you press down a key if event.type == pygame.KEYDOWN: # what happens when you press down a key
if event.key == pygame.K_ESCAPE: # what happens when you press escape if event.key == pygame.K_ESCAPE:
running = False # poof levels.dialognum += 1
if event.key == pygame.K_h:
if levels.dialognum == 9:
levels.dialognum = 10
if event.type == pygame.MOUSEBUTTONDOWN: # what happens when you press down a mouse button if event.type == pygame.MOUSEBUTTONDOWN: # what happens when you press down a mouse button
click = True # sets the click variable to True so level function in levels.py can see click = True # sets the click variable to True so level function in levels.py can see
print(pygame.mouse.get_pos()) # prints out where the mouse is during the click for debugging purposes print(pygame.mouse.get_pos()) # prints out where the mouse is during the click for debugging purposes
@ -39,14 +47,14 @@ def main(fps=window_fps): # the main function
if level == 0: if level == 0:
running = False running = False
if level == 1: # what happens when the level variable is equal to 1 if level == 1: # what happens when the level variable is equal to 1
level = levels.level1(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, pygame.mouse, click, bigfont, level, tick, slightly_smaller_than_bigfont) # runs the level1 function from levels.py level = levels.level1(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, pygame.mouse, click, bigfont, level, tick, slightly_smaller_than_bigfont, pygame.mixer.music) # runs the level1 function from levels.py
if level == 2: if level == 2:
pass level = levels.level2(blip, screen, sheet, screen_width, screen_height, lastclickpos, basicfont, pygame.mouse, click, bigfont, level, tick, slightly_smaller_than_bigfont, pygame.mixer.music)
# THE REASON WE CALL IT LIKE THIS INSTEAD OF NORMALLY IS SO WE CAN CHANGE THE LEVEL VARIABLE # THE REASON WE CALL IT LIKE THIS INSTEAD OF NORMALLY IS SO WE CAN CHANGE THE LEVEL VARIABLE
elif level == 2: # what happens when the level variable is equal to 2 ofc elif level == 2: # what happens when the level variable is equal to 2 ofc
level = levels.level2(screen, sheet, lastclickpos, basicfont, pygame.mouse, click, level) # runs the level2 function from levels.py level = levels.level2(screen, sheet, lastclickpos, basicfont, pygame.mouse, click, level) # runs the level2 function from levels.py
fps_text = basicfont.render(str(int(clock.get_fps())), True, (0, 255, 0)) # defines a thing that renders your fps in the top left corner fps_text = sysfont.render(str(int(clock.get_fps())), True, (0, 255, 0)) # defines a thing that renders your fps in the top left corner
screen.blit(fps_text, (5, 5)) # this actually renders "ftp_text" on the screen at the position (5, 5) which is the top left corner screen.blit(fps_text, (5, 5)) # this actually renders "ftp_text" on the screen at the position (5, 5) which is the top left corner
pygame.display.flip() # this updates the display so it displays all the new stuff we added pygame.display.flip() # this updates the display so it displays all the new stuff we added
clock.tick(fps) # this makes sure the game loop runs at the fps we set it to before clock.tick(fps) # this makes sure the game loop runs at the fps we set it to before

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Before After
Before After

Binary file not shown.

BIN
theme.wav Normal file

Binary file not shown.