View Full Version : Scrolling games
xelanoimis
25-04-09, 07:01 PM
Hi,
Since it's such a hot thing and everybody is doing it, I decided to find a good use for my Saturday and implement
native scrolling in DizzyAGE.
( I know I should've done it a long time ago, but better later than never :) )
Here is what I come up with:
http://www.yolkfolk.com/dizzyage/tmp/demo.zip
I wasn't so difficult as I imagined and I found a very simple and elegant solution. Basically I have another offset for the room view, exported in G_VIEWPORTX and G_VIEWPORTY game variables. The technique is activated by setting G_VIEWPORTMODE to 1. When so, the engine will paints a viewport of 3x3 rooms (with the current room in the middle). It does all the clipping and optimizing so the fps impact is as little as it can be.
The above paragraph is translated in code simply like this:
In handler.gs add in HandlerGameStart
GameSet(G_VIEWPORTMODE,1);
And in HandlerGameAfterUpdate
// scrolling games support
if( GameGet(G_VIEWPORTMODE) )
{
roomw = GameGet(G_ROOMW);
roomh = GameGet(G_ROOMH);
GameSet( G_VIEWPORTX, GameGet(G_ROOMX)*roomw - PlayerGet(P_X) + roomw/2 );
GameSet( G_VIEWPORTY, GameGet(G_ROOMY)*roomh - PlayerGet(P_Y) + roomh/2 );
}
And voila, any game can have scrolling! Of course depending on the game there may be other tricks to do. For example the bats in the demo had to be updated from the next room too. And if you want it to scroll only when player is close to screen sides, no problem.
-------------------------
And there's another surprise feature: open the console [`] and write [ins]
GameSet( G_VIEWPORTFLIP, 1 );
Or 2, or 3 ;)
-------------------------
I also have a VSYNC option in dizzy.ini and setup. Don't know if it does much on LCD monitors, except dropping the frame, but who knows - please try it.
If all works fine this will be the DizzyAGE v2.3.
Here is the history.txt so far: http://www.yolkfolk.com/dizzyage/tmp/history.txt
Fave fun!
Alex
nice one! i should be able to make that work quite easily instead of my scrolling 'fix' :D
couple of things i found. firstly, if you block the vertical scrolling code, then you can make it so that it only scrolls left and right:
// scrolling games support
if( GameGet(G_VIEWPORTMODE) )
{
roomw = GameGet(G_ROOMW);
//roomh = GameGet(G_ROOMH);
GameSet( G_VIEWPORTX, GameGet(G_ROOMX)*roomw - PlayerGet(P_X) + roomw/2 );
//GameSet( G_VIEWPORTY, GameGet(G_ROOMY)*roomh - PlayerGet(P_Y) + roomh/2 );
}
personally i prefer classic Dizzy games like that, as you don't get the screen moving up and down when you jump, or walk over every little hump. Also you could make it scroll only up and down by using the same method on the X axis code (hmmm....)
secondly, the flip screen is excellent! however the controls seem to flip too, so you have to use z for right and x for left. could the direction of the controls be set as a variable too? i realise that you may want it like a 'mirror' effect, but someone may want it with the usual controls too.
i'm so very glad the tiles path limitation bug has been fixed! :) i do have one other request tho. please could you add a larger window size for the editor?
do previous v2.2 games need to be updated to v2.3 when you release it? i'm guessing not. Also, if we do decide to upgrade games, do we need to do anything other than change the .exe file?
excellent work! even though it makes redundant about 3 hours work from me! :p
xelanoimis
25-04-09, 08:21 PM
I'll write a small article about the scrolling to be ready when people ask about it.
About the flip and the controls, everything is working as normal up to the render module, where the image is inverted. To "correct" the left-right keys, you have to switch their values in the update handler, like the old upsidedown demo.
left = GetKey(KEY_LEFT)?1:0;
right = GetKey(KEY_RIGHT)?1:0;
SetKey(KEY_LEFT,right);
SetKey(KEY_RIGHT,left);
How big do you want the editor window? The current max size is 1280x1024. My desktop is 1680x1050, probably yours is bigger since you have a 24". I could add a "full desktop size", like for maximized window. Let me know how you want it.
The old games (v2.2 or higher) should work with the new dizzy.exe I recommend the setup.exe too and the ini, fro the vsync option, in case some player finds it useful.
There is also another game property, G_FULLMATERIALMAP. It makes the game fill a larger material map (3x3 rooms), when entering a room, or when when requested from script. It may be useful with some scrolling games. For example my TOS Daisy that followed the player used the material map and in a scrolling game it might be useful to have more than just the current room with material map. The access is the same as before, same coordinates system.
my desktop is 1920x1200, however i don't really want the editor full screen, i think 1600 x 1100 would be good enough. :)
i'll have a read of the scrolling article, as i'm not quite sure when the game 'changes' the 3x3 screen to the next one.
I've also wrote an explanation of my scrolling code in the 'Dizzy Legends Scroll Demo' thread in Fan Games if anyone is curious.
i've added it into SBD as a test and seems to work well. oviously there are quite a few changes that would have to be made. i found that deactivating the y portion of the code worked best in it.
I did find an odd effect though
i found that if you have brushes that overlap on the same layer. some seem to swap foreground to background as the screen scrolls
http://homepage.ntlworld.com/colin.page33/2.jpg
http://homepage.ntlworld.com/colin.page33/1.jpg
it's simply fixed by changing the brush layer
interesting...
i will of course be incorporating it into CoTM, and will probably have bits of my next Classic-style Dizzy game using it as well.
xelanoimis
25-04-09, 11:48 PM
I did find an odd effect though
i found that if you have brushes that overlap on the same layer. some seem to swap foreground to background as the screen scrolls
Can you send me a running example, I can't make it out from the images. It could be one of the optimizations.
[EDIT] Nevermind that, I started your SBD and seen where it happens. I'll check it out tomorrow.
About the 3x3 rooms it's just that it paints another 8 rooms around the current player location (3 above, 3 below, 1 left, 1 right). Material map is updated when current room changes, and objects are gathered (marked as present) then too, from the whole 3x3 rooms viewport.
F11 now also shows how many brushes (static and dynamic) are visible (painted after clippings). And how many objects are currently present.
xelanoimis
26-04-09, 04:30 PM
I fixed the bug Colin mentioned.
Download the demo again (it has a new dizzy.exe).
Please check it out and see if it's indeed fixed or if there are any other issues.
Thanks!
right i've incorporated it into my Dizzy Legends Scroll Demo, for people to have a look at here:
http://www.filefactory.com/file/agd5g80/n/DL_Scroll_Demo_2_zip
i've played it, and i do believe that (for my comp anyway), the frame rate is pretty much exactly the same!
There were no problems incorporating it. :)
alex, adz says that your demo doesn't flicker, but mine does:
http://www.filefactory.com/file/agd5h71/n/DL_Scroll_Demo_3_zip
yet all my demo now is is a cut down version of TLoD with your scrolling code added. Any ideas?
i think it might be the tiles causing a optical illusion, causing the flicker.
most of the tiles, I notice are checker board in appearance. as the tiles move across the screen while walking. it's like each pixel is switching on and off on odd pixels. when you run, you are moving the tile an even number of pixels. it's definately more noticable on my laptop.
as a test suggestion, try increasing the walk speed buy 1 pixel move. i bet the flicker disappears!
as a test suggestion, try increasing the walk speed buy 1 pixel move. i bet the flicker disappears!
i can't. it would throw out the lining up of the character with the blocks.
can you try it on a different level for me? use dev mode to move the character right-wards through the map until you get the the archives or castle levels, and see if that is the same.
i can't. the game switches off dev mode!
yes you can, i'll PM you how.... ;)
ok, version 4 moves the player slightly quicker (4 pixels at a time, rather than 3), hopefully fixing the problem:
http://www.filefactory.com/file/agd54b8/n/DL_Scroll_Demo_4_zip
It fixes the problem on all the levels!
DizzyFanUK
26-04-09, 08:29 PM
Ive tried Deltas V4 Demo - Works perfect on my machine, no flicker either when walking or running, unlike the other version i tried.
Great stuff!
Could there now be potential to build games in DizzAge something like the Magic Maniax series?
xelanoimis
26-04-09, 09:38 PM
Hm, interesting! I new it was something tricky with these LCDs when I gave up my good old CRT monitor. :)
Oh, and you don't want to see how it looks on a video projector! I did a presentation about 1 or 2 years ago. I first thought it was something wrong with the engine.
Demo4 works fine on my comp too - no flicker.
Good fix Jamie!
xelanoimis
26-04-09, 10:09 PM
OK, DizzyAGE v2.3 is ready.
I posted in the DizzyAGE news thread.
Now,
I read this thread and the article on scrolling, but when I add that bit of code to my old games to allow scrolling, an error occurs.
Scrolling is not a priority, but it would be nice. :)
you need to have the .exe file as the latest version of DizzyAGE (v2.3) or it won't work.
drat
Thanks anyway, Delta!
drat
Thanks anyway, Delta!
just replace it! your game will still work fine with the new .exe file. just download the latest version of dizzyage and change the .exe file of your game.
just replace it! your game will still work fine with the new .exe file. just download the latest version of dizzyage and change the .exe file of your game.
Thanks Delta! :)
Works like a charm! Awsome!
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.