Hello everyone.
I've seen a few threads related to "Zelda Camera Style", but none of them seem to cover a view size with WIDTHxHEIGHT instead of one number. lazy_eye seems to make the camera jump halfway of what I'm aiming for. Hiead's Scrolling Camera gives an error with WIDTHxHEIGHT views as well. Each room in this world is 13x9 and the mobs are tile-based. I don't intend for it to scroll, I'm trying to get the camera to jump from the center of the last room I was in to the center of the next room I'm entering.
Problem description: I can't seem to get the camera to lock-on to the center of the next room when I exit the previous room (and therefore, the camera boundaries) using a WIDTHxHEIGHT view of "13x9".
Copyright © 2024 BYOND Software.
All rights reserved.
This can be calculated:
Once you know the room_x/room_y, finding the center of the room is easy:
As for ceil and floor:
These two rounding functions should be a part of every programmer's repertoire. They are way too useful not to be.
Once you have the center_x and center_y values, you can simply:
A highly efficient way to manage this sort of setup in tiled movement:
Optionally, you can create an object that will act as the client's eye and then smoothly move it from one room to the next if the cumulative abs(xdelta)+abs(ydelta)+abs(zdelta) is equal to 1.