Ball to pass through the back of paddles for pong?

Get help using Construct 2

Post » Fri Dec 27, 2013 11:24 pm

Hi i'm having trouble with making it so the ball in pong passes through the paddles in my pong-like game. I tried using the jump through behavior but it didnt seem to work. Idk if im just not using the behavior correctly but if there is an alternative that would be really helpful below are screenshots.

remove the {{{

http:{{{//puu.sh/60Gu3.{{{png

http:{{{//puu.sh/{{{60GvX

http:{{{//puu.sh/{{{60GwW.png

All help will be greatly appreciated ty for reading.guccimerica2013-12-27 23:25:19
B
7
S
2
Posts: 15
Reputation: 532

Post » Sat Dec 28, 2013 1:55 am

I'm guessing this will probably do what you're after.

https://dl.dropboxusercontent.com/u/108799982/Capx%20Demos/Pong.capx
Using R243 for all examples
B
69
S
20
G
6
Posts: 379
Reputation: 9,699

Post » Sat Dec 28, 2013 8:46 am

or another way

pass through
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Sat Dec 28, 2013 9:56 am

another version version 2

this version brings in acceleration to a max speed of the ball (acceleration is just bullet acceleration and max speed is on line 9)

it also slows down the ball as it passes through the bats.

one version (line 4)checks to see if the ball is going over 100 and then halves it

ball.Bullet.Speed>100 ? ball.bullet.Speed/2 : ball.Bullet.Speed

(I've not used these conditional operators before but it appears to work )

the other slow down is in (line 7)

ball.Bullet.Speed-((ball.Bullet.Speed>200)*100)

which takes 100 away from the speed if it is over 200.

I also added a random change of direction to the ball as it passes through the bats

ball.Bullet.AngleOfMotion+random(-30,30)

line 8 is to just stop the ball getting stuck going backwards ad forwards between two bats.

lines 5 and 2 check for collisions as I have turned off the solid check in bullets.
lines 3 and 6 check to see if the ball is going at the correct angle to bounce

else (lines 4 and 7)

pass through the bat. slow down the ball (if going fast enough). turn on acceleration. bend angle of the ball.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Sat Dec 28, 2013 10:02 am



I guess it might have been worth making a function as 4 and 7 are the same ?

Hope this helps

(I certainly learnt something new about the conditional operator - which I've never used before)
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests