Hello everyone! As you can plainly see from the title I'm trying to create a ping pong (basic) game. I've finished designing the map and I'm starting to do the brainstorming for the triggers. I havn't started yet and I thought I'd take this opportunity to ask on the forums for some guideline help. I'm not too sure how I'm going to get the pads moving only left and right on a straight line and for the ball to bounce back towards the enemy player. Any thoughts?
Well i'm just going to guess you're going to stick to the very basic pong, 2D, and square! lol
The way I would go about doing it is giving each ball it's X and Y velocities. Then you would also give the paddles their Y velocities.
The ball's position would be updated every time space... (a periodic timer that has 0 for its paramater)
I don't know how you want to have the paddles controlled. But...
I would make an origin for each paddle, and then create a triggered rectangle box around them.
If you wanted to keep it simple, you could do really easy checks with this triggered box. like so... (I don't know how to put it in a special box:( )
bool BallEntersLeftPaddle(unit ball)
If ((PointGetX(UnitGetPosition(Ball)) < LeftPaddleX + 3) && PointGetX(UnitGetPosition(Ball)) > LeftPaddleX - 3))
And then do the same for the Y component!
Being really simple you could check to see if it was because of the VelX or VelY did the ball enter the square, then change the sign of that component.
Example:
If (BallEntersLeftPaddle) then check to see if from one time space away does the X or Y velocity make it enter the box.
if (OldPosition + VelX <= LeftPaddleXMax && OldPosition + VelX >= LeftPaddleMin)
then VelX = -VelY
Except you'd be checking on the X and Y componenets!
You'd also have to make sure you were using the right positions for the paddle when checking.
You could get a little more complicated and put the velocity of the paddle into the equation! (this would create some dynamic game play)
You would just change it by doing some vector math instead of reversing the signs.
In this your ball would most likely just be a circle, an origin with a radius.
There might be a few collision bugs but it shouldn't be that hard to work out.
This is just one way to do it, i'm sure there are better and simpler ways. Just thought I might contribute!
I would also make the walls with regions, and do a similar thing with the triggered box. to make it really simple!
For the triggers you could just have a trigger-only point that is controlled by W and S and use a seperate trigger for the graphics. I'd rather not go into great detail unless you really want me to. In other words if you dont know what im talking about id rather not explain it :P.
Thanks a lot. I really appreciate the input. I was kinda lost as to how I should handle the problem. Now i'll just study your post because I have to admit. I don't fully understand it. I look forward to consulting you again on the matter!
I've been trying to use Keyboardmovementlib to get my phoenix (using them as pads until I can model one)
For some reason I can't seam to change the key being pressed. I need to use the Up and Down only and I'm trying to change it to the A and D keys.
For some reason it works if its set up to W and down to S but When I set A to UP and D to down it just stands still. Does anyone have any thoughts on how I could fix this?
MovementRedPadMovementUpDownEventsUI-Player1pressesWkeyDownwithshiftAllow,controlAllow,altAllowLocalVariables-------Changetounityouwanttomovebykey-pressUnit=gMovementUnit<Unit>ConditionsActions-------Don't touch. General - Switch (Actions) depending on (Key Pressed) Cases General - If (W) Actions Variable - Set gMoveUpBool = true Default General - While (Conditions) are true, do (Actions) Conditions Actions General - If (Conditions) then do (Actions) else do (Actions) If gMoveDwnBool == gMoveUpBool Then Unit - Order Unit to ( Move targeting relative points near ((Position of Unit) offset by 0 towards (CalcAngle(false, gMoveUpBool, false, gMoveDwnBool)) degrees)) (Replace Existing Orders) Else Unit - Order Unit to ( Move targeting relative points near ((Position of Unit) offset by 5.0 towards (CalcAngle(false, gMoveUpBool, false, gMoveDwnBool)) degrees)) (Replace Existing Orders) General - Wait 0.15 Game Time seconds MovementDownDown Events UI - Player 1 presses S key Down with shift Allow, control Allow, alt Allow Local Variables ------- Change to unit you want to move by key-press Unit = gMovementUnit <Unit> Conditions Actions ------- Don'ttouch.General-Switch(Actions)dependingon(KeyPressed)CasesGeneral-If(S)ActionsVariable-SetgMoveDwnBool=trueDefaultGeneral-While(Conditions)aretrue,do(Actions)ConditionsActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)IfgMoveDwnBool==gMoveUpBoolThenUnit-OrderUnitto(Movetargetingrelativepointsnear((PositionofUnit)offsetby0towards(CalcAngle(false,gMoveUpBool,false,gMoveDwnBool))degrees))(ReplaceExistingOrders)ElseUnit-OrderUnitto(Movetargetingrelativepointsnear((PositionofUnit)offsetby5.0towards(CalcAngle(false,gMoveUpBool,false,gMoveDwnBool))degrees))(ReplaceExistingOrders)General-Wait0.15GameTimesecondsMovementUpUpUI-Player1pressesWkeyUpwithshiftExclude,controlExclude,altExcludeLocalVariablesConditionsActionsVariable-SetgMoveUpBool=falseTrigger-StopallinstancesofMovementUpDownGeneral-If(Conditions)thendo(Actions)elsedo(Actions)IfAndConditionsgMoveDwnBool==falseThenUnit-OrdergMovementUnitto(Stop)(ReplaceExistingOrders)ElseMovementDwnUpUI-Player1pressesSkeyUpwithshiftExclude,controlExclude,altExcludeLocalVariablesConditionsActionsVariable-SetgMoveDwnBool=falseTrigger-StopallinstancesofMovementDownDownGeneral-If(Conditions)thendo(Actions)elsedo(Actions)IfAndConditionsgMoveUpBool==falseThenUnit-OrdergMovementUnitto(Stop)(ReplaceExistingOrders)gMoveUpBool=false<Boolean>gMoveDwnBool=false<Boolean>gMovementUnit=Pads[15.00,32.00]<Unit>
Hello everyone! As you can plainly see from the title I'm trying to create a ping pong (basic) game. I've finished designing the map and I'm starting to do the brainstorming for the triggers. I havn't started yet and I thought I'd take this opportunity to ask on the forums for some guideline help. I'm not too sure how I'm going to get the pads moving only left and right on a straight line and for the ball to bounce back towards the enemy player. Any thoughts?
Hello!
Well i'm just going to guess you're going to stick to the very basic pong, 2D, and square! lol
The way I would go about doing it is giving each ball it's X and Y velocities. Then you would also give the paddles their Y velocities.
The ball's position would be updated every time space... (a periodic timer that has 0 for its paramater)
I don't know how you want to have the paddles controlled. But...
I would make an origin for each paddle, and then create a triggered rectangle box around them.
If you wanted to keep it simple, you could do really easy checks with this triggered box. like so... (I don't know how to put it in a special box:( )
bool BallEntersLeftPaddle(unit ball)
If ((PointGetX(UnitGetPosition(Ball)) < LeftPaddleX + 3) && PointGetX(UnitGetPosition(Ball)) > LeftPaddleX - 3))
And then do the same for the Y component!
Being really simple you could check to see if it was because of the VelX or VelY did the ball enter the square, then change the sign of that component.
Example:
If (BallEntersLeftPaddle) then check to see if from one time space away does the X or Y velocity make it enter the box.
if (OldPosition + VelX <= LeftPaddleXMax && OldPosition + VelX >= LeftPaddleMin)
then VelX = -VelY
Except you'd be checking on the X and Y componenets!
You'd also have to make sure you were using the right positions for the paddle when checking.
You could get a little more complicated and put the velocity of the paddle into the equation! (this would create some dynamic game play)
You would just change it by doing some vector math instead of reversing the signs.
In this your ball would most likely just be a circle, an origin with a radius.
There might be a few collision bugs but it shouldn't be that hard to work out.
This is just one way to do it, i'm sure there are better and simpler ways. Just thought I might contribute!
I would also make the walls with regions, and do a similar thing with the triggered box. to make it really simple!
@DarlD: Go
I'd play it :P
For the triggers you could just have a trigger-only point that is controlled by W and S and use a seperate trigger for the graphics. I'd rather not go into great detail unless you really want me to. In other words if you dont know what im talking about id rather not explain it :P.
@Juxtapozition: Go
Thanks a lot. I really appreciate the input. I was kinda lost as to how I should handle the problem. Now i'll just study your post because I have to admit. I don't fully understand it. I look forward to consulting you again on the matter!
@DarlD: Go
Yep! Just ask away in the thread or PM me and I'll do my best haha. I've never been very good at explaining things though
Does anyone know of a way to make a unit move on the sides only and have a camera following it? never rotating just sliding to the left and right.
I've been trying to use Keyboardmovementlib to get my phoenix (using them as pads until I can model one)
For some reason I can't seam to change the key being pressed. I need to use the Up and Down only and I'm trying to change it to the A and D keys.
For some reason it works if its set up to W and down to S but When I set A to UP and D to down it just stands still. Does anyone have any thoughts on how I could fix this?
So. Any thoughts?
I'm still having no luck with these triggers. Does anyone see the problem?