0 Favourites

Need some help on my game

  • So at the moment I'm making a traffic game (where there is a 4 way cross road and you have to control one of the sides with a set of traffic lights).

    I'm stuck on 2 things:

    First one is spawning. I need to spawn a car at random 1-3 seconds and also spawn different types of cars (as I have different coloured cars and I don't want them to be the same).

    Second thing is stopping. once the first car is stopped, the car behind goes ontop. I know I could put collide but I want there to be a gap inbetween the two.

    Help would be really appreciated and don't worry if you don't know both, just post me one!

    Thanks!

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • But you haven't describe what exactly problem do you have?

    First one is spawning.

    Spawning an object you can do by System -> Create object or by some sprite object -> spawn object.

    I need to spawn a car at random 1-3 seconds...

    You can use "Every x second" or any other loop with "wait" function, but there is a special way you have to build a delay between iterations. You can learn it here: https://www.scirra.com/tutorials/723/using-wait-in-loops.

    Regarding random function, the most precise is the following format: "floor(random(b-a+1)) + a" which returns an integer number from "a" to "b" (including them).

    and also spawn different types of cars (as I have different coloured cars and I don't want them to be the same).

    If the only thing which differs is the color then I encourage to use one sprite and put various cars as separate frames.

    Second thing is stopping. once the first car is stopped, the car behind goes ontop. I know I could put collide but I want there to be a gap inbetween the two.

    Well this really depends on how exactly your game works. You can for instance check the distance between car1 and car2 by X and Y position.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread sticky
763 305,714
asikanddestroy's avatar
asikanddestroy
Unread hot topic
232 177,689
Tetriser's avatar
Tetriser
Unread hot topic
157 12,697
megatronx's avatar
megatronx