Jump to content


Photo

Block breaker paddle help


  • Please log in to reply
2 replies to this topic

#1 DiamondPhoenix

DiamondPhoenix

    GMC Member

  • GMC Member
  • 107 posts
  • Version:GM8

Posted 22 August 2011 - 07:05 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:11 AM.

  • 0

#2 filulilus

filulilus

    GMC Member

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

Posted 22 August 2011 - 07:38 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)
if (y+7 >= obj_paddle.y-8 && y+7 < obj_paddle.y-6) {
direction = 90+(obj_paddle.x-x)*2
//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:44 AM.

  • 0

#3 DiamondPhoenix

DiamondPhoenix

    GMC Member

  • GMC Member
  • 107 posts
  • Version:GM8

Posted 23 August 2011 - 02:56 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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users