Development #2

Merged
jaffa merged 114 commits from InfoProjekt/game:Development into Development 2024-03-11 00:39:31 +01:00
71 changed files with 467 additions and 22 deletions
Showing only changes of commit c5cc9e6acc - Show all commits

BIN
.idea/InfoProjekt.xlsx generated Normal file

Binary file not shown.

44
.idea/ideas.txt generated Normal file
View file

@ -0,0 +1,44 @@
Anmerkungen in Klammern
? - unsicher
name? - Name noch unklar, bzw. steht zur Diskussion
! - festgelegt / Einigung
Game:
Rogue-like Game mit Story
Pixel
viele Gegner:
Skelette Schwert
Zombies Knüppel
Ratten -
Kröten(?) -
Gläubige(?) Bogen / Schwert
Story:
Theme
mittelalterlich(?)
fairy-tale-like(?)
medieval(!)
Homeless guy in Berlin (oder so) im Winter in einer Stadtbibliothek, weil warm und Shelter.
er hasst eigentlich Bücher, aber aus Langeweile durchstöbert er die Bibo
findet cool aussehendes antikes/magisches Buch, nimmt es aus dem Regal, blättert es auf und wird ohnmächtig
-> Erwacht als magische Person in magischer Welt wieder
Buch dient als Skillbaum (verschiedene Kapitel)
Kampfmagier (name?)
Heilender Magier -> Priester(name?)
Elementmagier(?)
Hexenkraft / Hexenwerke / Hexenmagie / Flüche (?)
Kampf
Faust
Zauberstab - range und strength von Skills und Level(?) abhängig
NPCS
Priester / Mönch (eher Mönch)
Henker
armer Bauer
"Hexe"
Ziel(e)
-> Zurückkommen
-> Happy werden (?)

View file

53
READ.ME Normal file
View file

@ -0,0 +1,53 @@
Brief Explanation of all files and classes and pygame
Button CLass:
Button(position_x, position_y, width, height, font key phrase/word (see dictionary), the function which should be executed, and if the function should be executed while holding the button or only once per press)
fonts = {
'medieval': 'medieval.ttf',
'minecraft': 'Minecraft Evenings.otf',
'3dpixel': '3D-Pixel.ttf',
'8bit': '8bitlim.ttf',
'8bito': '8blimro.ttf',
'arcade': 'ARCADECLASSIC.ttf',
'modern_game': 'astron boy video.otf',
'modern': 'astron boy.otf',
'wonder': 'Beyond Wonderland.ttf',
'curved': 'Digitag.ttf',
'simple': 'DisposableDroidBB.ttf',
'rounded': 'dpcomic.ttf',
'playfull': 'Endalian Script.ttf',
'blocky': 'FREAKSOFNATURE.ttf',
'catchy': 'Future TimeSplitters.otf',
'simple_wide': 'Halo3.ttf',
'simple_fat': 'INVASION2000.ttf',
'very_gamy': 'ka1.ttf',
'simple_round': 'Karma Suture.otf',
'mono': 'manaspc.ttf',
'damaged': 'Merchant Copy.ttf',
'big_natural': 'MorialCitadel.TTF',
'spacy': 'nasalization-rg.otf',
'sci-fi': 'neuropol.otf',
'hollow_big_edge': 'papercut.ttf',
'space_shuttle': 'pdark.ttf',
'thin': 'PixelFJVerdana12pt.ttf',
'random': 'Seattle Avenue.ttf',
'pixel': 'yoster.ttf'
}
Pygame window: (0, 0) is in the top left corner, the height and width are stored in HEIGHT and WIDTH
GameObjects for rooms, scenes and maybe MorialCitadel
Scene:
type - normal, dungeon, cutscene
objects - contain rooms, npcs, mobs, the character etc.
Room:
type - normal, shop, special (?), boss
objects - npcs, mobs, the character etc.
exits - position of exits --> [top:bool, right:bool, down:bool, left:bool]; 1 to 4 exits per room
locked - bool if the room is unlocked; locked upon first entering unless all mobs are dead

BIN
art/image files/exit.png Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 738 B

After

Width:  |  Height:  |  Size: 738 B

