Welcome, Guest. Please Login or Register.  • Help
SMF Underground
+ SHMUP-DEV » SHMUP DEV FORUMS » Assistance
|-+ Scrolling design question

Pages: [1]   Go Down
0 Members and 1 Guest are viewing this topic. Topic Tools  
Read February 17, 2011, 01:57:48 PM #0
jtx2

Scrolling design question

I am trying to code a vertical scrolling shmup at the moment and was wondering how the scrolling mechanism would generally be implemented. I have ideas on two different ways of implementing it but was unsure on how it is done conventionally.

1. Scrolling background with static entities - I thought about having the game space be in a 800x600 rectangle and simply have a layer behind it with a constantly scrolling background. The enemies would appear based on the time they are programmed to appear at and follow a predefined path across the game space.

2. Scrolling background and scrolling entities - The game and all entities are scrolling, The enemies are given a location vector in which they appear as well as a time to appear and will scroll with the background.

I figured the second method would make it easier to make the enemies move realistically as they scroll with the background as well but I was wondering how the bullets would be implemented. Would it be wise to have them scroll with the screen as well? or could a hybrid method be implemented with the enemies following the scrolling but the bullets being drawn onto a static layer which does not scroll?
Offline  
Read February 17, 2011, 02:49:12 PM #1
Hornet600S

Re: Scrolling design question

Hi and welcome,

personally I'd define my game-space say 20 screens high and implement scrolling by incrementing one single number, a scrolling offset by a per_frame_scrolling_offset. That scrolling offset is added to the drawing-(!)-position of every entity that shall be affected.
Note: how efficient that is depends on the graphics APIs you're using. In DX or OpenGL this is just a single line of code (a translation) that automatically affects all entities, you draw them with their logical world coordinates but magically they appear at the correct scrolled position on screen.

The key is that you don't modify the logical positions of the entities. After all scrolling is just a camera movement, it should not actively move objects around.

This makes placing of enemies very easy, just set their coordinates to their logical world position.
The bullets will automatically scroll too. If that's desired or not depends on the situation:

As long as the scrolling speed is low this is may be fine and natural.
If you're doing a high-speed section it will obviously be bad and in such cases you should compensate it by decrementing the bullets' logical coordinate by that per_frame_scrolling_offset.
Another thing were compensating is useful are bullets that were aimed at the player.

I wouldn't go for your option (1). If I understand it correctly you'd essentially have no "world" coordinates that way, just your screen, and scrolling is just a visual background effect. That's definitely a limiter. It may be okay for Galaga-like shooters, but if you want to do something more complex, especially something where enemies are integrated into the background or so, I wouldn't recommend that.


"When the Amiga came out, everyone at Apple was scared as hell."
(Jean-Louis Gassée - Head of Macintosh development at Apple)
Offline  
Read February 17, 2011, 03:07:40 PM #2
jtx2

Re: Scrolling design question

Thanks for the quick reply!

I have just changed my code to use world co-ordinates instead of screen coords now, it seems to work more naturally for the movement of enemies Smiley. I kept the bullets on the screen coords system though as I realised that it could mess up the gameplay if the scrolling behavior changed and moved the bullets in a new direction with it.
Offline  
Read February 17, 2011, 03:16:23 PM #3
Hornet600S

Re: Scrolling design question

Quote
I kept the bullets on the screen coords system though

Maybe I don't get you right, but that way parts of your logic (enemy-bullets vs. player) operate in screen-space, while other parts of your logic (enemy movement, player-shots vs. enemies) operate in world-space, at least I asume it's that way. You could of course always operate in screen-space, but that would mean to switch coordinate-system once the enemies are spawned. Hm.

I prefer to always operate on logical coordinates everywhere.


"When the Amiga came out, everyone at Apple was scared as hell."
(Jean-Louis Gassée - Head of Macintosh development at Apple)
Offline  
Read February 17, 2011, 04:06:46 PM #4
motorherp

Re: Scrolling design question

Just to be awkward evil1 hehe, I tend to use option 1.  I prefer to have all my stuff defined in absolute screen space for the reason that it's then easier to accurately control their positions as they follow their paths since you dont have to account for an additional velocity offset being applied.  As for enemy spawning, instead of thinking of it in terms of reaching enemies due to your forward motion, you can then instead think of everything as being just timeline dependant.  This seems to make more sense for me since I only want to spawn entities when I need them which is easier to control this way and also I tend to want enemies to swoop on screen from different directions rather than just scrolling onto the screen.  As for the scrolling background itself, this can then be simply done with a static quad and by applying an offset to the tex-coords each frame to acheive scrolling.

With the correct editor tools you could get either to work well so I think this is one of those things were its really just down to personal preference and whether you'd rather think in terms of time or position.

« Last Edit: February 17, 2011, 04:14:25 PM by motorherp »

Offline  
Read February 17, 2011, 04:15:30 PM #5
Hornet600S

Re: Scrolling design question

 Grin I knew it was only a matter of time until somebody prefering the screen-world appeared.
But maybe we agree here:
better stick with 1 coordinate system inside your calculus.

Quote
and also I tend to want enemies to swoop on screen from different directions rather than just scrolling onto the screen

You can do that with the other technique too, in many ways. For example, you could define some (invisible) spawn-trigger-object that activates other entities when scrolling in.
« Last Edit: February 17, 2011, 04:20:39 PM by Hornet600S »

"When the Amiga came out, everyone at Apple was scared as hell."
(Jean-Louis Gassée - Head of Macintosh development at Apple)
Offline  
Read February 17, 2011, 04:23:56 PM #6
motorherp

Re: Scrolling design question

better stick with 1 coordinate system inside your calculus.

Yeh I definately agree with you here.  Using mixed coord systems is only going to confuse the issue.  And yeh, there's nothing that can be done in one system that cant be done with the other, its really just preference.  Just pick the way you're most comfotable thinking in and customise your tools to work that way.


Offline  
Read February 17, 2011, 04:31:47 PM #7
Hornet600S

Re: Scrolling design question

Right, basically a matter of taste.
I hope jtx2 isn't more confused now than at the beginning...  Roll Eyes


"When the Amiga came out, everyone at Apple was scared as hell."
(Jean-Louis Gassée - Head of Macintosh development at Apple)
Offline  
Read February 17, 2011, 05:08:35 PM #8
jtx2

Re: Scrolling design question

Just switched everything over to the world coord system Smiley. I realised I would be getting confused with the hybrid system whereas I can easily switch between world and screen coords when I want by sticking to one system.
Offline  
Pages: [1]   Go Up
Jump to:  

Page created in 0.115 seconds with 17 queries.