(SCRIPT REQUEST) ADVANCED SCREEN PAN (ACE)

Posts

Pages: 1
Rave
Even newspapers have those nowadays.
290
Could someone write script that would allow for advanced screen panning?

By advanced I mean that you can choose direction of pan in degrees (0-359, floating point numbers acceptable), speed (in pixels per seconds) and length of pan (in pixels).

Could someone write such script for me?
Not exactly what you want, but can work how you want it ( I think, unless I misunderstand you. )
http://quasixi.wordpress.com/2014/08/13/quasi-screen-scrolling/
For pixel scrolling do something like:

That would scroll side 40 pixels and up 10 pixels, ( with a smooth scroll of course. )
7 is just the general direction, so it would be within 90 to 180 degrees.

Only thing is this doesn't have the speed set up like you would like it.
Rave
Even newspapers have those nowadays.
290
No, I want to pan in any direction possible. I need you to excuse me for my poor MS Paint skills.



Here are all default RM scrolling directions. That's it, 8 directions separated by 45 degrees each.


I want to be able to scroll in any direction possible (blue line), with direction being set in degrees (0-359 range).
Like I said you can scroll in any direction, 9 is 0-90 degrees, 7 is 90-180 degrees, 1 is 180-270 degrees, 2 is 180-360 degrees.
Converting to degrees imo would be unneeded effort, since you should have a point that you want to scroll too in mind. All you have to do is make a triangle from that point to the center, put the opposite set as Y and adjacent as X

Example:


X would be 11/32.0, Y would be 100/32.0 with direction being 9.

Edited: I completely forgot in image editors, you can see the angle lol. So I was thinking it would be more trouble finding the angle then to just get the x/y.
Add this into my script, and you'll have the angle'd distances (Exactly the same, but converts angles into one of the number directions, then changes the distances to the x/y values)

#--------------------------------------------------------------------------
# * Start Scroll
#--------------------------------------------------------------------------
def start_angled(angle, distance, speed)
# convert distance to grid numbers
distance = distance/32.0

# Grab direction from angle
if angle == 0 || angle == 360
dir = 6
elsif angle > 0 && angle < 90
dir = 9
elsif angle == 90
dir = 8
elsif angle > 90 && angle < 180
dir = 7
elsif angle == 180
dir = 4
elsif angle > 180 && angle < 270
dir = 1
elsif angle == 270
dir = 2
elsif angle > 270 && angle < 360
dir = 3
end
@scroll_direction = dir

# Get X/Y Distance
radian = (angle/180.0) * Math::PI
x = distance * Math.cos(radian)
y = distance * Math.sin(radian)
@scroll_rest = x.abs
@scroll_rest2 = y.abs

# Speed is weird, needs more work
# idk what the 256.0 in def scroll_distance is for
# if I try to multiply it back in, scrolling will be instant
@scroll_speed = (@scroll_rest/distance) * speed
@scroll_speed2 = (@scroll_rest2/distance) * speed
end

To use it do a script call:
$game_map.start_angled(angle, distance, speed)

Angle should be between 0-259
Distance is just the distance of that line angle.
Speed is still weird, I couldn't really figure it out when I made my own scrolling, since I wanted it to be in frames instead but it just acts weird and I was too lazy to dig deep/back track it and modify. But it should be a low number, 0~10
Rave
Even newspapers have those nowadays.
290
Except your solution will scroll either horizontally, vertically or diagonally (by 45 degrees), not "a bit" diagonally (where direction differs by discrete amounts like 5 degs off).
I just finished editing last post, not sure if you saw it. My script should do all angles if you plugged in the numbers correct. That last method I just posted won't work if the script didn't do all angles, since I just converted the values for you and kept the rest the same.
Rave
Even newspapers have those nowadays.
290
Thanks, didn't see the edit, probably because you finished writing it after I've already left the page. That will do, thank you.

Also consider adding this to main script as I imagine that it may be useful for others.
Rave
Even newspapers have those nowadays.
290
Quasi, got some problems with your script: If speed is too big (for instance when I want to instantly scroll somewhere) camera misses its target. It can even end up on the other side of the map. It is especially visible in case of big maps (like 100x100 big). Could you somehow fix the problem, perhaps after scroll is finished to stiffly assign camera position to x/y of the object/position that is the target?
Yeah I'll give this a look, seems like a pretty big issue that I never caught. I'll have it done before the end of the week hopefully. Don't have much free time until Thursday.
Also for testing/fixing purposes, how far did you scroll and what speeds? I probably only need the distance though, it probably starts bugging after a few distances since I've never tried scrolling past 15 I think.
Rave
Even newspapers have those nowadays.
290
author=Quasi
Yeah I'll give this a look, seems like a pretty big issue that I never caught. I'll have it done before the end of the week hopefully. Don't have much free time until Thursday.
Also for testing/fixing purposes, how far did you scroll and what speeds? I probably only need the distance though, it probably starts bugging after a few distances since I've never tried scrolling past 15 I think.

scroll_to(0,10) - it still isn't instant but just as buggy

//edit: Is there any way to set viewport x/y directly? If so I could possibly cook up something on my own.
Well if you want the display to move somewhere instantly without a scroll it's
$game_map.set_display_pos(x, y)

and oh it's the scroll_to def? Might have to rewrite the math in that one then. Did you run that after doing a pixel scroll ( like in my examples where I divided by 32.0 )? Since that could be what's setting it off, or it might be the Scroll type Loops, in the map options.
Rave
Even newspapers have those nowadays.
290
No, map doesn't loop and yes I did it after pixel scroll.
http://pastebin.com/kWbMrfcD
Well this is what I'm at atm. Only tested this with scroll_to method, and seemed pretty good with speeds up to 20 and about 10-15 distance away. Did most of this at 1am-3am so not too confident on my math lol. Let me know if there's any issues. I think there might still be an very small offset, can't really tell.

Edit: I redid it again, changed speed to work in frames. So you can think of speed as duration the scroll will take. 60 frames = 1 second. Change this seemed to fix the offset, as long as you don't scroll while it is still scrolling. Again let me know if you run into anything, I just finished it and have to go back to class so I can't do a full test.
Pages: 1