Esempio n. 1
0
    def loadAssets(self):
        path = 'Assets/isometric_Mini-Crusader/walk/'
        self.walk_frames = tools.load_all_gfx(path,
                                              pg,
                                              accept=('.png'),
                                              width=128,
                                              height=150)

        path = 'Assets/isometric_Mini-Crusader/idle/'
        self.idle_frames = tools.load_all_gfx(path,
                                              pg,
                                              accept=('.png'),
                                              width=128,
                                              height=150)

        path = 'Assets/isometric_Mini-Crusader/attack/'
        self.attack_frames = tools.load_all_gfx(path,
                                                pg,
                                                accept=('.png'),
                                                width=128,
                                                height=150)

        path = 'Assets/isometric_Mini-Crusader/jump/'
        self.jump_frames = tools.load_all_gfx(path,
                                              pg,
                                              accept=('.png'),
                                              width=128,
                                              height=150)
Esempio n. 2
0
import os
import pygame as pg
import tools


SCREEN_SIZE = (1280, 720)
ORIGINAL_CAPTION = "Pygame Challenge"

pg.mixer.pre_init(44100, -16, 1, 512)

pg.init()
os.environ['SDL_VIDEO_CENTERED'] = "TRUE"
pg.display.set_caption(ORIGINAL_CAPTION)
SCREEN = pg.display.set_mode(SCREEN_SIZE)
SCREEN_RECT = SCREEN.get_rect()



GFX   = tools.load_all_gfx(os.path.join("resources", "graphics"))

for num in range(1, 5):
    img = GFX["tree{}".format(num)]
    curvy = pg.Rect(0, 0, 128, 128)
    straight = pg.Rect(128, 0, 96, 128)
    GFX["curvy-tree{}".format(num)] = img.subsurface(curvy)
    GFX["straight-tree{}".format(num)] = img.subsurface(straight)
import os
import pygame as pg
import tools

# Useful constants.
CAPTION = "Drawing Order"
SCREEN_SIZE = (500, 500)
BACKGROUND_COLOR = pg.Color("darkgreen")

DIRECT_DICT = {"UP": (0, -1), "RIGHT": (1, 0), "DOWN": (0, 1), "LEFT": (-1, 0)}

DIRECTIONS = ("UP", "RIGHT", "DOWN", "LEFT")

CONTROLS = {
    pg.K_UP: "UP",
    pg.K_RIGHT: "RIGHT",
    pg.K_DOWN: "DOWN",
    pg.K_LEFT: "LEFT"
}

# Set up environment.
os.environ['SDL_VIDEO_CENTERED'] = '1'
pg.init()
pg.display.set_caption(CAPTION)
pg.display.set_mode(SCREEN_SIZE)

# Load all graphics.
GFX = tools.load_all_gfx("rpgsprites")
FONT = os.path.join("resources", "DOS.ttf")
# Display a message while prepare prepares
font = pg.font.Font(FONT, 64)
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))
Esempio n. 5
0
SCALE_FACTOR = 0.3  # For scaling down ship images.

ROTATE = {pg.K_RIGHT: 1, pg.K_LEFT: -1}
ACCELERATE = pg.K_UP
DECELERATE = pg.K_DOWN
FIRE = pg.K_d
BOOST = pg.K_SPACE

# Set up environment.
os.environ['SDL_VIDEO_CENTERED'] = '1'
pg.init()
pg.display.set_caption(CAPTION)
pg.display.set_mode(SCREEN_SIZE)

# Load all graphics.
GFX = tools.load_all_gfx("resources")
GFX["ships"] = tools.load_all_gfx(os.path.join("resources", "ships"))

