Compare commits

..

No commits in common. "5123b19cb0136f876d6bdc7bd426e14259637d9a" and "51a287ba662e7ded9d2140506c4c4dcf9bce26da" have entirely different histories.

46 changed files with 15 additions and 78 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 644 B

After

Width:  |  Height:  |  Size: 607 B

View file

@ -1,41 +1,9 @@
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'
}
font = pygame.font.SysFont('Arial', 40)
class Button():
def __init__(self, x, y, width, height, font, buttonText='Button', onclickFunction=None, onePress=False):
font = pygame.font.Font(f'fonts/{fonts[font]}', 48)
def __init__(self, x, y, width, height, buttonText='Button', onclickFunction=None, onePress=False):
self.x = x
self.y = y
self.width = width
@ -44,30 +12,14 @@ class Button():
self.onePress = onePress
self.alreadyPressed = False
with open('art/textbox.png', 'r') as tb:
self.box = pygame.image.load(tb)
self.box = pygame.transform.scale(self.box, (width, height))
self.fillColors = {
'normal': '#ffffff',
'hover': '#666666',
'pressed': '#333333',
}
self.buttonSurface = pygame.Surface((self.width, self.height))
self.buttonRect = pygame.Rect(self.x, self.y, self.width, self.height)
self.buttonSurf = font.render(buttonText, True, '#baab80')
def process(self, screen):
mousePos = pygame.mouse.get_pos()
if self.buttonRect.collidepoint(mousePos):
#self.buttonSurface.fill(self.fillColors['hover'])
if pygame.mouse.get_pressed(num_buttons=3)[0]:
#self.buttonSurface.fill(self.fillColors['pressed'])
if self.onePress:
self.onclickFunction()
elif not self.alreadyPressed:
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)
self.buttonSurf = font.render(buttonText, True, (20, 20, 20))
return self

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

25
main.py
View file

@ -2,7 +2,6 @@ import pygame
import sys
import json
import time
from classes import *
def setUp(config):
pygame.init()
@ -11,30 +10,18 @@ def setUp(config):
else:
screen = pygame.display.set_mode(config["res"])
clock = pygame.time.Clock()
return screen, clock, True, True, "start.png", []
with open('art/textbox.png', 'r') as tb:
box = pygame.image.load(tb)
return screen, clock, True, True, "start.png", box
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()
sys.exit()
def uwu():
print('uwu')
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', "Exit game", quitGame))
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'medieval', "Options", uwu))
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 - 72, 160, 64, 'medieval', "Play", uwu))
print(objects)
screen, clock, running, background, isblack, box = setUp(config["screen"])
while running:
for event in pygame.event.get():
@ -44,7 +31,7 @@ def main():
if not isblack:
with open(background, 'r') as i:
bg = pygame.image.load(i)
bg = pygame.transform.scale(bg, (WIDTH, HEIGHT))
bg = pygame.transform.scale(bg, screen.get_size())
# fill the screen with a color to wipe away anything from last frame
screen.blit(bg, (0, 0))
@ -52,8 +39,6 @@ def main():
else:
screen.fill('#000000')
for obj in objects:
obj.process(screen)
# flip() the display to put your work on screen
pygame.display.flip()