My Pygame Game Engine
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Started work on ui quick commit to laptop

WillM 1ec3e2b8 fb8a244d

+45 -10
src/scripts/__pycache__/__init__.cpython-39.pyc

This is a binary file and will not be displayed.

src/scripts/__pycache__/game_manager.cpython-39.pyc

This is a binary file and will not be displayed.

src/scripts/modules/__pycache__/colors.cpython-39.pyc

This is a binary file and will not be displayed.

src/scripts/modules/__pycache__/debug.cpython-39.pyc

This is a binary file and will not be displayed.

src/scripts/modules/__pycache__/fonts.cpython-39.pyc

This is a binary file and will not be displayed.

src/scripts/modules/__pycache__/gui.cpython-39.pyc

This is a binary file and will not be displayed.

src/scripts/modules/__pycache__/image.cpython-39.pyc

This is a binary file and will not be displayed.

src/scripts/modules/__pycache__/input.cpython-39.pyc

This is a binary file and will not be displayed.

src/scripts/modules/__pycache__/language.cpython-39.pyc

This is a binary file and will not be displayed.

src/scripts/modules/__pycache__/math_utils.cpython-39.pyc

This is a binary file and will not be displayed.

src/scripts/modules/__pycache__/renderer.cpython-39.pyc

This is a binary file and will not be displayed.

src/scripts/modules/__pycache__/sound.cpython-39.pyc

This is a binary file and will not be displayed.

+2 -1
src/scripts/modules/gui.py
··· 294 294 295 295 self.hover = False 296 296 self.toggled = False 297 + self.input_state = "" 297 298 298 299 def update(self): 299 300 self.rect.update() ··· 302 303 else: 303 304 self.hover = False 304 305 305 - if self.hover and self.game.input.is_mouse_button_just_pressed(): 306 + if self.hover and self.game.input.is_mouse_button_just_pressed(self.input_state): 306 307 self.toggled = not self.toggled 307 308 308 309 def render(self):
+10 -4
src/scripts/modules/input.py
··· 89 89 90 90 ## Returns if mb_left is pressed 91 91 92 - def is_mouse_button_pressed(self): 93 - return pygame.mouse.get_pressed()[0] 92 + def is_mouse_button_pressed(self, input_state=""): 93 + if input_state == "": 94 + return pygame.mouse.get_pressed()[0] 95 + else: 96 + return pygame.mouse.get_pressed()[0] and self.input_state == input_state 94 97 95 98 ## Returns if mb_left was pressed this frame 96 99 97 - def is_mouse_button_just_pressed(self): 98 - return pygame.mouse.get_pressed()[0] and not self.mouse_button_last_frame 100 + def is_mouse_button_just_pressed(self, input_state=""): 101 + if input_state == "": 102 + return pygame.mouse.get_pressed()[0] and not self.mouse_button_last_frame 103 + else: 104 + return pygame.mouse.get_pressed()[0] and not self.mouse_button_last_frame and self.input_state == input_state
src/scripts/screens/__pycache__/__init__.cpython-39.pyc

This is a binary file and will not be displayed.

src/scripts/screens/__pycache__/engine_main_screen.cpython-39.pyc

This is a binary file and will not be displayed.

+33 -5
src/scripts/screens/engine_main_screen.py
··· 22 22 self.top_panel.set_color(self.game.color_handler.get_rgb('engine.background_alt'), 2) 23 23 24 24 self.bottom_panel = gui_rect(game) 25 - self.bottom_panel.set_pos(percentage_constraint(0.221), percentage_constraint(0.598), 1) 26 - self.bottom_panel.set_size(percentage_constraint(0.56), percentage_constraint(0.4), 1) 25 + self.bottom_panel.set_pos(percentage_constraint(0.22), percentage_constraint(0.595), 1) 26 + self.bottom_panel.set_size(percentage_constraint(0.56), percentage_constraint(0.4375), 1) 27 27 self.bottom_panel.set_color(self.game.color_handler.get_rgb('engine.background_alt'), 2) 28 28 29 29 self.screen_panel = gui_rect(game) 30 - self.screen_panel.set_pos(percentage_constraint(0.221), pixel_constraint(26), 2) 30 + self.screen_panel.set_pos(percentage_constraint(0.22), pixel_constraint(26), 2) 31 31 self.screen_panel.set_size(aspect_constraint(1.7777), percentage_constraint(0.56), 2) 32 32 self.screen_panel.set_color((255, 0, 0), 2) 33 33 34 - self.add_asset_button = gui_press_button(game) 34 + self.add_asset_button = gui_toggle_button(game) 35 35 self.add_asset_button.rect.parent = self.bottom_panel 36 36 self.add_asset_button.rect.set_pos(pixel_constraint(5), pixel_constraint(5), 2) 37 37 self.add_asset_button.rect.set_size(pixel_constraint(30), pixel_constraint(30), 5) 38 38 self.add_asset_button.rect.visible = False 39 + self.add_asset_button.input_state = "general" 39 40 40 41 self.add_asset_button_1 = gui_rect(game) 41 42 self.add_asset_button_1.parent = self.add_asset_button.rect 42 43 self.add_asset_button_1.set_pos(center_constraint(), center_constraint(), 2) 43 44 self.add_asset_button_1.set_size(percentage_constraint(1), percentage_constraint(0.2), 2) 44 45 self.add_asset_button_1.set_border_radius(10) 46 + self.add_asset_button_1.set_color((200, 200, 200), 1) 45 47 46 48 self.add_asset_button_2 = gui_rect(game) 47 49 self.add_asset_button_2.parent = self.add_asset_button.rect 48 50 self.add_asset_button_2.set_pos(center_constraint(), center_constraint(), 2) 49 51 self.add_asset_button_2.set_size(percentage_constraint(0.2), percentage_constraint(1), 2) 50 52 self.add_asset_button_2.set_border_radius(10) 53 + self.add_asset_button_2.set_color((200, 200, 200), 1) 54 + 55 + self.add_asset = gui_rect(game) 56 + self.add_asset.set_pos(percentage_constraint(0.3), percentage_constraint(1), 1) 57 + self.add_asset.set_size(percentage_constraint(0.2), percentage_constraint(0.6), 1) 58 + self.add_asset.set_color(self.game.color_handler.get_rgb('engine.background'), 1) 59 + self.add_asset.set_border_radius(10) 51 60 52 61 def update(self): 62 + self.add_asset.set_pos(percentage_constraint(0.3), (percentage_constraint(1)), 6) 63 + self.add_asset_button_1.set_color((200, 200, 200), 12) 64 + self.add_asset_button_2.set_color((200, 200, 200), 12) 65 + if self.add_asset_button.hover: 66 + self.add_asset_button_1.set_color((100, 100, 100), 6) 67 + self.add_asset_button_2.set_color((100, 100, 100), 6) 68 + 69 + if self.add_asset_button.toggled: 70 + self.add_asset_button_1.set_color((100, 100, 100), 6) 71 + self.add_asset_button_2.set_color((100, 100, 100), 6) 72 + self.add_asset.set_pos(percentage_constraint(0.3), (percentage_constraint(0.5)), 6) 73 + self.game.input.set_input_state("asset_pack_change") 74 + if not self.add_asset.is_touching_mouse() and self.game.input.is_mouse_button_just_pressed(): 75 + self.add_asset_button.toggled = False 76 + self.game.input.set_input_state("general") 77 + 53 78 self.right_panel.update() 54 79 self.left_panel.update() 55 80 self.top_panel.update() ··· 58 83 self.add_asset_button.update() 59 84 self.add_asset_button_1.update() 60 85 self.add_asset_button_2.update() 86 + self.add_asset.update() 61 87 62 88 def render(self): 89 + self.game.renderer.main_surface.fill((0, 0, 0)) 63 90 self.right_panel.render() 64 91 self.left_panel.render() 65 92 self.top_panel.render() ··· 67 94 self.screen_panel.render() 68 95 self.add_asset_button.render() 69 96 self.add_asset_button_1.render() 70 - self.add_asset_button_2.render() 97 + self.add_asset_button_2.render() 98 + self.add_asset.render()