예제 #1
0
def hit_dmg(g, a, b, top=1, right=1, bottom=1, left=1):
    r, cur, prev = a.rect, b.rect, b.prev

    got_hit = False

    if top and prev.bottom <= r.top and cur.bottom > r.top:
        got_hit = True
        cur.bottom = r.top
        if hasattr(b, 'standing'): b.standing = a
    if right and prev.left >= r.right and cur.left < r.right:
        got_hit = True
        cur.left = r.right
    if bottom and prev.top >= r.bottom and cur.top < r.bottom:
        got_hit = True
        cur.top = r.bottom
        # if hasattr(b,'vy'): b.vy = 0
        if hasattr(b, 'standing') and b.standing != None:
            import sprite
            sprite.stop_standing(g, b)
    if left and prev.right <= r.left and cur.right > r.left:
        got_hit = True
        cur.right = r.left

    # if got_hit and 'shoot' in b.groups:
    #   b.active = False
    #
    # if got_hit and 'laser' in b.groups:
    #   b.active = False

    player.damage(g, b, a)
예제 #2
0
def hit_dmg(g, a, b, top=1, right=1, bottom=1, left=1):
    r, cur, prev = a.rect, b.rect, b.prev

    got_hit = False

    if top and prev.bottom <= r.top and cur.bottom > r.top:
        got_hit = True
        cur.bottom = r.top
        if hasattr(b, 'standing'): b.standing = a
    if right and prev.left >= r.right and cur.left < r.right:
        got_hit = True
        cur.left = r.right
    if bottom and prev.top >= r.bottom and cur.top < r.bottom:
        got_hit = True
        cur.top = r.bottom
        # if hasattr(b,'vy'): b.vy = 0
        if hasattr(b, 'standing') and b.standing != None:
            import sprite
            sprite.stop_standing(g, b)
    if left and prev.right <= r.left and cur.right > r.left:
        got_hit = True
        cur.right = r.left

    # if got_hit and 'shoot' in b.groups:
    #   b.active = False
    #
    # if got_hit and 'laser' in b.groups:
    #   b.active = False

    player.damage(g, b, a)
예제 #3
0
def hit_block(g,a,b,top=1,right=1,bottom=1,left=1):
    #print 'you hit a block'
    
    r,cur,prev = a.rect,b.rect,b.prev
    
    got_hit = False
    
    if top and prev.bottom <= r.top and cur.bottom > r.top:
        got_hit = True
        cur.bottom = r.top
        if hasattr(b,'standing'): b.standing = a
    if right and prev.left >= r.right and cur.left < r.right:
        got_hit = True
        cur.left = r.right
    if bottom and prev.top >= r.bottom and cur.top < r.bottom:
        got_hit = True
        cur.top = r.bottom
        #if hasattr(b,'vy'): b.vy = 0
        if hasattr(b,'standing') and b.standing != None:
            import sprite
            sprite.stop_standing(g,b)
    if left and prev.right <= r.left and cur.right > r.left:
        got_hit = True
        cur.right = r.left

    if got_hit and 'bubble' in b.groups:
        b.active = False
def hit_block(g, a, b, top=1, right=1, bottom=1, left=1):
    # print 'you hit a block'

    r, cur, prev = a.rect, b.rect, b.prev

    got_hit = False

    if top and prev.bottom <= r.top and cur.bottom > r.top:
        got_hit = True
        cur.bottom = r.top
        if hasattr(b, 'standing'):
            b.standing = a
    if right and prev.left >= r.right and cur.left < r.right:
        got_hit = True
        cur.left = r.right
    if bottom and prev.top >= r.bottom and cur.top < r.bottom:
        got_hit = True
        cur.top = r.bottom
        # if hasattr(b,'vy'): b.vy = 0
        if hasattr(b, 'standing') and b.standing is not None:
            import sprite
            sprite.stop_standing(g, b)
    if left and prev.right <= r.left and cur.right > r.left:
        got_hit = True
        cur.right = r.left

    if got_hit and 'bubble' in b.groups:
        b.active = False

    if got_hit and 'laser' in b.groups:
        b.active = False
