See which player is in lead?

Get help using Construct 2

Post » Fri Dec 02, 2011 3:36 pm

I have a racing game, with 3 opponents which race around the track, but how do i tell which one is in the lead?
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Fri Dec 02, 2011 3:41 pm

Are the opponents separate sprites, or are they just clones of the same sprite?

If they are separate sprites you could make a variable Opponent1X or Opponent1Y (depending on if the direction is vertical or horizontal) and create an event to declare the variable as Opponent.X or Opponent.Y. Make another even that compares your location to theirs like so: Player.X < Opponent1X = you are behind the opponent or Player.Y < Opponent1Y = you are behind the enemy. You can make a boolean variable (either instanced or global) that determines that you are behind the enemy.kiasta2011-12-02 15:51:56
B
3
G
1
Posts: 12
Reputation: 599

Post » Fri Dec 02, 2011 3:47 pm

clones, but i gave them each a local variable so they have a name.

my capx: http://dl.dropbox.com/u/51270524/Racing%20Game.zip
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Fri Dec 02, 2011 3:51 pm

Im not sure if the players x is greater than opponents x will work, because then at some points on the track the x will be greater than the opponents event when the player is not in the lead, same for y
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Fri Dec 02, 2011 4:02 pm

What I am thinking is probably different than what you have. I'm at work atm so if someone answers you than great if not i'll look at it when I get home.
B
3
G
1
Posts: 12
Reputation: 599

Post » Fri Dec 02, 2011 4:22 pm

How about using invisible sprites as waypoints and use individual instance variables for the cars to keep a count of laps and waypoints.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,840
Reputation: 48,281

Post » Fri Dec 02, 2011 4:31 pm

you should probably combine some checks, first of all you keep track of laps, if lap greater then , is ahead, then keep track of wich waypoint it crossed, if waypoint is > is ahead, en then maybe distance to next waypoint is smaller then,

distance to next 50px is ahead of distance 60px

edit: you better use distance is greater then and use the waypoints that already crossedvtrix2011-12-02 16:41:40
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Fri Dec 02, 2011 5:06 pm

@vtrix, thanks for your advice, but im having trouble understanding how to do this, I have a finish line, which im using to count the laps of my player, Are you saying i should do the same but for the opponents? But if so there just copy's of each other not individual sprites.. Haave you downloaded the capx? maybe you could show me?
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Fri Dec 02, 2011 6:57 pm

i didnt sayed it was easy, this would take me to long to 'show you' you have multiple npc's these have to be compaired to eachother and to the player, there is still much to do, like surrounding borders so player/npc cant go way offroad, you are however already counting the waypoints per npc

as for the npc crossing finish,

for each npc
on collision with startline
npc.name = Mcdonalds    | add 1 to npc.currentlap
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Fri Dec 02, 2011 8:07 pm

I added all the Bounding boxes ect.

http://dl.dropbox.com/u/51270524/Racing%20Game.zip
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Next

Return to How do I....?

Who is online

Users browsing this forum: Radulepy and 7 guests