How do I - Infinite Diagonal Scrolling (For endless runner)

Get help using Construct 2

Post » Wed Apr 09, 2014 10:35 pm

EDIT: CAPX file included.

Hi All,

Very new to Construct 2 and I already love it.

I am trying to make an infinite running game where I randomly line up different poles(or road) which my hero has to walk on. The poles are not in straight platforms but diagonal. Start from Top right scrolling towards bottom left. Here is a sample image I created to show what I am trying to achieve.

PolerunnerForumCopy.capx

seamlessscroll.png


At every Tick, I am incrementing the Pole objects' X,Y but (-1,1). Also tried at Layout Start added bullet motion to -225 deg.

As the poles move downwards, I am creating new poles at the top. This is where the problem started.

1) I am not able to properly identify where to place the newly created Pole from. How do I get the Position of the Last created Pole, so that I can "attach" the new pole to it?

2) I then noticed my Pole platform started drifting to much towards the left, like this:
seamlessscroll2.png


3) I managed to identify the last created Pole using an Instance boolean variable called ISLAST. Using this I trapped the X and Y and use it to position the newly created object. But I am hoping there is a better way of doing it.

I primarily need help with the drifting Platform/Pole. Any help will be greatly appreciated! :)

Thanks,
Sam
You do not have the required permissions to view the files attached to this post.
Last edited by SamRock on Fri Apr 11, 2014 3:55 pm, edited 3 times in total.
Create your own Isometric Runner Game using C2:

Image

Check out my game "Last of the Survivors":
Play Store
App Store
B
58
S
13
G
2
Posts: 421
Reputation: 5,397

Post » Fri Apr 11, 2014 2:22 pm

I don't think you need the ID of the last placed pole at all. In most infinite scrollers you don't even need to scroll - it's an illusion.

Is the character always "climbing" up and to the right, in the same angle, or are there sections where the player can go down and to the right, or horizontally to the right?
B
36
S
8
G
8
Posts: 532
Reputation: 6,903

Post » Fri Apr 11, 2014 3:23 pm

Hey @Fimbul

So glad someone responded.. Thanks a lot.

I created an "invisible" wall to mark the point at which a new block should be created. Its kind of okay now. I was able to nearly able align the new objects to the currently colliding block.

To solve the drifting issue I used the "Custom Movement" behavior and at every TICK telling the block to Accelerate toward certain X,Y(ie, Bottom left corner). For now its working fine except the initially created poles.

But yes.. later on I would want my character to change directions too. In that case my "Accelerate toward X,Y logic wont work out. Is there a something that can handle the change in direction?

Attached is the Capx file for your study.
PolerunnerForumCopy.capx
You do not have the required permissions to view the files attached to this post.
Create your own Isometric Runner Game using C2:

Image

Check out my game "Last of the Survivors":
Play Store
App Store
B
58
S
13
G
2
Posts: 421
Reputation: 5,397

Post » Fri Apr 11, 2014 5:33 pm

Here's an example I put together. All in 13 events, so you could work this into a game even with the free edition. Also I was wrong, you apparently do need the last platform ID (unless you want more maths).

Press "enter" to change the angle (but wait a few seconds before you do that)
Scrolling is a bit bonkers but you should be able to fix it with some maths or creativity.

Sorry for the scary math. It's probably possible to get rid of it all and replace it with something easy.
You do not have the required permissions to view the files attached to this post.
B
36
S
8
G
8
Posts: 532
Reputation: 6,903

Post » Fri Apr 11, 2014 9:02 pm

Thank you!! Looks like you saved this with the Beta. Downloading the new version now :)
Create your own Isometric Runner Game using C2:

Image

Check out my game "Last of the Survivors":
Play Store
App Store
B
58
S
13
G
2
Posts: 421
Reputation: 5,397

Post » Sat Apr 12, 2014 7:37 pm

@Fimbul You sir are a genius!!! I literally had tears in my eyes when I saw how much time and effort you took to comment every line with so much detail. Thank you so much!

After all those math functions I realized I am far behind and need to do some serious reading.

I will now try to integrate your awesome logic into mine. I had just one more question but I will ask that once I have your awesome logic on my game :)
Create your own Isometric Runner Game using C2:

Image

Check out my game "Last of the Survivors":
Play Store
App Store
B
58
S
13
G
2
Posts: 421
Reputation: 5,397

Post » Mon Apr 14, 2014 8:52 pm

Hi @Fimbul

I am back. .. I tried your code. It works great. . I had to make some changes in order to keep the images from rotating but keep the angle of scroll same. After I replaced your sprite with mine, I had to make some adjustments to the Y coordinate in order align them properly. But when I do that, the platform starts moving downwards at every interval.

Here is the change I made to adjust the Y position for a new platform:

