trying a new template indisn guy

This commit is contained in:
Stephen Deaton 2024-07-03 17:42:42 -04:00
parent 4c9336cd3b
commit 721f2939e2
6 changed files with 182 additions and 25 deletions

View File

@ -0,0 +1,32 @@
import pygame
pygame.init()
SCREEN_WIDTH = 800
SCREEN_HEIGTH = 600
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGTH))
player = pygame.Rect((300,250,50,50))
run = True
while run:
screen.fill((0, 0, 0))
pygame.draw.rect(screen, (255, 0, 0), player)
key = pygame.key.get_pressed()
if key[pygame.K_a] == True:
player.move_ip(-1, 0)
elif key[pygame.K_d] == True:
player.move_ip(1, 0)
elif key[pygame.K_w] == True:
player.move_ip(0, -1)
elif key[pygame.K_s] == True:
player.move_ip(0, 1)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.display.update()
pygame.quit()

View File

@ -0,0 +1,56 @@
import pygame
import random
import os
WIDTH = 360
HEIGHT = 480
WINDOW_SIZE = (WIDTH, HEIGHT)
FPS = 30
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
class Player(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.surface((50, 50))
self.image.fill(GREEN)
self.rect = self.image.get_rect()
self.rect.center = (WIDTH /2, HEIGHT /2)
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode(WINDOW_SIZE)
pygame.display.set_caption("My Game")
clock = pygame.time.Clock()
all_sprites = pygame.sprite.group()
player = Player()
all_sprites.add(player)
running = True
while running:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
all_sprites.update()
screen.fill(BLACK)
all_sprites.draw(screen)
pygame.display.flip()
pygame.quit()

View File

@ -1,8 +1,11 @@
import pygame
import random
import os
WIDTH = 360
HEIGHT = 480
WINDOW_SIZE = (WIDTH, HEIGHT)
FPS = 30
WHITE = (255, 255, 255)
@ -13,10 +16,10 @@ BLUE = (0, 0, 255)
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode(360, 480)
screen = pygame.display.set_mode(WINDOW_SIZE)
pygame.display.set_caption("My Game")
clock = pygame.time.Clock()
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
running = True
while running:
clock.tick(FPS)
@ -28,5 +31,5 @@ while running:
pygame.QUIT()
pygame.quit()

View File

@ -1,4 +1,33 @@
{
"title": "The Portents of Doom",
"description": "You have ventured into blah blah blah..."
"description": "You have ventured into blah blah blah...",
"rooms": [
{
"id": 0,
"name": "The Starting Room" ,
"discription": "The room is made up of stones worn smoth from age. It is 20 fett by 20 feet big.",
"action":"You awakin laying on the floor, there is a door on the North wall and on the East Wall",
"player": "What door do you choose.",
"directions": {"North": 2, "East": 1}
},
{
"id": 1,
"name" : "Second Room" ,
"discription" : "This room is boring as taxes.",
"action" :"You sell your soul to the devil",
"player" : "What door do you choose.",
"directions": {"West": 0}
},
{
"id": 2,
"name" : "Third Room" ,
"discription" : "This room is boring as taxes.",
"action" :"You sell your soul to the devil",
"player" : "What door do you choose.",
"directions": {"South": 0}
}
]
}

View File

@ -1,26 +1,64 @@
import json
import os
import sys
from pathlib import Path
from typing import List, Dict, Tuple
def game():
MAPDATA_FILE = os.path.join("mapdata.json")
VALID_DIRECTIONS = {
"n": "North",
"s": "South",
"e": "East",
"w": "West"
}
answer=input('Would you like to play a game?(y/n)')
mapdata_raw = Path(MAPDATA_FILE).read_text()
mapdata = json.loads(mapdata_raw)
if answer.lower() =='y':
print('Welcome to the Adventure')
start = True
inventory = []
def get_room(data, room_id) -> Dict:
for room in data["rooms"]:
if room["id"] == room_id:
return room
else:
answer = input('Would you like to play a game?(y/n)')
if answer.lower() == 'n':
print( 'Ok Maybe Some other time' )
sys.exit()
print('Welcome to the Adventure')
start = True
inventory = []
player_room = 0
name = input("Enter Your Name : ")
print("Greetings, " + name + "\n###Let's Start the Game###")
print("""\nAs you slowly regained consciousness, you found yourself in a strange room bathed in an eerie glow.
There are three imposing doors, each beckoning you towards a different path.
Which door would you choose---1, 2 or 3???""")
#print("""\nAs you slowly regained consciousness, you found yourself in a strange room bathed in an eerie glow.
#There are three imposing doors, each beckoning you towards a different path.
#Which door would you choose---1, 2 or 3???""")
current_room_data = get_room(mapdata, player_room)
print(f"You wake up in {current_room_data['name']}")
print(f"\n{current_room_data['discription']}")
print(f"{current_room_data['action']}")
print(f"\n{current_room_data['player']}")
door = ""
while door not in current_room_data["directions"].keys():
print("Available directions to travel: ", end='')
for direction, room_id in current_room_data['directions'].items():
print(f" {direction}", end='')
print()
door = input(">")
door = door.lower()[0:1]
if door not in VALID_DIRECTIONS.keys():
print(" You bump into a wall of your own incompetence.")
door = ""
else:
door = VALID_DIRECTIONS[door]
player_room = current_room_data["directions"][VALID_DIRECTIONS[door.lower()[0:1]]]
current_room_data = get_room(mapdata, player_room)
door = input(">")
if(door == "1"):
print("You entered the First room and through time travelling you found yourself in a an ancient Battle")
@ -82,4 +120,3 @@ if (door == "3"):
else:
print("Type a Number!!!\nGAME OVER\nPLEASE RESTART the GAME")
game()

View File

@ -6,13 +6,13 @@ if sys.platform == "win32":
just_fix_windows_console()
from colorama import Fore, Back, Style
from termcolor import colored, cprint
#GLOBAL variables all caps becasue they are static and do not change.
# GLOBAL variables all caps becasue they are static and do not change.
MAX_LINES = 3
MAX_BET = 100
MIN_BET = 1
ROWS = 3
COLS = 3
#The list of sybmbols used in the slot machine.
# The list of sybmbols used in the slot machine.
SYMBOL_COUNT = {
"A": 2,
"B": 4,
@ -24,7 +24,7 @@ SYMBOL_COUNT = {
"\u16d4": 2,
"\u16f8": 2
}
#The value when calculating bets of sybmbols used in the slot machine.
# The value when calculating bets of sybmbols used in the slot machine.
SYMBOL_VALUE = {
"A": 5,
"B": 4,
@ -36,7 +36,7 @@ SYMBOL_VALUE = {
"\u16d4": 5,
"\u16f8": 5
}
#The list of sybmbol colors used used in the slot machine.
# The list of sybmbol colors used used in the slot machine.
SYMBOL_COLORS = {
"A": Fore.CYAN,
"B": Fore.GREEN,
@ -82,7 +82,7 @@ def get_slot_machine_spin() -> List:
column.append(value)
columns.append(column)
return columns
#This function shows the rows and cloumns in a display like a real machine.
# This function shows the rows and cloumns in a display like a real machine.
def print_slotmachine(columns: List):
for row in range(ROWS):
for index, column in enumerate(columns):
@ -107,7 +107,7 @@ def deposit() -> int:
else:
print(Fore.RED + " Error: Please enter a number" + Fore.RESET)
return amount
#This function asks the user how many rows are they betting on 1 to 3
# This function asks the user how many rows are they betting on 1 to 3
def get_number_of_lines() -> int:
"""
This function asks for how many rows they want to bet on.
@ -124,7 +124,7 @@ def get_number_of_lines() -> int:
print(" Error: Please enter a number")
return lines
#This function asks the user how much they want to bet on each line.
# This function asks the user how much they want to bet on each line.
def get_bet() -> int:
"""
THis function asks the user how much they want to bet per row.