How do I spawn stars around the player?

0 favourites
  • 11 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • hey there :)

    im creating a SPACE GAME THAT never have been made

    also i have a problem creating a star background performance wise

    the scene is 999999 x 999999

    so i cant make it to spawn stars everywhere lol

    i want to make it so it only spawn around the player

    i made it to work but when i start to more if i reach a certain range ... it stop creating stars

    when i get back in the range on the left corner ... it restart again wich is weard because im using a everytick if stars = less then 100

    can i get help ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could do like this:

    random(1000): random distance within 1000 from Player, you could change to another number.

  • kiugetski

    another way to tackle this problem is to make a grid of background sprites, and rotate them so that there is always one ready to scroll on to the screen...

    I made a sample to show you what I mean. The screen is 1920 x 1080, so I made a grid of 9 background sprites (3 rows of 3 sprites - each 1920 x 1080). You start in the middle one. Which ever way you move, whenever you move into a new row or column of the grid, the row or column furthest away gets moved up to the front in the direction you are moving. This keeps you in the middle of the grid, so you can move in any direction and there is a sprite up ahead to scroll on.

    to make it easier to see it in action, you can press Z to zoom out, and press C to change the backgound sprites to solid colors. Zoomed out you can see the row or column get rotated to the front.

    (Press Z again to zoom back in, and press S to show stars again).

    It uses Unbounded scrolling, so you can fly in any direction forever - the backgounds keep rotating under you so you always see stars (or the solid colors).

    The only thing interesting that I put in the universe is at sector 0,0 and 3,3

    (you start in 1,1).

    use the arrow keys to move the spaceship, spacebar to fire - but there is nothing to shoot.

  • You could do like this:

    random(1000): random distance within 1000 from Player, you could change to another number.

    still same problem it stop spawning when i reach 5000 pixels

  • ok now i do understand the problem for my stars spawning

    since im using 5 layers with différent parallax

    the stars are spawning on thoses layers but they do not show behind the player

    how can i remedy to that

  • kiugetski

    when you create the stars, you can use "Move to bottom" to send them to the bottom of the layer.

    or have a separate layer above all the background stuff for the player and other foreground objects.

  • yeah that i already do but what i want to doo is user the paralax backgrounds

    but no mater what i do when its on the paralax backgrounds

    the stars stop spawning when i reach 5000 pixels in either x or y

  • kiugetski

    that is probably the edge of your layout for that layer - because of the parallax settings. put an object on the edge of that layer to see if it shows up, or use layertocanvas from the player's layer then canvastolayer for the background to see what the coordinates are there.

    you may have to create stars farther out than you think because of the parallax... or it could be something else. it would help if you made a sample capx with just the layers, stars and player to look at.

  • how do i use the layertocanvas

  • yeah so it still does the same problem :(

  • seem like spawning stars on a parallax layer make it uneven

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