Y= (Platform.Y)-sin(Platform.Angle)*(PlatformWidth/2)-sin(PlatformCreationAngle)*(PlatformWidth/2) + addY


And this is how I intend to create my images (not final). As you can see they are isometric tiles, which I will be joining to create a chain to pipes connected.
Sample.png


Now when I am walking on tile #1, I continue scrolling in the default angle (as in ur code). But when my character touches tile #3, I change scroll angle to the opposite direction. Of course the character will remain in center of the screen.

The only problem I have right now is that the platform starts moving downwards when I add a Y value. Is there an mathematical way of handling this?? :)

Thanks again for your time and help!!
You do not have the required permissions to view the files attached to this post.
Create your own Isometric Runner Game using C2:

Image

Check out my game "Last of the Survivors":
Play Store
App Store
B
58
S
13
G
2
Posts: 421
Reputation: 5,397

Post » Tue Apr 15, 2014 12:06 am

Ah, I understand now what you're trying to do. I was operating under the impression that this auto-runner of yours was a platformer, but it's an isometric game...
Which is quite weird since your drawing on the original post showed a platformer-style auto-runner. Did you change the scope of your project? If so, this smells like feature creep, and you should probably revert to the original platformer design.

However, if you still want to press on with the isometric gameplay, you're better off ditching the whole logic and starting over with a modified iso tiling engine (one that only draws the tiles you need), since your pipes are basically tiles. There should be some examples around in the forum.
When creating new tiles, remember to push them to the bottom of the z-order, and use image points (as well as instance variables) to create attachment points for the newest pipes.
You'll need to scroll all the tiles instead of the player, which will have to be done using basic trig (you can't rely on the layout editor to handle the scrolling for you).

All in all, I recommend reverting to the original design.
B
36
S
8
G
8
Posts: 532
Reputation: 6,903

Post » Tue Apr 15, 2014 10:13 am

@Fimbul, only the graphics look like isometric but concept is still the same. Instead of rotating the platform, I want to use a curved platform to represent the change in direction. I drew an isometric diamond around the pipes to give you an idea of what ends need to join when a new tile is created.

Your logic works perfectly, I was even able to randomly pick variously tiles and make a continuous path. The problem I am facing is when I try to adjust the height with the previous tile, the whole platform starts drifting downwards.

And I am really sorry about the first images. I had no images ready and quickly made them on Paintbrush to give an idea of the problem I was facing. I should have taken an isometric character to show that he will be walking inside the pipe area

Thanks again for your time and recommendation. I am sticking to your logic, just need help with managing the additional X, Y adjustments :)

Most Importantly: If my game ever sees light of day.... I will give you all the credit for helping me :)
Create your own Isometric Runner Game using C2:

Image

Check out my game "Last of the Survivors":
Play Store
App Store
B
58
S
13
G
2
Posts: 421
Reputation: 5,397

Post » Tue Apr 15, 2014 1:33 pm

SamRock wrote:@Fimbul, only the graphics look like isometric but concept is still the same. Instead of rotating the platform, I want to use a curved platform to represent the change in direction. I drew an isometric diamond around the pipes to give you an idea of what ends need to join when a new tile is created.

I see. Well in that case you could draw a "connector" bend every time the direction changes.

SamRock wrote:Your logic works perfectly, I was even able to randomly pick variously tiles and make a continuous path. The problem I am facing is when I try to adjust the height with the previous tile, the whole platform starts drifting downwards.
Code: Select all
Y= (Platform.Y)-sin(Platform.Angle)*(PlatformWidth/2)-sin(PlatformCreationAngle)*(PlatformWidth/2) + addY


That code is responsible for scrolling all platforms! Adding/subtracting a number means "add drift" in this context, whereas multiplying by a number means "change the speed". Your code adds to Y, which means it's going to drift downwards.
Let's simplify the formula so that it becomes easier to see:
Y=(Platform.Y)-sin(Platform.Angle)*(PlatformWidth/2)-sin(PlatformCreationAngle)*(PlatformWidth/2) + addY
This looks suspiciously like:
Code: Select all
Y=Y+addY


What you need to do is:
  • Pick only the instance you just created (the create-object action pre-picks the newest instance for you, but I don't know if it "un-picks" the other instances, you'll have to test)
  • Add/Subtract to it's Y position only once (preferrably at the moment of creation). You don't need any fancy formulas to it, just add directly to it's Y position.
  • I would avoid adjusting the X position, since that can cause seams to appear. The platforms will always be coming from the right, correct?

SamRock wrote:Most Importantly: If my game ever sees light of day.... I will give you all the credit for helping me :)

Don't worry about that man, just pay it forward.
B
36
S
8
G
8
Posts: 532
Reputation: 6,903

Next

Return to How do I....?

Who is online

Users browsing this forum: 25games, jatin1726, kiki4construct, Username05 and 33 guests