Example #1
0
    def create_wall_sprite_list(self, texture):
        sprite = Sprite(texture)
        wall_sprites = []
        for i in range(PP_WIDTH):
            wall_sprite = sprite.copy()
            wall_sprite.position = (i, PP_HEIGHT / 2 - 32)
            wall_sprite.set_texture_rect(IntRect(0, 0, 1, 64))
            wall_sprites.append(wall_sprite)

        return wall_sprites
Example #2
0
    def create_wall_sprite_list(self, texture):
        sprite = Sprite(texture)
        wall_sprites = []
        for i in range(PP_WIDTH):
            wall_sprite = sprite.copy()
            wall_sprite.position = (i, PP_HEIGHT / 2 - 32)
            wall_sprite.set_texture_rect(IntRect(0, 0, 1, 64))
            wall_sprites.append(wall_sprite)

        return wall_sprites
Example #3
0
    def __init__(self, player, background, faces, hudweapons, weapons, numbers):
        self.player = player

        self.background = Sprite(background)
        self.background.position = 0, PP_HEIGHT+1

        self.face = Sprite(faces)
        self.face.position = 116, 205
        self.face.scale = 2/3, 2/3

        self.hudweapon = Sprite(hudweapons)
        self.hudweapon.position = 251, 205

        self.weapon = Sprite(weapons)
        # self.weapon.position = 112, 105 #for x1.5
        # self.weapon.position = 96, 73 #for x2
        self.weapon.position = 104, 89
        self.weapon.scale = 1.75, 1.75

        self.deck_10 = Sprite(numbers)
        self.deck_10.position = 12, 223

        self.deck_1 = Sprite(numbers)
        self.deck_1.position = 25, 223

        self.score_1000 = Sprite(numbers)
        self.score_1000.position = 53, 223

        self.score_100 = Sprite(numbers)
        self.score_100.position = 67, 223

        self.score_10 = Sprite(numbers)
        self.score_10.position = 81, 223

        self.score_1 = Sprite(numbers)
        self.score_1.position = 95, 223

        self.hp_100 = Sprite(numbers)
        self.hp_100.position = 162, 223

        self.hp_10 = Sprite(numbers)
        self.hp_10.position = 176, 223

        self.hp_1 = Sprite(numbers)
        self.hp_1.position = 190, 223

        self.ammo_10 = Sprite(numbers)
        self.ammo_10.position = 214, 223

        self.ammo_1 = Sprite(numbers)
        self.ammo_1.position = 228, 223

        self.all_numbers = [self.deck_10, self.deck_1, self.score_1000,
            self.score_100, self.score_10, self.score_1, self.hp_100,
                self.hp_10, self.hp_1, self.ammo_10, self.ammo_1]
Example #4
0
def gen_sprite_slices(texture, sprite_x, sprite_y):
    """Creates a list of 64 sprite slices to be scaled and displayed one by one.
    """

    sprite = []
    for i in range(PP_WIDTH):
        sprite_slice = Sprite(texture)
        sprite_slice.position = (i, PP_HEIGHT/2 - 32)
        sprite.append(sprite_slice)

    return sprite
 def newParticle(self):
   
   sprite = Sprite(ResourceManager.getTexture("planet5521/data/sprites.png"))
   sprite.texture_rectangle = Rectangle(Vector2(161, 234), Vector2(25, 20))
   sprite.origin = Vector2(12, 10)
   sprite.ratio = Vector2(0.08,0.08)
   
   r = self.gameView.entityToView[self.building].getDrawBounds()
   x = r.left + Rand.r.random()*r.width
   y = self.building._world.groundLevel
   sprite.position = Vector2(x, y + sprite.global_bounds.height/2-0.01)
   
   p = SimpleParticle(sprite)
   p.v = Vector2(Rand.r.random()*0.3, -Rand.r.random()*4)
   p.a = Vector2(0, 5)
   p.rV = Rand.r.random()*100
   
   self.particles.append(p)
