How Do I Replicate This Bounce Effect?

Get help using Construct 2

Post » Sun Feb 16, 2014 4:18 am

First of all, I am new to Construct 2 and prior to asking this I have looked through various threads and experimented with numerous movement types including; Sine, Custom Movement and Bullet to achieve this effect to no avail.

I've created a JSFiddle to show you exactly what I am trying to do here: jsfiddle.net/cCfDb/ basically as you can see the ball is bouncing consistently in a sine type movement. How would I go about replicating this JSFiddle example I've created in Construct 2? As my example is HTML5, is there perhaps a way I can use some of this code?

To put it simply, the ball needs to bounce off each wall, there are 4 walls (1 top, 1 bottom, 1 left and 1 right). And it just needs to hit a different part on each wall every time it hits it. So it needs to go around in a circular part, it can't go up and down (just essentially like my linked example).

Any help would be gratefully appreciated. If I didn't provide enough information, please let me know and I can provide whatever I can to help you assist me. I hope to be proficient in Construct 2 soon, so I too, can help others like myself.
B
6
S
1
Posts: 43
Reputation: 536

Post » Sun Feb 16, 2014 4:40 am

Add Solid behaviour to your wall spite - make four and place at each side. Give ball sprite Bullet with 'Bounce off solids' behaviour. Set a starting angle (let's say 40) - done.
ImageImageImage
B
71
S
21
G
220
Posts: 3,646
Reputation: 123,721

Post » Sun Feb 16, 2014 4:44 am

[QUOTE=blackhornet] Add Solid behaviour to your wall spite - make four and place at each side. Give ball sprite Bullet with 'Bounce off solids' behaviour. Set a starting angle (let's say 40) - done.[/QUOTE]

I essentially tried the same thing, but the bounce doesn't consistently hit each wall. The bounce either becomes too predictable (pattern never changes) or it doesn't do the sine effect I am after where the ball should hit each wall once, just a different spot each time.

As you can see in my posted JSFiddle, the ball consistently touches each side. With the bounce behaviour and movement set to bullet, the ball could bounce up and down, side to side, corner to corner, but not achieve the sine bounce I am after.

I want there to be somewhat of a pattern in movement, but hit a different point each time. This will allow users of the game to use tactics because the movement will be the same touch each side of the wall once movement, but it will slightly randomise the path roughly every 5 seconds or so.Digitalsa2014-02-16 04:55:47
B
6
S
1
Posts: 43
Reputation: 536

Post » Sun Feb 16, 2014 4:57 am

Bullet Gravity might be worth experimenting with - set > 0 and then tinker... Bouncing within a rectangular container like that will always yield predictable patterns unless you add a random element to it - gravity is predictable but will change the ball's dynamics so you could also change the ball's angle by a slight random amount on every wall collision.Colludium2014-02-16 04:58:10
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
73
S
19
G
66
Posts: 2,198
Reputation: 42,183

Post » Sun Feb 16, 2014 8:08 am

To add some unpredictability, you could simply set the density, friction, elasticity or any of the other options to CHOOSE or RANDOM pick a certain number of values, and set it to every few seconds. That way, you are guaranteed to get some different results each time.
B
42
S
20
G
31
Posts: 685
Reputation: 20,221

Post » Sun Feb 16, 2014 7:44 pm

@Digitalsa
Why not do it just like your code?

You have this:
[code]if (x + dx > WIDTH || x + dx < 0)
    dx = -dx;
if (y + dy > HEIGHT || y + dy < 0)
    dy = -dy;

x += dx;
y += dy;[/code]
Which is all doable with events.
This tutorial may be of help to get you up to speed: https://www.scirra.com/tutorials/37/beginners-guide-to-construct-2
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Mon Feb 17, 2014 3:24 am

[QUOTE=R0J0hound] @Digitalsa
Why not do it just like your code?

You have this:
[code]if (x + dx > WIDTH || x + dx < 0)
    dx = -dx;
if (y + dy > HEIGHT || y + dy < 0)
    dy = -dy;

x += dx;
y += dy;[/code]
Which is all doable with events.
This tutorial may be of help to get you up to speed: https://www.scirra.com/tutorials/37/beginners-guide-to-construct-2[/QUOTE]

I feel so silly, but you're right. After giving it a little more thought, the code in the JSFiddle I posted isn't all that difficult in Construct 2 using events. I'll let everyone know how I go. I'll give it a shot converting over my fiddle code to C2.

Thank you for your help. I think the long stressful week just fried the logic part of my brain.
B
6
S
1
Posts: 43
Reputation: 536

Post » Sat Feb 22, 2014 7:01 am

Sadly replicating the above code was a difficult experience for me. Would it be possible to get a little help with this? I would be happy to pay a small sum of money for the right solution. I want to learn, a simple bounce that touches each side without doing weird things like bouncing side to side or up and down. It seems like it shouldn't be that difficult, but it is and after countless searching it seems that this is an issue many have struggled with.

Just let me know what you need and I'll supply it. I can talk over Skype if that helps.
B
6
S
1
Posts: 43
Reputation: 536

Post » Sat Feb 22, 2014 9:32 am

Just taking R0J0s code I get :-

https://www.dropbox.com/s/j2js9jokjs5sn ... e5d4m.capx

If this is what you want and if you were serious about a small sum of money then please place this small sum into a children charity box.
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,812

Post » Sun Feb 23, 2014 2:13 am

RamPackWobble wrote:Just taking R0J0s code I get :-

https://www.dropbox.com/s/j2js9jokjs5sn ... e5d4m.capx

If this is what you want and if you were serious about a small sum of money then please place this small sum into a children charity box.


Thanks for the link mate. Will check that out shortly. And yes, I was serious about the cash and I completely agree with donating it to a children's charity, I will do just that. There is one fantastic community here!
B
6
S
1
Posts: 43
Reputation: 536

Next

Return to How do I....?

Who is online

Users browsing this forum: marc254 and 10 guests