diff --git a/.idea/InfoProjekt.xlsx b/.idea/InfoProjekt.xlsx new file mode 100644 index 0000000..570d52e Binary files /dev/null and b/.idea/InfoProjekt.xlsx differ diff --git a/.idea/ideas.txt b/.idea/ideas.txt new file mode 100644 index 0000000..131e8a8 --- /dev/null +++ b/.idea/ideas.txt @@ -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 (?) \ No newline at end of file diff --git a/storyline.txt b/.idea/storyline.txt similarity index 100% rename from storyline.txt rename to .idea/storyline.txt diff --git a/READ.ME b/READ.ME new file mode 100644 index 0000000..156111f --- /dev/null +++ b/READ.ME @@ -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 + + diff --git a/art/image files/exit.png b/art/image files/exit.png new file mode 100644 index 0000000..0fcda62 Binary files /dev/null and b/art/image files/exit.png differ diff --git a/art/image files/field.kra b/art/image files/field.kra new file mode 100644 index 0000000..f99eaf6 Binary files /dev/null and b/art/image files/field.kra differ diff --git a/art/image files/field.png b/art/image files/field.png new file mode 100644 index 0000000..008cb35 Binary files /dev/null and b/art/image files/field.png differ diff --git a/art/image files/mauer.png b/art/image files/mauer.png new file mode 100644 index 0000000..41ca7f1 Binary files /dev/null and b/art/image files/mauer.png differ diff --git a/art/image files/mauer_down-left.png b/art/image files/mauer_down-left.png new file mode 100644 index 0000000..e08c486 Binary files /dev/null and b/art/image files/mauer_down-left.png differ diff --git a/art/image files/mauer_down-right.png b/art/image files/mauer_down-right.png new file mode 100644 index 0000000..b6ac2ee Binary files /dev/null and b/art/image files/mauer_down-right.png differ diff --git a/art/image files/mauer_down.png b/art/image files/mauer_down.png new file mode 100644 index 0000000..9444e8e Binary files /dev/null and b/art/image files/mauer_down.png differ diff --git a/art/image files/mauer_left.png b/art/image files/mauer_left.png new file mode 100644 index 0000000..dd36a63 Binary files /dev/null and b/art/image files/mauer_left.png differ diff --git a/art/image files/mauer_right.png b/art/image files/mauer_right.png new file mode 100644 index 0000000..616d840 Binary files /dev/null and b/art/image files/mauer_right.png differ diff --git a/art/image files/mauer_top-left.png b/art/image files/mauer_top-left.png new file mode 100644 index 0000000..a08eac8 Binary files /dev/null and b/art/image files/mauer_top-left.png differ diff --git a/art/image files/mauer_top-right.png b/art/image files/mauer_top-right.png new file mode 100644 index 0000000..8f12ed8 Binary files /dev/null and b/art/image files/mauer_top-right.png differ diff --git a/art/image files/mauer_top.png b/art/image files/mauer_top.png new file mode 100644 index 0000000..9840b47 Binary files /dev/null and b/art/image files/mauer_top.png differ diff --git a/art/image files/new_game.png b/art/image files/new_game.png new file mode 100644 index 0000000..b5fc60a Binary files /dev/null and b/art/image files/new_game.png differ diff --git a/art/image files/options.png b/art/image files/options.png new file mode 100644 index 0000000..8d334fa Binary files /dev/null and b/art/image files/options.png differ diff --git a/art/image files/set1.png b/art/image files/set1.png new file mode 100644 index 0000000..bed3214 Binary files /dev/null and b/art/image files/set1.png differ diff --git a/art/images/reddy.png b/art/images/reddy.png new file mode 100644 index 0000000..40954a2 Binary files /dev/null and b/art/images/reddy.png differ diff --git a/art/images/start.png b/art/images/start.png new file mode 100644 index 0000000..3d7f7c5 Binary files /dev/null and b/art/images/start.png differ diff --git a/art/images/textbox.png b/art/images/textbox.png new file mode 100644 index 0000000..be01aef Binary files /dev/null and b/art/images/textbox.png differ diff --git a/classes.py b/classes.py new file mode 100644 index 0000000..d288c1d --- /dev/null +++ b/classes.py @@ -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 diff --git a/config.json b/config.json new file mode 100644 index 0000000..76e9637 --- /dev/null +++ b/config.json @@ -0,0 +1,7 @@ +{ + "screen": + { + "res":[1280, 720], + "fullscreen": false + } +} \ No newline at end of file diff --git a/fonts/3D-Pixel.ttf b/fonts/3D-Pixel.ttf new file mode 100644 index 0000000..15a051c Binary files /dev/null and b/fonts/3D-Pixel.ttf differ diff --git a/fonts/8bitlim.ttf b/fonts/8bitlim.ttf new file mode 100644 index 0000000..f8051e4 Binary files /dev/null and b/fonts/8bitlim.ttf differ diff --git a/fonts/8bitlimo.ttf b/fonts/8bitlimo.ttf new file mode 100644 index 0000000..fbd4d88 Binary files /dev/null and b/fonts/8bitlimo.ttf differ diff --git a/fonts/8bitlimr.ttf b/fonts/8bitlimr.ttf new file mode 100644 index 0000000..c66935d Binary files /dev/null and b/fonts/8bitlimr.ttf differ diff --git a/fonts/8blimro.ttf b/fonts/8blimro.ttf new file mode 100644 index 0000000..1f9da76 Binary files /dev/null and b/fonts/8blimro.ttf differ diff --git a/fonts/ARCADECLASSIC.TTF b/fonts/ARCADECLASSIC.TTF new file mode 100644 index 0000000..394a9f7 Binary files /dev/null and b/fonts/ARCADECLASSIC.TTF differ diff --git a/fonts/Beyond Wonderland.ttf b/fonts/Beyond Wonderland.ttf new file mode 100644 index 0000000..8cf093b Binary files /dev/null and b/fonts/Beyond Wonderland.ttf differ diff --git a/fonts/Digitag.ttf b/fonts/Digitag.ttf new file mode 100644 index 0000000..ea523e9 Binary files /dev/null and b/fonts/Digitag.ttf differ diff --git a/fonts/DisposableDroidBB.ttf b/fonts/DisposableDroidBB.ttf new file mode 100644 index 0000000..84f98c5 Binary files /dev/null and b/fonts/DisposableDroidBB.ttf differ diff --git a/fonts/DisposableDroidBB_bld.ttf b/fonts/DisposableDroidBB_bld.ttf new file mode 100644 index 0000000..9748e29 Binary files /dev/null and b/fonts/DisposableDroidBB_bld.ttf differ diff --git a/fonts/DisposableDroidBB_bldital.ttf b/fonts/DisposableDroidBB_bldital.ttf new file mode 100644 index 0000000..5544fe4 Binary files /dev/null and b/fonts/DisposableDroidBB_bldital.ttf differ diff --git a/fonts/DisposableDroidBB_ital.ttf b/fonts/DisposableDroidBB_ital.ttf new file mode 100644 index 0000000..596d523 Binary files /dev/null and b/fonts/DisposableDroidBB_ital.ttf differ diff --git a/fonts/Endalian Script.ttf b/fonts/Endalian Script.ttf new file mode 100644 index 0000000..1304f00 Binary files /dev/null and b/fonts/Endalian Script.ttf differ diff --git a/fonts/FREAKSOFNATURE.ttf b/fonts/FREAKSOFNATURE.ttf new file mode 100644 index 0000000..335c851 Binary files /dev/null and b/fonts/FREAKSOFNATURE.ttf differ diff --git a/fonts/FREAKSOFNATUREMASSIVE.ttf b/fonts/FREAKSOFNATUREMASSIVE.ttf new file mode 100644 index 0000000..f9b49d8 Binary files /dev/null and b/fonts/FREAKSOFNATUREMASSIVE.ttf differ diff --git a/fonts/Future TimeSplitters.otf b/fonts/Future TimeSplitters.otf new file mode 100644 index 0000000..f28a9a9 Binary files /dev/null and b/fonts/Future TimeSplitters.otf differ diff --git a/fonts/Halo3.ttf b/fonts/Halo3.ttf new file mode 100644 index 0000000..daeb3f2 Binary files /dev/null and b/fonts/Halo3.ttf differ diff --git a/fonts/INVASION2000.TTF b/fonts/INVASION2000.TTF new file mode 100644 index 0000000..87f629b Binary files /dev/null and b/fonts/INVASION2000.TTF differ diff --git a/fonts/Karma Future.otf b/fonts/Karma Future.otf new file mode 100644 index 0000000..c05849b Binary files /dev/null and b/fonts/Karma Future.otf differ diff --git a/fonts/Karma Suture.otf b/fonts/Karma Suture.otf new file mode 100644 index 0000000..31279ea Binary files /dev/null and b/fonts/Karma Suture.otf differ diff --git a/fonts/Merchant Copy Doublesize.ttf b/fonts/Merchant Copy Doublesize.ttf new file mode 100644 index 0000000..6651f4b Binary files /dev/null and b/fonts/Merchant Copy Doublesize.ttf differ diff --git a/fonts/Merchant Copy Wide.ttf b/fonts/Merchant Copy Wide.ttf new file mode 100644 index 0000000..74527d2 Binary files /dev/null and b/fonts/Merchant Copy Wide.ttf differ diff --git a/fonts/Merchant Copy.ttf b/fonts/Merchant Copy.ttf new file mode 100644 index 0000000..a095272 Binary files /dev/null and b/fonts/Merchant Copy.ttf differ diff --git a/fonts/Minecraft Evenings.otf b/fonts/Minecraft Evenings.otf new file mode 100644 index 0000000..ada43f1 Binary files /dev/null and b/fonts/Minecraft Evenings.otf differ diff --git a/fonts/MoriaCitadel.TTF b/fonts/MoriaCitadel.TTF new file mode 100644 index 0000000..7a63981 Binary files /dev/null and b/fonts/MoriaCitadel.TTF differ diff --git a/fonts/PixelFJVerdana12pt.ttf b/fonts/PixelFJVerdana12pt.ttf new file mode 100644 index 0000000..5531267 Binary files /dev/null and b/fonts/PixelFJVerdana12pt.ttf differ diff --git a/fonts/Seattle Avenue.ttf b/fonts/Seattle Avenue.ttf new file mode 100644 index 0000000..21f3099 Binary files /dev/null and b/fonts/Seattle Avenue.ttf differ diff --git a/fonts/SeattleAvenue.otf b/fonts/SeattleAvenue.otf new file mode 100644 index 0000000..57f51c1 Binary files /dev/null and b/fonts/SeattleAvenue.otf differ diff --git a/fonts/astron boy italic.otf b/fonts/astron boy italic.otf new file mode 100644 index 0000000..25f5c1f Binary files /dev/null and b/fonts/astron boy italic.otf differ diff --git a/fonts/astron boy video.otf b/fonts/astron boy video.otf new file mode 100644 index 0000000..78a3c9d Binary files /dev/null and b/fonts/astron boy video.otf differ diff --git a/fonts/astron boy wonder.otf b/fonts/astron boy wonder.otf new file mode 100644 index 0000000..72c7e49 Binary files /dev/null and b/fonts/astron boy wonder.otf differ diff --git a/fonts/astron boy.otf b/fonts/astron boy.otf new file mode 100644 index 0000000..d27810f Binary files /dev/null and b/fonts/astron boy.otf differ diff --git a/fonts/dpcomic.ttf b/fonts/dpcomic.ttf new file mode 100644 index 0000000..a0776ae Binary files /dev/null and b/fonts/dpcomic.ttf differ diff --git a/fonts/ka1.ttf b/fonts/ka1.ttf new file mode 100644 index 0000000..d1df852 Binary files /dev/null and b/fonts/ka1.ttf differ diff --git a/fonts/kirbyss.ttf b/fonts/kirbyss.ttf new file mode 100644 index 0000000..018853f Binary files /dev/null and b/fonts/kirbyss.ttf differ diff --git a/fonts/manaspc.ttf b/fonts/manaspc.ttf new file mode 100644 index 0000000..0c56733 Binary files /dev/null and b/fonts/manaspc.ttf differ diff --git a/fonts/medieval.ttf b/fonts/medieval.ttf new file mode 100644 index 0000000..5337005 Binary files /dev/null and b/fonts/medieval.ttf differ diff --git a/fonts/nasalization-rg.otf b/fonts/nasalization-rg.otf new file mode 100644 index 0000000..ce4625f Binary files /dev/null and b/fonts/nasalization-rg.otf differ diff --git a/fonts/neuropol.otf b/fonts/neuropol.otf new file mode 100644 index 0000000..5732517 Binary files /dev/null and b/fonts/neuropol.otf differ diff --git a/fonts/papercut.ttf b/fonts/papercut.ttf new file mode 100644 index 0000000..4f47ef4 Binary files /dev/null and b/fonts/papercut.ttf differ diff --git a/fonts/pcsenior.ttf b/fonts/pcsenior.ttf new file mode 100644 index 0000000..0bb46c4 Binary files /dev/null and b/fonts/pcsenior.ttf differ diff --git a/fonts/pdark.ttf b/fonts/pdark.ttf new file mode 100644 index 0000000..0eace6e Binary files /dev/null and b/fonts/pdark.ttf differ diff --git a/fonts/yoster.ttf b/fonts/yoster.ttf new file mode 100644 index 0000000..bbbeb51 Binary files /dev/null and b/fonts/yoster.ttf differ diff --git a/ideas.txt b/ideas.txt deleted file mode 100644 index 51bcf0f..0000000 --- a/ideas.txt +++ /dev/null @@ -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 (?) \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..d4c669f --- /dev/null +++ b/main.py @@ -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() diff --git a/test.png b/test.png new file mode 100644 index 0000000..4a92572 Binary files /dev/null and b/test.png differ diff --git a/viecher.py b/viecher.py new file mode 100644 index 0000000..1cb3211 --- /dev/null +++ b/viecher.py @@ -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)