Dynamic starfield

This forum is currently in read-only mode.
From the Asset Store
Firebase: Analytics, Dynamic Links, Remote Config, Performance, Crashlytics on Android, iOS & Web Browser
  • 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.

  • 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

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)