simple water by shinkan

Discussion and feedback on Construct 2

Post » Fri Aug 14, 2015 11:42 am

Hi,

I am new to construct 2. I came across an old post of how to create water in construct 2 by Shinkan.

https://www.scirra.com/tutorials/1124/s ... ter-plugin

so I thought of trying out some modifications to get a boat on the surface just to see how this works with physics. Basically I connected all the waterControls with sprite instances, applied physics behavior to them along with the boat. Everything seemed to be working well until this crash with the following error message:

https://www.dropbox.com/s/n4tpouyhog9zz ... e.JPG?dl=0

I'm not sure what those error messages were saying but it seems like they were referring to construct 2 physics error? Anyways here's the capx. Thanks in advance for taking the time to check this out.

https://www.dropbox.com/sh/c4t264eozkz1 ... ZNCLa?dl=0
B
8
S
1
Posts: 2
Reputation: 354

Post » Fri Aug 14, 2015 9:11 pm

Out of interest, is that with box2d web or asm.js?
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,205
Reputation: 43,832

Post » Fri Aug 14, 2015 9:56 pm

I see you went a step ahead of me when I was playing with it. For all my tests I've been just adding sine behavior for all my ships xD

Anyways, I run your capx with few different settings and never got this error message. And just to let you know, Canvas+WebGL don't work so great (one of the reasons I abandoned that project) but good luck!
ImageImageImageImage
B
157
S
66
G
41
Posts: 2,597
Reputation: 34,821

Post » Sat Aug 15, 2015 5:55 am

@donutpond

I remember having a lot of fun with the capx @shinkan made way back then. I tried to make the waves look a little rounder, and I wanted to make splashes too, so I ended up adapting some formulas I found somewhere. It worked well on my desktop, but I was disappointed with the performance on my iPhone... I meant to post a link back on the original thread but never did.

To have things float in the water, I have a row of invisible sprites with the solid behavior - they get updated to the water's surface (minus an offset to make things look partially submerged).

Press space bar to make waves, or click the mouse to make a splash. The beach ball has the platform behavior so you can move it around with the arrow keys. (Flushing drains the water, then it fills up again)

try it out here: http://www.rieperts.com/games/Water

you can get the capx here: http://www.rieperts.com/games/forum/water.capx
B
95
S
33
G
20
Posts: 438
Reputation: 17,640

Post » Sat Aug 15, 2015 6:54 am

@colludium
oh my, I think you just fixed the crashing issue, I was using box2d asm.js for the physics engine. After switching to box2d web, the crashes stopped! I have no idea what's the difference between the 2 engines, but they seem to look and perform the same (by eyeballing).

@shinkan
thanks for the original demo. It's really awesome. I was just exploring that construct 2 can do, so was fiddling with various tutorials and plugins.

@AllanR
that's a pretty awesome adaptation you got there! I have no coding experience, your capx looks really impressive. Looks more like actual C code than construct 2 lol. I tried it on my mobile and indeed the performance is super sluggish where as it worked very smoothly on the desktop. Do you know why that is?
B
8
S
1
Posts: 2
Reputation: 354

Post » Sat Aug 15, 2015 12:07 pm

Aha! I had my suspicions - the asm.js physics is still rather beta and, in my opinion, may never reach full functionality because its use here depends on 3rd party updates.
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,205
Reputation: 43,832

Post » Sat Aug 15, 2015 1:49 pm

Ashley says asm.js is much faster than the old Box2d web. But there are known bugs in the asm.js that cause crashes like that. Chipmunk Physics is a really good alturnative (plugin by Rojohound). It is the fastest as far as I can tell, however asm.js is more accurate in terms of simulating real physics.

I think it is sluggish on mobiles because they have much weaker GPUs and can't handle the constant flood fill that creates the water - plus in my version the subroutine that calculates the splashes and smooths out the waves is pretty cpu intensive as well. But I know it should be possible to do on mobile because Jetpack Joyride does it just fine - they must have found some way to optimize the process! : )
B
95
S
33
G
20
Posts: 438
Reputation: 17,640


Return to Construct 2 General

Who is online

Users browsing this forum: Lorvin and 3 guests