Post new topic    
Liquid Metal King Slime
Send private message
Screenwise scrolling 
 PostTue Aug 11, 2020 10:10 pm
Send private message Reply with quote
starjelly0000.gif
I wanted to share a little screenwise scrolling script I wrote.

Code:
#-----------------------------------------------------------------------

define constant(1, timer:camera)

#-----------------------------------------------------------------------

plotscript, on new game, begin
  init game
end

#-----------------------------------------------------------------------

script, init game, begin
  set hero speed(me, 6)
  camera handler
end

script, camera handler, begin
  variable(x, y, sx, sy)
  x := (hero pixel x(me) + 10) / 20
  y := (hero pixel y(me) + 10) / 20
  sx := x ,mod, 16
  sy := y ,mod, 10
  if(sx == 0) then(scrolling action(-1, 0))
  elseif(sx == 15) then(scrolling action(1, 0))
  elseif(sy == 0) then(scrolling action(0, -1))
  elseif(sy == 9) then(scrolling action(0, 1))
  put camera on screen by tile(hero x(me), hero y(me))
  set timer(timer:camera, 0, 1, @camera handler)
end

script, scrolling action, xgo, ygo, begin
  suspend player
  cancel hero walk(me)
  wait for hero(me)
  pan camera screenwise(xgo, ygo)
  walk hero relative(me, xgo * 2, ygo * 2)
  wait for camera
  wait for hero(me)
  resume player
end

script, walk hero relative, rank, xgo, ygo, begin
  if(xgo < 0) then(walk hero(rank, left, abs(xgo)))
  if(xgo > 0) then(walk hero(rank, right, abs(xgo)))
  if(ygo < 0) then(walk hero(rank, up, abs(ygo)))
  if(ygo > 0) then(walk hero(rank, down, abs(ygo)))
end

script, pan camera screenwise, xgo, ygo, begin
  # Pan the camera one screen in the given direction
  if(xgo < 0) then(pan camera(left, 16, 10))
  if(xgo > 0) then(pan camera(right, 16, 10))
  if(ygo < 0) then(pan camera(up, 10, 10))
  if(ygo > 0) then(pan camera(down, 10, 10))
end

script, put camera on screen by tile, tx, ty, begin
  # Set the camera so that the selected tile coordinates will be on-screen
  put camera(tx / 16 * 16 * 20, ty / 10 * 10 * 20)
end


This assumes that your map is organized into screens of 16x10 tiles and that the edges of each are only ever used for walking between maps (so your practical gameplay area is 14x8 tiles)

Yes, this was inspired by playing Xoo Xeno Xafari, which I believe uses a whole bunch of 16x16 maps connected with regular doors-- but it just got me thinking, how would you script this if you wanted to make it a single map?
Liquid Metal Slime
Send private message
 
 PostTue Aug 11, 2020 10:51 pm
Send private message Reply with quote
Okay, I intend to absolutely use this. I had a fan game concept in my head and had been considering simply making the dungeon a series of 16x10 maps linked via doors, but now I think I can fit that entire game onto one map.
In the past, I apologized when I was in the right because I was afraid of peer pressure. For this, I apologize.

I must be cruel, but to be kind; that bad may begin, and worse be left behind.
-Prince Hamlet of Denmark
Liquid Metal Slime
Send private message
 
 PostSat Aug 15, 2020 6:51 am
Send private message Reply with quote
aaa0010.gif
Not the same project I had in mind, but what the heck, I'll use it a little early.
In the past, I apologized when I was in the right because I was afraid of peer pressure. For this, I apologize.

I must be cruel, but to be kind; that bad may begin, and worse be left behind.
-Prince Hamlet of Denmark
Metal Slime
Send private message
 
 PostSat Aug 15, 2020 8:19 am
Send private message Reply with quote
Seeing those two GIFs of this scrolling script in action, I'm suddenly reminded of "Spiritual Warfare," an obscure(?) old NES game which was a Zelda-clone sort of thing that happened to be religiously themed (complete with Bible quiz mini-game to win extra money to buy items with.)

It had black backgrounds just like Nathan's screens in most areas, and walls keeping you from walking off the edges where you weren't supposed to were mostly made up of single large rocks like James's screens rather than trying to copy Zelda's "mountain-ish" look.

Really neat to see that Zelda-type scrolling like this is possible in the OHRRPGCE!
Bok's Expedition -- DONE! Go play it!
FYS:AHS -- Underschool tunnels (west side) mapping and etc.
Puckamon -- Not until the reserve party is expanded.
Liquid Metal Slime
Send private message
 
 PostSat Aug 15, 2020 9:50 am
Send private message Reply with quote
The screen jittered a little when I left the dungeon and went to the overworld through a standard door link, but then corrected itself (after I get some sleep I'll see if this repeats itself when I change the map to Crop mode instead of Wrap mode; it might also have to do with my standard doors being on the edges of maps). I have this script set up on the second floor of my dungeon, but not on the first floor (which is a one-screen map altogether) or any of the towns/interiors (likewise) or overworld (a 32x20 area with only the upper-left quarter being filled with anything).

Ah yes, Spiritual Warfare, probably Wisdom Tree's only good game. Or its most relatively good game?
In the past, I apologized when I was in the right because I was afraid of peer pressure. For this, I apologize.

I must be cruel, but to be kind; that bad may begin, and worse be left behind.
-Prince Hamlet of Denmark
Liquid Metal King Slime
Send private message
 
 PostSat Aug 15, 2020 1:07 pm
Send private message Reply with quote
Oh, yeah, I never tested this on wrap maps or with regular doors.

That looks nice, Nathan!
Liquid Metal Slime
Send private message
 
 PostSat Aug 15, 2020 5:26 pm
Send private message Reply with quote
aaa0007.png
aaa0009.png
aaa0011.png
I think what's happening is that my exit doors are usually on the bottom edge of the one-screen rooms the rest of the game consists of. So the script continues running itself even when you leave the map, and teleporting to one of the only maps large enough to scroll happening to be simultaneous with reaching the edge of the screen, the screen scrolls for a bit and then pops back into place.

So it looks like there's two easy ways to fix it: Shrinking the overworld to be 16x10 like most of the others and cutting off some inaccessible aesthetic tiles or writing different script(s) for the other maps. (My overworld is 32x20 but only 16x11 of that gets used). A third way would be to move everything in my town/dungeon maps up one space so the "return to overworld" doors never touch the edge, but I don't have a lot of room to work with here.
In the past, I apologized when I was in the right because I was afraid of peer pressure. For this, I apologize.

I must be cruel, but to be kind; that bad may begin, and worse be left behind.
-Prince Hamlet of Denmark
Liquid Metal Slime
Send private message
 
 PostSun Aug 16, 2020 1:14 am
Send private message Reply with quote
This is cool! Too had I didn't build Xoo as one big map.

Actually, that wouldn't have worked well anyway. Compartmentalizing all the numerous NPCs into lots of little maps turned out to be a handy organizational tool.
Liquid Metal Slime
Send private message
 
 PostSun Aug 16, 2020 2:39 am
Send private message Reply with quote
Be super careful not to put any open spots on the edge of a map if you use this. Your characters will get locked into walking in place against the edge.

I still haven't tried it with a wrap map; perhaps a Cave of Riches should be a floor of this dungeon?
In the past, I apologized when I was in the right because I was afraid of peer pressure. For this, I apologize.

I must be cruel, but to be kind; that bad may begin, and worse be left behind.
-Prince Hamlet of Denmark
Liquid Metal Slime
Send private message
 
 PostMon Aug 17, 2020 1:07 am
Send private message Reply with quote
aaa0012.gif
Can confirm it works on wrap maps too, so long as there's corresponding empty spaces on both edges of the map.

This particular floor is going to have a puzzle to it.
In the past, I apologized when I was in the right because I was afraid of peer pressure. For this, I apologize.

I must be cruel, but to be kind; that bad may begin, and worse be left behind.
-Prince Hamlet of Denmark
Liquid Metal Slime
Send private message
 
 PostFri Aug 21, 2020 12:43 am
Send private message Reply with quote
aaa0014.gif
I found a funny interaction with this script and door linking into a map with a door placed on the edge of a screen. I mean, I suppose I could shrink all my indoors maps vertically by one square, keeping a completely blank row of spaces along the bottom edge, and moving my doors accordingly?

The heroes also walk to spaces above/below the town when they exit to the overworld and again I'm pretty sure this is because I put the exit doors right on the edges of the screens.
In the past, I apologized when I was in the right because I was afraid of peer pressure. For this, I apologize.

I must be cruel, but to be kind; that bad may begin, and worse be left behind.
-Prince Hamlet of Denmark
Slime
Send private message
 
 PostTue Aug 25, 2020 1:30 pm
Send private message Reply with quote
It works for me as well, thanks, I was really stuck with that...
Liquid Metal Slime
Send private message
 
 PostSun Sep 06, 2020 12:54 pm
Send private message Reply with quote
https://www.slimesalad.com/forum/viewgame.php?p=138395

Here you go, an entire game making use of this script.

Now that this weird distraction is finished I can return to revising TutOHRial.
In the past, I apologized when I was in the right because I was afraid of peer pressure. For this, I apologize.

I must be cruel, but to be kind; that bad may begin, and worse be left behind.
-Prince Hamlet of Denmark
Display posts from previous: