How do I generate terrain with javascript

Get help using Construct 2

Post » Sun Oct 26, 2014 1:24 pm

hello,

I find a script that genere random field for " infinite runner" using canvas and javascript. But i dont know how I could integrate it to construct 2. I 'm not a pro in javascript, if you have any idea how I could make it works, can be very useful .

Here is the script : jsfiddle.net/loktar/XDpd3/light/

thank you.

PS : sorry for my bad english ^^"
B
9
S
3
Posts: 14
Reputation: 653

Post » Sun Oct 26, 2014 2:26 pm

You could do it with sprites set to width 1, height to window width - random(n), and the xy to x +1, y to window width.
Where the hotspot is set to the bottom of the sprite.

Thats a lot of objects.
Thats a lot of objects to move.
Thats a lot of objects to do collisions on.
Image ImageImage
B
169
S
50
G
174
Posts: 8,327
Reputation: 110,798

Post » Sun Oct 26, 2014 6:58 pm

we cant generate line sprite with construct 2?
B
9
S
3
Posts: 14
Reputation: 653

Post » Sun Oct 26, 2014 8:08 pm

You can't draw to the canvas, but there are third party plugs that you can draw in.
Keep in mind they don't do collisions, and some don't do webgl.
Image ImageImage
B
169
S
50
G
174
Posts: 8,327
Reputation: 110,798

Post » Sun Oct 26, 2014 8:59 pm

This is very basic, but you can use a tiled-background of 1x1 and just adjust the height.
You do not have the required permissions to view the files attached to this post.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Sun Oct 26, 2014 9:28 pm

You can also make it less jaggy by interpolating the random data over time, lerp works nice.
Image ImageImage
B
169
S
50
G
174
Posts: 8,327
Reputation: 110,798

Post » Mon Oct 27, 2014 8:09 am

Thanks you for your quick response ^^
B
9
S
3
Posts: 14
Reputation: 653


Return to How do I....?

Who is online

Users browsing this forum: khelaghor and 40 guests