Skip to content

Commit

Permalink
Merge pull request #20 from candycane124/newGUI
Browse files Browse the repository at this point in the history
NewGUI to main
  • Loading branch information
BambooShi authored Jun 1, 2023
2 parents 9c2d747 + 43e2116 commit 244a2a2
Show file tree
Hide file tree
Showing 26 changed files with 87 additions and 76 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ Built with python using pygame and tkinter.

## Credits
Developed by: Angela Huang, Alina Huan, Snow Shi

Last Updated: 30 May 2023
72 changes: 36 additions & 36 deletions game/STS_b2.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ def startLevel(level, controller):
#'r' to reset
user.setPos([spawnX,spawnY])
score = 0
money = 0
sacked = 0
sprint = 1000
timer = 0
Expand Down Expand Up @@ -347,33 +346,34 @@ def startLevel(level, controller):
# CHARACTER MOVEMENT
# ------------------
pressed = pygame.key.get_pressed()
if pressed[K_RIGHT] or pressed[K_d]:
faceRight = True
stop = False
user.moveRight()
if pressed[K_LEFT] or pressed[K_a]:
faceRight = False
stop = False
user.moveLeft()
if pressed[K_DOWN] or pressed[K_s]:
stop = False
user.moveDown()
if pressed[K_UP] or pressed[K_w]:
stop= False
user.moveUp()
if pressed[K_LSHIFT] and sprint > 0:
user.setSpeed(sprintSpeed*dt)
sprint -= 5
stop = False
else:
user.setSpeed(walkSpeed*dt)
if pressed[K_h]:
user.setSpeed(2)
sackMax = 3
if not pressed[K_RIGHT] and not pressed[K_d] and not pressed[K_LEFT] and not pressed[K_a] and not pressed[K_DOWN] and not pressed[K_s] and not pressed[K_UP] and not pressed[K_w]:
stop = True
if sprint < 1000:
sprint += sprintGen*dt
if lifeStatus != False:
if pressed[K_RIGHT] or pressed[K_d]:
faceRight = True
stop = False
user.moveRight()
if pressed[K_LEFT] or pressed[K_a]:
faceRight = False
stop = False
user.moveLeft()
if pressed[K_DOWN] or pressed[K_s]:
stop = False
user.moveDown()
if pressed[K_UP] or pressed[K_w]:
stop= False
user.moveUp()
if pressed[K_LSHIFT] and sprint > 0:
user.setSpeed(sprintSpeed*dt)
sprint -= 5
stop = False
else:
user.setSpeed(walkSpeed*dt)
if pressed[K_h]:
user.setSpeed(2)
sackMax = 3
if not pressed[K_RIGHT] and not pressed[K_d] and not pressed[K_LEFT] and not pressed[K_a] and not pressed[K_DOWN] and not pressed[K_s] and not pressed[K_UP] and not pressed[K_w]:
stop = True
if sprint < 1000:
sprint += sprintGen*dt

#win conditions
if not sheeps and home:
Expand Down Expand Up @@ -628,27 +628,27 @@ def startLevel(level, controller):
genText(screen,"Score: " + str(score), (0,0,0), [300,250], "middle")
match level:
case 1:
if score >= 442:
if score >= 450:
stars = 3
elif score >= 428:
elif score >= 400:
stars = 2
elif score >= 410:
elif score >= 350:
stars = 1
else:
stars = 0
case 2:
if score >= 500:
if score >= 400:
stars = 3
elif score >= 390:
elif score >= 350:
stars = 2
elif score >= 290:
elif score >= 300:
stars = 1
else:
stars = 0
case 3:
if score >= 500:
if score >= 450:
stars = 3
elif score >= 350:
elif score >= 325:
stars = 2
elif score >= 250:
stars = 1
Expand Down
Binary file modified game/__pycache__/STS_b2.cpython-310.pyc
Binary file not shown.
Binary file modified game/__pycache__/animate.cpython-310.pyc
Binary file not shown.
Binary file modified game/__pycache__/scores.cpython-310.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion game/animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __init__(self, key):
self.imageList = self.imageDict[self.key]
self.imageIndex = 0
self.animationTimer = 0
self.animationSpeed = 40 #slightly adjusted for Snow's laptop (initial was 10)
self.animationSpeed = 30 #slightly adjusted for Snow's laptop (initial was 10)
def update(self):
self.animationTimer +=1
if self.animationTimer >= self.animationSpeed:
Expand Down
10 changes: 9 additions & 1 deletion game/backup_text/reset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
def reset(x):
'''
Resets all information to initial condition.
Parameters
----------
x: boolean
True or False; Run if true
'''
with open('game/backup_text/stats_backup.txt','r') as statsFile:
stats = statsFile.readlines()
with open('game/stats.txt','w') as textFile:
Expand All @@ -23,4 +31,4 @@ def reset(x):
textFile.write(blankScores)
with open('game/scores/lvl3.txt','w') as textFile:
textFile.write(blankScores)
reset(True)
reset(False)
2 changes: 1 addition & 1 deletion game/backup_text/shop_items_backup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ assets/shop/shoe_leather.png,False,60,60,110,308,1,Speedy Spurs: Slightly increa
assets/shop/shoe_gold.png,False,60,60,260,308,2,Golden Clogs: Increases walking & running speed,1,0.055
assets/shop/shoe_dia.png,False,60,60,220,382,3,Shiny Sneakers: Greatly increases walking & running speed,1,0.075
assets/shop/pot_I.png,True,27,45,460,276,1,Magic Mana Potion I: Improves sprint regeneration,4,0.1
assets/shop/pot_II.png,True,36,60,460,211,2,Magic Mana Potion II: Greatly improves sprint regeneration,4,0.2
assets/shop/pot_II.png,True,36,60,460,211,2,Magic Mana Potion II: Greatly improves sprint regeneration,4,0.15
2 changes: 2 additions & 0 deletions game/scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def highScore(controller):
white = (250,250,250)
gray = (20,100,20)
running = True
pygame.mouse.set_visible(True)
pygame.mouse.set_cursor(*pygame.cursors.arrow)
while running:
for event in pygame.event.get():
if event.type == QUIT:
Expand Down
4 changes: 2 additions & 2 deletions game/scores/lvl1.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
453 0 0 0 0
candy - - - -
453 427 409 376 332
candy ANON angela upgrade one
4 changes: 2 additions & 2 deletions game/scores/lvl2.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
360 317 315 0 0
udar bamboo EDWard - -
511 371 360 317 212
ang WALT udar bamboo two
4 changes: 2 additions & 2 deletions game/scores/lvl3.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
319 254 0 0 0
anon box - - -
554 319 295 254 199
candycan anon phew box tree
42 changes: 22 additions & 20 deletions game/shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ def shop(controller):
raw.append(i)
itemData = i.split(",")
shop.append(Item(itemData[0],itemData[1]=="True",(int(itemData[2]),int(itemData[3])),(int(itemData[4]),int(itemData[5])),int(itemData[6]),itemData[7],[int(itemData[8]),float(itemData[9])]))

# shop = [
# Item("assets/shop/sack.png",False,(70,70),(120,210),3,"Better Sack: Carry up to 2 sheeps at a time!",[3,1]),
# Item("assets/shop/shoe.png",False,(78,64),(220,310),2,"Speedy Spurs: Increases your walking and running speed!",[1,0.1]),
# Item("assets/shop/temp_pot.png",True,(60,60),(410,230),2,"Magic Mana: Improve your sprint regeneration!",[4,0.5])
# ]

#back
backPos = 15
Expand Down Expand Up @@ -117,20 +111,28 @@ def shop(controller):
currentCursor = grabImg
genText(screen,str(i.cost) + " coin(s) | " + i.description,black,(490,10),"bottom-left",12)
if pygame.mouse.get_pressed()[0]:
if info[2] >= i.cost:
info[2] -= i.cost
raw.pop(shop.index(i))
shop.remove(i)
info[i.ability[0]] = i.ability[1]
with open('game\stats.txt','w') as outFile:
newStats = ""
for j in info:
newStats += str(j)
# if j != info[-1]:
newStats += " "
newStats += "\nlevel walkSpeed money sackMax sprintGen"
outFile.write(newStats)
buyTimer = True
if str(i) == "Golden Clogs: Increases walking & running speed, costs 2 and results in [1, 0.055]" and str(shop[1]) == "Speedy Spurs: Slightly increases walking & running speed, costs 1 and results in [1, 0.04]":
genText(screen, "Purchase Speedy Spurs first!",black,(150,250),"middle",24)
elif str(i) == "Shiny Sneakers: Greatly increases walking & running speed, costs 3 and results in [1, 0.075]" and str(shop[1]) == "Speedy Spurs: Slightly increases walking & running speed, costs 1 and results in [1, 0.04]":
genText(screen, "Purchase Speedy Spurs first!",black,(150,250),"middle",24)
elif str(i) == "Shiny Sneakers: Greatly increases walking & running speed, costs 3 and results in [1, 0.075]" and str(shop[1]) == "Golden Clogs: Increases walking & running speed, costs 2 and results in [1, 0.055]":
genText(screen, "Purchase Golden Clogs first!",black,(150,250),"middle",24)
elif str(i) == "Magic Mana Potion II: Greatly improves sprint regeneration, costs 2 and results in [4, 0.15]" and str(shop[4]) == "Magic Mana Potion I: Improves sprint regeneration, costs 1 and results in [4, 0.1]":
genText(screen, "Purchase Magic Mana Potion I first!",black,(150,250),"middle",24)
elif info[2] >= i.cost:
info[2] -= i.cost
raw.pop(shop.index(i))
shop.remove(i)
info[i.ability[0]] = i.ability[1]
with open('game\stats.txt','w') as outFile:
newStats = ""
for j in info:
newStats += str(j)
# if j != info[-1]:
newStats += " "
newStats += "\nlevel walkSpeed money sackMax sprintGen"
outFile.write(newStats)
buyTimer = True
else:
errTimer = True
screen.blit(i.image, i.rect)
Expand Down
2 changes: 1 addition & 1 deletion game/shop_items.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ assets/shop/shoe_leather.png,False,60,60,110,308,1,Speedy Spurs: Slightly increa
assets/shop/shoe_gold.png,False,60,60,260,308,2,Golden Clogs: Increases walking & running speed,1,0.055
assets/shop/shoe_dia.png,False,60,60,220,382,3,Shiny Sneakers: Greatly increases walking & running speed,1,0.075
assets/shop/pot_I.png,True,27,45,460,276,1,Magic Mana Potion I: Improves sprint regeneration,4,0.1
assets/shop/pot_II.png,True,36,60,460,211,2,Magic Mana Potion II: Greatly improves sprint regeneration,4,0.2
assets/shop/pot_II.png,True,36,60,460,211,2,Magic Mana Potion II: Greatly improves sprint regeneration,4,0.15
2 changes: 1 addition & 1 deletion game/stats.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
2.0 0.03 2 1.0 0.05
1.0 0.03 0.0 1.0 0.05
level walkSpeed money sackMax sprintGen
2 changes: 0 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from menu_PYTHON.menu import Menu
from game.STS_b2 import *

