diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b92839d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,22 @@ +{ + "workbench.colorCustomizations": { + "activityBar.activeBackground": "#65c89b", + "activityBar.background": "#65c89b", + "activityBar.foreground": "#15202b", + "activityBar.inactiveForeground": "#15202b99", + "activityBarBadge.background": "#945bc4", + "activityBarBadge.foreground": "#e7e7e7", + "commandCenter.border": "#15202b99", + "sash.hoverBorder": "#65c89b", + "statusBar.background": "#42b883", + "statusBar.foreground": "#15202b", + "statusBarItem.hoverBackground": "#359268", + "statusBarItem.remoteBackground": "#42b883", + "statusBarItem.remoteForeground": "#15202b", + "titleBar.activeBackground": "#42b883", + "titleBar.activeForeground": "#15202b", + "titleBar.inactiveBackground": "#42b88399", + "titleBar.inactiveForeground": "#15202b99" + }, + "peacock.color": "#42b883" +} \ No newline at end of file diff --git a/constants.py b/constants.py new file mode 100644 index 0000000..eec4dad --- /dev/null +++ b/constants.py @@ -0,0 +1,3 @@ +class Config: + FPS=60 + WINDOW_SIZE=(800,600) \ No newline at end of file diff --git a/data/theme/theme.json b/data/theme/theme.json new file mode 100644 index 0000000..f1d3fac --- /dev/null +++ b/data/theme/theme.json @@ -0,0 +1,26 @@ +{ + "defaults": { + "colours": { + "normal_bg": "#45494e", + "hovered_bg": "#35393e", + "disabled_bg": "#25292e", + "selected_bg": "#193754", + "dark_bg": "#15191e", + "normal_text": "#c5cbd8", + "hovered_text": "#FFFFFF", + "selected_text": "#FFFFFF", + "disabled_text": "#6d736f", + "link_text": "#0000EE", + "link_hover": "#2020FF", + "link_selected": "#551A8B", + "text_shadow": "#777777", + "normal_border": "#DDDDDD", + "hovered_border": "#B0B0B0", + "disabled_border": "#808080", + "selected_border": "#8080B0", + "active_border": "#8080B0", + "filled_bar": "#f4251b", + "unfilled_bar": "#CCCCCC" + } + } +} \ No newline at end of file diff --git a/game/game.py b/game/game.py new file mode 100644 index 0000000..79eeec1 --- /dev/null +++ b/game/game.py @@ -0,0 +1,40 @@ +import pygame as pg +import pygame_gui +from constants import Config + +class Game(): + def __init__(self, screen, clock, manager): + self.screen = screen + self.clock = clock + self.manager = manager + self.fps_label = pygame_gui.elements.UILabel( + relative_rect=pg.Rect((10, 10), (120, 40)), + text="FPS: 0", + manager=self.manager + ) + + def run(self): + self.running = True + while self.running: + self.clock.tick(Config.FPS) + self.update() + self.draw() + return self.running + + def update(self): + fps = str(int(self.clock.get_fps())) + self.fps_label.set_text('fps: ' + fps) + + for event in pg.event.get(): + if event.type == pg.QUIT: + self.running = False + + self.manager.process_events(event) + + time_delta = self.clock.tick(Config.FPS)/1000.0 + self.manager.update(time_delta) + + def draw(self): + self.screen.fill(self.manager.get_theme().get_colour('normal_bg')) + self.manager.draw_ui(self.screen) + pg.display.update() \ No newline at end of file diff --git a/game/player.py b/game/player.py new file mode 100644 index 0000000..e69de29 diff --git a/main.py b/main.py new file mode 100644 index 0000000..64c1f95 --- /dev/null +++ b/main.py @@ -0,0 +1,29 @@ +import pygame as pg +import pygame_gui + +from constants import Config +from game.game import Game + +def main(): + + running = True + + pg.init() + # pygame.mixer.init() + pg.display.set_caption('Portal') + screen = pg.display.set_mode(Config.WINDOW_SIZE) + manager = pygame_gui.UIManager(Config.WINDOW_SIZE, theme_path="data/theme/theme.json") + + clock = pg.time.Clock() + + # implement game + game = Game(screen, clock, manager) + + while running: + + running = game.run() + + pg.quit() + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..d177e2d Binary files /dev/null and b/requirements.txt differ