First of all, let me make clear that I'm not posting this to be a jerk in any way, just trying to help you ...
Got some bad news and a couple of tips.
First, the bad news, it didn't work. After a bit of messing around the only thing I could see were 5 dots slowly moving away from the top left corner changing into all sorts of colors, and suddenly it gave me an error (somewhere in the UpdStar sub, couldn't see the exact location since the whole screen was black )...
Now for the tips (don't know if some things were to be removed and were just for testing, but going to post them anyways):
RaiseEvent
I noticed you used RaiseEvent somewhere in the code, but didn't actually use it. RaiseEvent is slow! You might not notice it normally, but at 60 or 70 FPS it's really a nightmare. If you do want to raise some sort of event, you might want to take a look at the 'Implement' command, which is a lot faster...
FS.Initialize
First thing I got when I started it was an error, you forgot to call FS.Initialize...
BltColorFill
Clear the backbuffer before your next drawing cycle. Use something like:
Code:
With rScreen
.Top = 0
.Left = 0
.Bottom = 600
.Right = 800
End With
BB.BltColorFill rScreen, 0
Aaaargh! 1024x768!!
Don't hard-code the resolution into the program unless you're absolutely sure it's supported (like 640x480x16 is a safe choice, but preferably let the user choose)...
That's all I can think of right now . About the stars, I think there's a little problem in your calculations, although I'm not sure what it is exactly, still figuring out what you did. I hope it can be fixed, so I can finally get rid of the default starfield screensaver ...
Teaudirenopossum.Musasapientumfixaestinaure. (I can't hear you. There's a banana in my ear)
Yeah. Well, I fixed the routine, I just had set the start x and y, and not the real x and y, so it had started from the middle. And it does 'bursts' of stars, which is easy for me to fix. I made one of these before and it worked like a charm, implementing a class mod. really took it down, eh?
Anyways, I will fix the star bursting code, and maybe you could do something with it, I'll post the updated class module here.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
(Just a heads-up)
I was also just being a jerk because this prog. was just to test if it would work, then I would rewrite it (with the vital parts remaining) and newer, less hard-coded code.
BTW. You must set the disp. mode in DDraw before you initialse it. And also, the only reason all of those other subroutines are available is because I put no private in them. This is how you use it:
(for sake of coding lets say you have the cla-mod. in SF.)
(and actually I'm going to take out the events cause I will never use them.)
Code:
SF.MaxStars = 50
SF.ColourHigh = RGB(255,255,255) 'displayed when closest to you
SF.ColourLow = RGB(0,0,0) 'displayed when created
'set modes(display and coop. level)
SF.Enabled = True ' this will also call initialise (in the new c-mod)
When you want to blit a star, get it's X, Y, and Colour:
Code:
SF.GetStarData # '# = the number of the star you want to find info about
Col = SF.StarColour
X = SF.StarX
Y = SF.StarY
Put this code before BLT in the loop of DDraw prog:
[/code]
Do
SF.Redraw
BlitStars
DoEvents
Loop
[/code]
And that's how to use my Class Module, I actually wont "silence" the other subroutines as you may have use for them:
Code:
Sub SplitRGB(Colour, R, G, B)
R = SF.GetR(Colour)
G = SF.GetG(Colour)
B = SF.GetB(Colour)
End Sub
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
(Just a heads-up)
C was at that point (I think, but shouldn't matter much) 122, with the results of GetR 0 and 255 (first and second call) and Stars(C).Stage=129...
So I commented the line and broke it in pieces, and replaced all the variables with the numbers, it looked like this:
Stars(C).R = ((0 * 126) + (255 * 129)) / 255
Still an error, so I tried this:
Stars(C).R = 255 * 129
And that's where the error occured. According to my calculator, the result is 32895...
The weird thing is, I changed the Integer to Long before running this code, but it still raised the Overflow error, should it? As far as I know, even an Integer should be able to hold this value...
Tried using CLng(), but didn't work either...
Teaudirenopossum.Musasapientumfixaestinaure. (I can't hear you. There's a banana in my ear)
Don't ask me why, but X = 255 * 129 gives an Overflow, but X = 32895 doesn't...
It's not a nice way to work things out, but I've changed the 255*129 to call a function 'Multiply', which multiplies the two numbers in a not so pretty way (a loop).
Anyways, this fixes the overflow error, the stars show up, they go all the way, but the Multiply function is a little bit too slow to keep up (or any other calculations are, don't know exactly what is slowing it down), and it still doesn't look like stars to me...
But here's my version, do whatever you like with it...
Btw, I removed the Debug.Print in the StarField Initialize sub, because it took about 6 seconds extra time...
My suggestion for the current starfield: use Shift+Del on the files and start over again.
Teaudirenopossum.Musasapientumfixaestinaure. (I can't hear you. There's a banana in my ear)