From 9d12890ee3df51e5a5f1fd1851d907a5a0e9b4f3 Mon Sep 17 00:00:00 2001 From: Stephen Deaton <sdeaton@jaj.com> Date: Fri, 14 Jun 2024 17:37:24 -0400 Subject: [PATCH] Menu Pracitce commit pymenu --- PyGame/dieproj/dice_in_window.py | 33 +++++++++++++++++++++++++++++++++ PyGame/practice/prac.py | 31 +++++++++++++++++++++++++++++++ Python/Examples/dice.py | 13 ++++++++----- 3 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 PyGame/dieproj/dice_in_window.py create mode 100644 PyGame/practice/prac.py diff --git a/PyGame/dieproj/dice_in_window.py b/PyGame/dieproj/dice_in_window.py new file mode 100644 index 0000000..6d90fa9 --- /dev/null +++ b/PyGame/dieproj/dice_in_window.py @@ -0,0 +1,33 @@ +import random +import pygame +import pygame_gui +import sys + +pygame.init() + +pygame.display.set_caption('Dice Roll') + +window_surface = pygame.display.set_mode((800, 600)) + +background = pygame.Surface((800, 600)) + +background.fill(pygame.Color('#009900')) + +manager = pygame_gui.UIManager((800, 600)) + +is_running = True + +while is_running: + + + for event in pygame.event.get(): + + if event.type == pygame.QUIT: + + is_running = False + + + window_surface.blit(background, (0, 0)) + + + pygame.display.update() diff --git a/PyGame/practice/prac.py b/PyGame/practice/prac.py new file mode 100644 index 0000000..5445a92 --- /dev/null +++ b/PyGame/practice/prac.py @@ -0,0 +1,31 @@ +import pygame +import pygame_menu +pygame.init() + +screen_width = 800 +screen_height = 600 + +screen = pygame.display.set_mode((screen_width, screen_height)) +color = (128, 128, 128) +screen.fill(color) + +pygame.display.set_caption('Dice Roll') +clock = pygame.time.Clock() + +def set_number_dice(value: str, die_number: int): + # Do the job here ! + pass +def set_dice_sides(value: str, sides: int): + # Do the job here ! + pass + + + +run = True +while run == True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + run = False + pygame.display.flip() + clock.tick(60) +pygame.quit() \ No newline at end of file diff --git a/Python/Examples/dice.py b/Python/Examples/dice.py index 5e14e6d..8353f70 100644 --- a/Python/Examples/dice.py +++ b/Python/Examples/dice.py @@ -1,14 +1,17 @@ import json import random +import pygame from pathlib import Path from typing import List from Rooms import Room -my_rooms = [] -raw_room_data = Path('room_data.json').read_text() -room_data = json.loads(raw_room_data) -for room in room_data: - my_rooms.append(Room(room['grid_col'], room['grid_row'], room['name'], room['description'], room['dark'])) + +background_colour = (0, 76, 153) +screen = pygame.display.set_mode((400, 300)) +pygame.display.set_caption('Dice Rolling') +screen.fill(background_colour) +pygame.display.flip() +running = True dice = ["1", "2",] sides = ["4", "6", "8", "10", "12", "20"]