def event(g, s, e):
    #print 'player.event',e
    if s.door_timer != None or s.exploded > 0:
        return

    if e.type is USEREVENT and e.action == 'jump' and s.standing != None and s.jumping == 0 and s.vy == 0:
        sprite.stop_standing(g, s)
        #s.vy = -1.8
        s.vy = -0.5
        s.jumping = 1.4
        g.game.sfx['jump'].play()
    if e.type is USEREVENT and e.action == 'stop-jump':
        s.jumping = 0

    if e.type is USEREVENT and (e.action == 'up' or e.action == 'down'):
        if sprite.get_code(g, s, 0, 0) in DOOR_CODES:
            s.vx = 0
            s.vy = 0
            s.door_timer = DOOR_DELAY
            if s.current_door != None:  # It should never be None actually...
                #print "door!"
                s.current_door.open = DOOR_DELAY
            s.image = None
            s.door_pos = s.rect.centerx / TW, s.rect.centery / TH
            #tiles.t_put(g,(x,y), 0x32)
            #tiles.t_put(g,(x,y-1), 0x22)
    if e.type is USEREVENT and e.action == 'bubble':
        if s.powered_up:
            sprites.bubble.init(g, s.rect, s, big=True)
        else:
            sprites.bubble.init(g, s.rect, s, big=False)
        s.shooting = 10

    #MYCODE
    if e.type is USEREVENT and e.action == 'right':
        if s.vx < 2:
            s.vx += 2
        s.facing = 'right'
        #s.vx -= 1
    if e.type is USEREVENT and e.action == 'left':
        if s.vx > -2:
            s.vx -= 2
        s.facing = 'left'

    if e.type is KEYDOWN and e.key == K_F10:
        powerup(g, s)
        s.god_mode = True

    if e.type is KEYDOWN and e.key == K_F12:
        1 / 0
예제 #6
0
def loop(g, s):
    sprite.apply_gravity(g, s)
    sprite.apply_standing(g, s)

    if s.bounces > 0 and s.standing:
        sprite.stop_standing(g, s)
        s.vy = -s.bounces * 0.75
        s.bounces -= 1
        if s.bounces == 0:
            s.vx = 0

    s.rect.x += sprite.myinc(g.frame, s.vx)
    s.rect.y += sprite.myinc(g.frame, s.vy)

    s.life -= 1
    if s.life == 0:
        s.active = False
예제 #7
0
def loop(g, s):
    # print 'loop'
    sprite.apply_gravity(g, s)
    sprite.apply_standing(g, s)

    # print s.vy

    if s.next_jump == 0 and s.standing:
        s.vy = -6.0
        s.next_jump = FPS * 2
        sprite.stop_standing(g, s)
    if s.next_jump > 0:
        s.next_jump -= 1

    # if s.rect.x == s._prev.x:
    # s.vx = -s.vx
    s._prev = pygame.Rect(s.rect)

    # s.rect.x += s.vx
    s.rect.y += sprite.myinc(g.frame, s.vy)
예제 #8
0
def loop(g,s):
    print 'loop'
    sprite.apply_gravity(g,s)
    sprite.apply_standing(g,s)

    print s.vy

    if s.next_jump == 0 and s.standing:
        s.vy = -6.0
        s.next_jump = FPS * 2
        sprite.stop_standing(g,s)
    if s.next_jump > 0:
        s.next_jump -= 1
    
    #if s.rect.x == s._prev.x:
        #s.vx = -s.vx
    s._prev = pygame.Rect(s.rect)
    
    #s.rect.x += s.vx
    s.rect.y += sprite.myinc(g.frame,s.vy)
예제 #9
0
def hit_block(g, a, b, top=1, right=1, bottom=1, left=1):
    # print 'you hit a block'

    r, cur, prev = a.rect, b.rect, b.prev

    got_hit = False

    if top and prev.bottom <= r.top and cur.bottom > r.top:
        got_hit = True
        cur.bottom = r.top
        if hasattr(b, 'standing'): b.standing = a
    if right and prev.left >= r.right and cur.left < r.right:
        got_hit = True
        cur.left = r.right
    if bottom and prev.top >= r.bottom and cur.top < r.bottom:
        got_hit = True
        cur.top = r.bottom
        # if hasattr(b,'vy'): b.vy = 0
        if hasattr(b, 'standing') and b.standing != None:
            import sprite
            sprite.stop_standing(g, b)
    if left and prev.right <= r.left and cur.right > r.left:
        got_hit = True
        cur.right = r.left

    if got_hit and 'shoot' in b.groups:
        b.active = False
        sprites.shoot.sound(g)

    if got_hit and 'cannon' in b.groups:
        sprites.shoot.sound(g)
        sprites.explosion.init(g, b.rect, b)
        b.active = False

    if got_hit and 'granadelauncher' in b.groups:
        sprites.shoot.sound(g)
        sprites.explosion.init(g, b.rect, b)
        b.active = False

    if got_hit and 'enemyshoot' in b.groups:
        b.active = False
