This commit is contained in:
Joe Penny 2025-03-23 10:48:12 +00:00
commit b11ab75d45
22 changed files with 69 additions and 8 deletions

View file

@ -1,7 +1,7 @@
from operator import truediv
import random
import pygame
import resources
import util
class SurfaceButton:
@ -67,3 +67,27 @@ def text_button(text, size, font=resources.FONT_SM) -> SurfaceButton:
)
return SurfaceButton(surface)
class Character:
torso: pygame.Surface
head: pygame.Surface
glasses: pygame.Surface
hair: pygame.Surface
headpos: int
def __init__(self):
self.torso = random.choice(resources.CHARACTER_TORSOS)
self.head = random.choice(resources.CHARACTER_HEADS)
self.glasses = random.choice(resources.CHARACTER_GLASSES)
self.hair = random.choice(resources.CHARACTER_HAIR)
self.headpos = self.head.get_size()[1] * random.randint(6, 9) / 10
def blit_onto(self, output_surface: pygame.SurfaceType, pos: tuple[int, int]):
output_surface.blit(self.torso, util.add_coord(pos, (0, self.headpos)))
torso_centerpoint = util.center_within(self.torso.get_size(), self.head.get_size())
output_surface.blit(self.head, util.add_coord(pos, (torso_centerpoint[0], 0)))
if self.head not in resources.CHARACTER_HEADS[-2:]:
output_surface.blit(self.glasses, util.add_coord(pos, (torso_centerpoint[0], 50)))
output_surface.blit(self.hair, util.add_coord(pos, (torso_centerpoint[0], 0)))

View file

@ -13,6 +13,9 @@ class GamePlay:
lettuce_button: components.SurfaceButton
top_button: components.SurfaceButton
character: components.Character
character_pos: tuple[int, int]
def __init__(self, surface):
self.surface = surface
self.menu_button = components.text_button("Menu", (250, 50), font=resources.FONT)
@ -32,6 +35,9 @@ class GamePlay:
self.start = True
self.suspicion = 0
self.character = components.Character()
self.character_pos = (400 + random.randint(0, 100), 100 + random.randint(25, 100))
def displaysandwich(screen, sandwich):
position = 125
picposition = 100
@ -42,28 +48,28 @@ class GamePlay:
(1110, position),
)
if start == 0:
screen.blit(
screen.blit(
resources.TICKET_TOP_SPRITE_3X,
(975, picposition),
)
start = 1
elif i == "Lettuce":
screen.blit(
screen.blit(
resources.TICKET_LETTUCE_SPRITE_3X,
(992, picposition + 15),
)
elif i == "Ham":
screen.blit(
screen.blit(
resources.TICKET_HAM_SPRITE_3X,
(975, picposition - 2),
)
elif i == "Tomatoes":
screen.blit(
screen.blit(
resources.TICKET_TOMATO_SPRITE_3X,
(992, picposition + 15),
)
elif i == "Bread":
screen.blit(
screen.blit(
resources.TICKET_BOTTOM_SPRITE_3X ,
(975, picposition),
)
@ -90,6 +96,7 @@ class GamePlay:
self.start = False
self.newOrder = False
if self.menu_button.blit_onto(self.surface, (15, 5)):
pygame.event.post(util.make_transition_event("menu"))
@ -101,6 +108,7 @@ class GamePlay:
self.surface.blit(resources.SUB_BOTTOM_SPRITE_10X, (300, 300))
elif self.status == "Food":
if self.counter_button.blit_onto(self.surface, (1000, 5)):
self.character.blit_onto(self.surface, self.character_pos)
self.surface.fill("lightgreen")
self.surface.blit(resources.COUNTER_SCREEN_IMAGE, (0, 0))
self.status = "Counter"

View file

@ -16,7 +16,7 @@ class Menu:
def do(self):
self.surface.blit(resources.SPLASH_SCREEN_IMAGE, (0, 0))
title_text = "SANDWICH"
title_text = "Secret Sandwich Service"
self.surface.blit(
resources.FONT_XL.render(title_text, True, "black"),

View file

@ -42,5 +42,34 @@ TICKET_TOP_SPRITE_3X = pygame.transform.scale_by(TICKET_TOP_SPRITE, 3)
SUB_BOTTOM_SPRITE = pygame.image.load(RESOURCES_DIR / "sprites" / "sub_bottom.png")
SUB_BOTTOM_SPRITE_10X = pygame.transform.scale_by(SUB_BOTTOM_SPRITE, 10)
TICKET_BOTTOM_SPRITE = pygame.image.load(RESOURCES_DIR / "sprites" / "ticket_bottom.png")
TICKET_BOTTOM_SPRITE_3X = pygame.transform.scale_by(TICKET_BOTTOM_SPRITE, 3)
CHARACTER_TORSOS = [
pygame.image.load(RESOURCES_DIR / "sprites" / "character_torso_1.png"),
pygame.image.load(RESOURCES_DIR / "sprites" / "character_torso_2.png"),
pygame.image.load(RESOURCES_DIR / "sprites" / "character_torso_3.png"),
]
CHARACTER_HEADS = [
pygame.image.load(RESOURCES_DIR / "sprites" / "character_head_1.png"),
pygame.image.load(RESOURCES_DIR / "sprites" / "character_head_2.png"),
pygame.image.load(RESOURCES_DIR / "sprites" / "character_head_3.png"),
pygame.image.load(RESOURCES_DIR / "sprites" / "character_head_4.png"),
pygame.image.load(RESOURCES_DIR / "sprites" / "character_head_5.png"),
]
CHARACTER_GLASSES = [
pygame.image.load(RESOURCES_DIR / "sprites" / "character_glasses_1.png"),
pygame.image.load(RESOURCES_DIR / "sprites" / "character_glasses_2.png"),
pygame.image.load(RESOURCES_DIR / "sprites" / "character_glasses_3.png"),
pygame.image.load(RESOURCES_DIR / "sprites" / "character_glasses_4.png"), # the blank one
]
CHARACTER_HAIR = [
pygame.image.load(RESOURCES_DIR / "sprites" / "character_hair_1.png"),
pygame.image.load(RESOURCES_DIR / "sprites" / "character_hair_2.png"),
pygame.image.load(RESOURCES_DIR / "sprites" / "character_hair_3.png"),
pygame.image.load(RESOURCES_DIR / "sprites" / "character_hair_4.png"), # the bald one
]

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B