Exemple #1
0
def loop(g,s):
    sprite.apply_gravity(g,s)
    sprite.apply_standing(g,s)
    
    #if s.rect.x == s._prev.x: # or sprite.get_code(g,s,sign(s.vx),0) == CODE_TENTACTUL_TURN:
    #    s.vx = -s.vx

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

    if g.player.rect.centerx > s.rect.centerx:
        s.vx += 0.02
    elif g.player.rect.centerx < s.rect.centerx:
        s.vx -= 0.02

    if s.vx > 0.0:
        s.facing = 'right'
    elif s.vx < 0.0:
        s.facing = 'left'
    s.image = 'tentactul/tentactul-%s-%s' % (s.facing, (g.frame / 10) % 4)

    if sprite.get_code(g,s,sign(s.vx),0) == CODE_TENTACTUL_TURN:
        s.vx = 0.0

    s.vx = min(1.0, s.vx)
    s.vx = max(-1.0, s.vx)
    
    if s.shoot == 0:
        shot = tentactulshoot.init(g,s.rect,s)
        #g.sprites.append(shot)
        s.shoot = 120
        s.shooting = 10

    if s.shooting > 0:
        s.image = 'tentactul/tentactul-%s-shoot' % (s.facing)
        s.shooting -= 1

    s.shoot -= 1
    
    s.rect.x += sprite.myinc(g.frame,s.vx)
    s.rect.y += sprite.myinc(g.frame,s.vy)
def loop(g, s):
    # sprite.apply_gravity(g,s)
    sprite.apply_standing(g, s)

    # if s.rect.x == s._prev.x: # or sprite.get_code(g,s,sign(s.vx),0) == CODE_TENTACTUL_TURN:
    #   s.vx = -s.vx

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

    if g.player.rect.centerx > s.rect.centerx:
        s.vx += 0.02
    elif g.player.rect.centerx < s.rect.centerx:
        s.vx -= 0.02

    if s.vx > 0.0:
        s.facing = 'right'
    elif s.vx < 0.0:
        s.facing = 'left'
    s.image = 'tentactul/tentactul-%s-%s' % (s.facing, (g.frame / 10) % 4)

    if sprite.get_code(g, s, sign(s.vx), 0) == CODE_TENTACTUL_TURN:
        s.vx = 0.0

    s.vx = min(1.0, s.vx)
    s.vx = max(-1.0, s.vx)

    if s.idling > 0:
        if s.idling % 40 > 20:
            s.facing = 'left'
        else:
            s.facing = 'right'
        s.idling -= 1
        if s.idling == 0:
            s.moving = 90
            # if g.game.random % 2 == 0:
            if random.randint(0, 1):
                s.vx = -s.speed
                s.facing = 'left'
            else:
                s.vx = s.speed
                s.facing = 'right'
    elif s.moving > 0:
        s.moving -= 1
        if s.moving == 0:
            s.idling = 80
            s.vx = 0
    else:
        s.idling = 80

    if s.vx < 0:
        s.facing = 'left'
    else:
        s.facing = 'right'

    s.image = 'tentactul/tentactul-%s-%s' % (s.facing, (s.frame / 5) % 2)
    s.frame += 1

    if s.shoot == 0:
        shot = tentactulshoot.init(g, s.rect, s)
        # g.sprites.append(shot)
        s.shoot = s.shoot_reload
        s.shooting = 5

    if s.shooting > 0:
        s.image = 'tentactul/tentactul-%s-shoot' % (s.facing)
        s.shooting -= 1

    s.shoot -= 1

    s.rect.x += sprite.myinc(g.frame, s.vx)
    s.rect.y += sprite.myinc(g.frame, s.vy)
Exemple #3
0
def loop(g, s):
    # sprite.apply_gravity(g,s)
    sprite.apply_standing(g, s)

    # if s.rect.x == s._prev.x: # or sprite.get_code(g,s,sign(s.vx),0) == CODE_TENTACTUL_TURN:
    #   s.vx = -s.vx

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

    if g.player.rect.centerx > s.rect.centerx:
        s.vx += 0.02
    elif g.player.rect.centerx < s.rect.centerx:
        s.vx -= 0.02

    if s.vx > 0.0:
        s.facing = 'right'
    elif s.vx < 0.0:
        s.facing = 'left'
    s.image = 'tentactul/tentactul-%s-%s' % (s.facing, (g.frame / 10) % 4)

    if sprite.get_code(g, s, sign(s.vx), 0) == CODE_TENTACTUL_TURN:
        s.vx = 0.0

    s.vx = min(1.0, s.vx)
    s.vx = max(-1.0, s.vx)

    if s.idling > 0:
        if s.idling % 40 > 20:
            s.facing = 'left'
        else:
            s.facing = 'right'
        s.idling -= 1
        if s.idling == 0:
            s.moving = 90
            # if g.game.random % 2 == 0:
            if random.randint(0, 1):
                s.vx = -s.speed
                s.facing = 'left'
            else:
                s.vx = s.speed
                s.facing = 'right'
    elif s.moving > 0:
        s.moving -= 1
        if s.moving == 0:
            s.idling = 80
            s.vx = 0
    else:
        s.idling = 80

    if s.vx < 0:
        s.facing = 'left'
    else:
        s.facing = 'right'

    s.image = 'tentactul/tentactul-%s-%s' % (s.facing, (s.frame / 5) % 2)
    s.frame += 1

    if s.shoot == 0:
        shot = tentactulshoot.init(g, s.rect, s)
        # g.sprites.append(shot)
        s.shoot = s.shoot_reload
        s.shooting = 5

    if s.shooting > 0:
        s.image = 'tentactul/tentactul-%s-shoot' % (s.facing)
        s.shooting -= 1

    s.shoot -= 1

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