예제 #10
0
def hit_block(g, a, b, top=1, right=1, bottom=1, left=1):
    # print 'you hit a block'

    r, cur, prev = a.rect, b.rect, b.prev

    got_hit = False

    if top and prev.bottom <= r.top and cur.bottom > r.top:
        got_hit = True
        cur.bottom = r.top
        if hasattr(b, 'standing'): b.standing = a
    if right and prev.left >= r.right and cur.left < r.right:
        got_hit = True
        cur.left = r.right
    if bottom and prev.top >= r.bottom and cur.top < r.bottom:
        got_hit = True
        cur.top = r.bottom
        # if hasattr(b,'vy'): b.vy = 0
        if hasattr(b, 'standing') and b.standing != None:
            import sprite
            sprite.stop_standing(g, b)
    if left and prev.right <= r.left and cur.right > r.left:
        got_hit = True
        cur.right = r.left

    if got_hit and 'shoot' in b.groups:
        b.active = False
        sprites.shoot.sound(g)

    if got_hit and 'cannon' in b.groups:
        sprites.shoot.sound(g)
        sprites.explosion.init(g, b.rect, b)
        b.active = False

    if got_hit and 'granadelauncher' in b.groups:
        sprites.shoot.sound(g)
        sprites.explosion.init(g, b.rect, b)
        b.active = False

    if got_hit and 'enemyshoot' in b.groups:
        b.active = False
예제 #11
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()
예제 #12
0
def event(g,s,e):
    #print 'player.event',e
    if s.door_timer != None or s.exploded > 0:
        return

    if s.death_counter >= 0:
        return
    
    if e.type is USEREVENT and e.action == 'jump' and s.standing != None and s.jumping == 0 and s.vy == 0:
        sprite.stop_standing(g,s)
        #s.vy = -1.8
        s.vy = -0.1
        s.jumping = 1.2
        g.game.sfx['jump'].play()
    if e.type is USEREVENT and e.action == 'stop-jump':
        s.jumping = 0
        
    if e.type is USEREVENT and (e.action == 'up' or e.action == 'down'):
        if sprite.get_code(g,s,0,0) in DOOR_CODES:
            s.vx = 0
            s.vy = 0
            s.door_timer = DOOR_DELAY
            if s.current_door != None: # It should never be None actually...
                #print "door!"
                s.current_door.open = DOOR_DELAY
            s.image = None
            s.door_pos = s.rect.centerx/TW,s.rect.centery/TH
            #tiles.t_put(g,(x,y), 0x32)
            #tiles.t_put(g,(x,y-1), 0x22)
    if e.type is USEREVENT and e.action == 'shoot':
        if s.powered_up:
            sprites.shoot.init(g,s.rect,s,big=True)
        else:
            sprites.shoot.init(g,s.rect,s,big=False)
        s.shooting = 10
        
    if e.type is KEYDOWN and e.key == K_F10:
        powerup(g,s)
        s.god_mode = True
