Smooth Scrolling Demonstration

Need help with using DizzyAGE then look here
User avatar
Noggin the Nog
Hard Boiled Egg
Posts: 406
Joined: Sun Jul 01, 2012 12:04 am

Smooth Scrolling Demonstration

Postby Noggin the Nog » Fri Jul 24, 2015 9:09 pm

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. :)

AndyG
Hard Boiled Egg
Posts: 208
Joined: Thu May 22, 2014 1:54 pm
Location: UK
Contact:

Postby AndyG » Sat Jul 25, 2015 11:02 am

Nice one! That definitely looks nicer. To my mind though, Dizzy moves just a little too slow. I'm making a scrolling game at the moment, and I think if anything I was looking to speed him up. Fantastic Dizzy has a large map, but you can cross it in just a few minutes. But I'd imagine it has to do with graphic limitations, so instead I'm just going to make warp points. (Is this why you did too?)

You've really helped me out with reaching the end of the screen though so thanks for that! I wanted to make Dizzy continue to the edge like you've done and I couldn't work it out. Just changing the room's properties is something I'd never have thought of. I tried using colliders to change G_Viewportmode, and it was weird; it would work once and then get all jerky, or it would stop working altogether.

User avatar
Noggin the Nog
Hard Boiled Egg
Posts: 406
Joined: Sun Jul 01, 2012 12:04 am

Postby Noggin the Nog » Sat Jul 25, 2015 7:04 pm

You can always speed Dizzy up by increasing the G_FPS further, it's just everything else gets sped up too. The frame rate is set in the GameStart Handler.

Grandad
Hard Boiled Egg
Posts: 1275
Joined: Sat Aug 08, 2009 10:47 am
Location: Balham - gateway to the south

Postby Grandad » Sun May 22, 2016 8:39 am

Recently I've been playing the early apogee games and the first Rick Dangerous game and noticed that they all use room scrolling techniques so thought it about time I learned the basic rules of scrolling. Unpaking most scrolling games and trying to figure the technique just made my brain hurt. So, on the off chance did a 'advanced' search and found your demo Simon. Thank you so much for doing this as it seems that I might finally be able to get to grips with this.

One thing though, the bottom co-ordinate of the map is noted as 536, which is actually 8 pixels up from the bottom of the 'room', but assume that it's not relevant as the area is a block, so Dizzy can never actually reach it.

User avatar
Noggin the Nog
Hard Boiled Egg
Posts: 406
Joined: Sun Jul 01, 2012 12:04 am

Postby Noggin the Nog » Sun May 22, 2016 4:31 pm

That's great, I'm glad to hear it's being used.

Yes, there's no need to set the edge of the scrolling area to the edge of a room, you can put it anywhere. Using room variables is just a convenient way to attach the properties to the map, say if you want to make two or more separate areas linked by doors or something, you can set different room properties in each area.

Let me know if you've got any questions. :)

Grandad
Hard Boiled Egg
Posts: 1275
Joined: Sat Aug 08, 2009 10:47 am
Location: Balham - gateway to the south

Postby Grandad » Mon May 23, 2016 8:24 am

Thanks Simon, I'm sure I'll have lots when I start playing around with the demo and start adding stuff.

AndyG
Hard Boiled Egg
Posts: 208
Joined: Thu May 22, 2014 1:54 pm
Location: UK
Contact:

Postby AndyG » Mon May 23, 2016 12:06 pm

I was actually never able to work this out. How to set the edge of the scrolling screen, I mean, so Dizzy can walk all the way to the edge. I'm not sure why. I went through it with a fine tooth comb. It's not really hampered me much, but it always bugs me a little when I can't solve a coding problem!

Grandad
Hard Boiled Egg
Posts: 1275
Joined: Sat Aug 08, 2009 10:47 am
Location: Balham - gateway to the south

Postby Grandad » Tue May 24, 2016 7:05 am

I might be talking out of my backside Andy, but from what I gather from Simon's demo is that the room properties act as a sort of 'frame' for the whole map, so that once the r/h or l/h edge is displayed in the hud the map stops centering round Dizzy's co-ordinates, but still allow him to continue walking in the same direction..

User avatar
Noggin the Nog
Hard Boiled Egg
Posts: 406
Joined: Sun Jul 01, 2012 12:04 am

Postby Noggin the Nog » Tue May 24, 2016 5:18 pm

That would be exactly right. You need to just set the room properties (left, right, top, bottom) to the x and y coordinates of the edges of your game area.

Grandad
Hard Boiled Egg
Posts: 1275
Joined: Sat Aug 08, 2009 10:47 am
Location: Balham - gateway to the south

Postby Grandad » Fri Jun 10, 2016 7:22 am

Got a bit of a problem Simon. Been trying to incorporate the 'scrolling' aspects into a test template that also includes a lot of stuff I've previously built into some of my games ie, running, turning, fading, climbing etc.

Now the game is falling over as it starts as it is failing to find something in the following line
in the handler after update:

left = RoomGet(roomx,roomy, R_LEFT) + roomw/2;

I've included the R_LEFT, R_RIGHT, R_TOP etc in the defines in the def file and set the room properties on the map.

Also included the G_ROOMXSTORE in the defines (just in case it was the previous line in the handler script that was iffy).

I'm sure I've done everything such as changing the frame and delay rate in the start up , added all the defines and the set screen coding in game and handler and replaced the movement.gs file with the one in the demo.

Is there anywhere you can point me to check further?