|
-
Aug 18th, 2002, 01:28 AM
#1
Thread Starter
Member
Moving Stars
I was wondering how to get scrolling stars in the background of a game that I'm making. I would appreciate any help.
110359
Why is it that when you kill one man people call you a murderer and when you kill one thousand you are a conqueror?
-
Aug 18th, 2002, 09:53 AM
#2
Hyperactive Member
scroll vertically, horizontally, ? Vertical is something like this. It assumes that you want 100 stars scrolling vertically in a 100*100 pixel area.
VB Code:
Type PointAPI
x as long
y as long
End Type
Sub Game_Loop()
Dim StarPos(99) as POINTAPI,lCounter1 as Long
For lCounter1 = 0 To 99
StarPos(lCounter1).x=Rnd*100
StarPos(lCounter1).y=Rnd*100
Next lCounter1
While Running
For lCounter1 = 0 To 99
StarPos(lCounter1).y=(StarPos(lCounter1).y+1) Mod 100
Form1.PSet (StarPos(lCounter1).x,StarPos(lCounter1.y)),vbWhite
Next lCounter1
Wend
End Sub
-
Aug 18th, 2002, 12:38 PM
#3
Good Ol' Platypus
That's a nice loop snake! 
But, he may mean like the screensaver... It's not all that hard to do, but it is a challenge nonetheless. To have it come from the middle, I suggest using sine and cosine with a different radius and angle for each star. Expand the radius by the star's speed (if they all have the same speed it looks flat and boring) and draw it. When it's offscreen, you can create it in the middle again and start the loop over.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 18th, 2002, 12:52 PM
#4
Good Ol' Platypus
Oh, snake, put a doevents in there or else your code will never be displayed
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 18th, 2002, 07:37 PM
#5
Hyperactive Member
[hides head in ass for shame]
oops, I am sorry. Doevents is also needed.
[/hides head in ass for shame]
-
Aug 18th, 2002, 08:19 PM
#6
Frenzied Member
It will look more 3D if a star's brightness is proportional to its speed. So a fast star is bright and a slow star is not
-
Aug 18th, 2002, 08:36 PM
#7
Thread Starter
Member
Thanks
Thanks for the help guys. Yes I did mean vertically. Again thank you.
110359
Why is it that when you kill one man people call you a murderer and when you kill one thousand you are a conqueror?
-
Aug 18th, 2002, 08:47 PM
#8
Thread Starter
Member
Where ever I put the section:
Type PointAPI
x As Long
y As Long
End Type
It tells me it can't go there. Also where should the doevents go.
Why is it that when you kill one man people call you a murderer and when you kill one thousand you are a conqueror?
-
Aug 18th, 2002, 08:56 PM
#9
Frenzied Member
You're declaring a Type, and declarations are always before the subs and functions 
The DoEvents should be right after the While.
-
Aug 18th, 2002, 11:14 PM
#10
Good Ol' Platypus
Originally posted by Jotaf98
It will look more 3D if a star's brightness is proportional to its speed. So a fast star is bright and a slow star is not
As that is true, far away stars could be really bright... add some randomness into that
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 19th, 2002, 12:30 AM
#11
Thread Starter
Member
It keeps coming up with an error saying:
Cannot define as a Public user-defined type within a private object module.
Why is it that when you kill one man people call you a murderer and when you kill one thousand you are a conqueror?
-
Aug 19th, 2002, 06:02 AM
#12
Hyperactive Member
Select Project->Add Module
Not class module, not a form, but a module.
-
Aug 20th, 2002, 12:48 AM
#13
Thread Starter
Member
Sorry about all the questions. Thanks for all the help.
Why is it that when you kill one man people call you a murderer and when you kill one thousand you are a conqueror?
-
Aug 20th, 2002, 03:41 AM
#14
New Member
All you have to do is declare the type as a private type...
Private Type PointAPI
x As Long
y As Long
End Type
no prob, right!
-
Aug 20th, 2002, 03:52 AM
#15
Retired VBF Adm1nistrator
In my game craft, stars move opposite to the direction of travel.
Check it out :
http://www.coolground.com/plenderj/1.0.17.zip
Older versions of the game also had stars moving at different speeds in the background to make them look farther away, but that effect only works if you're travelling in the one direction.
It looks stupid if the player changes direction often
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|