Esempio n. 1
0
def effect_new(g,rect,e,f):
    s = isovid.Sprite(g.images['blank'],rect)
    s.effect = e
    
    s.frames = f
    g.sprites.append(s)
    
    s.loop = effect_loop
    
    return s
Esempio n. 2
0
def cannon_new(g, t, v):
    g.clayer[t.ty][t.tx] = 0
    s = isovid.Sprite(g.images['cannon'], t.rect)

    s.frame = random.randrange(0, FPS * 3)

    g.sprites.append(s)
    s.loop = cannon_loop
    s.hit = cannon_hit
    s.groups = g.string2groups("cannon")
    #s.agroups =g.string2groups("castle")

    s.unit = CannonTower()
Esempio n. 3
0
def truck_new(g, t, v):
    print 'trucks disabled'
    return
    g.clayer[t.ty][t.tx] = 0
    s = isovid.Sprite(g.images['truck'], t.rect)

    s.frame = 0

    g.sprites.append(s)
    s.loop = truck_loop
    s.hit = truck_hit
    s.groups = g.string2groups("truck")
    s.agroups = g.string2groups("castle")

    s.origin = t.tx, t.ty
    s.state = 'init'
    s.unit = CoalTruck()
Esempio n. 4
0
def cball_new(g, pos, damage=1.0):
    g.level.game.sm.Play("cannon")

    s = isovid.Sprite(g.images['cball'], pos)

    s.frame = 0

    g.sprites.append(s)
    s.loop = cball_loop
    s.hit = cball_hit
    #s.groups = g.string2groups("cball")
    s.agroups = g.string2groups("castle")

    #s.rect, s._rect

    dx, dy = g.castle.rect.x - s.rect.x, g.castle.rect.y - s.rect.y
    dist = (dx * dx + dy * dy)**0.5
    v = 16
    s.vx, s.vy = dx * v / dist, dy * v / dist
    s.vz = -8
    s.z = 0
    s.damage = damage
Esempio n. 5
0
def factory_new(g, t, value):
    print 'factory', g.clayer[t.ty][t.tx], t.rect

    g.clayer[t.ty][t.tx] = 0
    g.blayer[t.ty][t.tx] = 0x14
    g.blayer[t.ty - 1][t.tx] = 0x14
    g.blayer[t.ty][t.tx - 1] = 0x14
    g.blayer[t.ty + 1][t.tx] = 0x14
    g.blayer[t.ty][t.tx + 1] = 0x14

    #s = isovid.Sprite(g.images['factory.3'],(0,0))
    #s.rect.centerx,s.rect.centery = t.rect.centerx,t.rect.centery/2
    s = isovid.Sprite(g.images['factory.3'], t.rect)
    g.sprites.append(s)
    print s.rect
    tx, ty = s.rect.centerx / g.iso_w, s.rect.centery / g.iso_h
    print tx, ty

    #NOTE: this is just to show off!
    #import steam
    #s.effect = steam.Effect(32,1)

    import fire
    s.effect = fire.Effect(16, 1)

    #s.groups = g.string2groups('coal')
    #s.agroups = g.string2groups('castle')
    #s.hit = coal_hit

    #s.groups = g.string2groups('factory')
    #s.agroups =g.string2groups("castle")
    s.hit = factory_hit

    s.loop = factory_loop
    s.frame = 0
    s.type = 'factory'

    s.unit = Factory()
Esempio n. 6
0
def robot_new(g, t, v):
    g.clayer[t.ty][t.tx] = 0
    s = isovid.Sprite(g.images['robot'], t.rect)

    s.frame = 0
    s.origin = t.tx, t.ty

    g.sprites.append(s)
    s.loop = robot_loop
    #if random.randrange(0,20) == 0:
    #    s.loop = robot_loop_2
    s.hit = robot_hit
    s.groups = g.string2groups("robot")
    s.agroups = 0  #g.string2groups("castle")
    s.path = []
    s.state = 'alive'
    s.type = 'robot'

    s.unit = Robot()

    s.x, s.y = float(s.rect.x), float(s.rect.y)
    s._x, s._y = s.x, s.y
    s._min = s.min = MIN + random.randrange(-MIN_RAND, MIN_RAND)
    s.max = MAX + random.randrange(-MAX_RAND, MAX_RAND)
    s.radius = RADIUS + random.randrange(-RADIUS_RAND, RADIUS_RAND)
    s.center = CENTER + random.randrange(-CENTER_RAND, CENTER_RAND)
    s.search = SEARCH
    s._flock_frame = 0
    s.near = []
    s.avx = 0
    s.avy = 0
    s.ax = 0
    s.ay = 0

    g.robots.append(s)

    ty, tx = t.ty, t.tx
    g.robot_list_layer[ty][tx].append(s)
Esempio n. 7
0
def cball_new(g, pos, dest, damage=1.0, pressure=16):
    #g.level.game.sm.Play(random.choice(sound_info.cannon))
    #g.level.game.sm.Play(sound_info.cannon.nextone())

    if pressure < 9:
        g.level.game.sm.Play(sound_info.cannon[0], wait=3)
        print "cannon 1 sound"
    elif pressure >= 9 and pressure < 15:
        g.level.game.sm.Play(sound_info.cannon[1], wait=3)
        print "cannon 2 sound"
    elif pressure >= 15 and pressure < 25:
        g.level.game.sm.Play(sound_info.cannon[2], wait=3)
        print "cannon 3 sound"
    elif pressure >= 25:
        print "cannon 4 sound,  two cannon 3 sounds played at once."
        g.level.game.sm.Play(sound_info.cannon[2], wait=3)
        g.level.game.sm.Play(sound_info.cannon[2], wait=3)

    # Here we use a different graphic for the cannon balls depending on Damage.

    if damage <= 1.:
        img_name = 'cball'
        num_steam, num_steam_add = 20, 5
    elif damage > 1. and damage < 4.:
        img_name = 'cball2'
        num_steam, num_steam_add = 30, 10
    elif damage >= 4. and damage < 6.:
        img_name = 'cball3'
        num_steam, num_steam_add = 25, 15
    elif damage >= 6. and damage < 8.:
        img_name = 'cball4'
        num_steam, num_steam_add = 35, 20
    elif damage >= 8. and damage < 10.:
        img_name = 'cball4'
        num_steam, num_steam_add = 42, 23
    elif damage >= 10.:
        img_name = 'cball4'
        num_steam, num_steam_add = 50, 25

    s = isovid.Sprite(g.images[img_name], pos)

    # we assign the damage that is done by this cannon ball.
    s.damage = damage
    s.num_steam, s.num_steam_add = num_steam, num_steam_add

    s.frame = 0

    g.sprites.append(s)
    s.loop = cball_loop
    s.hit = cball_hit
    s.groups = g.string2groups("cball")
    s.agroups = g.string2groups("robot,cannon")  #,factory,truck,cannon")

    #s.rect, s._rect

    dx, dy = dest[0] - s.rect.x, dest[1] - s.rect.y
    dist = (dx * dx + dy * dy)**0.5
    if dist <= 0: return
    v = float(pressure)
    s.vx, s.vy = dx * v / dist, dy * v / dist
    s.vz = -5
    s.z = 0

    # we add a steam effect for when firing the cannon ball.
    #   It's steamyness is different depending on the damage of the cannon.
    rect = pygame.Rect(s.rect)
    rect.x += s.vx * 2
    rect.y += s.vy * 2
    effect.effect_new(
        g, rect, steam.Effect(num_steam, num_steam_add, 12, 0,
                              (255, 255, 255)), 20)