BIN
art/image files/field.kra Normal file

Binary file not shown.

BIN
art/image files/field.png Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 544 B

BIN
art/image files/mauer.png Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 629 B

After

Width:  |  Height:  |  Size: 629 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 703 B

After

Width:  |  Height:  |  Size: 703 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 651 B

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 706 B

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 694 B

After

Width:  |  Height:  |  Size: 694 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 731 B

After

Width:  |  Height:  |  Size: 731 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 719 B

After

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 657 B

After

Width:  |  Height:  |  Size: 657 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 B

After

Width:  |  Height:  |  Size: 974 B

BIN
art/image files/options.png Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 808 B

After

Width:  |  Height:  |  Size: 808 B

BIN
art/image files/set1.png Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

BIN
art/images/reddy.png Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 654 B

After

Width:  |  Height:  |  Size: 654 B

BIN
art/images/start.png Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
art/images/textbox.png Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 644 B

After

Width:  |  Height:  |  Size: 644 B

160
classes.py Normal file
View file

@ -0,0 +1,160 @@
import pygame
pygame.font.init()
fonts = {
'medieval': 'medieval.ttf',
'minecraft': 'Minecraft Evenings.otf',
'3dpixel': '3D-Pixel.ttf',
'8bit': '8bitlim.ttf',
'8bito': '8blimro.ttf',
'arcade': 'ARCADECLASSIC.ttf',
'modern_game': 'astron boy video.otf',
'modern': 'astron boy.otf',
'wonder': 'Beyond Wonderland.ttf',
'curved': 'Digitag.ttf',
'simple': 'DisposableDroidBB.ttf',
'rounded': 'dpcomic.ttf',
'playfull': 'Endalian Script.ttf',
'blocky': 'FREAKSOFNATURE.ttf',
'catchy': 'Future TimeSplitters.otf',
'simple_wide': 'Halo3.ttf',
'simple_fat': 'INVASION2000.ttf',
'very_gamy': 'ka1.ttf',
'simple_round': 'Karma Suture.otf',
'mono': 'manaspc.ttf',
'damaged': 'Merchant Copy.ttf',
'big_natural': 'MorialCitadel.TTF',
'spacy': 'nasalization-rg.otf',
'sci-fi': 'neuropol.otf',
'hollow_big_edge': 'papercut.ttf',
'space_shuttle': 'pdark.ttf',
'thin': 'PixelFJVerdana12pt.ttf',
'random': 'Seattle Avenue.ttf',
'pixel': 'yoster.ttf'
}
class Button():
def __init__(self, x, y, width, height, font, font_size, buttonText='Button', onclickFunction=None, onePress=False):
self.font = pygame.font.Font(f'fonts/{fonts[font]}', font_size)
self.x = x
self.y = y
self.width = width
self.height = height
self.onclickFunction = onclickFunction
self.onePress = onePress
self.alreadyPressed = False
with open('art/images/textbox.png', 'r') as tb:
self.box = pygame.image.load(tb)
self.box = pygame.transform.scale(self.box, (width, height))
self.buttonRect = pygame.Rect(self.x, self.y, self.width, self.height)
self.buttonSurf = self.font.render(buttonText, True, '#baab80')
def process(self, screen, clock, running, background, isblack, WIDTH, HEIGHT):
mousePos = pygame.mouse.get_pos()
if self.buttonRect.collidepoint(mousePos):
if pygame.mouse.get_pressed(num_buttons=3)[0]:
if self.onePress:
self.onclickFunction()
elif not self.alreadyPressed:
if 'play' in str(self.onclickFunction):
self.onclickFunction(screen, clock, running, background, isblack, WIDTH, HEIGHT)
self.alreadyPressed = True
else:
self.onclickFunction()
self.alreadyPressed = True
else:
self.alreadyPressed = False
self.box.blit(self.buttonSurf, [
self.buttonRect.width/2 - self.buttonSurf.get_rect().width/2,
self.buttonRect.height/2 - self.buttonSurf.get_rect().height/2
])
screen.blit(self.box, self.buttonRect)
class DropDown():
def __init__(self, x, y, width, height, font, font_size, color_menu, color_option, main, options):
self.rect = pygame.Rect(x, y, width, height)
self.font = pygame.font.Font(f'fonts/{fonts[font]}', font_size)
self.main = main
self.options = options
self.draw_menu = False
self.menu_active = False
self.active_option = -1
with open('art/images/textbox.png', 'r') as tb:
self.box = pygame.image.load(tb)
self.box = pygame.transform.scale(self.box, (width, height))
def draw(self, screen):
#pygame.draw.rect(screen, self.color_menu[self.menu_active], self.rect, 0)
surface = self.font.render(self.main, 1, (0, 0, 0))
self.box.blit(surface, [
self.rect.width/2 - surface.get_rect().width/2,
self.rect.height/2 - surface.get_rect().height/2
])
screen.blit(self.box, surface.get_rect(center = self.rect.center))
if self.draw_menu:
for i, text in enumerate(self.options):
rect = self.rect.copy()
rect.y += (i+1) * self.rect.height
rect.x = self.rect.x
#pygame.draw.rect(screen, self.color_option[1 if i == self.active_option else 0], rect, 0)
#msg = self.font.render(text, 1, (0, 0, 0))
#screen.blit(msg, msg.get_rect(center = rect.center))
surface = self.font.render(text, 1, (0, 0, 0))
self.box.blit(surface, [
rect.width/2 - surface.get_rect().width/2,
rect.height/2 - surface.get_rect().height/2
])
screen.blit(self.box, rect)
def update(self, event_list):
mpos = pygame.mouse.get_pos()
self.menu_active = self.rect.collidepoint(mpos)
self.active_option = -1
for i in range(len(self.options)):
rect = self.rect.copy()
rect.y += (i+1) * self.rect.height
if rect.collidepoint(mpos):
self.active_option = i
break
if not self.menu_active and self.active_option == -1:
self.draw_menu = False
#self.draw_menu = True
#return -1
if pygame.mouse.get_pressed(num_buttons=3)[0]:
if self.menu_active:
self.draw_menu = not self.draw_menu
elif self.draw_menu and self.active_option >= 0:
self.draw_menu = False
return self.active_option
return -1
class GameObjects():
def __init__(self, name:str, _type:str, bg, objects:list) -> None:
self.name = name
self.type = _type
self.background = bg
self.objects = objects
class Scene(GameObjects):
def __init__(self, name:str, _type:str, bg, objects:list) -> None:
super().__init__(name, _type, bg, objects)
class Room(GameObjects):
def __init__(self, name:str, _type:str, bg, objects:list, exits:list) -> None:
super().__init__(name, _type, bg, objects)
self.exits = exits
if self.type == 'normal' or self.type == 'boss':
self.locked = True
else:
self.locked = False

