Dynamic starfield

For questions about using Classic.

Post » Sun Dec 21, 2008 7:49 am

So what I've been trying to do is create a dynamic starfield around a player where the stars will deleted as soon as they're a certain distance away. So far I've got the deleting down but I just can't figure out how to tell the stars to spawn out of the player view, so any help would be appreciated.
B
2
S
2
G
4
Posts: 136
Reputation: 1,722

Post » Sun Dec 21, 2008 8:41 am

Chat has it's benefits:

deadeye: okay
deadeye: make two variables called lastX and lastY
Barri167: ANd I could get vectors based on those.
Barri167: And the new ones that is.
deadeye: yes
deadeye: that will give you the direction
deadeye: then you just always set lastX to X and lastY to Y afterward to get ready for the next tick
Barri167: Yeah but... even with the direction, I could add that to the player X and Y to get the point where I'd want to spawn the stars.
Barri167: But how would I spawn them in that AREA.
Barri167: As soon as you said get the direction I knew I'd use lastx and lasty to get the direction vector.
Barri167: But I still can't think of how i'd spawn the stars in a general area and not just in a line.
deadeye: well, once you have the angle you can pick a spawn point away from the player
deadeye: then do system: spawn star at random(100)-50, random(100)-50
deadeye: or something like that
deadeye: er, sorry...
deadeye: (spawnPointX+random((100)-50)), (spawnPointY+((random100)-50))
deadeye: that will give you a relative x range of -50 to 50, same for y
Barri167: What would be the point of doing the -50 afterwards? wouldn't it be the same to do random(50)?
Barri167: Ohhh
deadeye: nope
Barri167: I see now.
Barri167: Thanks!
deadeye: yep :)
deadeye: no problem
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Mon Dec 22, 2008 11:43 pm

So far this is the farthest I've gotten. I'm sure there are a lot of extra unnecessary things I've included in it and it's far from done but meh, here's the progress.

Linky.
B
2
S
2
G
4
Posts: 136
Reputation: 1,722

Post » Tue Dec 23, 2008 1:52 am

Not bad so far. The concept as a whole seems to work... well, not great, but okay.

You probably already know what problems it has but I'll go over the few I noticed... it seems that the spawning area when flying vertically isn't wide enough to fill the screen. Also, stars spawn more densely when you're flying slower.

It also appears that you'll need to spawn stars perpendicular to the ship on either side, because when you change direction quickly there's a blank patch of empty space there. Perhaps my idea for spawning stars was flawed to begin with... it might just be better to do it something like this:



You could just set up those zones as static areas around the play area. It'd probably work better than trying to tweak my old idea into working properly.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Dec 23, 2008 2:53 am

Your above idea was originally how I was going to go about it. But I have no idea where to start with it.
B
2
S
2
G
4
Posts: 136
Reputation: 1,722


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest