So I've had a couple of free days this week and began to wonder how to do smooth scrolling in DizzyAGE, much like you find in The Last Hero and Night at the Museum. After a bit of work I came up with a technique which, though not quite as good as those games, works pretty well and I thought I'd share it on here in case anyone wants to use it.
What I've done is make a little demo - just a small map without any puzzles - so people can download it and see.
You can download the "data" folder from DropBox here:
https://www.dropbox.com/s/mojafni7bdwi7hh/smooth_scrolling_demo.zip?dl=0
Aside from the scrolling, I've modified Dizzy's movement to make that smoother too. If you're interested in any of the code, you'll find it all in the game.gs, handlers.gs and movement.gs files.
EDIT: There's also a new function in the util.gs file.
A quick a technical point too: The big trick to the technique is that I've changed the game's frame rate (G_FPS) from 36 to 48, and increased Dizzy's frame delay (P_DELAY) to 4. This means that whilst Dizzy's motion appears unchanged, he now moves (horizontally) four pixels every four frames, instead of four every three. This really simplifies the coding for the scrolling and made it possible to smooth up Dizzy's movement too. However, these things won't work properly if G_FPS and P_DELAY aren't changed, so you can't just add the scrolling code to an existing game without making a bunch of other changes. Obviously, increasing the FPS will make everything else (animations, AI) run a third faster.
But please feel free to use the demo as a template or to contact me if you have any questions etc. I'm getting a little cold on making new games (doing the graphics is interminable) but I'm happy to help other people. :smile:
What I've done is make a little demo - just a small map without any puzzles - so people can download it and see.
You can download the "data" folder from DropBox here:
https://www.dropbox.com/s/mojafni7bdwi7hh/smooth_scrolling_demo.zip?dl=0
Aside from the scrolling, I've modified Dizzy's movement to make that smoother too. If you're interested in any of the code, you'll find it all in the game.gs, handlers.gs and movement.gs files.
EDIT: There's also a new function in the util.gs file.
A quick a technical point too: The big trick to the technique is that I've changed the game's frame rate (G_FPS) from 36 to 48, and increased Dizzy's frame delay (P_DELAY) to 4. This means that whilst Dizzy's motion appears unchanged, he now moves (horizontally) four pixels every four frames, instead of four every three. This really simplifies the coding for the scrolling and made it possible to smooth up Dizzy's movement too. However, these things won't work properly if G_FPS and P_DELAY aren't changed, so you can't just add the scrolling code to an existing game without making a bunch of other changes. Obviously, increasing the FPS will make everything else (animations, AI) run a third faster.
But please feel free to use the demo as a template or to contact me if you have any questions etc. I'm getting a little cold on making new games (doing the graphics is interminable) but I'm happy to help other people. :smile: