# How do I Clockwise driving?

Get help using Construct 2

### » Wed Nov 26, 2014 8:30 am

I'm making top view racing game and almost everything works as I planned, except one thing.

Player is able to pass current lap regardles he drives, either he drive clockwise or back clockwise laps and checkpoints are counted. OK checkpoint counter is fine, but I want to force on track only clockwise direction of driving.

draft
red arrows - direction I want to block
green arrows - desired direction
Code: Select all
`http://scr.hu/1yl7/ofufq`

Eventsheet
Code: Select all
`http://scr.hu/1yl7/2rt6v`

B
6
S
1
Posts: 57
Reputation: 514

### » Wed Nov 26, 2014 10:02 am

There's probably MUCH better ways of doing this but something that comes to mind is that you could divide the track into zones, and each zone would have a range of directions (angles) the car is allowed to have, and if it's outside of those angles then it's going in the wrong direction. For example in the track you showed us, the left side of the track would restrict the car to angles 180 to 360 (or whatever). The right hand side would be 0 to 180, etc. To know which zone the car is in you could use invisible sprites that cover each zone and do an overlapping test with that sprite and the car, or check x,y coordinates to determine which zone the car is in.

Another thought is that if the driver is collecting checkpoints in the wrong order, you'd know they are going in the wrong direction.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

### » Wed Nov 26, 2014 11:41 am

codah wrote:There's probably MUCH better ways of doing this but something that comes to mind is that you could divide the track into zones, and each zone would have a range of directions (angles) the car is allowed to have, and if it's outside of those angles then it's going in the wrong direction. For example in the track you showed us, the left side of the track would restrict the car to angles 180 to 360 (or whatever). The right hand side would be 0 to 180, etc. To know which zone the car is in you could use invisible sprites that cover each zone and do an overlapping test with that sprite and the car, or check x,y coordinates to determine which zone the car is in.

Another thought is that if the driver is collecting checkpoints in the wrong order, you'd know they are going in the wrong direction.

Yes, the order of chekpoints would do the trick, but as you saw in my sheet there is set instance variable to Pick instance with lowest (variable) but (I don't know how it is possible) always counts checkpoint. In other words, Sprite called checkpoint has uniqe variable and I pick the lowest value of this variable but always when I get through checkpoint system counts that checkpoint as correct.

If my words are too confusing I will provide necessary files.
B
6
S
1
Posts: 57
Reputation: 514

### » Wed Nov 26, 2014 1:26 pm

I basically threw this together.. hope it helps some.

https://dl.dropboxusercontent.com/u/666 ... oints.capx
B
15
S
5
G
7
Posts: 876
Reputation: 5,650

### » Wed Nov 26, 2014 3:16 pm

Message: Lazarus1988 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
procrastinator wrote:I basically threw this together.. hope it helps some.

https://dl.dropboxusercontent.com/u/666 ... oints.capx

Thank you very very much I owe you big one ;]
B
6
S
1
Posts: 57
Reputation: 514

### » Wed Nov 26, 2014 4:09 pm

No problem. Hope it's useful. There are flaws of course, but if you design your tracks right, that method should be fine.
B
15
S
5
G
7
Posts: 876
Reputation: 5,650

### » Wed Nov 26, 2014 5:28 pm

Yes, very usefull. You know, I'm getting old but I remember when I was in Highschool (IT school) my teacher told me that
One person can make great things, imagine what would create a group of individuals
B
6
S
1
Posts: 57
Reputation: 514