예제 #13
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()
예제 #14
0
def event(g, s, e):
    # print 'player.event',e

    enemy_sprites = g.sprites[:]

    if s.door_timer is not None or s.exploded > 0:
        return

    if s.death_counter >= 0:
        return

    if s.jetpack == "double_jump":
        if e.type is USEREVENT and e.action == 'jump' and s.standing is not None and s.jumping == 0 and s.vy == 0:
            sprite.stop_standing(g, s)

            s.double_jumping = 1

            s.jumping = 1.18

            g.game.sfx['jump'].play()
        elif e.type is USEREVENT and e.action == 'jump' and s.double_jumping == 1:
            sprite.stop_standing(g, s)

            s.double_jumping = 0

            if s.vy > 0:
                #print("Down timer = %d" % s.jump_timer)
                if s.jump_timer >= 8:
                    s.jumping = 1.20
                elif 8 > s.jump_timer >= 2:
                    s.jumping = 1.25
                elif s.jump_timer < 2:
                    s.jumping = 1.60
            else:
                #print("UP timer = %d" % s.jump_timer)
                s.jumping = 0.60

            g.game.sfx['jump'].play()

    elif s.jetpack == "fly":
        if e.type is USEREVENT and e.action == 'jump':
            sprite.stop_standing(g, s)

            # s.vy = 0
            s.jumping = 0.4
            g.game.sfx['jump'].play()

    else:
        if e.type is USEREVENT and e.action == 'jump' and s.standing is not None and s.jumping == 0 and s.vy == 0:
            sprite.stop_standing(g, s)

            # s.vy = 0
            s.jumping = 1.21
            g.game.sfx['jump'].play()

    if e.type is USEREVENT and e.action == 'stop-jump':
        s.jumping = 0

    if e.type is USEREVENT and (e.action == 'up' or e.action == 'down'):
        if sprite.get_code(g, s, 0, 0) in DOOR_CODES:
            s.vx = 0
            s.vy = 0
            s.door_timer = DOOR_DELAY
            if s.current_door is not None:  # It should never be None actually...
                # print "door!"
                s.current_door.open = DOOR_DELAY
            s.image = None
            s.door_pos = s.rect.centerx / TW, s.rect.centery / TH
            # tiles.t_put(g,(x,y), 0x32)
            # tiles.t_put(g,(x,y-1), 0x22)

    if e.type is USEREVENT and e.action == 'shoot':
        enemy_objective = None
        for enemy in enemy_sprites:
            if "enemy" in enemy.groups:
                enemy_objective = enemy
        if s.canshoot:
            if s.powered_up == 'granadelauncher':
                s.shoot = sprites.shoot.init(g, s.rect, s, s.powered_up, enemy_objective, granade=1)
                s.shoot = sprites.shoot.init(g, s.rect, s, s.powered_up, enemy_objective, granade=2)
                s.shoot = sprites.shoot.init(g, s.rect, s, s.powered_up, enemy_objective, granade=3)
            else:
                s.shoot = sprites.shoot.init(g, s.rect, s, s.powered_up, enemy_objective)
            s.shooting = 10
            s.canshoot = False
    """
    if e.type is USEREVENT and e.action == 'stop-shoot':
        if s.powered_up == "granadelauncher" and s.shoot.active is True:
            explosion.init(g, s.shoot.rect, s.shoot)
            s.shoot.active = False
    """

    if e.type is KEYDOWN and e.key == K_F10:

        g.game.chips = [True, True, True, True]

        g.game.powerup = "laser"

        g.game.weapons[0] = 'gun'
        g.game.weapons[1] = 'shootgun'
        g.game.weapons[2] = 'cannon'
        g.game.weapons[3] = 'granadelauncher'
        g.game.weapons[4] = 'laser'

        g.game.drone = "killer"

        g.game.drones[0] = "guardian"
        g.game.drones[1] = "defender"
        g.game.drones[2] = "killer"

        g.game.jetpack = "fly"

        g.game.jetpacks[0] = "jump"
        g.game.jetpacks[1] = "double_jump"
        g.game.jetpacks[2] = "fly"

        s.god_mode = True
