The Daily Click ::. Forums ::. Klik Coding Help ::. Scrolling stars?
 

Post Reply  Post Oekaki 
 

Posted By Message

Benny Lindberg



Registered
  08/11/2010
Points
  54
18th October, 2011 at 22:14:02 -

Heya! Feels like I'm constantly bugging you guys, but I'm curious as to one thing. Is there an efficient way to make a star-background that scrolls along, with stars at different distances travelling at distant speeds. You know, like you'd have in a scrolling spaceshooter?

 
n/a

Rob Westbrook



Registered
  25/05/2007
Points
  193

360 OwnerVIP Member
18th October, 2011 at 22:20:54 -

Have a bunch of different layers with different X and Y coefficients and stars randomly dotted about on them. The lower the coefficient is below 1, the slower the layer will be when scrolling, giving a pretty good parallax effect!

In the past I've run a fastloop that pastes stars into the background for a quick and easy starfield that requires no effort at all! I'm lazy.

Of course this is in MFF2, what are you using?

 
There are 10 types of people in the world: Those who understand binary and those who don't.

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
19th October, 2011 at 00:19:40 -

Layers have a terrible effect on older systems, a problem that compounds with each layer.

Honestly, I'd just position several objects off screen that shoot active objects at different speeds. Not nearly as much of a performance hit, and as long as you don't care about the stars not being the same layout each time.

http://www.mediafire.com/?q3qtqoxcy8q50jg

Also remember to clean them up. I didn't do it here.

 
Craps, I'm an old man!

Benny Lindberg



Registered
  08/11/2010
Points
  54
19th October, 2011 at 10:10:48 -

Hey! I considered the parallax solution, but i want the stars to be moving even when the screen isnt, you see?
And I tried the shooting approach, but it gets a bit cluttery.

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
19th October, 2011 at 12:22:16 -

@ Benny: I do the "shooting stars" approach, and it works wonders. I'm not at my home computer so I'm unable to have a look at Shab's example, but there may be a few things you can do to address the "cluttered" nature you referred to.
- slightly dim the colour of the star sprites; display them at a hue closer to the background colour
- make the star sprites slightly transparent with an Ink Effect (available only in MMF2, to my knowledge)
- limit the number of star sprites visible on the screen at any one time
- instead of coming up with sprites of different sizes, randomly scale the star sprites and base the speed it travels on that

Again, if I had the opportunity to see an example I'd have more input at the moment. But I'll offer more suggestions sometime soon. Best of success, Benny.

 
n/a

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
19th October, 2011 at 18:06:18 -

Define Cluttery. How do you want the stars to appear? There are many, many ways to customize the extremely basic system I showed.

 
Craps, I'm an old man!

Benny Lindberg



Registered
  08/11/2010
Points
  54
19th October, 2011 at 18:45:19 -

What I did with the shooting star thing is have several "starshooters", and every 0.5(for example) i select one of them and have them shoot a star. The problem is, sometimes the same shooter gets selected and thus two stars come a bit too close too eachother and it looks wonky. Know what I mean?

 
n/a

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
19th October, 2011 at 19:12:26 -

Look at my example, I think you'll find that it doesn't do that nearly as much as you think.

 
Craps, I'm an old man!

Benny Lindberg



Registered
  08/11/2010
Points
  54
19th October, 2011 at 21:11:55 -

It was beautiful Knudde! Looks like the solution I needed

 
n/a
   

Post Reply



 



Advertisement

Worth A Click