示例#1
0
def raster_callback(line):
    global xpos, ypos

    # line 0: begin of frame
    if line == 0:
        tln.SetLayer(LAYER_FOREGROUND, tileset_horizon, tilemap_horizon)
        tln.SetLayer(LAYER_BACKGROUND, tileset_horizon, tilemap_horizon)
        tln.SetLayerPosition(LAYER_FOREGROUND, lerp(angle * 2, 0, 360, 0, 256),
                             24)
        tln.SetLayerPosition(LAYER_BACKGROUND, lerp(angle, 0, 360, 0, 256), 0)
        tln.ResetLayerMode(LAYER_BACKGROUND)
        affine.angle = angle

        rad = math.radians(angle)
        xpos += (math.sin(rad) * speed)
        ypos -= (math.cos(rad) * speed)

    if line == 24:
        tln.SetLayer(LAYER_BACKGROUND, tileset_track, tilemap_track)
        tln.SetLayerPosition(LAYER_BACKGROUND, int(xpos), int(ypos))
        tln.DisableLayer(LAYER_FOREGROUND)

    if line >= 24:
        scale = lerp(line, 24, HEIGHT, MIN_SCALE, MAX_SCALE)
        affine.sx = scale
        affine.sy = scale
        tln.SetLayerTransform(LAYER_BACKGROUND, affine.angle, affine.dx,
                              affine.dy, affine.sx, affine.sy)
示例#2
0
def Update():
    global ypos

    # calculate background scale factor
    fgscale = scale
    bgscale = lerp(scale, MIN_SCALE, MAX_SCALE, 0.75, 1.5)

    # scale dependant lower clipping
    maxy = 640 - (HEIGHT / scale)
    if ypos > maxy:
        ypos = maxy

    # update position
    bgypos = lerp(scale, MIN_SCALE, MAX_SCALE, 0, 80)
    tln.SetLayerPosition(LAYER_FOREGROUND, int(xpos * 2), int(ypos))
    tln.SetLayerPosition(LAYER_BACKGROUND, int(xpos), int(bgypos))
    tln.SetLayerScaling(LAYER_FOREGROUND, fgscale, fgscale)
    tln.SetLayerScaling(LAYER_BACKGROUND, bgscale, bgscale)
示例#3
0
def raster_callback(line):
    if line == 24:
        tln.SetLayer(LAYER_BACKGROUND, tileset_track, tilemap_track)
        tln.SetLayerPosition(LAYER_BACKGROUND, int(x), int(y))
        tln.DisableLayer(LAYER_FOREGROUND)

    if line >= 24:
        scale = lerp(line, 24, HEIGHT, 0.2, 5.0)
        affine.sx = scale
        affine.sy = scale
        tln.SetLayerTransform(LAYER_BACKGROUND, affine.angle, affine.dx,
                              affine.dy, affine.sx, affine.sy)
示例#4
0
def raster_callback(line):
    pos = -1

    # start of frame
    if line == 0:
        global basepos
        basepos += speed
        pos_foreground = basepos * 3
        tln.SetLayerPosition(LAYER_FOREGROUND, int(pos_foreground), 0)

        pos_background[0] = basepos * 0.562
        pos_background[1] = basepos * 0.437
        pos_background[2] = basepos * 0.375
        pos_background[3] = basepos * 0.625
        pos_background[4] = basepos * 1.0
        pos_background[5] = basepos * 2.0

        pos = pos_background[0]

    elif line == 32:
        pos = pos_background[1]
    elif line == 48:
        pos = pos_background[2]
    elif line == 64:
        pos = pos_background[3]
    elif line == 112:
        pos = pos_background[4]
    elif line >= 152:
        pos = lerp(line, 152, 224, pos_background[4], pos_background[5])

    if pos != -1:
        tln.SetLayerPosition(LAYER_BACKGROUND, int(pos), 0)

    if line == 0:
        tln.SetBGColor(28, 0, 140)
    elif line == 144:
        tln.SetBGColor(0, 128, 238)
示例#5
0
def raster_callback(line):
    pos = -1

    if line == 0:
        pos = pos_background[0]
    elif line == 32:
        pos = pos_background[1]
    elif line == 48:
        pos = pos_background[2]
    elif line == 64:
        pos = pos_background[3]
    elif line == 112:
        pos = pos_background[4]
    elif line >= 152:
        pos = lerp(line, 152, 224, pos_background[4], pos_background[5])

    if pos != -1:
        tln.SetLayerPosition(LAYER_BACKGROUND, int(pos), 0)

    if line == 0:
        tln.SetBGColor(28, 0, 140)
    elif line == 144:
        tln.SetBGColor(0, 128, 238)
示例#6
0
        alpha += 2
    if tln.GetInput(tln.INPUT_D) and alpha > 1:
        alpha -= 2

    # calculate scale factor from fixed point base
    fgscale = scale / 100.0
    bgscale = lerp(scale, MIN_SCALE, MAX_SCALE, 0.75, 1.5)

    # scale dependant lower clipping
    maxy = 640 - (HEIGHT * 100 / scale)
    if ypos > maxy:
        ypos = maxy

    # update position
    bgypos = lerp(scale, MIN_SCALE, MAX_SCALE, 0, 80)
    tln.SetLayerPosition(LAYER_FOREGROUND, xpos * 2, ypos)
    tln.SetLayerPosition(LAYER_BACKGROUND, xpos, bgypos)
    tln.SetLayerScaling(LAYER_FOREGROUND, fgscale, fgscale)
    tln.SetLayerScaling(LAYER_BACKGROUND, bgscale, bgscale)

    # update transparency
    if alpha < 255:
        tln.SetLayerBlendMode(LAYER_FOREGROUND, tln.BLEND_MIX, alpha)
    else:
        tln.SetLayerBlendMode(LAYER_FOREGROUND, tln.BLEND_NONE, 0)

    # render to the window
    tln.DrawFrame(frame)
    frame += 1

tln.DeleteWindow()
示例#7
0
        if speed < 0.0:
            speed = 0.0

    if tln.GetInput(tln.INPUT_LEFT):
        speed -= 0.02
        if speed < -1.0:
            speed = -1.0

    elif speed < 0.0:
        speed += 0.02
        if speed > 0.0:
            speed = 0.0

    # scroll
    basepos += speed
    pos_foreground = basepos * 3
    tln.SetLayerPosition(LAYER_FOREGROUND, int(pos_foreground), 0)

    pos_background[0] = basepos * 0.562
    pos_background[1] = basepos * 0.437
    pos_background[2] = basepos * 0.375
    pos_background[3] = basepos * 0.625
    pos_background[4] = basepos * 1.0
    pos_background[5] = basepos * 2.0

    tln.DrawFrame(frame)
    frame += 1

tln.DeleteWindow()
tln.Deinit()
示例#8
0
# load resources
tileset_horizon = tln.LoadTileset("track1_bg.tsx")
tilemap_horizon = tln.LoadTilemap("track1_bg.tmx", "Layer 1")
tileset_track = tln.LoadTileset("track1.tsx")
tilemap_track = tln.LoadTilemap("track1.tmx", "Layer 1")

# set raster callback
CB_FUNC_TYPE = CFUNCTYPE(None, c_int)
cb_func = CB_FUNC_TYPE(raster_callback)
tln.SetRasterCallback(cb_func)

# main loop
while tln.ProcessWindow():
    tln.SetLayer(LAYER_FOREGROUND, tileset_horizon, tilemap_horizon)
    tln.SetLayer(LAYER_BACKGROUND, tileset_horizon, tilemap_horizon)
    tln.SetLayerPosition(LAYER_FOREGROUND, lerp(angle * 2, 0, 360, 0, 256), 24)
    tln.SetLayerPosition(LAYER_BACKGROUND, lerp(angle, 0, 360, 0, 256), 0)
    tln.ResetLayerMode(LAYER_BACKGROUND)

    # input
    if tln.GetInput(tln.INPUT_LEFT):
        angle -= 2
    elif tln.GetInput(tln.INPUT_RIGHT):
        angle += 2

    if tln.GetInput(tln.INPUT_UP):
        s += a
        if s > 2:
            s = 2
    elif s >= a:
        s -= a