# Help with creating an infinite driving game

Get help using Construct 2

### » Thu Aug 24, 2017 11:07 am

Hi!

You probably are familiar with the endless runner games, except when I take a look at the sample capx from Scirra, I notice that this game doesn't let you control your player. So it's using a set speed with a set obstacle speed.

Now I'm wanting the player (car) to be able to drive left and right, finish a stage and then have another stage spawn after it.

Problem is... I can't figure out how to adapt the endless runner sample nor am I able to get some of my ideas to work. Since the layout width isn't endless, I have to come up with something that will relocate the player back to a starting point when it reaches an end point:

------StartPoint---------------------------------EndPoint-------

And I would set the sprite (ground/stage) to a new random frame so it will create a new stage. The car and ground both have physics. Problem with the relocate idea is that it didn't 'remember' the speed it had at the endpoint. Upon relocation it would simply start at 0 speed again, I could use a solution for that!

Or if anyone has any other ideas to get this done efficiently. Basically the player can drive forwards and backwards. So I was thinking either I need to fix the relocation issue OR the ground would need to move in opposite direction when driving forwards or backwards. Now I tried and asked some stuff about that but couldn't get it to work without some weird occurences (like ground sprites miraculously falling from the sky at certain point).

Anyway, I'd like to thank anyway who might be able to help.

- R
B
14
S
7
G
4
Posts: 145
Reputation: 3,610

### » Fri Aug 25, 2017 7:15 pm

Well... Based on the template:

Change the player behaviour to 8Direction (Up and Down)

Car is on ground >>> Simulate pressing right

you can use

Every Tick >>> Car set vector X to 10

so then you rearrange the obstacles, and make some events.
Howdy, I'm HenryPK! I love helping people and making games... Hope we can be friends. (Also check my game: Blue)
B
10
S
2
G
1
Posts: 60
Reputation: 1,233

### » Sat Aug 26, 2017 12:05 am

Yes, you need to make the ground move in the opposite direction to make it look as if the car is moving.
My first project:
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

### » Sat Aug 26, 2017 3:42 am

Howdy, I'm HenryPK! I love helping people and making games... Hope we can be friends. (Also check my game: Blue)
B
10
S
2
G
1
Posts: 60
Reputation: 1,233

### » Sat Aug 26, 2017 8:15 pm

Physics objects are touchy about being moved with the set position action. It confuses the physics engine when things suddenly teleport.
Anyways, I haven't done it in a bit but you should be able to keep the velocity by:
1. save the the velocities to variables.
2. move the object.
3. wait a tick and set the velocities from the variables.

Or just use the chipmunk behavior, it doesn't have that quirk. You can just simply move stuff without issue. Anyways either of those should fix the relocation issue.

The objects raining from the sky is probably from them being launched there from off screen overlapping objects.
B
97
S
36
G
131
Posts: 5,519
Reputation: 83,476