# All enemy types
ENEMIES = {
    "destroyer": {
        "image": GFX["ships"]["destroyer"],
        "guns": 3,
        "speed": 40,
        "angular": 20,
        "value": 3
    },
    "cruiser": {
        "image": GFX["ships"]["cruiser"],
        "guns": 2,
        "speed": 60,
Esempio n. 6
0
import os
from random import choice, sample
import pygame as pg
import tools


SCREEN_SIZE = (1280, 720)
ORIGINAL_CAPTION = "Skeet Shoot"

pg.mixer.pre_init(44100, -16, 1, 512)

pg.init()
os.environ['SDL_VIDEO_CENTERED'] = "TRUE"
pg.display.set_caption(ORIGINAL_CAPTION)
SCREEN = pg.display.set_mode(SCREEN_SIZE)
SCREEN_RECT = SCREEN.get_rect()
pg.mixer.set_num_channels(16)
GFX = tools.load_all_gfx(os.path.join("resources", "graphics"), colorkey=(255,255,255))
SFX = tools.load_all_sfx(os.path.join("resources", "sounds"))
night_colors = [
        ("trees1", {(95, 137, 75): (6, 10, 5)}),
        ("trees2", {(82, 117, 64): (5, 7, 3)}),
        ("trees3", {(73, 104, 57): (3, 5, 2)})]
for name, swaps in night_colors:
    img = GFX[name]
    GFX["night-{}".format(name)] = tools.color_swap(img, swaps)
Esempio n. 7
0
import os
from random import choice, sample
import pygame as pg
import tools

SCREEN_SIZE = (1280, 720)
ORIGINAL_CAPTION = "Skeet Shoot"

pg.mixer.pre_init(44100, -16, 1, 512)

pg.init()
os.environ['SDL_VIDEO_CENTERED'] = "TRUE"
pg.display.set_caption(ORIGINAL_CAPTION)
SCREEN = pg.display.set_mode(SCREEN_SIZE)
SCREEN_RECT = SCREEN.get_rect()
pg.mixer.set_num_channels(16)
GFX = tools.load_all_gfx(os.path.join("resources", "graphics"),
                         colorkey=(255, 255, 255))
SFX = tools.load_all_sfx(os.path.join("resources", "sounds"))
night_colors = [("trees1", {
    (95, 137, 75): (6, 10, 5)
}), ("trees2", {
    (82, 117, 64): (5, 7, 3)
}), ("trees3", {
    (73, 104, 57): (3, 5, 2)
})]
for name, swaps in night_colors:
    img = GFX[name]
    GFX["night-{}".format(name)] = tools.color_swap(img, swaps)
Esempio n. 8
0
import os
import pygame as pg
import tools

SCREEN_SIZE = (1280, 720)
ORIGINAL_CAPTION = "Pygame Challenge"

pg.mixer.pre_init(44100, -16, 1, 512)

pg.init()
os.environ['SDL_VIDEO_CENTERED'] = "TRUE"
pg.display.set_caption(ORIGINAL_CAPTION)
SCREEN = pg.display.set_mode(SCREEN_SIZE)
SCREEN_RECT = SCREEN.get_rect()

GFX = tools.load_all_gfx(os.path.join("resources", "graphics"))

for num in range(1, 5):
    img = GFX["tree{}".format(num)]
    curvy = pg.Rect(0, 0, 128, 128)
    straight = pg.Rect(128, 0, 96, 128)
    GFX["curvy-tree{}".format(num)] = img.subsurface(curvy)
    GFX["straight-tree{}".format(num)] = img.subsurface(straight)
Esempio n. 9
0
import pygame as pg

import tools
import options
import map_tools

opts = options.Options()
the_map = map_tools.Map(opts)

screen_width = opts.cell_width * (
    the_map.num_cells_x + opts.wraparound_repeat * 2 + opts.coord_display)
screen_height = opts.cell_height * (
    the_map.num_cells_y + opts.wraparound_repeat * 2 + opts.coord_display)

pg.init()
screen = pg.display.set_mode((screen_width, screen_height), pg.RESIZABLE, 32)
pg.display.set_caption("MapMaker BT by CanuckMonkey Games")

GFX = tools.load_all_gfx(os.path.join("asset", "image"))
SFX = tools.load_all_sfx(os.path.join("asset", "sound"))
FONTS = tools.load_all_fonts(os.path.join("asset", "font"))
MUSIC = tools.load_all_music(os.path.join("asset", "music"))

background = pg.Surface(screen.get_size())
background = background.convert()
overlay = pg.Surface(screen.get_size())
overlay = screen.convert_alpha()
the_map.draw(background)
screen.blit(background, (0, 0))
pg.display.flip()
Esempio n. 10
0
import pygame as pg
import os

import constants as c
import tools

# Center game window.
os.environ['SDL_VIDEO_CENTERED'] = 'TRUE'

pg.init()
pg.display.set_caption(c.CAPTION)
display = pg.display.set_mode(c.DISPLAY_SIZE)
surf_to_display = pg.Surface(c.DISPLAY_SIZE)
window = pg.Surface(c.WINDOW_SIZE)

GFX = tools.load_all_gfx(os.path.join('assets', 'graphics'))
TMX = tools.load_all_tmx(os.path.join('assets', 'tmx'))
FONTS = tools.load_all_fonts(os.path.join('assets', 'fonts'))
MUSIC = tools.load_all_music(os.path.join('assets', 'music'))
SFX = tools.load_all_sfx(os.path.join('assets', 'sfx'))

pg.display.set_icon(GFX['icon'])


def play_sfx(sound_name, volume=c.SFX_DEFAULT_VOLUME):
    sound = SFX[sound_name]
    sound.set_volume(volume)
    sound.play()


def update_display(window):
Esempio n. 11
0
TILE_SIZE = 32 # Assume tiles are square.
BACKGROUND_COLOR = pg.Color("darkgreen")


DIRECT_DICT = {"UP"    : ( 0,-1),
               "RIGHT" : ( 1, 0),               
               "DOWN"  : ( 0, 1),
               "LEFT"  : (-1, 0)}


DIRECTIONS = ("UP", "RIGHT", "DOWN", "LEFT")


CONTROLS = {pg.K_UP    : "UP",
            pg.K_RIGHT : "RIGHT",
            pg.K_DOWN  : "DOWN",
            pg.K_LEFT  : "LEFT"}


# Set up environment.
os.environ['SDL_VIDEO_CENTERED'] = '1'
pg.init()
pg.display.set_caption(CAPTION)
pg.display.set_mode(SCREEN_SIZE)


# Load all graphics.
GFX = {}
GFX = tools.load_all_gfx("resources")
GFX["characters"] = tools.load_all_gfx(os.path.join("resources", "rpgsprites"))
Esempio n. 12
0
import pygame as pg

import tools
import options
import map_tools


opts = options.Options()
the_map = map_tools.Map(opts)

screen_width = opts.cell_width * (the_map.num_cells_x + opts.wraparound_repeat * 2 + opts.coord_display)
screen_height = opts.cell_height * (the_map.num_cells_y + opts.wraparound_repeat * 2 + opts.coord_display)

pg.init()
screen = pg.display.set_mode((screen_width, screen_height), pg.RESIZABLE, 32)
pg.display.set_caption("MapMaker BT by CanuckMonkey Games")


GFX = tools.load_all_gfx(os.path.join("asset", "image"))
SFX = tools.load_all_sfx(os.path.join("asset", "sound"))
FONTS = tools.load_all_fonts(os.path.join("asset", "font"))
MUSIC = tools.load_all_music(os.path.join("asset", "music"))

background = pg.Surface(screen.get_size())
background = background.convert()
overlay = pg.Surface(screen.get_size())
overlay = screen.convert_alpha()
the_map.draw(background)
screen.blit(background, (0, 0))
pg.display.flip()