예제 #15
0
def event(g, s, e):
    # print 'player.event',e

    enemy_sprites = g.sprites[:]

    if s.door_timer is not None or s.exploded > 0:
        return

    if s.death_counter >= 0:
        return

    if s.jetpack == "double_jump":
        if e.type is USEREVENT and e.action == 'jump' and s.standing is not None and s.jumping == 0 and s.vy == 0:
            sprite.stop_standing(g, s)

            s.double_jumping = 1

            s.jumping = 1.18

            g.game.sfx['jump'].play()
        elif e.type is USEREVENT and e.action == 'jump' and s.double_jumping == 1:
            sprite.stop_standing(g, s)

            s.double_jumping = 0

            if s.vy > 0:
                #print("Down timer = %d" % s.jump_timer)
                if s.jump_timer >= 8:
                    s.jumping = 1.20
                elif 8 > s.jump_timer >= 2:
                    s.jumping = 1.25
                elif s.jump_timer < 2:
                    s.jumping = 1.60
            else:
                #print("UP timer = %d" % s.jump_timer)
                s.jumping = 0.60

            g.game.sfx['jump'].play()

    elif s.jetpack == "fly":
        if e.type is USEREVENT and e.action == 'jump':
            sprite.stop_standing(g, s)

            # s.vy = 0
            s.jumping = 0.4
            g.game.sfx['jump'].play()

    else:
        if e.type is USEREVENT and e.action == 'jump' and s.standing is not None and s.jumping == 0 and s.vy == 0:
            sprite.stop_standing(g, s)

            # s.vy = 0
            s.jumping = 1.21
            g.game.sfx['jump'].play()

    if e.type is USEREVENT and e.action == 'stop-jump':
        s.jumping = 0

    if e.type is USEREVENT and (e.action == 'up' or e.action == 'down'):
        if sprite.get_code(g, s, 0, 0) in DOOR_CODES:
            s.vx = 0
            s.vy = 0
            s.door_timer = DOOR_DELAY
            if s.current_door is not None:  # It should never be None actually...
                # print "door!"
                s.current_door.open = DOOR_DELAY
            s.image = None
            s.door_pos = s.rect.centerx / TW, s.rect.centery / TH
            # tiles.t_put(g,(x,y), 0x32)
            # tiles.t_put(g,(x,y-1), 0x22)

    if e.type is USEREVENT and e.action == 'shoot':
        enemy_objective = None
        for enemy in enemy_sprites:
            if "enemy" in enemy.groups:
                enemy_objective = enemy
        if s.canshoot:
            if s.powered_up == 'granadelauncher':
                s.shoot = sprites.shoot.init(g,
                                             s.rect,
                                             s,
                                             s.powered_up,
                                             enemy_objective,
                                             granade=1)
                s.shoot = sprites.shoot.init(g,
                                             s.rect,
                                             s,
                                             s.powered_up,
                                             enemy_objective,
                                             granade=2)
                s.shoot = sprites.shoot.init(g,
                                             s.rect,
                                             s,
                                             s.powered_up,
                                             enemy_objective,
                                             granade=3)
            else:
                s.shoot = sprites.shoot.init(g, s.rect, s, s.powered_up,
                                             enemy_objective)
            s.shooting = 10
            s.canshoot = False
    """
    if e.type is USEREVENT and e.action == 'stop-shoot':
        if s.powered_up == "granadelauncher" and s.shoot.active is True:
            explosion.init(g, s.shoot.rect, s.shoot)
            s.shoot.active = False
    """

    if e.type is KEYDOWN and e.key == K_F10:

        g.game.chips = [True, True, True, True]

        g.game.powerup = "laser"

        g.game.weapons[0] = 'gun'
        g.game.weapons[1] = 'shootgun'
        g.game.weapons[2] = 'cannon'
        g.game.weapons[3] = 'granadelauncher'
        g.game.weapons[4] = 'laser'

        g.game.drone = "killer"

        g.game.drones[0] = "guardian"
        g.game.drones[1] = "defender"
        g.game.drones[2] = "killer"

        g.game.jetpack = "fly"

        g.game.jetpacks[0] = "jump"
        g.game.jetpacks[1] = "double_jump"
        g.game.jetpacks[2] = "fly"

        s.god_mode = True
예제 #16
0
def loop(g, s):
    sprite.apply_gravity(g, s)
    sprite.apply_standing(g, s)

    # if s.standing != None and s.vx != 0:
    # next_tile = g.layer[s.standing.pos[1]][s.standing.pos[0] + s.direction]
    # next2_tile = g.layer[s.standing.pos[1]][s.standing.pos[0] + s.direction*2]
    # if (next_tile.standable == 0) or (next2_tile.standable == 0):
    # s.rect.x = s._prev.x
    # s.direction = - s.direction
    # s.next_frame = 1


    if g.frame % s.speed == 0:
        if s.walking:
            if s._prev != None:
                if s.rect.x == s._prev.x or sprite.get_code(g, s, sign(s.vx), 0) == CODE_ZOMBIE_TURN:
                    s.vx = -s.vx
                    s.next_frame = 1
                    if s.vx < 0:
                        s.facing = 'left'
                    else:
                        s.facing = 'right'

            if s.standing != None and sprite.get_code(g, s, sign(s.vx), 1) == CODE_ZOMBIE_JUMP:
                # s.vy_jump = -3.1
                """
				if sprite.get_code(g,s,sign(s.vx)*2,1) == CODE_ZOMBIE_JUMP:
					s.vy_jump = -3.0
					if sprite.get_code(g,s,sign(s.vx)*3,1) == CODE_ZOMBIE_JUMP:
						s.vy_jump = -4.1
				"""
                s.jumping = True
                s.walking = False
                s.next_frame = 20
                s.image = 'zombie/prejump-%s' % s.facing

            s._prev = pygame.Rect(s.rect)

            s.rect.x += s.vx
            s.rect.y += s.vy
        else:
            s._prev = pygame.Rect(s.rect)
            if (s.next_frame <= 0):
                if (s.standing != None):
                    s.walking = True
                    s.jumping = False
                    s.next_frame = 1
                # s.vx*1
                vx = s.vx
                s.rect.x += sprite.myinc(g.frame, vx)
                s.rect.y += sprite.myinc(g.frame, s.vy)

        s.next_frame -= 1
        if s.next_frame == 0:
            if s.jumping:
                sprite.stop_standing(g, s)
                s.vy = s.vy_jump
                s.image = 'zombie/jump-%s' % s.facing
            else:
                s.next_frame = s.frame_speed
                s.frame += 1
                if s.frame > 3:
                    s.frame = 0
                s.image = 'zombie/walk-%s-%s' % (s.facing, s.frame)
