Autoscrolling effect

Bloodbane

Well-known member
Alright, some people has requested this so I'll share what I know about it.

This is example of entity which produces autoscrolling effect:

name ScreenMover
type none


anim spawn
@script
    if(frame==1){
      changelevelproperty("scrollspeed", 0);
    }
@end_script
delay 5
offset 1 1
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif

anim idle
@script
    void self = getlocalvar("self");
    int Dir = getentityproperty(self, "direction");
    int XPos = openborvariant("xpos");
    int Width = openborvariant("levelwidth");
    int Screen = openborvariant("hResolution");

    if(Dir==1){
      if(XPos < Width-Screen && Dir==1){
        changeopenborvariant("xpos", XPos+2);
      } else {
        changelevelproperty("scrollspeed", 2);
        killentity(self);
      }
    } else if(Dir==0){
      if(XPos > 0){
        changeopenborvariant("xpos", XPos-2);
      } else {
        changelevelproperty("scrollspeed", 2);
        killentity(self);
      }
    }
@end_script
loop 1
delay 5
offset 1 1
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif

When this entity is spawned on level, the first thing it does is stop camera scrolling. This is to nullify player's control to camera.
Then in its IDLE animation, it moves screen slowly with speed : 2 pixels / 5 centiseconds (see same colored numbers above)
Modify these values in script above to change speed.

At end of level (right side if it autoscrolls right or left side if it autoscrolls left), it will stop, removes itself and returns cameracontrol back to player(s).

It has 2 modes defined by its facing direction:

Autoscroll right

spawn ScreenMover
flip 1
coords 100 190
at 0

ScreenMover is facing right

Autoscroll left

spawn ScreenMover
coords 100 190
at 0

ScreenMover is facing left

Known issues:
Autoscroll != Autodrag

If player is left behind because of this effect, it won't drag nor pull player inscreen
 
I just want be clear here.

So this is nothing like bgspeed, right? This scrolls the actual panels? Does it affect spawn points for entities? (ie, at 200 or something)?

Would it thus render waits useless, since the script will move the level by itself?
 
Yep, it's real scrolling not pseudo scrolling

As for affecting level spawns, of course, this script changes scrollpos directly so when it reaches 200 (for instance), anything set to spawn at scrollpos 200 or less will be spawned

For wait, yes, this script doesn't care about it at all i.e it will forcefully scroll screen.

Hmm.... maybe I ought to test it

[couple hours later]

Yep, my statement above is correct, this autoscrolling effect does exactly like that.
Against wait, this effect will push wait spot to end of level. However against scrollx command, once this effect wears off, scrollx will apply.
 
For enemies, it's not big deal since they aren't subject to screen by default
For players, I tested this in empty level so I don't know what will happen to players which are left offscreen too long. The only sure thing is if player presses direction button, engine will put player back on screen
 
Bloodbane said:
The only sure thing is if player presses direction button, engine will put player back on screen
Even for some enemies, that would defeat the purpose of such levels, wouldn't it? They should die or be dragged, right? I suppose a permanent hazard or wall moving with the screen would remedy it.
 
I'm doing something like that : (start at 2min and 12 seconds)

Ah good work! I can see the effect you're making :)

I suppose a permanent hazard or wall moving with the screen would remedy it.

Yeah, that might work. There are many solutions to solve left behind issue, just need to pick the proper one :)
 
A made a minor edit so it would only scroll ONE screen length...

