Skip to content

Commit ecc66df

Browse files
committed
Joshua Levy
1 parent 493cb3b commit ecc66df

File tree

4 files changed

+186
-0
lines changed

4 files changed

+186
-0
lines changed

List Diary Subroutine.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import os, time
2+
DailyDiary = []
3+
print("**** Welcome to Joshua's Daily Scheduler ****")
4+
print()
5+
6+
7+
def dailyroutine():
8+
print()
9+
for schedule in DailyDiary:
10+
print(schedule)
11+
print()
12+
while True:
13+
menu = input("view, add or edit: ")
14+
if menu == "add":
15+
schedule = input("What is on the agenda?: ")
16+
DailyDiary.append(schedule)
17+
elif menu == "edit":
18+
schedule = input("Which agenda you would like to edit?: ")
19+
DailyDiary.remove(schedule)
20+
elif menu == "view":
21+
print("******** Your Agenda so far ********")
22+
print()
23+
dailyroutine()
24+
dailyroutine()

Pygame menu.py

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
"""
2+
Importing important libraries
3+
"""
4+
import pygame, sys
5+
6+
"""
7+
Setting up an environment to initialize pygame
8+
"""
9+
mainClock = pygame.time.Clock()
10+
from pygame.locals import *
11+
12+
pygame.init()
13+
pygame.display.set_caption('game base')
14+
screen = pygame.display.set_mode((600, 300), 0, 32)
15+
16+
# setting font settings
17+
font = pygame.font.SysFont(None, 30)
18+
19+
"""
20+
A function that can be used to write text on our screen and buttons
21+
"""
22+
23+
24+
def draw_text(text, font, color, surface, x, y):
25+
textobj = font.render(text, 1, color)
26+
textrect = textobj.get_rect()
27+
textrect.topleft = (x, y)
28+
surface.blit(textobj, textrect)
29+
30+
31+
# A variable to check for the status later
32+
click = False
33+
34+
35+
# Main container function that holds the buttons and game functions
36+
def main_menu():
37+
while True:
38+
39+
screen.fill((0, 190, 255))
40+
draw_text('Main Menu', font, (0, 0, 0), screen, 250, 40)
41+
42+
mx, my = pygame.mouse.get_pos()
43+
44+
# creating buttons
45+
button_1 = pygame.Rect(200, 100, 200, 50)
46+
button_2 = pygame.Rect(200, 180, 200, 50)
47+
48+
# defining functions when a certain button is pressed
49+
if button_1.collidepoint((mx, my)):
50+
if click:
51+
game()
52+
if button_2.collidepoint((mx, my)):
53+
if click:
54+
options()
55+
pygame.draw.rect(screen, (255, 0, 0), button_1)
56+
pygame.draw.rect(screen, (255, 0, 0), button_2)
57+
58+
# writing text on top of button
59+
draw_text('PLAY', font, (255, 255, 255), screen, 270, 115)
60+
draw_text('OPTIONS', font, (255, 255, 255), screen, 250, 195)
61+
62+
click = False
63+
for event in pygame.event.get():
64+
if event.type == QUIT:
65+
pygame.quit()
66+
sys.exit()
67+
if event.type == KEYDOWN:
68+
if event.key == K_ESCAPE:
69+
pygame.quit()
70+
sys.exit()
71+
if event.type == MOUSEBUTTONDOWN:
72+
if event.button == 1:
73+
click = True
74+
75+
pygame.display.update()
76+
mainClock.tick(60)
77+
78+
79+
"""
80+
This function is called when the "PLAY" button is clicked.
81+
"""
82+
83+
84+
def game():
85+
running = True
86+
while running:
87+
screen.fill((0, 0, 0))
88+
89+
draw_text('GAME SCREEN', font, (255, 255, 255), screen, 20, 20)
90+
for event in pygame.event.get():
91+
if event.type == QUIT:
92+
pygame.quit()
93+
sys.exit()
94+
if event.type == KEYDOWN:
95+
if event.key == K_ESCAPE:
96+
running = False
97+
98+
pygame.display.update()
99+
mainClock.tick(60)
100+
101+
102+
"""
103+
This function is called when the "OPTIONS" button is clicked.
104+
"""
105+
106+
107+
def options():
108+
running = True
109+
while running:
110+
screen.fill((0, 0, 0))
111+
112+
draw_text('OPTIONS SCREEN', font, (255, 255, 255), screen, 20, 20)
113+
for event in pygame.event.get():
114+
if event.type == QUIT:
115+
pygame.quit()
116+
sys.exit()
117+
if event.type == KEYDOWN:
118+
if event.key == K_ESCAPE:
119+
running = False
120+
121+
pygame.display.update()
122+
mainClock.tick(60)
123+
124+
125+
main_menu()

Pygame test.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Simple pygame program
2+
3+
# Import and initialize the pygame library
4+
import pygame
5+
pygame.init()
6+
7+
# Set up the drawing window
8+
screen = pygame.display.set_mode([500, 500])
9+
10+
# Run until the user asks to quit
11+
running = True
12+
while running:
13+
14+
# Did the user click the window close button?
15+
for event in pygame.event.get():
16+
if event.type == pygame.QUIT:
17+
running = False
18+
19+
# Fill the background with white
20+
screen.fill((255, 255, 255))
21+
22+
# Draw a solid blue circle in the center
23+
pygame.draw.circle(screen, (0, 0, 255), (250, 250), 75)
24+
25+
# Flip the display
26+
pygame.display.flip()
27+
28+
# Done! Time to quit.
29+
pygame.quit()

Triangle nested loop.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
n=5
2+
for rows in range(n):
3+
for space in range(rows,n):
4+
print(" ", end=' ')
5+
for space in range(rows+1):
6+
print("*",end=" ")
7+
print()
8+

0 commit comments

Comments
 (0)