7
config.json Normal file
View file

@ -0,0 +1,7 @@
{
"screen":
{
"res":[1280, 720],
"fullscreen": false
}
}

BIN
fonts/3D-Pixel.ttf Normal file

Binary file not shown.

BIN
fonts/8bitlim.ttf Normal file

Binary file not shown.

BIN
fonts/8bitlimo.ttf Normal file

Binary file not shown.

BIN
fonts/8bitlimr.ttf Normal file

Binary file not shown.

BIN
fonts/8blimro.ttf Normal file

Binary file not shown.

BIN
fonts/ARCADECLASSIC.TTF Normal file

Binary file not shown.

BIN
fonts/Beyond Wonderland.ttf Normal file

Binary file not shown.

BIN
fonts/Digitag.ttf Normal file

Binary file not shown.

BIN
fonts/DisposableDroidBB.ttf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
fonts/Endalian Script.ttf Normal file

Binary file not shown.

BIN
fonts/FREAKSOFNATURE.ttf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
fonts/Halo3.ttf Normal file

Binary file not shown.

BIN
fonts/INVASION2000.TTF Normal file

Binary file not shown.

BIN
fonts/Karma Future.otf Normal file

Binary file not shown.

BIN
fonts/Karma Suture.otf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
fonts/Merchant Copy.ttf Normal file

Binary file not shown.

Binary file not shown.

BIN
fonts/MoriaCitadel.TTF Normal file

