Ejemplo n.º 1
0
def cball_loop(g, s):
    try:
        s.rect.x += s.vx
    except AttributeError:
        return

    s.rect.y += s.vy
    s.z += s.vz
    s.vz += 1
    if s.vz == 8:
        if s in g.sprites:
            g.sprites.remove(s)

        img_name = get_hole_for_damage(s.damage)
        g.bkgr_blit(g.images[img_name], (s.rect.centerx, s.rect.centery))

        g.level.game.sm.Play(sound_info.hitground.nextone(), wait=3)

        if HOLES_ARE_TILES:
            tw, th = g.iso_w, g.iso_h
            tx, ty = s.rect.centerx / tw, s.rect.centery / th

            dirs = [(0, 0)]
            if HOLES_ARE_TILES > 1:
                dirs.extend([(-1, 0), (1, 0), (0, 1), (0, -1)])
            for dx, dy in dirs:
                xx, yy = tx + dx, ty + dy
                v = g.get((xx, yy))
                if v in (0, 7):
                    g.set((xx, yy), 30)

        #ss = effect.effect_new(g,s.rect,steam.Effect(20,20,8,0,(117,110,94)),20)
        num_steam, num_steam_add = s.num_steam, s.num_steam_add
        ss = effect.effect_new(
            g, s.rect,
            steam.Effect(int(num_steam * 2), int(num_steam_add * 2),
                         num_steam_add, 0, (0, 0, 0)), 20)
        ss.z = 8

        print 'gahhh'
        a = s
        for r in g.robots:
            rx, ry = r.x, r.y
            ax, ay = a.rect.x, a.rect.y
            dx, dy = rx - ax, ry - ay
            dist = (dx * dx + dy * dy)**0.5
            if dist and dist < 32 * 4:
                r.min = min(r._min, r.min + 12.0)
                inc = 31.0
                x, y = rx + dx * inc / dist, ry + dy * inc / dist
                robot.robot_shove(g, r, (x, y))

            if dist < 32 * 3:  #1.5:
                r.state = 'dead'

    #print s.rect
    s.frame += 1
Ejemplo n.º 2
0
def cball_loop(g,s):
    try:
        s.rect.x += s.vx
    except AttributeError: 
        return

    s.rect.y += s.vy
    s.z += s.vz
    s.vz += 1
    if s.vz == 8:
        if s in g.sprites:
            g.sprites.remove(s)

        img_name = get_hole_for_damage(s.damage)
        g.bkgr_blit(g.images[img_name],(s.rect.centerx,s.rect.centery))


        g.level.game.sm.Play(sound_info.hitground.nextone(), wait=3)
        
        if HOLES_ARE_TILES:
            tw,th = g.iso_w,g.iso_h
            tx,ty = s.rect.centerx/tw,s.rect.centery/th
            
            dirs = [(0,0)]
            if HOLES_ARE_TILES > 1:
                dirs.extend([(-1,0),(1,0),(0,1),(0,-1)])
            for dx,dy in dirs:
                xx,yy = tx+dx,ty+dy
                v = g.get((xx,yy))
                if v in (0,7):
                    g.set((xx,yy),30)
        

        #ss = effect.effect_new(g,s.rect,steam.Effect(20,20,8,0,(117,110,94)),20)
        num_steam, num_steam_add = s.num_steam, s.num_steam_add
        ss = effect.effect_new(g,s.rect,steam.Effect(int(num_steam*2), int(num_steam_add*2),num_steam_add,0,(0,0,0)),20)
        ss.z = 8
        
        print 'gahhh'
        a = s
        for r in g.robots:
            rx,ry = r.x,r.y
            ax,ay = a.rect.x,a.rect.y
            dx,dy = rx-ax,ry-ay
            dist = (dx*dx+dy*dy)**0.5
            if dist and dist < 32*4:
                r.min = min(r._min,r.min+12.0)
                inc = 31.0
                x,y = rx + dx*inc/dist, ry + dy*inc/dist
                robot.robot_shove(g,r,(x,y))

            if dist < 32*3: #1.5:
                r.state = 'dead'

    #print s.rect
    s.frame += 1