예제 #17
0
def die(g,s):
    g.game.sfx['pop'].play()
    s.active = False
    for b in s.carrying:
        sprite.stop_standing(g,b)
예제 #18
0
def loop(g,s):
    sprite.apply_gravity(g,s)
    sprite.apply_standing(g,s)
    
    #if s.standing != None and s.vx != 0:
        #next_tile = g.layer[s.standing.pos[1]][s.standing.pos[0] + s.direction]
        #next2_tile = g.layer[s.standing.pos[1]][s.standing.pos[0] + s.direction*2]
        #if (next_tile.standable == 0) or (next2_tile.standable == 0):
            #s.rect.x = s._prev.x    
            #s.direction = - s.direction
            #s.next_frame = 1
    if s.walking:
        if s._prev != None:
            if s.rect.x == s._prev.x or sprite.get_code(g,s,sign(s.vx),0) == CODE_FROG_TURN:
                s.vx = -s.vx
                s.next_frame=1
                
        if s.standing != None and sprite.get_code(g,s,sign(s.vx),1) == CODE_FROG_JUMP:
            #s.vy_jump = -4.0
            s.vy_jump = -1.8
            if sprite.get_code(g,s,sign(s.vx)*2,1) == CODE_FROG_JUMP:
                #s.vy_jump = -6.5
                s.vy_jump = -3.0
                if sprite.get_code(g,s,sign(s.vx)*3,1) == CODE_FROG_JUMP:
                    #s.vy_jump = -8.5
                    s.vy_jump = -4.1
                
            s.jumping = True
            s.walking = False
            s.next_frame = 20
            if s.vx > 0:
                s.image = 'frog/prejump-right'
            elif s.vx < 0:
                s.image = 'frog/prejump-left' 
            
        s._prev = pygame.Rect(s.rect)
        
        s.rect.x += s.vx*1
        s.rect.y += s.vy
    else:
        s._prev = pygame.Rect(s.rect)
        if (s.next_frame <= 0): 
            if (s.standing != None):
                s.walking=True
                s.jumping=False
                s.next_frame=1
            #s.vx*1
            vx = s.vx*1.5
            s.rect.x += sprite.myinc(g.frame,vx)
            s.rect.y += sprite.myinc(g.frame,s.vy)
            
    s.next_frame -= 1
    if s.next_frame == 0:
        if s.jumping:
            sprite.stop_standing(g,s)
            s.vy = s.vy_jump
            if s.vx > 0:
                s.image = 'frog/jump-right'
            elif s.vx < 0:
                s.image = 'frog/jump-left' 
        else: 
            s.next_frame = 6
            s.frame += 1
            if s.frame > 4:
                s.frame = 0
            if s.vx > 0:
                s.image = 'frog/walk-right-' + str(s.frame)
            elif s.vx < 0:
                s.image = 'frog/walk-left-' + str(s.frame)