Changed
Code:
if(XPos < Width-Screen && Dir==1){

to

Code:
if(XPos < Screen && Dir==1){

I'm making a two-way door at the screen edge, i have 'wait 0' set at start of stage.  My stage is DIRECTION BOTH.

I'm using the script to transition ONE SCREEN length only.  It works and looks great so far, it's pushing the wait like Bloodbane said and one stage is working like two branches now.

...but I can't work out how to get it to go back the other way.  :-\

I tried without the wait command and changing with the scrollspeed after you exit the door, but I couldn't get to look as good as it does with the wait command.  The mod is platform style, 16x16 tile based, pretty much like NES.  So I need to get things pixel perfect.  Right now the first transition is working how I want it and it looks awesome.  So I'm just trying to replicate it for the opposite direction.

DOORp1.png


doorp6.png


doorp4.png




Could you guys help me do it properly?


My brain is fried from working on this all weekend  :o

 
So I'm thinking I need to set triggers to change the stage direction instead of stopping the scroll speed.  I will try this today.  Thought of this earlier but I thought the script nullified direction.

EDIT: Actually I'm sure as long as there's a WAIT command it won't work.  I control over wait regardless if enemies are on screen or not.

So I need to know is there a way to remove/control WAIT with script? 

EDIT2: level property direction not supported - so I'll make everything NPC instead of enemy and that should null the wait once the empty enemy dies.

I'm still interested thou if anyone has better ideas, like changing the script to completely control the two-way door function. 

At the moment I have an entity in place at the door, touching it makes it change anim and spawn the screenmover.  After that it changes to another anim that does the same thing for the opposite direction.



 
Cool thanks for the info,  :)

I must of missed that when he posted it.  I will try it out now.

Thou it works with grouping, my game is non-linear and turning groups on and off could be a nightmare.  I confess I always hated doing grouping and usually messed it up.  I stopped using wait and groups and everything is scripted or spawned at start of map. 

I wonder if there any script function to control scrollx ?

Really I just want to turn it on and off at will like we can do with scrollspeed.

Code:
@script
    if(frame==1){
      changelevelproperty("scrollspeed", 0);
    }
@end_script

 
That's Great!, thanks so much for the video example, was good to see it in action.  The mod looks awesome btw.  8)

*scurries off*

I got it all working now perfect now, thanks so much for pointing this feature out.  ;D

And I realized again I was over complicating it with the enemies.  I'll just make them NPC with offscreen kill, and doorpoints are enemy.  The doorpoint dies and spawns a new doorpointB that goes the other way. 

It's rough but it works for now, I can expand on it later once I decide/figure out how everything else will work.

Thanks again for the help!

 
Beastie, the only way to disable scrollx or wait is to simply create script based scrollx or in general, script controlled camera
This autoscrolling effect is basically script controlled camera except that it's not controllable by player

For metroidvania, script controlled camera is tough cause aside of setting limit for camera's movement, you have to incorporate vertical levels too. That's why I prefer use multi rooms system instead
 
Oh I worded it wrong, I meant we won't be using scrollx nor wait command at all and instead completely use script to control camera
 
hmm that's originally  what I was trying to do  ???

EDIT:

At least we worked out a few different ways to get the effect. 

For a linear game where you don't want enemies re-spawning, but you want to be able to go back to other rooms scrollx method works great.  You can access each room (screen width) with the doors, but enemies stay dead.  If you keep enemies outside of the grouping and just have the doorpoint then enemies won't need to be defeated to access the door and move to next room.

I think this is good to save having multiple branches for something that should be one map.  Like if time were a factor, or previous rooms change after activating a switch or defeating a boss. 

In situations like -  for example you must kill all enemies to access the door to the next room, but you need to come back to these rooms to either.

- exit the stage from first room

- collect items you diddn't need earlier, like health packs etc.

- parts of rooms can't be accessed until a certain requirement is met (like defeat the boss, activate a switch etc.)

- the stage has a timer, example "The Base is Going to Explode" - so you must reach the end, obtain 'some item' and run back to the start to stop 'the bomb'

- or for an RPG, get the medicine from end of stage boss and run back to save the NPC etc.



Also if you were making something specifically for handhelds/console it would be a good trick to prevent any extra loading screens between small areas.  Even if the loading is fast (like PC) you can often see a quick flickering of the load screens.
 

 
Okay then, I'm used to Metroidvania design :D

Anyways, for multiplayer, script based camera is tough cause we need to think where camera would be if players go in different directions. However for single player, it's simple cause there's only one player controlling camera

I may need to expand the script for vertical movement but one thing for sure is that I have coded script based camera control before. In Dungeons & Dragons mod we just released, there's joust mini game. The camera in that mini game is fully controlled by script
 
Yeah I hadn't poked around yet in other mods yet to see what they have.  I didn't want to just copy everything.

I'm experimenting a bit and trying get better with scripting again to improve a lot of things in doom and other mods.  Working out the best ways in another mod so I can retro-fit doom and wolf3d with the best methods.

Working on things like HUD's/Menu systems etc.  I know you have things like shops/menus in warduke I could copy, but I was trying to get better creating my own scripts.  Getting the hang of entityvars etc.


For 2players I think it would just screen pan for the effect but jumptobranch after.  Each stage image would have the next room as part of it's map that is hidden.

For sake of a small image, let's say your screensize is 240, then your stage would be like this.

48000.png

Blue is the playable screen, black is the next room as part of the image so we get scrolling effect.

When scrolling ends it jumps to branch.

 
You're probably set in the autoscroll, but just throwing this out:

Were it me, I might take a page out of Capcom's book for the original Resident Evil. They would "hide" loading of the next area with a creepy semi-generic first person cut scene of doors opening.

You could do something similar. When a transition is reached, use playgif(), textfile cut scene, or whatever method to display a generic transition of your choice. Obviously you could make as many different ones as you want and match them to the level theme, so no troubles with the transitions looking out of place.

DC
 
Back
Top Bottom