# Problems with endless running game

Get help using Construct 2

### » Thu Jan 24, 2013 11:00 am

I've been trying to figure out how I want to generate my terrain and make my guy run through it, and the first idea I had was the old Starship game method, which would be to have my guy run on the spot and have the terrain just move under him. This didn't work so well because I wouldn't find a good method to move the floor consistently in C2. It started generating gaps between my tiles.

The second way was I had generated a static level, and have my guy run through it, when he reaches the end of the level, it teleports him back to the start and regenerates the level. The problem is, the game is a endless runner / shooter game, and having my platform character actually run, has affected the accuracy of my bullets because they shoot where it was a moment ago, and not relative to his running speed.

How would you solve either of these problems? In theory? or example.

Would be very appreciative of any help!
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

### » Thu Jan 24, 2013 11:23 am

I would like to know about this as well. I'v been thinking of experimenting with endless runner genre myself
Game Over teaches you more than Stage Clear.
- Nagi
B
8
Posts: 7
Reputation: 643

### » Thu Jan 24, 2013 12:53 pm

I would also like to know as well. I am currently using a method involving three sprites using the wrap and bullet behavior to make the ground look like it is moving backwards so the character looks like he is running forward however I know this method is probably bad but at the moment it works.

i also did try some other methods however as the OP said it would often have gaps. :S
B
4
Posts: 9
Reputation: 468

### » Thu Jan 24, 2013 1:42 pm

Can't you just give the bullet the speed & direction the player has at the moment of shooting and then adding the bullet's own speed & direction? So if you'd shoot the same direction as you were walking the bullet's speed would be the players speed + its own speed. It should be possible to calculate the bullet's speed & angle when the player shoots in a complete different direction using sin, cos and/or tan. I can help you with that if you'd like (if you didn't try this method before and you don't know whether it works, I'm not completely sure either ;) ).

If that doesn't work out you could also consider making bullets which hit at the moment of shooting, so fast it can not be seen. You could use a thin rectangle for the bullet sprite, which will test for collisions with other objects as soon as is created (and after that it is immidiately destroyed).

Edit: I created an example of my first mentioned solution:
Note; Because I made the bullets so slow it might look a little weird, but this way the effect is seen best. If you have a question about it let me know ;)Jasper2013-01-24 14:19:52
B
13
S
3
G
4
Posts: 35
Reputation: 3,358

### » Wed Jan 30, 2013 7:25 am

@Rory - someone left a link to an endless runner tutorial on a different program. i've been trying to recreate it in construct to use in my own game with different mechanics and also leave as an example file for anyone who wanted to learn from it - however i am suffering from the same problem.

if made with dt it leaves tiny (dt spaced i assume) gaps in the floor tiles, i couldn't for the life of me figure out how to account for dt in all the equations
B
14
S
6
G
2
Posts: 136
Reputation: 3,210

### » Wed Jan 30, 2013 7:33 am

You can get rid of the gap in the tiles by "offsetting" them based on an integer variable rather than moving them individually by, say, 60*dt.
B
223
S
26
G
13
Posts: 1,768
Reputation: 17,862

### » Wed Jan 30, 2013 8:31 am

I had this problem and using integer variable didn't fix it for me. Use rex's MoveTo behaviour.. worked perfectly and got rid of the gaps. Plus it's framerate independent.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

### » Wed Jan 30, 2013 10:58 am

That doesn't fix the gap between the previous and newly generated parts of the level though, just individual tiles.Tokinsom2013-01-30 10:59:08
B
223
S
26
G
13
Posts: 1,768
Reputation: 17,862

### » Wed Jan 30, 2013 3:10 pm

You mean, creating a new tile offscreen at the end of the last tile? If so, then yeah, that's where MoveTo worked for me.

I was doing a slots game and needed each reel segment to be created before it came into sight. I had terrible gaps.. tried everything. Then thought I'd have a go with MoveTo and it worked perfectly! No more gaps ever. ;)
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

### » Wed Jan 30, 2013 6:11 pm

@procrastinator Alright! Will check that out :) Thanks a billion.

@Jasper - PERFECT! That's exactly what I wanted. Now that it's in plain sight I can't believe how simple the solution was, you're a genius man. Thanks :)

Must say, it took a few days, but you guys solved all my problems at one go. Scirra must be proud of this community Rory2013-01-30 18:12:53
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Next