예제 #19
0
def loop(g, s):
    sprite.apply_gravity(g, s)
    sprite.apply_standing(g, s)

    # if s.standing != None and s.vx != 0:
    # next_tile = g.layer[s.standing.pos[1]][s.standing.pos[0] + s.direction]
    # next2_tile = g.layer[s.standing.pos[1]][s.standing.pos[0] + s.direction*2]
    # if (next_tile.standable == 0) or (next2_tile.standable == 0):
    # s.rect.x = s._prev.x
    # s.direction = - s.direction
    # s.next_frame = 1

    if s.flying:
        if s._prev != None:
            if s.rect.x == s._prev.x or sprite.get_code(g, s, sign(s.vx),
                                                        0) == CODE_BAT_TURN:
                s.vx = -s.vx
                s.next_frame = 1
                if s.vx < 0:
                    s.facing = 'left'
                else:
                    s.facing = 'right'

        if s.standing != None and sprite.get_code(g, s, sign(s.vx),
                                                  1) == CODE_BAT_ATTACK:
            s.vy_attack = -4
            """
			if sprite.get_code(g,s,sign(s.vx)*2,1) == CODE_BAT_ATTACK:
				s.vy_attack = -3.0
				if sprite.get_code(g,s,sign(s.vx)*3,1) == CODE_BAT_ATTACK:
					s.vy_attack = -4.1
			"""
            s.attacking = True
            s.flying = False
            s.next_frame = 20
            s.image = 'bat/preattack-%s' % s.facing

        s._prev = pygame.Rect(s.rect)

        s.rect.x += s.vx
        s.rect.y += s.vy
    else:
        s._prev = pygame.Rect(s.rect)
        if (s.next_frame <= 0):
            if (s.standing != None):
                s.flying = True
                s.attacking = False
                s.next_frame = 1
            # s.vx*1
            vx = s.vx
            s.rect.x += sprite.myinc(g.frame, vx)
            s.rect.y += sprite.myinc(g.frame, s.vy)

    s.next_frame -= 1
    if s.next_frame == 0:
        if s.attacking:
            sprite.stop_standing(g, s)
            s.vy = s.vy_attack
            s.image = 'bat/attack-%s' % s.facing
        else:
            s.next_frame = 6
            s.frame += 1
            if s.frame > 2:
                s.frame = 0
            s.image = 'bat/fly-%s-%s' % (s.facing, s.frame)
예제 #20
0
def loop(g, s):
    sprite.apply_gravity(g, s)
    sprite.apply_standing(g, s)

    # if s.standing != None and s.vx != 0:
    # next_tile = g.layer[s.standing.pos[1]][s.standing.pos[0] + s.direction]
    # next2_tile = g.layer[s.standing.pos[1]][s.standing.pos[0] + s.direction*2]
    # if (next_tile.standable == 0) or (next2_tile.standable == 0):
    # s.rect.x = s._prev.x
    # s.direction = - s.direction
    # s.next_frame = 1

    if g.frame % s.speed == 0:
        if s.walking:
            if s._prev != None:
                if s.rect.x == s._prev.x or sprite.get_code(
                        g, s, sign(s.vx), 0) == CODE_ZOMBIE_TURN:
                    s.vx = -s.vx
                    s.next_frame = 1
                    if s.vx < 0:
                        s.facing = 'left'
                    else:
                        s.facing = 'right'

            if s.standing != None and sprite.get_code(g, s, sign(s.vx),
                                                      1) == CODE_ZOMBIE_JUMP:
                # s.vy_jump = -3.1
                """
				if sprite.get_code(g,s,sign(s.vx)*2,1) == CODE_ZOMBIE_JUMP:
					s.vy_jump = -3.0
					if sprite.get_code(g,s,sign(s.vx)*3,1) == CODE_ZOMBIE_JUMP:
						s.vy_jump = -4.1
				"""
                s.jumping = True
                s.walking = False
                s.next_frame = 20
                s.image = 'zombie/prejump-%s' % s.facing

            s._prev = pygame.Rect(s.rect)

            s.rect.x += s.vx
            s.rect.y += s.vy
        else:
            s._prev = pygame.Rect(s.rect)
            if (s.next_frame <= 0):
                if (s.standing != None):
                    s.walking = True
                    s.jumping = False
                    s.next_frame = 1
                # s.vx*1
                vx = s.vx
                s.rect.x += sprite.myinc(g.frame, vx)
                s.rect.y += sprite.myinc(g.frame, s.vy)

        s.next_frame -= 1
        if s.next_frame == 0:
            if s.jumping:
                sprite.stop_standing(g, s)
                s.vy = s.vy_jump
                s.image = 'zombie/jump-%s' % s.facing
            else:
                s.next_frame = s.frame_speed
                s.frame += 1
                if s.frame > 3:
                    s.frame = 0
                s.image = 'zombie/walk-%s-%s' % (s.facing, s.frame)
