Log In  

Cart #hmmmm-0 | 2021-02-27 | Code ▽ | Embed ▽ | No License

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

P#88257 2021-02-27 16:38 ( Edited 2021-02-27 16:39)

2

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.

P#88266 2021-02-27 18:51 ( Edited 2021-02-28 20:17)

it did!! thank you very much!

P#88270 2021-02-27 19:30

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 05:52:40 | 0.010s | Q:17