Binary file not shown.

Binary file not shown.

BIN
fonts/Seattle Avenue.ttf Normal file

Binary file not shown.

BIN
fonts/SeattleAvenue.otf Normal file

Binary file not shown.

BIN
fonts/astron boy italic.otf Normal file

Binary file not shown.

BIN
fonts/astron boy video.otf Normal file

Binary file not shown.

BIN
fonts/astron boy wonder.otf Normal file

Binary file not shown.

BIN
fonts/astron boy.otf Normal file

Binary file not shown.

BIN
fonts/dpcomic.ttf Normal file

Binary file not shown.

BIN
fonts/ka1.ttf Normal file

Binary file not shown.

BIN
fonts/kirbyss.ttf Normal file

Binary file not shown.

BIN
fonts/manaspc.ttf Normal file

Binary file not shown.

BIN
fonts/medieval.ttf Normal file

Binary file not shown.

BIN
fonts/nasalization-rg.otf Normal file

Binary file not shown.

BIN
fonts/neuropol.otf Normal file

Binary file not shown.

BIN
fonts/papercut.ttf Normal file

Binary file not shown.

BIN
fonts/pcsenior.ttf Normal file

Binary file not shown.

BIN
fonts/pdark.ttf Normal file

Binary file not shown.

BIN
fonts/yoster.ttf Normal file

Binary file not shown.

View file

@ -1,22 +0,0 @@
Game:
Rogue-like Game mit Story
Pixel
viele Gegner:
Skelette
Zombies
Story:
Homeless guy in Berlin (oder so) im Winter in einer Stadtbibliothek, weil warm und Shelter.
er hasst eigentlich Bücher, aber aus Langeweile durchstöbert er die Bibo
findet cool aussehendes antikes/magisches Buch, nimmt es aus dem Regal, blättert es auf und wird ohnmächtig
-> Erwacht als magische Person in magischer Welt wieder
Buch dient als Skillbaum (verschiedene Kapitel)
Kampfmagier
Heilender Magier -> Priester?
Elementmagier(?)
maybe noch irgendwas 4.
Ziel(e)
-> Zurückkommen
-> Happy werden (?)

147
main.py Normal file
View file

