SCUBA24 Cooking Project

(back to SCUBA24)

main.py

# main doc 

import pygame 
import helper

pygame.init()
pygame.font.init()

window_size = (800, 600)
window = pygame.display.set_mode(window_size)
starting_coordinates = (250,300)

font = pygame.font.SysFont("comicsans", 50)
text = font.render("Burger", 0, (0,0,0))
text2 = font.render("choose c to start", 0, (0,0,0))

def main():
    window.fill((255,255,255))
    window.blit(text, (250,300))
    window.blit(text2, (250,370))
    pygame.display.update()
    
    y_food = starting_coordinates[1] - 30
    x_food = starting_coordinates[0]
    
    app_is_running = True
    while app_is_running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                app_is_running = False
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_c:
                    window.fill((255,255,255))
                    pygame.display.update()
                # update this list to include the new burger elements keys
                if event.key in [pygame.K_p, pygame.K_b, pygame.K_t]: 
                    y_food = helper.cook(window,event,starting_coordinates,x_food,y_food)  
 
main()
    

helper.py

import pygame


bottom_bun = pygame.image.load("../images/burger/bottom_bun.png")
patty = pygame.image.load("../images/burger/patty.png")
tomato = pygame.image.load("../images/burger/tomato.png")
# finish adding the other burger elements ...


def cook(window,event,starting_coordinates,x_food,y_food):
    #update the if statement to inclue the new burger elements
    if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_b:
            window.blit(bottom_bun,(x_food,y_food))
        if event.key == pygame.K_p:
            window.blit(patty,(x_food,y_food))
        if event.key == pygame.K_t:
            window.blit(tomato,(x_food,y_food))
        y_food -= 30

    pygame.display.update()
    return y_food