Esempio n. 1
0
def init(g, r, n, *params):
    s = sprite.Sprite3(
        g, r, 'player/right',
        (5, 10, 9, 20))  #(0,0,19,25))#(43-14,8,28,48))#left,top,width,height
    s.rect.bottom = r.bottom
    s.rect.centerx = r.centerx
    s.groups.add('player')
    s.groups.add('solid')
    g.sprites.append(s)
    s.loop = loop
    s.vx = 0
    s.vy = 0
    s.walk_frame = 1
    s.jumping = 0
    s.facing = 'right'
    s.flash_counter = 0
    s.flash_timer = 0
    s.shooting = 0
    s.powered_up = False
    if hasattr(g.game, 'powerup'):
        s.powered_up = g.game.powerup
    s.powerup_transition = 0
    s.door_timer = None
    s.current_door = None
    s.door_pos = None
    g.player = s
    s.event = event
    s.pan = pan_screen
    s.damage = damage
    s.kill = kill
    s.god_mode = False
    s.death_counter = -1

    s._prev = pygame.Rect(s.rect)
    s._prev2 = pygame.Rect(s.rect)
    s.looking = False

    sprite.init_bounds(g, s)
    sprite.init_view(g, s)
    sprite.init_codes(g, s)
    s.no_explode = False

    return s
Esempio n. 2
0
    def hit(self, pos, b):
        
        cx, cy = pos
        
        dx = 1
        while self.game.data[2][cy][cx + dx] in DOOR_CODES:
            dx += 1
        n_code = g.data[2][cy][cx + dx]
        
        if n_code == 0:
            return
        
        layer = self.game.data[2]
        
        w, h = self.game.size
        xx = cx
        yy = cy

        for y in xrange(h):
            for x in xrange(w):
                if layer[y][x] in DOOR_CODES and layer[y][x - 1] == n_code:
                    xx = x
                    yy = y
        
        #t = g.layer[yy][xx]
        self.rect = pygame.Rect(xx * TW, yy * TH, TW, TH)
        self = b
        self.rect.centerx = rect.centerx
        s.rect.bottom = rect.bottom

        if self.standing != None:
            self.stop_standing()
        
        sprite.init_bounds(self.game, self)
        sprite.init_view(self.game, self)
        sprite.init_codes(self.game, self)
        self.prev = pygame.Rect(self.rect)
        self._prev = pygame.Rect(self.rect)
        
        self.game.status = 'transition'
        
        self.game.game.sfx['door'].play()
Esempio n. 3
0
def init(g,r,n,*params):
    s = sprite.Sprite3(g,r,'player/right',(5,10,9,20)) #(0,0,19,25))#(43-14,8,28,48))#left,top,width,height
    s.rect.bottom = r.bottom
    s.rect.centerx = r.centerx
    s.groups.add('player')
    s.groups.add('solid')
    g.sprites.append(s)
    s.loop = loop
    s.vx = 0
    s.vy = 0
    s.walk_frame = 1
    s.jumping = 0
    s.facing = 'right'
    s.flash_counter = 0
    s.flash_timer = 0
    s.shooting = 0
    s.powered_up = False
    if hasattr(g.game, 'powerup'):
        s.powered_up = g.game.powerup
    s.powerup_transition = 0
    s.door_timer = None
    s.current_door = None
    s.door_pos = None
    g.player = s
    s.event = event
    s.pan = pan_screen
    s.damage = damage
    s.kill = kill
    s.god_mode = False
    s.death_counter = -1
    
    s._prev = pygame.Rect(s.rect)
    s._prev2 = pygame.Rect(s.rect)
    s.looking = False
    
    sprite.init_bounds(g,s)
    sprite.init_view(g,s)
    sprite.init_codes(g,s)
    s.no_explode = False
    
    return s
Esempio n. 4
0
def hit(g, pos, b):

    cx, cy = pos

    import sprite
    # n_code = sprite.get_code(g,a,1,0)
    dx = 1
    while g.codes_data[cy][cx + dx] in DOOR_CODES:
        dx += 1
    n_code = g.codes_data[cy][cx + dx]

    if n_code == 0:
        return

    layer = g.codes_data

    w, h = g.size
    xx, yy = cx, cy
    for y in xrange(h):
        for x in xrange(w):
            if layer[y][x] in DOOR_CODES and layer[y][x - 1] == n_code:
                xx, yy = x, y

    # t = g.layer[yy][xx]
    rect = pygame.Rect(xx * TW, yy * TH, TW, TH)
    s = b
    s.rect.centerx = rect.centerx
    s.rect.bottom = rect.bottom
    if s.standing is not None:
        sprite.stop_standing(g, s)

    sprite.init_bounds(g, s)
    sprite.init_view(g, s)
    sprite.init_codes(g, s)
    s.prev = pygame.Rect(s.rect)
    s._prev = pygame.Rect(s.rect)

    g.status = 'transition'

    g.game.sfx['door'].play()
Esempio n. 5
0
def hit(g,pos,b):
    
    cx,cy = pos
    
    import sprite
    #n_code = sprite.get_code(g,a,1,0)
    dx = 1
    while g.data[2][cy][cx+dx] in DOOR_CODES: dx += 1
    n_code = g.data[2][cy][cx+dx]
    
    if n_code == 0: return
    
    layer = g.data[2]
    
    w,h = g.size
    xx,yy = cx,cy
    for y in xrange(0,h):
        for x in xrange(0,w):
            if layer[y][x] in DOOR_CODES and layer[y][x-1] == n_code:
                xx,yy = x,y
    
    #t = g.layer[yy][xx]
    rect = pygame.Rect(xx*TW,yy*TH,TW,TH)
    s = b
    s.rect.centerx = rect.centerx
    s.rect.bottom = rect.bottom
    if s.standing != None:
        sprite.stop_standing(g,s)
    
    sprite.init_bounds(g,s)
    sprite.init_view(g,s)
    sprite.init_codes(g,s)
    s.prev = pygame.Rect(s.rect)
    s._prev = pygame.Rect(s.rect)
    
    g.status = 'transition'
    
    g.game.sfx['door'].play()
Esempio n. 6
0
def init(g, r, n, *params):
    s = sprite.Sprite3(g, r, 'player/right',
                       (5, 2, 9, 28))  # left,top,width,height
    s.rect.bottom = r.bottom
    s.rect.centerx = r.centerx
    s.groups.add('player')
    s.groups.add('solid')
    g.sprites.append(s)
    s.loop = loop
    s.vx = 0
    s.vy = 0
    s.walk_frame = 1
    s.jumping = 0
    s.double_jumping = 0
    s.facing = 'right'
    s.flash_counter = 0
    s.flash_timer = 0
    s.shooting = 0
    s.powered_up = ''
    if hasattr(g.game, 'powerup'):
        s.powered_up = g.game.powerup
    s.powerup_transition = 0
    s.door_timer = None
    s.current_door = None
    s.door_pos = None
    g.player = s
    s.event = event
    s.pan = pan_screen
    s.damage = damage
    s.damaged_transition = 0
    s.kill = kill
    s.god_mode = False
    s.death_counter = -1
    s.canshoot = True
    s.got_hit = 0
    s.jump_timer = 0
    s.keep_jump = False

    s.jetpack = "jump"

    s.drone = None
    s.drone_sprite = None

    s.shield = False
    s.shield_sprite = None
    s.shield_countdown = 5 * 30
    s.shield_counter = 0

    s._prev = pygame.Rect(s.rect)
    s._prev2 = pygame.Rect(s.rect)
    s.looking = False

    sprite.init_bounds(g, s)
    sprite.init_view(g, s)
    sprite.init_codes(g, s)
    s.no_explode = False

    s.view_counter = 0

    s.speed = 1

    if hasattr(g.game, 'strength'):
        s.strength = g.game.strength

    return s
Esempio n. 7
0
def init(g, r, n, *params):
    s = sprite.Sprite3(g, r, 'player/right', (5, 2, 9, 28))  # left,top,width,height
    s.rect.bottom = r.bottom
    s.rect.centerx = r.centerx
    s.groups.add('player')
    s.groups.add('solid')
    g.sprites.append(s)
    s.loop = loop
    s.vx = 0
    s.vy = 0
    s.walk_frame = 1
    s.jumping = 0
    s.double_jumping = 0
    s.facing = 'right'
    s.flash_counter = 0
    s.flash_timer = 0
    s.shooting = 0
    s.powered_up = ''
    if hasattr(g.game, 'powerup'):
        s.powered_up = g.game.powerup
    s.powerup_transition = 0
    s.door_timer = None
    s.current_door = None
    s.door_pos = None
    g.player = s
    s.event = event
    s.pan = pan_screen
    s.damage = damage
    s.damaged_transition = 0
    s.kill = kill
    s.god_mode = False
    s.death_counter = -1
    s.canshoot = True
    s.got_hit = 0
    s.jump_timer = 0
    s.keep_jump = False

    s.jetpack = "jump"

    s.drone = None
    s.drone_sprite = None

    s.shield = False
    s.shield_sprite = None
    s.shield_countdown = 5*30
    s.shield_counter = 0

    s._prev = pygame.Rect(s.rect)
    s._prev2 = pygame.Rect(s.rect)
    s.looking = False

    sprite.init_bounds(g, s)
    sprite.init_view(g, s)
    sprite.init_codes(g, s)
    s.no_explode = False

    s.view_counter = 0

    s.speed = 1

    if hasattr(g.game, 'strength'):
        s.strength = g.game.strength

    return s