How do I make the screen scroll?

From OHRRPGCE-Wiki
Jump to: navigation, search

Scrolling the screen (known as panning in the movie and video game industries) is easy. You can pan the screen with a single plotscripting command (well, two if you include the wait. Three if you want to put the camera back after). Which one you use depends on the type of panning, so we'll go over them below.

Note: It is highly recommended that you suspend player before, and resume player after panning (or the rest of the cutscene, if applicable.)

Note II: It is also recommended to put wait for camera after panning so that the camera reaches its destination before your script continues.

Directional Panning[edit]

pan camera (direction,distance,pixelstep)

With pan camera, you can move the camera in any of the four cardinal directions, for as long as you want, and as fast as you want.

  • direction: The direction to pan the camera. This can be one of up/north, down/south, left/west, right/east (or, a number, if you're masochistic!).
  • distance: How far you want to pan, in tile units.
  • pixelstep: How fast to pan, in pixels per tick. The default is 2, which is half the normal hero walking speed. Unlike with hero speeds, this can be any number, not just a factor of 20.

Examples:

pan camera(north,3) #scroll north 3 tiles, as 2 pixels per tick
wait for camera
pan camera(north,10)
pan camera(west,10) #diagonal scrolling is also possible
wait for camera
pan camera(north,10,4)
pan camera(west,5) #if you know trig, you can pan at any angle ;)
wait for camera

Spot Panning[edit]

focus camera (x,y,speed)

Focus camera allows you to pan the camera to an arbitraty point on the map, at whatever speed you want.

  • x and y: The coordinates to pan to, in tiles. The camera will be centered on this spot.
  • speed: How fast to pan. Defaults to 2, as with pan camera.

A note about how it scrolls: It will not go directly to where you want. Instead, the camera will pan diagonally towards the spot, until it's either horizontally or vertically aligned. Then it'll pan straight. That is because the camera can only move at 45 degree angles in this command.

Examples:

focus camera(12,85) #show an arbitrary point on the map
wait for camera
focus camera(hero x(me) -- 5,hero y(me)) #same as pan camera (left,5)
wait for camera

Camera Positioning[edit]

put camera (x,y)

Put camera does not scroll, like the others. Instead, it will instantly place the camera at the specified co-ordinates. Note also that the coordinates are in pixels, not tiles.

  • x and y: The coordinates to move to. Measured in pixels. The camera will have this pixel in the top-left corner of the screen.

Examples:

put camera(241,743) # just move to an arbitrary spot
#wait for camera is not needed
put camera(12 * 20, 60 * 20) #you can focus on tiles, by multiplying them by 20

When you're done[edit]

camera follows hero(who)

After you're done doing whatever with the camera, it's usually a good idea to focus the camera on the hero again, so they can see what they're doing. Use camera follows hero for that.

  • who: Which active hero to focus on, measured in party slots.

This will jump to the hero, not pan.

Examples:

pan camera (left, 20)
wait for camera
show text box(10) #whatever
wait for text box
camera follows hero(me) #all done