@ -0,0 +1,147 @@
import pygame
import sys
import json
import time
from classes import *
from viecher import *
fps = 60
def setUp(config):
pygame.init()
if config["fullscreen"]:
screen = pygame.display.set_mode(config["res"], pygame.FULLSCREEN)
else:
screen = pygame.display.set_mode(config["res"])
clock = pygame.time.Clock()
return screen, clock, True, True, "start.png", []
def readConfig():
with open('config.json', 'r') as c:
json_data = c.read()
return json.loads(json_data)
def quitGame():
#save progress somehow, if needed
pygame.quit()
quit()
def play(screen, clock, running, background, isblack, WIDTH, HEIGHT):
objects = []
objects.append(MainCharacter('Herbert', 100, 'reddy.png', 125, 5, 1, 1, 50))
while running:
screen.fill('#000000')
events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT:
quitGame()
# RENDER YOUR GAME HERE
"""with open(background, 'r') as i:
bg = pygame.image.load(i)
bg = pygame.transform.scale(bg, (WIDTH, HEIGHT))
# fill the screen with an image to clear the screen
screen.blit(bg, (0, 0))
"""
for obj in objects:
obj.update(pygame.key.get_pressed())
obj.draw(screen)
# flip() the display to put your work on screen
pygame.display.flip()
clock.tick(fps) # limits FPS to 60
def options(screen, clock, running, background, isblack, WIDTH, HEIGHT):
objects = []
# List that is displayed while selecting the window resolution level
resolution = [("1920x1080", "1920x1080"),
("1920x1200", "1920x1200"),
("1280x720", "1280x720"),
("2560x1440", "2560x1440"),
("3840x2160", "3840x2160")]
# This function displays the currently selected options
def printSettings():
print("\n\n")
# getting the data using "get_input_data" method of the Menu class
settingsData = settings.get_input_data()
for key in settingsData.keys():
print(f"{key}\t:\t{settingsData[key]}")
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# RENDER YOUR GAME HERE
with open(background, 'r') as i:
bg = pygame.image.load(i)
bg = pygame.transform.scale(bg, (WIDTH, HEIGHT))
# fill the screen with an image to clear the screen
screen.blit(bg, (0, 0))
for obj in objects:
obj.process(screen)
# flip() the display to put your work on screen
pygame.display.flip()
clock.tick(60) # limits FPS to 60
def menu(screen, clock, running, background, isblack, WIDTH, HEIGHT):
objects = []
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'medieval', 48, "Play", play))
#objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 - 72, 160, 64, 'medieval', 48, "Options", uwu))
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 + 72, 160, 64, 'medieval', 48, "Exit game", quitGame))
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
quitGame()
# RENDER YOUR GAME HERE
with open(f'art/images/{background}', 'r') as i:
bg = pygame.image.load(i)
bg = pygame.transform.scale(bg, (WIDTH, HEIGHT))
# fill the screen with an image to clear the screen
screen.blit(bg, (0, 0))
for obj in objects:
obj.process(screen, clock, running, background, isblack, WIDTH, HEIGHT)
# flip() the display to put your work on screen
pygame.display.flip()
clock.tick(60) # limits FPS to 60
def main():
config = readConfig()
screen, clock, running, isblack, background, objects = setUp(config["screen"])
WIDTH, HEIGHT = screen.get_size()
#objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 - 72, 160, 64, 'medieval', 48, "Play", play))
#objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'medieval', 48, "Options", uwu))
#objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 + 72, 160, 64, 'medieval', 48, "Exit game", quitGame))
menu(screen, clock, running, background, isblack, WIDTH, HEIGHT)
"""while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
#menu(screen, clock, running, background, isblack, WIDTH, HEIGHT)
if not isblack:
with open(background, 'r') as i:
bg = pygame.image.load(i)
bg = pygame.transform.scale(bg, (WIDTH, HEIGHT))
# fill the screen with a color to wipe away anything from last frame
screen.blit(bg, (0, 0))
# RENDER YOUR GAME HERE
else:
for obj in objects:
obj.process(screen, clock, running, background, isblack, WIDTH, HEIGHT)
# flip() the display to put your work on screen
pygame.display.flip()
clock.tick(60) # limits FPS to 60"""
pygame.quit()
if __name__ == '__main__':
main()

BIN
test.png Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 529 KiB

After

Width:  |  Height:  |  Size: 529 KiB

56
viecher.py Normal file
View file

@ -0,0 +1,56 @@
import pygame
fps = 60
class Character():
def __init__(self, name, ms, sprite) -> None:
self.name = name
self.speed = ms
with open(f'art/images/{sprite}') as i:
self.sprite = pygame.image.load(i)
self.x = 524
self.y = 524
self.hidden = False
self.rect = pygame.Rect(self.x, self.y, self.sprite.get_width(), self.sprite.get_height())
def draw(self, screen):
if self.hidden:
return
self.rect.x, self.rect.y = self.x, self.y
screen.blit(self.sprite, self.rect)
class NPC(Character):
pass
class Fighter(Character):
def __init__(self, name, ms, sprite, health, damage, level, asp, atr) -> None:
super().__init__(name, ms, sprite)
self.health = health
self.damage = damage
self.level = level
self.attack_speed = asp
self.attack_range = atr
class MainCharacter(Fighter):
def __init__(self, name, ms, sprite, health, damage, level, asp, atr, weapon=None, shield=None) -> None:
super().__init__(name, ms, sprite, health, damage, level, asp, atr)
self.attack_spell = weapon
self.shield_spell = shield
self.talking = False
def update(self, keys):
if keys[pygame.K_w]:
self.y -= self.speed / fps
if keys[pygame.K_a]:
self.x -= self.speed / fps
if keys[pygame.K_s]:
self.y += self.speed / fps
if keys[pygame.K_d]:
self.x += self.speed / fps
class Mobs(Fighter):
def __init__(self, name, ms, sprite, health, damage, level, asp, atr, drops) -> None:
super().__init__(name, ms, sprite, health, damage, level, asp, atr)
self.drops = drops * (self.level / 2)