# Dynamic starfield

This forum is currently in read-only mode.
0 favourites
• 5 posts
From the Asset Store
Create your quiz game! Create unlimited categories. Manage categories and questions
• 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.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Chat has it's benefits:

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: 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: 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

Barri167: I see now.

Barri167: Thanks!

• 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.

• 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:

<img src="http://i43.tinypic.com/amtvtg.png">

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.

• Your above idea was originally how I was going to go about it. But I have no idea where to start with it.