예제 #21
0
def loop(g, s):
    sprite.apply_gravity(g, s)
    sprite.apply_standing(g, s)

    # if s.standing != None and s.vx != 0:
    # next_tile = g.layer[s.standing.pos[1]][s.standing.pos[0] + s.direction]
    # next2_tile = g.layer[s.standing.pos[1]][s.standing.pos[0] + s.direction*2]
    # if (next_tile.standable == 0) or (next2_tile.standable == 0):
    # s.rect.x = s._prev.x
    # s.direction = - s.direction
    # s.next_frame = 1

    if s.flying:
        if s._prev != None:
            if s.rect.x == s._prev.x or sprite.get_code(g, s, sign(s.vx), 0) == CODE_BAT_TURN:
                s.vx = -s.vx
                s.next_frame = 1
                if s.vx < 0:
                    s.facing = 'left'
                else:
                    s.facing = 'right'

        if s.standing != None and sprite.get_code(g, s, sign(s.vx), 1) == CODE_BAT_ATTACK:
            s.vy_attack = -4
            """
			if sprite.get_code(g,s,sign(s.vx)*2,1) == CODE_BAT_ATTACK:
				s.vy_attack = -3.0
				if sprite.get_code(g,s,sign(s.vx)*3,1) == CODE_BAT_ATTACK:
					s.vy_attack = -4.1
			"""
            s.attacking = True
            s.flying = False
            s.next_frame = 20
            s.image = 'bat/preattack-%s' % s.facing

        s._prev = pygame.Rect(s.rect)

        s.rect.x += s.vx
        s.rect.y += s.vy
    else:
        s._prev = pygame.Rect(s.rect)
        if (s.next_frame <= 0):
            if (s.standing != None):
                s.flying = True
                s.attacking = False
                s.next_frame = 1
            # s.vx*1
            vx = s.vx
            s.rect.x += sprite.myinc(g.frame, vx)
            s.rect.y += sprite.myinc(g.frame, s.vy)

    s.next_frame -= 1
    if s.next_frame == 0:
        if s.attacking:
            sprite.stop_standing(g, s)
            s.vy = s.vy_attack
            s.image = 'bat/attack-%s' % s.facing
        else:
            s.next_frame = 6
            s.frame += 1
            if s.frame > 2:
                s.frame = 0
            s.image = 'bat/fly-%s-%s' % (s.facing, s.frame)
예제 #22
0
def die(g, s):
    g.game.sfx['pop'].play()
    s.active = False
    for b in s.carrying:
        sprite.stop_standing(g, b)
        print b.standing
예제 #23
0
파일: frog.py 프로젝트: pointtonull/Tokuah
    def loop(self):
        self.apply_gravity()
        self.apply_standing()

        if self.walking:
            if self._prev != None:
                if (self.rect.x == self._prev.x or self.get_code(sign(self.vx),
                    0) == CODE_FROG_TURN):
                    self.vx = -self.vx
                    self.next_frame = 1

            if (self.standing != None and self.get_code(sign(self.vx),
                    1) == CODE_FROG_JUMP):
                self.vy_jump = - 3.6 * 1.22
                if (sprite.get_code(self.game, self, sign(self.vx) * 2, 1)
                        == CODE_FROG_JUMP):
                    self.vy_jump = - 6.0 * 1.22
                    if (sprite.get_code(game, self, sign(self.vx) * 3, 1)
                         == CODE_FROG_JUMP):
                        self.vy_jump = - 8.1 * 1.22

                self.jumping = True
                self.walking = False
                self.next_frame = 20

                if self.vx > 0:
                    self.image = 'frog/prejump-right'
                elif self.vx < 0:
                    self.image = 'frog/prejump-left'

            self._prev = pygame.Rect(self.rect)

            self.rect.x += self.vx
            self.rect.y += self.vy

        else:
            self._prev = pygame.Rect(self.rect)
            if (self.next_frame <= 0):
                if (self.standing != None):
                    self.walking = True
                    self.jumping = not self.walking
                    self.next_frame = 1
                vx = self.vx * 1.8
                self.rect.x += sprite.myinc(self.game.frame, vx)
                self.rect.y += sprite.myinc(self.game.frame, self.vy)

        self.next_frame -= 1
        if self.next_frame == 0:
            if self.jumping:
                sprite.stop_standing(self.game, self)
                self.vy = self.vy_jump
                if self.vx > 0:
                    self.image = 'frog/jump-right'
                elif self.vx < 0:
                    self.image = 'frog/jump-left'
            else:
                self.next_frame = 6
                self.frame += 1
                if self.frame > 4:
                    self.frame = 0
                if self.vx > 0:
                    self.image = 'frog/walk-right-' + str(self.frame)
                elif self.vx < 0:
                    self.image = 'frog/walk-left-' + str(self.frame)