Making sandwich and checking if correct
This commit is contained in:
parent
09ba5f8edf
commit
85535c171e
2 changed files with 77 additions and 39 deletions
|
@ -14,23 +14,19 @@ class GamePlay:
|
|||
|
||||
def __init__(self, surface):
|
||||
self.surface = surface
|
||||
self.play_button = components.text_button("Switch", (250, 50), font=resources.FONT)
|
||||
self.ham_button = components.SurfaceButton(resources.SUB_TOMATO_SPRITE)
|
||||
self.tomato_button = components.SurfaceButton(resources.SUB_TOMATO_SPRITE)
|
||||
self.lettuce_button = components.SurfaceButton(resources.SUB_TOMATO_SPRITE)
|
||||
self.top_button = components.SurfaceButton(resources.SUB_TOMATO_SPRITE)
|
||||
self.switch_button = components.text_button("Switch", (250, 50), font=resources.FONT)
|
||||
self.serve_button = components.text_button("Serve", (250, 50), font=resources.FONT)
|
||||
self.ham_button = components.SurfaceButton(resources.SUB_HAM_SPRITE_3X)
|
||||
self.tomato_button = components.SurfaceButton(resources.SUB_TOMATO_SPRITE_3X)
|
||||
self.lettuce_button = components.SurfaceButton(resources.SUB_LETTUCE_SPRITE_3X)
|
||||
self.top_button = components.SurfaceButton(resources.SUB_TOP_SPRITE_3X)
|
||||
self.status = "Counter"
|
||||
self.newOrder = True
|
||||
self.sandwichmade = False
|
||||
self.correctsandwich = []
|
||||
self.madesandwich = ["bread"]
|
||||
|
||||
def sandwich(screen):
|
||||
fillings = ["lettuce", "ham", "tomatoes"]
|
||||
amountOfFilling = random.randrange(1,4)
|
||||
sandwich = ["bread"]
|
||||
for _ in range(amountOfFilling):
|
||||
filling = random.randrange(0,3)
|
||||
sandwich.append(fillings[filling])
|
||||
sandwich.append("bread")
|
||||
def displaysandwich(screen, sandwich):
|
||||
position = 200
|
||||
for i in sandwich:
|
||||
screen.blit(
|
||||
|
@ -39,43 +35,66 @@ class GamePlay:
|
|||
)
|
||||
position += 50
|
||||
|
||||
def do(self):
|
||||
#self.surface.blit(resources.SPLASH_SCREEN_IMAGE, (0, 0))
|
||||
#width = self.get_width()
|
||||
#height = self.get_height()
|
||||
#gap = 15
|
||||
#central_button_block = util.center_within(self.surface.get_size(), (250, (self.play_button.size[1] * 2) + gap))
|
||||
def sandwich(self, screen):
|
||||
fillings = ["lettuce", "ham", "tomatoes"]
|
||||
amountOfFilling = random.randrange(1,4)
|
||||
sandwich = ["bread"]
|
||||
for _ in range(amountOfFilling):
|
||||
filling = random.randrange(0,3)
|
||||
sandwich.append(fillings[filling])
|
||||
sandwich.append("bread")
|
||||
self.correctsandwich = sandwich
|
||||
GamePlay.displaysandwich(screen, sandwich)
|
||||
|
||||
|
||||
if self.play_button.blit_onto(self.surface, (1000, 10)):
|
||||
#status = "Food"
|
||||
def do(self):
|
||||
if self.switch_button.blit_onto(self.surface, (1000, 10)):
|
||||
if self.status == "Counter" and self.sandwichmade == False:
|
||||
self.surface.fill("blue")
|
||||
self.surface.blit(
|
||||
resources.FONT.render("Food", True, (0, 0, 0)),
|
||||
(100, 100),
|
||||
)
|
||||
self.surface.fill("lightgreen")
|
||||
self.status = "Food"
|
||||
self.surface.blit(resources.SUB_BOTTOM_SPRITE_10X, (300, 350))
|
||||
else:
|
||||
self.surface.fill("lightblue")
|
||||
|
||||
self.surface.blit(
|
||||
resources.FONT.render("Counter", True, (0, 0, 0)),
|
||||
(100, 100),
|
||||
)
|
||||
self.surface.blit(resources.COUNTER_SCREEN_IMAGE, (0, 0))
|
||||
self.status = "Counter"
|
||||
self.newOrder = True
|
||||
|
||||
if self.serve_button.blit_onto(self.surface, (10, 600)):
|
||||
self.surface.blit(resources.COUNTER_SCREEN_IMAGE, (0, 0))
|
||||
#serve
|
||||
print("serve")
|
||||
print(self.correctsandwich)
|
||||
print(self.madesandwich)
|
||||
if self.correctsandwich == self.madesandwich:
|
||||
self.surface.blit(
|
||||
resources.FONT.render("Correct!!", True, (0, 0, 0)),
|
||||
(10, 10),
|
||||
)
|
||||
else:
|
||||
self.surface.blit(
|
||||
resources.FONT.render("Incorrect!!", True, (0, 0, 0)),
|
||||
(10, 10),
|
||||
)
|
||||
self.madesandwich = ["bread"]
|
||||
self.correctsandwich = []
|
||||
#change to counter button
|
||||
|
||||
if self.status == "Counter" and self.newOrder == True:
|
||||
GamePlay.sandwich(self.surface)
|
||||
GamePlay.sandwich(self, self.surface)
|
||||
self.newOrder = False
|
||||
elif self.status == "Food":
|
||||
elif self.status == "Food" :
|
||||
GamePlay.displaysandwich(self.surface, self.correctsandwich)
|
||||
if self.ham_button.blit_onto(self.surface, (100, 250)):
|
||||
print("HAM!")
|
||||
self.surface.blit(resources.SUB_HAM_SPRITE_10X, (300, 350))
|
||||
self.madesandwich.append("ham")
|
||||
elif self.tomato_button.blit_onto(self.surface, (250, 250)):
|
||||
print("TOMATO!")
|
||||
self.surface.blit(resources.SUB_TOMATO_SPRITE_10X, (300, 350))
|
||||
self.madesandwich.append("tomatoes")
|
||||
elif self.lettuce_button.blit_onto(self.surface, (400, 250)):
|
||||
print("LETTUCE!")
|
||||
self.surface.blit(resources.SUB_LETTUCE_SPRITE_10X, (300, 350))
|
||||
self.madesandwich.append("lettuce")
|
||||
elif self.top_button.blit_onto(self.surface, (550, 250)):
|
||||
print("TOP!")
|
||||
self.surface.blit(resources.SUB_TOP_SPRITE_10X, (300, 350))
|
||||
self.madesandwich.append("bread")
|
||||
self.sandwichmade == True
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,25 @@ FONT_LG = pygame.font.Font(RESOURCES_DIR / "Jersey10-Regular.ttf", size=60)
|
|||
FONT_XL = pygame.font.Font(RESOURCES_DIR / "Jersey10-Regular.ttf", size=100)
|
||||
|
||||
SPLASH_SCREEN_IMAGE = pygame.image.load(RESOURCES_DIR / "splash.png")
|
||||
COUNTER_SCREEN_IMAGE = pygame.image.load(RESOURCES_DIR / "counter.png")
|
||||
|
||||
SUB_TOMATO_SPRITE = pygame.image.load(RESOURCES_DIR / "sprites" / "sub_tomato.png")
|
||||
TICKET_TOMATO_SPRITE_2X = pygame.transform.scale_by(SUB_TOMATO_SPRITE, 2)
|
||||
SUB_TOMATO_SPRITE_3X = pygame.transform.scale_by(SUB_TOMATO_SPRITE, 3)
|
||||
SUB_TOMATO_SPRITE_10X = pygame.transform.scale_by(SUB_TOMATO_SPRITE, 10)
|
||||
|
||||
SUB_HAM_SPRITE = pygame.image.load(RESOURCES_DIR / "sprites" / "sub_ham.png")
|
||||
SUB_HAM_SPRITE_3X = pygame.transform.scale_by(SUB_HAM_SPRITE, 3)
|
||||
SUB_HAM_SPRITE_10X = pygame.transform.scale_by(SUB_HAM_SPRITE, 10)
|
||||
|
||||
|
||||
SUB_LETTUCE_SPRITE = pygame.image.load(RESOURCES_DIR / "sprites" / "sub_lettuce.png")
|
||||
SUB_LETTUCE_SPRITE_3X = pygame.transform.scale_by(SUB_LETTUCE_SPRITE, 3)
|
||||
SUB_LETTUCE_SPRITE_10X = pygame.transform.scale_by(SUB_LETTUCE_SPRITE, 10)
|
||||
|
||||
SUB_TOP_SPRITE = pygame.image.load(RESOURCES_DIR / "sprites" / "sub_top.png")
|
||||
SUB_TOP_SPRITE_3X = pygame.transform.scale_by(SUB_TOP_SPRITE, 3)
|
||||
SUB_TOP_SPRITE_10X = pygame.transform.scale_by(SUB_TOP_SPRITE, 10)
|
||||
|
||||
SUB_BOTTOM_SPRITE = pygame.image.load(RESOURCES_DIR / "sprites" / "sub_bottom.png")
|
||||
SUB_BOTTOM_SPRITE_10X = pygame.transform.scale_by(SUB_BOTTOM_SPRITE, 10)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue