i'm trying to make a function where the camera will jump forward by an amount when the player character reaches the end of a 'room' (the end of the current screen) but am struggling to find a way to make it work, anyone know what i should do?
p.s. code currently shows what i'd like it to be, currently can't make it do more than two rooms
Forgive me if I'm making bad assumptions about what you're looking to do, but here's what I came up with. If you replace:
if x>60 then camx=32 elseif x<60 then camx=-32 end
with something like this:
camx = (x\60*64)-32
I think that gives you the result you want. That divides your map into width 64 "screens" using the \ integer division operator and then offsets the camera by -32, so if x < 60, you're on "screen" 0 and camx = -32. Between 60 and 120, you're on screen 1, camx ends up at 32, screen 2, camx=96 & so on.
[Please log in to post a comment]