Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

TIC-80

Fantasy computer for making, playing and sharing tiny games. · By Nesbox

we need a camera script that's built-in ;-;

A topic by babol created Dec 26, 2022 Views: 475 Replies: 2
Viewing posts 1 to 3

i thought tic-80 was the best until i saw it has no camera script and i dont know how i can make a smooth camera like smb1 or sonic 1  ;-;

Here is an example of smooth scrolling the map. https://tic80.com/play?cart=342

(1 edit)

I've made a camera_system some time ago. Hope it helps.

-- title:   camera_system
-- author:  iZmae
-- desc:    A simple camera system you can use
-- site:    https://izmae.itch.io/
-- license: MIT License (change this to your license of choice)
-- version: 0.2
-- script:  lua
w=240
h=136
cam={
x=0,y=0,sx=0,sy=0, wlim=30, hlim=17, wmax=210, hmax=119, vel=0.25
}
function camera(x, y, mode, velx, vely)
    if mode=="follow" then
        if x>cam.wmax and cam.sx>-cam.wmax*8 then
            cam.sx=cam.sx-velx
        elseif x<cam.wlim and cam.sx<0 then
            cam.sx=cam.sx+velx end
        if y>cam.hmax and cam.sy>-cam.hmax*8 then
            cam.sy=cam.sy-vely
        elseif y<cam.hlim and cam.sy<0 then
            cam.sy=cam.sy+vely end
    end
end
function TIC()
    map(cam.x, cam.y, w, h, cam.sx, cam.sy, -1, 2)
    camera(sprx+cam.sx,spry+cam.sy, "follow",1,2)
    if btn(3) then sprx=sprx+1 end
    if btn(2) then sprx=sprx-1 end
    if btn(1) then spry=spry+1 end
    if btn(0) then spry=spry-1 end
    spr(256,sprx+cam.sx,spry+cam.sy,-1,1,0,0,1,1)
    print("x: "..sprx+cam.sx,123,90)
    print("y: "..spry+cam.sy,123,80)
end

EDIT: changed it, it's smoother now