PONG game problem

radz

  • Posts: 13
1.how to make a powerup that when the ball hit from the last paddle and then hit the powerup, that person gets a powerup. I couldn't find a way to make this.If a player shoots a power up their paddle speed will increase.

2.Every 8sec the paddle speed will slower. This effect resets when someone scores a point.
can someone teach me how to do this...

JeffreyDriver

  • Posts: 2262
You need to use attributes to achieve these things. Have you used them before?

Booleans will let you simply check if the paddle has been hit.
So when the ball hits the paddle, set it to true, when it hits a brick or a wall, set it to false.
If the boolean is true when it hits the powerup, run the code that triggers the powerup, if it's false, ignore it.

For the 8 second slow down, you'll need to store the velocity in an attribute so that you can refer to it later and make the ball slow down. Then every 8 seconds you would set the velocity to 'current velocity - amount (the amount to want to slow down by)'

To reset this, simple put a line in your existing code that adjusts the score to reset the velocity.

radz

  • Posts: 13
I already use attribute for Boolean,but i still not understand how to use for power up.Can you show me example code for that

Bhoopalan

  • Posts: 1018
What is that you want to achieve exactly with powerup? Can you show an example game?
If I helped you at anytime, help me back build my twitter followers :)
https://twitter.com/imbhoopalan

radz

  • Posts: 13
Dragon pong
Players fight for points by getting the dragon egg pass their opponent’s side. A player can shoot dragon egg hit. the speed of dragon egg will increase. First to 20 points win.

Player Action(s)
•   Shoot
o   When fire hit dragon egg.the speed will increase.

Game Object(s)
•   Special powerup (god speed)
o   If a player shoots a power up with ball/dragon egg their paddle speed will increase.

Gameplay Rule(s)
•   paddle speed become slower over time
o   Every 8sec the paddle speed will slower. This effect resets when someone scores a point.

Controls
P1
w=going up
s=going down
d=fire

P2
up=going up
down=going down
left=fire

radz

  • Posts: 13
i already make paddle slow every 8 sec but idk how to reset it  when someone scores a point.

« Last Edit: September 29, 2016, 07:43:32 am by radz »

radz

  • Posts: 13
plz help me someone

JeffreyDriver

  • Posts: 2262
Can I see your code that registers when the player scores a point?

It should be a simple case of add code in that behaviour to reset the value of 'speednormal1'

radz

  • Posts: 13
this is my score code

radz

  • Posts: 13
help me anyone.thank you

Bhoopalan

  • Posts: 1018
I'll share a screenshot shortly. But experimental and can't guarantee result.
If I helped you at anytime, help me back build my twitter followers :)
https://twitter.com/imbhoopalan

JeffreyDriver

  • Posts: 2262
In the second IF and OTHERWISE IF blocks, you just need code to reset the speed. How is the speed value stored? Is it in an attribute?

radz

  • Posts: 13

Bhoopalan

  • Posts: 1018
Wait a minute! You want the speed to be reset within the <when self exits the scene> event? Then why not simply use the <set speednormal1 to > block? You will have it in attribute setters.
If I helped you at anytime, help me back build my twitter followers :)
https://twitter.com/imbhoopalan

Bhoopalan

  • Posts: 1018
Got it. The problem is that you are writing the code separately for paddle and block. In that case, I would suggest using global number attribute for 'speednormal1'. You would then be able to access it from both the actors.

An additional tip would be to avoid writing codes for actors separately. Keep it to as low as possible. Writing every code in a single scene behavior and adding it to scene would be the best way to avoid all such mess.

If I helped you at anytime, help me back build my twitter followers :)
https://twitter.com/imbhoopalan