Basically I've set up a script for this pac-man game in which the camera only moves up and down, not left and right. the normal camera movement is suspended and this script is used as a keypress script.
if ((key is pressed (key: up)) == TRUE) then, begin
focus camera (7, hero y, 4)
end
if ((key is pressed (key: down)) == TRUE) then, begin
focus camera (7, hero y, 4)
end
(note: the "7" is just the center of the screen in tiles)
in the gif to the right you can see that when i take a step up, the script triggers instantly, moving the camera at about the same speed as the sprite. but when i take a step down, the script only triggers after i've completed the walking animation for one step, resulting in the camera lagging behind. Although the commands are exactly the same (besides the direction), there is still a glaring difference in output. is this fixable or should i use a different setup entirely?
I think this is a side effect of the fact that a hero's position is determined by the top left corner of the 20x20 space that they occupy, rather than the center.
I think you will have better luck with the command that positions the camera by pixels, and the command that gets hero position in pixels
You can apply the camera position every tick rather than just when the keys are pressed
It looks like the map is the same width as the screen, so why do you need to script camera movement anyway? You want the camera to lag the player position?
If you want it to lag one tile behind, you could use an 'each step' script instead, that way it will only trigger at the end of each 20 pixels of player movement.
Bob the Hamster wrote:I think you will have better luck with the command that positions the camera by pixels, and the command that gets hero position in pixels
thanks, this worked like a charm
@TMC it's a wrapping map, as to let the player go through the pipes smoothly