Exemple #1
0
 def make_layers(self):
     """
     Create the middle and base image of the stars.
     self.image scrolls with the player, self.mid_image scrolls at
     half the speed, and self.base always stays fixed. 
     """
     w, h = self.image.get_size()
     shrink = pg.transform.smoothscale(self.image, (w // 2, h // 2))
     self.mid_image = tools.tile_surface((w, h), shrink, True)
     shrink = pg.transform.smoothscale(self.image, (w // 4, h // 4))
     self.base = tools.tile_surface(prepare.SCREEN_SIZE, shrink, True)
 def make_layers(self):
     """
     Create the middle and base image of the stars.
     self.image scrolls with the player, self.mid_image scrolls at
     half the speed, and self.base always stays fixed.
     """
     w, h = self.image.get_size()
     shrink = pg.transform.smoothscale(self.image, (w//2, h//2))
     self.mid_image = tools.tile_surface((w,h), shrink, True)
     shrink = pg.transform.smoothscale(self.image, (w//4, h//4))
     self.base = tools.tile_surface(prepare.SCREEN_SIZE, shrink, True)
Exemple #3
0
 def __init__(self):
     self.screen = pg.display.get_surface()
     self.screen_rect = self.screen.get_rect()
     self.bg = tools.tile_surface(prepare.SCREEN_SIZE, prepare.GFX["grass"])
     self.clock  = pg.time.Clock()
     self.fps = 60
     self.done = False
     self.all_sprites = pg.sprite.LayeredDirty()
     self.player = actors.Player(self.screen_rect.center, 3)
     self.obstacles = self.make_obstacles()
     self.npcs = self.make_npcs()
     self.all_sprites.add(self.player)
     self.all_sprites.clear(self.screen, self.bg)         
Exemple #4
0
"""
This module contains the Level class.
Drawing and updating of actors should occur here.
"""

import pygame as pg

import prepare
import tools

BIG_STARS = tools.tile_surface((2048, 2048), prepare.GFX["stars"], True)


class Level(object):
    """
    This class represents the whole starscape.  The starscape consists of
    three star layers.  The player is drawn and updated by this class.
    The player is contained in a pg.sprite.GroupSingle group.
    """
    def __init__(self, viewport, player):
        self.image = BIG_STARS.copy()
        self.rect = self.image.get_rect()
        player.rect.midbottom = self.rect.centerx, self.rect.bottom - 50
        self.player_singleton = pg.sprite.GroupSingle(player)
        self.make_layers()
        self.viewport = viewport
        self.update_viewport(True)
        self.mid_viewport = self.viewport.copy()
        self.mid_true = list(self.mid_viewport.topleft)

    def make_layers(self):
"""
This module contains the Level class.
Drawing and updating of actors should occur here.
"""

import pygame as pg

import prepare
import tools


BIG_STARS = tools.tile_surface((2048,2048), prepare.GFX["stars"], True)


class Level(object):
    """
    This class represents the whole starscape.  The starscape consists of
    three star layers.  The player is drawn and updated by this class.
    The player is contained in a pg.sprite.GroupSingle group.
    """
    def __init__(self, viewport, player):
        self.image = BIG_STARS.copy()
        self.rect = self.image.get_rect()
        player.rect.midbottom = self.rect.centerx, self.rect.bottom-50
        self.player_singleton = pg.sprite.GroupSingle(player)
        self.make_layers()
        self.viewport = viewport
        self.update_viewport(True)
        self.mid_viewport = self.viewport.copy()
        self.mid_true = list(self.mid_viewport.topleft)