2 replies to this topic

### #1 DiamondPhoenix

DiamondPhoenix

GMC Member

• GMC Member
• 138 posts
• Version:GM:Studio

Posted 22 August 2011 - 07:19 AM

Before making this topic, i searched about how to make the ball go in an angle pepending on where it hits the paddle.
i got this
`direction=point_direction((other.x+x)/2,(other.y+y)/ 2,x,y);`

-I want the ball to only bounce if it above the paddle. If only 3 or 4 pixels get under the top of the paddle, it should not have any collision with the paddle.

-If the ball touches the side of the paddle, the paddle cannot move to this direction, because the ball blocks it.
EDIT: The ball also stops. i forgot to mention.

The ball is 14x14, the origin is 7,7

The paddle height is 16, origin is 8.

Edited by DiamondPhoenix, 22 August 2011 - 07:25 AM.

• 0

Games in progress:
Plunk (Videoway) Not cancelled
Tac-O-Tac, a 2 player game. Done!
Rolling Bob's Puzzle Game (made from scratch) In progress.
Some Random Impossible Game (Demo) A Super Frustrating game!

### #2 filulilus

filulilus

GMC Member

• GMC Member
• 972 posts
• Version:GM:Studio

Posted 22 August 2011 - 07:52 AM

"Before making this topic, i searched about how to make the ball go in an angle pepending on where it hits the paddle."

You can use the diffrence between the ball's x value and the paddle's x value.
`direction = 90+(obj_paddle.x-x)*3`

"I want the ball to only bounce if it above the paddle. If only 3 or 4 pixels get under the top of the paddle, it should not have any collision with the paddle."

This is a "home made" collision system, you might like to modefy it. The ball will only bounce when it's between 0 and 2 pixels inside of the paddles top.
```if (x+7 > obj_paddle.x-16 && x-7 < obj_paddle.x+16)
//or the following script if you like the ball to stop:
speed =0
}```

"If the ball touches the side of the paddle, the paddle cannot move to this direction, because the ball blocks it.
EDIT: The ball also stops. i forgot to mention."

This script checks if the new position is free. You should use this when you are trying to move something.
```if (place_free(new_x,new_y))
//example:
if (keyboard_check_pressed(vk_right) && place_free(x+5,y)) x+=5
```

Edited by filulilus, 22 August 2011 - 07:58 AM.

• 0

\/

### #3 DiamondPhoenix

DiamondPhoenix

GMC Member

• GMC Member
• 138 posts
• Version:GM:Studio

Posted 23 August 2011 - 03:10 AM

These doesnt seem to work.

Now, my only problem is, the paddle stops and the ball stops when they collide to each other to the side.
i dont want that
• 0

Games in progress:
Plunk (Videoway) Not cancelled
Tac-O-Tac, a 2 player game. Done!
Rolling Bob's Puzzle Game (made from scratch) In progress.
Some Random Impossible Game (Demo) A Super Frustrating game!