Ejemplo n.º 3
0
def castle_loop(g, s):
    #print "castle loop"

    s.unit.loop()

    # update the steam every second.
    #print g.level.game.ticks_passed

    #tw,th = g.iso_w,g.iso_h

    tw, th = g.iso_w, g.iso_h
    sx, sy = s.rect.centerx / tw, s.rect.centery / th

    s.last_update_steam += g.level.game.elapsed_time

    if s.can_move:
        #s.rect.x += 1

        speed = int(s.unit.stats['Speed'])

        kx, ky = 0, 0

        # put in the joystick movement.
        if kx == 0:
            kx += s.direction_dx
            #s.dx = 0
        if ky == 0:
            ky += s.direction_dy
            #s.dy = 0

        # HACK: we do a little invert here.  because hex movement is weird.
        # we try to make up joy go up on screen.

        if 1:

            if kx == 0 and ky == -1:
                kx = -1
                ky = -1

            elif kx == 0 and ky == 1:
                kx = 1
                ky = 1

            elif kx == 1 and ky == -1:
                kx = 0
                ky = -1

            elif kx == -1 and ky == -1:
                kx = -1
                ky = 0
            elif kx == -1 and ky == 1:
                kx = 0
                ky = 1
            elif kx == 1 and ky == 1:
                kx = 1
                ky = 0

            elif kx == 1 and ky == 0:
                kx = 1
                ky = -1

            elif kx == -1 and ky == 0:
                kx = -1
                ky = 1

        #if ky == 1 and kx == 0:
        #    kx = 1
        #    ky = 1

        #print kx,ky

        keyboard_or_joy_speed_slow = 1
        #if ky == 0 or kx == 0:
        #        if (kx,ky) != (0,0):
        #
        #            if (kx,ky) == (1,1) or (kx,ky) == (-1,-1) or kx == 0 or ky == 0:
        #                keyboard_or_joy_speed_slow = 0

        if (kx, ky) != (0, 0):
            keyboard_or_joy = 1

            tx, ty = sx + kx, sy + ky
            if g.castle_layer[ty][tx] == 0:
                s.path = [(tx, ty)]

        dx, dy = 0, 0
        path = s.path
        while len(path) > 0:
            g.auto_scroll = True
            bx, by = path[0]
            if (bx, by) == (sx, sy):
                path.pop(0)
                continue
            dx, dy = bx - sx, by - sy
            #v = 4
            #s.rect.x += sign(dx)*v
            #s.rect.y += sign(dy)*v
            dx, dy = sign(dx), sign(dy)
            break

        if keyboard_or_joy_speed_slow:
            speed = int(round(speed / 2.))

        if dx != 0 or dy != 0:
            #HACK: so i can move this guy ! :)
            if 1 or s.unit.try_move():
                s.rect.x += dx * speed
                s.rect.y += dy * speed

            if dx < 0:
                s.setimage(g.images['castle.left'])
            if dx > 0:
                s.setimage(g.images['castle.right'])

        #s.rect.clamp_ip(g.view)
    if s.last_hit_coal:
        #print "last_hit_coal, last"
        if s.last_hit_coal == s.last_loop:
            s.last_loop = 0
            s.last_hit_coal = 0
            s.no_pickup("")
        else:
            s.last_loop = s.last_hit_coal

    #okay, so the robots are scared to death of you...
    a = s
    for r in g.robots:
        rx, ry = r.x, r.y
        ax, ay = a.rect.x, a.rect.y
        dx, dy = rx - ax, ry - ay
        dist = (dx * dx + dy * dy)**0.5
        if dist and dist < 32 * 3:
            r.min = min(r._min, r.min + 12.0)
            inc = 16.0
            x, y = rx + dx * inc / dist, ry + dy * inc / dist
            robot.robot_shove(g, r, (x, y))

    s.frame += 1