# from main.shop import shop

class App(tk.Tk):
'''
A class that creates the base for the menu screen, able to switch between frames easier
Expand Down
Binary file modified menu_PYTHON/__pycache__/levels.cpython-310.pyc
Binary file not shown.
Binary file modified menu_PYTHON/__pycache__/menu.cpython-310.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions menu_PYTHON/levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ def __init__(self, parent, controller):
helv36 = tkFont.Font(family='Helvetica', size=18, weight='bold')

#Background
img = ImageTk.PhotoImage(Image.open('assets/grass-588.jpg'))
img = ImageTk.PhotoImage(Image.open('menu_PYTHON/menuAssets/background-grass.png'))
lbl = tk.Label(self, image=img)

lbl.image = img #keeping a reference, so the image will appear properly
# lbl.pack()
lbl.place(relx=0.5, rely=0.5, anchor="center") # Place label in center of parent.

#Title image
title = ImageTk.PhotoImage(Image.open('menu_PYTHON/menuAssets/LevelTemp.png'))
title = ImageTk.PhotoImage(Image.open('menu_PYTHON/menuAssets/screen-level.png'))
# title = ImageTk.PhotoImage(Image.open('menu_PYTHON/menuAssets/LevelSelectV2.png'))
labelTitle = tk.Label(self, image=title)

Expand Down
10 changes: 5 additions & 5 deletions menu_PYTHON/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ def __init__(self, parent, controller):
self.controller = controller

#Background
img = ImageTk.PhotoImage(Image.open('assets/grass-588.jpg'))
img = ImageTk.PhotoImage(Image.open('menu_PYTHON/menuAssets/background-grass.png'))
lbl = tk.Label(self, image=img)

lbl.image = img #keeping a reference, so the image will appear properly
# lbl.pack()
lbl.place(relx=0.5, rely=0.5, anchor="center") # Place label in center of parent.

#Title image
title = ImageTk.PhotoImage(Image.open('menu_PYTHON/menuAssets/titlePot.png'))
title = ImageTk.PhotoImage(Image.open('menu_PYTHON/menuAssets/screen-title.png'))
labelTitle = tk.Label(self, image=title)

labelTitle.image = title #keeping a reference, so the iamge shows up
# labelTitle.pack()
labelTitle.place(bordermode="inside", anchor="n", relx=0.5)

# Add Images to buttons
start_btn = tk.PhotoImage(file = "menu_PYTHON/menuAssets/potentialStart.png") #220 pi x 60 pi
shop_btn = tk.PhotoImage(file = "menu_PYTHON/menuAssets/settingsPot.png")
exit_btn = tk.PhotoImage(file = "menu_PYTHON/menuAssets/exitPot.png")
start_btn = tk.PhotoImage(file = "menu_PYTHON/menuAssets/button-play.png") #220 pi x 60 pi
shop_btn = tk.PhotoImage(file = "menu_PYTHON/menuAssets/button-shop.png")
exit_btn = tk.PhotoImage(file = "menu_PYTHON/menuAssets/button-exit.png")

style = ttk.Style()

Expand Down
Binary file added menu_PYTHON/menuAssets/background-grass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added menu_PYTHON/menuAssets/button-exit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added menu_PYTHON/menuAssets/button-play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added menu_PYTHON/menuAssets/button-shop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added menu_PYTHON/menuAssets/screen-level.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added menu_PYTHON/menuAssets/screen-title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 244a2a2

Please sign in to comment.