示例#1
0
    def init_level(self):
        self.wallsGroup = sprite.Group()
        self.playerGroup = sprite.Group()
        self.foodGroup = sprite.Group()
        self.entities = sprite.LayeredUpdates()

        time.set_timer(FOOD_SPAWN_EVENT, FOOD_SPAWN_TIME)
        self.load_level_file(self.lvl_list[self.current_level %
                                           len(self.lvl_list)])

        self.buildLevel(self.level)
        self.player = Dizzy(self.startx + 7 * self.game.block_size,
                            self.starty + (9 - 1) * self.game.block_size,
                            game=self.game,
                            shape='dizzy')
        self.entities.add(self.player, layer=self.LAYER_PLAYER)
        self.playerGroup.add(self.player)
        self.player2 = Dizzy(self.startx + 5 * self.game.block_size,
                             self.starty + (9 - 1) * self.game.block_size,
                             game=self.game,
                             shape='pacman')
        self.entities.add(self.player2, layer=self.LAYER_PLAYER)
        self.playerGroup.add(self.player2)

        for i in range(3):
            self.spawn_food()
示例#2
0
    def test_add__sprite_init_passing_layer(self):
        # test_add_sprite_init_passing_layer

        spr = self.sprite()
        lrg2 = sprite.LayeredUpdates(spr, layer=33)
        self.assert_(len(lrg2._spritelist) == 1)
        self.assert_(lrg2._spritelayers[spr] == 33)
示例#3
0
    def test_add__adding_sprite_on_init(self):
        # test_add_sprite_init

        spr = self.sprite()
        lrg2 = sprite.LayeredUpdates(spr)
        self.assert_(len(lrg2._spritelist) == 1)
        self.assert_(lrg2._spritelayers[spr] == lrg2._default_layer)
示例#4
0
 def create_level(self, mp, screen):
     all_group = sprite.LayeredUpdates()
     level = LevelMap(mp, screen, all_group, imgset_dir=self.resource)
     if self.bg_group is not None:
         level.create_background(self.bg_group)
     level.create_map(**self.groups)
     return all_group
示例#5
0
    def test_add__sprite_init_passing_layer(self):
        expected_layer = 33
        spr = self.sprite()
        lrg2 = sprite.LayeredUpdates(spr, layer=expected_layer)
        layer = lrg2._spritelayers[spr]

        self.assertEqual(len(lrg2._spritelist), 1)
        self.assertEqual(layer, expected_layer)
示例#6
0
    def test_add__adding_sprite_on_init(self):
        spr = self.sprite()
        lrg2 = sprite.LayeredUpdates(spr)
        expected_layer = lrg2._default_layer
        layer = lrg2._spritelayers[spr]

        self.assertEqual(len(lrg2._spritelist), 1)
        self.assertEqual(layer, expected_layer)
示例#7
0
    def test_add__sprite_init_layer_attr(self):
        # test_add_sprite_init_layer_attr

        spr = self.sprite()
        spr._layer = 20
        lrg2 = sprite.LayeredUpdates(spr)
        self.assert_(len(lrg2._spritelist) == 1)
        self.assert_(lrg2._spritelayers[spr] == 20)
示例#8
0
    def test_add__sprite_init_overiding_layer(self):
        # test_add_sprite_init_overiding_layer

        spr = self.sprite()
        spr._layer = 55
        lrg2 = sprite.LayeredUpdates(spr, layer=33)
        self.assertTrue(len(lrg2._spritelist) == 1)
        self.assertTrue(lrg2._spritelayers[spr] == 33)
示例#9
0
    def test_add__sprite_init_layer_attr(self):
        expected_layer = 20
        spr = self.sprite()
        spr._layer = expected_layer
        lrg2 = sprite.LayeredUpdates(spr)
        layer = lrg2._spritelayers[spr]

        self.assertEqual(len(lrg2._spritelist), 1)
        self.assertEqual(layer, expected_layer)
示例#10
0
    def test_add__spritelist_init(self):
        # test_add_spritelist_init

        self.assert_(len(self.LG._spritelist)==0)
        sprites = []
        for i in range(10):
            sprites.append(self.sprite())
        lrg2 = sprite.LayeredUpdates(sprites)
        self.assert_(len(lrg2._spritelist)==10)
        for i in range(10):
            self.assert_(lrg2.get_layer_of_sprite(sprites[i])==self.LG._default_layer)
示例#11
0
    def test_add__spritelist_init(self):
        sprite_count = 10
        sprites = [self.sprite() for _ in range(sprite_count)]

        lrg2 = sprite.LayeredUpdates(sprites)
        expected_layer = lrg2._default_layer

        self.assertEqual(len(lrg2._spritelist), sprite_count)

        for i in range(sprite_count):
            layer = lrg2.get_layer_of_sprite(sprites[i])

            self.assertEqual(layer, expected_layer)
示例#12
0
#variaveis
radius = 10
color = Color(0, 0, 0)
screen = display.set_mode((WIDTH, HEIGHT))
clock = time.Clock()
last_mouse_pos = (0, 0)
green_flag, red_flag, blue_flag = False, False, False
button_1_flag, button_2_flag = False, False
fonte = font.SysFont("Times New Roman", 15)
numeros = font.SysFont("Times New Roman", 50)
fonte.bold = True
loop = True

#canvas

group = sprite.LayeredUpdates()


class Canvas(Base):
    def __init__(self, *groups):
        Base.__init__(self, groups)
        self.image = surface.Surface((600, 600))
        self.rect = self.image.get_rect(topleft=(0, 0))
        self.image.fill(WHITE)


canvas = Canvas(group)


class Cursor(Base):
    def __init__(self, *groups):
示例#13
0
 def setUp(self):
     self.LG = sprite.LayeredUpdates()
示例#14
0
 def __init__(self, *groups, corpus={}, **kwargs):
     super().__init__(*groups)
     self.corpus = corpus
     self.animGroup = pgs.LayeredUpdates(corpus.values())
示例#15
0
from pygame import sprite

tiles = sprite.Group()
overlays = sprite.Group()
camera_relative = sprite.Group()
layeredItems = sprite.LayeredUpdates()

all = sprite.RenderUpdates()