Ejemplo n.º 4
0
def castle_loop(g,s):
    #print "castle loop"

    s.unit.loop()

    # update the steam every second.
    #print g.level.game.ticks_passed

    #tw,th = g.iso_w,g.iso_h

    tw,th = g.iso_w,g.iso_h
    sx,sy = s.rect.centerx/tw,s.rect.centery/th


    s.last_update_steam += g.level.game.elapsed_time

    if s.can_move:
        #s.rect.x += 1

        speed = int(s.unit.stats['Speed'])

        kx,ky = 0,0

        # put in the joystick movement.
        if kx == 0:
            kx += s.direction_dx
            #s.dx = 0
        if ky == 0:
            ky += s.direction_dy
            #s.dy = 0


        # HACK: we do a little invert here.  because hex movement is weird.
        # we try to make up joy go up on screen.

        if 1:


            if kx == 0 and ky == -1:
                kx = -1
                ky = -1

            elif kx == 0 and ky == 1:
                kx = 1
                ky = 1

            elif kx == 1 and ky == -1:
                kx = 0
                ky = -1

            elif kx == -1 and ky == -1:
                kx = -1
                ky = 0
            elif kx == -1 and ky == 1:
                kx = 0
                ky = 1
            elif kx == 1 and ky == 1:
                kx = 1
                ky = 0

            elif kx == 1 and ky == 0:
                kx = 1
                ky = -1

            elif kx == -1 and ky == 0:
                kx = -1
                ky = 1

        #if ky == 1 and kx == 0:
        #    kx = 1
        #    ky = 1

        #print kx,ky

        keyboard_or_joy_speed_slow = 1
        #if ky == 0 or kx == 0:
#        if (kx,ky) != (0,0):
#
#            if (kx,ky) == (1,1) or (kx,ky) == (-1,-1) or kx == 0 or ky == 0:
#                keyboard_or_joy_speed_slow = 0



        if (kx,ky) != (0,0):
            keyboard_or_joy = 1

            tx,ty = sx+kx,sy+ky
            if g.castle_layer[ty][tx] == 0:
                s.path = [(tx,ty)]

            
        dx,dy = 0,0
        path = s.path
        while len(path) > 0:
            g.auto_scroll = True
            bx,by = path[0]
            if (bx,by) == (sx,sy): 
                path.pop(0)
                continue
            dx,dy = bx-sx,by-sy
            #v = 4
            #s.rect.x += sign(dx)*v
            #s.rect.y += sign(dy)*v
            dx,dy = sign(dx),sign(dy)
            break

        if keyboard_or_joy_speed_slow:
            speed = int(round(speed / 2.))

        if dx != 0 or dy != 0:
            #HACK: so i can move this guy ! :)
            if 1 or s.unit.try_move():
                s.rect.x += dx*speed
                s.rect.y += dy*speed
                
            if dx < 0:
                s.setimage(g.images['castle.left'])
            if dx > 0:
                s.setimage(g.images['castle.right'])

        #s.rect.clamp_ip(g.view)
    if s.last_hit_coal:
        #print "last_hit_coal, last"
        if s.last_hit_coal == s.last_loop:
            s.last_loop = 0
            s.last_hit_coal = 0
            s.no_pickup("")
        else:
            s.last_loop = s.last_hit_coal

    #okay, so the robots are scared to death of you...
    a = s
    for r in g.robots:
        rx,ry = r.x,r.y
        ax,ay = a.rect.x,a.rect.y
        dx,dy = rx-ax,ry-ay
        dist = (dx*dx+dy*dy)**0.5
        if dist and dist < 32*3:
            r.min = min(r._min,r.min+12.0)
            inc = 16.0
            x,y = rx + dx*inc/dist, ry + dy*inc/dist
            robot.robot_shove(g,r,(x,y))


    s.frame +=1