Ejemplo n.º 1
0
def load_assets():
    global ASTEROID_SHEET
    global LABEL
    global FONT
    global QUOTE1
    global QUOTE2
    global RELAX
    global SONGS
    global SONGSPLAYTIMES
    global DISPLAYSURF
    global SCREEN_RECT
    global BG
    global score
    score = 0

    DISPLAYSURF = pg.display.set_mode(SCREEN_SIZE)
    SCREEN_RECT = pg.Rect((0, 0), SCREEN_SIZE)

    random.seed(datetime.now())

    SONGS = [
        "assets/eye_of_storm.mp3", "assets/island.ogg", "assets/seven.mp3",
        "assets/dream_music.ogg"
    ]
    SONGSPLAYTIMES = [3, 2, 1, 1]
    RELAX = ["assets/relax1.wav", "assets/relax3.wav", "assets/relax2.wav"]
    QUOTES1 = [
        "You've must've had a long day at work.", "Don't feel so tense,",
        "You need to treat yourself more."
    ]
    QUOTES2 = ["You need to relax", "you're safe here.", "Play our game."]

    num = random.randint(0, 2)

    BG = pg.image.load("assets/stars.png")

    FONT = pg.font.Font(None, 30)
    LABEL = FONT.render("Click to Continue", 1, (255, 255, 255))
    QUOTE1 = FONT.render(QUOTES1[num], 1, (255, 255, 255))
    QUOTE2 = FONT.render(QUOTES2[num], 1, (255, 255, 255))
    RELAX = pg.mixer.Sound(RELAX[num])
    ASTEROID_SHEET = pg.image.load("assets/asteroids.png")

    global FRAMES
    FRAMES = tools.split_sheet(ASTEROID_SHEET, SIZE, SHEET_DIM)
Ejemplo n.º 2
0
 def get_frames(self, character):
     """Get a list of all frames."""
     sheet = prepare.GFX[character]
     all_frames = tools.split_sheet(sheet, SPRITE_SIZE, 3, 4)
     return all_frames
label = font.render("Generating Galaxy", True, pg.Color(0, 220, 220), BACKGROUND_COLOR)
label_rect = label.get_rect(center=SCREEN.get_rect().center)
label.set_alpha(200)
SCREEN.fill(BACKGROUND_COLOR)
SCREEN.blit(label, label_rect)
pg.display.update()

# Load sound effects.
SFX = tools.load_all_sounds(os.path.join("resources", "sounds"))

# Load all graphics.
GFX = {}
GFX = tools.load_all_gfx("resources")
GFX["ships"] = tools.load_all_gfx(os.path.join("resources", "ships"))
colors = ("blue", "orange", "red", "green", "yellow", "purple")
imgs = tools.split_sheet(GFX["lasersheetsmall"], (48, 16), 6, 1)
imgs2 = tools.split_sheet(GFX["lasersheetfat"], (48, 16), 6, 1)
for color, img in zip(colors, *imgs):
    GFX["smallbeam{}".format(color)] = img
for color2, img2 in zip(colors, *imgs2):
    GFX["fatbeam{}".format(color2)] = img2


# bigger space image
stars = GFX["stars"]
w, h = stars.get_size()
big_stars = pg.Surface((w * 8, h * 8)).convert_alpha()
big_stars.fill((0, 0, 0, 0))
for x in range(0, w * 8 + 1, w):
    for y in range(0, h * 8 + 1, h):
        big_stars.blit(stars, (x, y))
Ejemplo n.º 4
0
 def get_frames(self, character):
     """Get a list of all frames."""
     sheet = prepare.GFX[character]
     all_frames = tools.split_sheet(sheet, SPRITE_SIZE, 3, 4)
     return all_frames