Example #6
0
 def _draw_Mask(self, target, states):  #draw
     Mask_sprite = Sprite(self.Mask.texture)
     Mask_sprite.position = self.position
     self.Mask.display()
     target.draw(Mask_sprite)
Example #7
0
 def __init__(self, *args):
     Sprite.__init__(self, *args)
     self.clip = clip(self)
Example #8
0
 def createSprite(self):
   sprite = Sprite(ResourceManager.getTexture("planet5521/data/sprites.png"))
   sprite.texture_rectangle = self._textureRect
   sprite.origin = Vector2(2.5, 3)
   sprite.ratio = Vector2(0.1, 0.1)
   return sprite
Example #9
0
 def _render_Lines(self):  #init
     for line in self._columns + self._rows:
         self._texture.draw(line)
     self._texture.display()
     self.sprite = Sprite(self._texture.texture)
Example #10
0
	def _draw_Mask(self, target, states): #draw
		Mask_sprite = Sprite(self.Mask.texture)
		Mask_sprite.position = self.position
		self.Mask.display()
		target.draw(Mask_sprite)
Example #11
0
    def __init__(self, player, background, faces, hudweapons, weapons,
                 numbers):
        self.player = player

        self.background = Sprite(background)
        self.background.position = 0, PP_HEIGHT + 1

        self.face = Sprite(faces)
        self.face.position = 116, 205
        self.face.scale = 2 / 3, 2 / 3

        self.hudweapon = Sprite(hudweapons)
        self.hudweapon.position = 251, 205

        self.weapon = Sprite(weapons)
        # self.weapon.position = 112, 105 #for x1.5
        # self.weapon.position = 96, 73 #for x2
        self.weapon.position = 104, 89
        self.weapon.scale = 1.75, 1.75

        self.deck_10 = Sprite(numbers)
        self.deck_10.position = 12, 223

        self.deck_1 = Sprite(numbers)
        self.deck_1.position = 25, 223

        self.score_1000 = Sprite(numbers)
        self.score_1000.position = 53, 223

        self.score_100 = Sprite(numbers)
        self.score_100.position = 67, 223

        self.score_10 = Sprite(numbers)
        self.score_10.position = 81, 223

        self.score_1 = Sprite(numbers)
        self.score_1.position = 95, 223

        self.hp_100 = Sprite(numbers)
        self.hp_100.position = 162, 223

        self.hp_10 = Sprite(numbers)
        self.hp_10.position = 176, 223

        self.hp_1 = Sprite(numbers)
        self.hp_1.position = 190, 223

        self.ammo_10 = Sprite(numbers)
        self.ammo_10.position = 214, 223

        self.ammo_1 = Sprite(numbers)
        self.ammo_1.position = 228, 223

        self.all_numbers = [
            self.deck_10, self.deck_1, self.score_1000, self.score_100,
            self.score_10, self.score_1, self.hp_100, self.hp_10, self.hp_1,
            self.ammo_10, self.ammo_1
        ]
Example #12
0
class Hud(object):
    """HUD controller."""
    def __init__(self, player, background, faces, hudweapons, weapons,
                 numbers):
        self.player = player

        self.background = Sprite(background)
        self.background.position = 0, PP_HEIGHT + 1

        self.face = Sprite(faces)
        self.face.position = 116, 205
        self.face.scale = 2 / 3, 2 / 3

        self.hudweapon = Sprite(hudweapons)
        self.hudweapon.position = 251, 205

        self.weapon = Sprite(weapons)
        # self.weapon.position = 112, 105 #for x1.5
        # self.weapon.position = 96, 73 #for x2
        self.weapon.position = 104, 89
        self.weapon.scale = 1.75, 1.75

        self.deck_10 = Sprite(numbers)
        self.deck_10.position = 12, 223

        self.deck_1 = Sprite(numbers)
        self.deck_1.position = 25, 223

        self.score_1000 = Sprite(numbers)
        self.score_1000.position = 53, 223

        self.score_100 = Sprite(numbers)
        self.score_100.position = 67, 223

        self.score_10 = Sprite(numbers)
        self.score_10.position = 81, 223

        self.score_1 = Sprite(numbers)
        self.score_1.position = 95, 223

        self.hp_100 = Sprite(numbers)
        self.hp_100.position = 162, 223

        self.hp_10 = Sprite(numbers)
        self.hp_10.position = 176, 223

        self.hp_1 = Sprite(numbers)
        self.hp_1.position = 190, 223

        self.ammo_10 = Sprite(numbers)
        self.ammo_10.position = 214, 223

        self.ammo_1 = Sprite(numbers)
        self.ammo_1.position = 228, 223

        self.all_numbers = [
            self.deck_10, self.deck_1, self.score_1000, self.score_100,
            self.score_10, self.score_1, self.hp_100, self.hp_10, self.hp_1,
            self.ammo_10, self.ammo_1
        ]

    def prepare(self):
        """Prepare all the data to be displayed."""

        #faces
        if self.player.hp == 0:
            self.face.set_texture_rect(IntRect(129, 0, 64, 64))
        elif self.player.hp > 0 and self.player.hp < 50:
            self.face.set_texture_rect(IntRect(65, 0, 64, 64))
        else:
            self.face.set_texture_rect(IntRect(0, 0, 64, 64))

        #hud weapons indicator
        if self.player.weapon.ident == 'rifle':
            self.hudweapon.set_texture_rect(IntRect(0, 85, 65, 42))
        elif self.player.weapon.ident == 'pistol':
            self.hudweapon.set_texture_rect(IntRect(0, 43, 65, 42))
        else:
            self.hudweapon.set_texture_rect(IntRect(0, 0, 65, 42))

        #in hand weapon indicator
        if self.player.attack == True:
            if self.player.weapon.ident == 'rifle':
                self.weapon.set_texture_rect(IntRect(64, 128, 64, 64))
            elif self.player.weapon.ident == 'pistol':
                self.weapon.set_texture_rect(IntRect(64, 64, 64, 64))
            else:
                self.weapon.set_texture_rect(IntRect(64, 0, 64, 64))

        else:
            if self.player.weapon.ident == 'rifle':
                self.weapon.set_texture_rect(IntRect(0, 128, 64, 64))
            elif self.player.weapon.ident == 'pistol':
                self.weapon.set_texture_rect(IntRect(0, 64, 64, 64))
            else:
                self.weapon.set_texture_rect(IntRect(0, 0, 64, 64))

        #numbers

        numbers(num_digits(2, self.player.deck), self.deck_10)
        numbers(num_digits(1, self.player.deck), self.deck_1)

        numbers(num_digits(4, self.player.score), self.score_1000)
        numbers(num_digits(3, self.player.score), self.score_100)
        numbers(num_digits(2, self.player.score), self.score_10)
        numbers(num_digits(1, self.player.score), self.score_1)

        numbers(num_digits(3, self.player.hp), self.hp_100)
        numbers(num_digits(2, self.player.hp), self.hp_10)
        numbers(num_digits(1, self.player.hp), self.hp_1)

        numbers(num_digits(2, self.player.weapon.ammo), self.ammo_10)
        numbers(num_digits(1, self.player.weapon.ammo), self.ammo_1)

    def display(self, window):
        """Display the HUD with correct values."""

        self.prepare()

        window.draw(self.background)
        window.draw(self.face)
        window.draw(self.hudweapon)
        window.draw(self.weapon)

        i = 0
        while i != len(self.all_numbers):
            window.draw(self.all_numbers[i])
            i += 1
Example #13
0
class Hud(object):
    """HUD controller."""

    def __init__(self, player, background, faces, hudweapons, weapons, numbers):
        self.player = player

        self.background = Sprite(background)
        self.background.position = 0, PP_HEIGHT+1

        self.face = Sprite(faces)
        self.face.position = 116, 205
        self.face.scale = 2/3, 2/3

        self.hudweapon = Sprite(hudweapons)
        self.hudweapon.position = 251, 205

        self.weapon = Sprite(weapons)
        # self.weapon.position = 112, 105 #for x1.5
        # self.weapon.position = 96, 73 #for x2
        self.weapon.position = 104, 89
        self.weapon.scale = 1.75, 1.75

        self.deck_10 = Sprite(numbers)
        self.deck_10.position = 12, 223

        self.deck_1 = Sprite(numbers)
        self.deck_1.position = 25, 223

        self.score_1000 = Sprite(numbers)
        self.score_1000.position = 53, 223

        self.score_100 = Sprite(numbers)
        self.score_100.position = 67, 223

        self.score_10 = Sprite(numbers)
        self.score_10.position = 81, 223

        self.score_1 = Sprite(numbers)
        self.score_1.position = 95, 223

        self.hp_100 = Sprite(numbers)
        self.hp_100.position = 162, 223

        self.hp_10 = Sprite(numbers)
        self.hp_10.position = 176, 223

        self.hp_1 = Sprite(numbers)
        self.hp_1.position = 190, 223

        self.ammo_10 = Sprite(numbers)
        self.ammo_10.position = 214, 223

        self.ammo_1 = Sprite(numbers)
        self.ammo_1.position = 228, 223

        self.all_numbers = [self.deck_10, self.deck_1, self.score_1000,
            self.score_100, self.score_10, self.score_1, self.hp_100,
                self.hp_10, self.hp_1, self.ammo_10, self.ammo_1]

    def prepare(self):
        """Prepare all the data to be displayed."""

        #faces
        if self.player.hp == 0:
            self.face.set_texture_rect(IntRect(129, 0, 64, 64))
        elif self.player.hp > 0 and self.player.hp < 50:
            self.face.set_texture_rect(IntRect(65, 0, 64, 64))
        else:
            self.face.set_texture_rect(IntRect(0, 0, 64, 64))

        #hud weapons indicator
        if self.player.weapon.ident == 'rifle':
            self.hudweapon.set_texture_rect(IntRect(0, 85, 65, 42))
        elif self.player.weapon.ident == 'pistol':
            self.hudweapon.set_texture_rect(IntRect(0, 43, 65, 42))
        else:
            self.hudweapon.set_texture_rect(IntRect(0, 0, 65, 42))

        #in hand weapon indicator
        if self.player.attack == True:
            if self.player.weapon.ident == 'rifle':
                self.weapon.set_texture_rect(IntRect(64, 128, 64, 64))
            elif self.player.weapon.ident == 'pistol':
                self.weapon.set_texture_rect(IntRect(64, 64, 64, 64))
            else:
                self.weapon.set_texture_rect(IntRect(64, 0, 64, 64))

        else:
            if self.player.weapon.ident == 'rifle':
                self.weapon.set_texture_rect(IntRect(0, 128, 64, 64))
            elif self.player.weapon.ident == 'pistol':
                self.weapon.set_texture_rect(IntRect(0, 64, 64, 64))
            else:
                self.weapon.set_texture_rect(IntRect(0, 0, 64, 64))


        #numbers

        numbers(num_digits(2, self.player.deck), self.deck_10)
        numbers(num_digits(1, self.player.deck), self.deck_1)

        numbers(num_digits(4, self.player.score), self.score_1000)        
        numbers(num_digits(3, self.player.score), self.score_100)
        numbers(num_digits(2, self.player.score), self.score_10)
        numbers(num_digits(1, self.player.score), self.score_1)

        numbers(num_digits(3, self.player.hp), self.hp_100)
        numbers(num_digits(2, self.player.hp), self.hp_10)
        numbers(num_digits(1, self.player.hp), self.hp_1)

        numbers(num_digits(2, self.player.weapon.ammo), self.ammo_10)
        numbers(num_digits(1, self.player.weapon.ammo), self.ammo_1)

    def display(self, window):
        """Display the HUD with correct values."""

        self.prepare()
        
        window.draw(self.background)
        window.draw(self.face)
        window.draw(self.hudweapon)
        window.draw(self.weapon)        

        i = 0
        while i != len(self.all_numbers):
            window.draw(self.all_numbers[i])
            i += 1
Example #14
0
	def __init__(self, *args):
		Sprite.__init__(self, *args)
		self.clip = clip(self)