Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///obj_ball code
- ///Create Event
- //Movement
- yv = 4;
- xv = 4;
- //Ball starts off in random direction
- //This needs to be tweaked, but is not too important right now
- ChooseX = choose (-xv, xv);
- ChooseY = choose (-yv, yv);
- ///Step Event
- //The actual collision
- if (place_meeting(x,y,obj_paddle))
- {
- if (obj_paddle.spd = 0)
- {
- xv *= -1;
- yv *= -1;
- }
- //If paddle and ball are moving in the same direction
- if ((obj_paddle.spd < 0) && (yv < 0) || obj_paddle.spd > 0) && (yv > 0)
- {
- xv *= -1;
- yv = obj_paddle.spd - yv;
- direction = 360;
- }
- //If paddle and ball are not moving in same direction
- if((obj_paddle.spd < 0) && (yv > 0) || obj_paddle.spd > 0) && (yv < 0)
- {
- //Don't know what to do here (!!!)
- xv *= -1;
- yv *= -1;
- direction = 360;
- }
- }
- //}
- //x = nextX;
- //y = nextY
- //Checking if ball hits wall, bounces it back
- if(y <= sprite_height/2 || y >= room_height - (sprite_height/2))
- {
- yv *= -1; //if vspeed goes up, -1 * -1 = 1, down, opp. for other
- }
- //Brings ball back to original position if goes offscreen, gives points
- if (x >= room_width)
- {
- //Give Player 2 a point
- with (obj_gamecontrol) player2points = player2points + 1;
- //Reset position, send Player 2's way
- x = xstart;
- y = ystart;
- xv = -4;
- yv = -4;
- //PickDirection = choose (xv, yv)
- }
- if (x <= 0)
- {
- //give Player 1 a point
- with (obj_gamecontrol) player1points = player1points + 1;
- //Reset position, send Player 1's way
- x = xstart;
- y = ystart;
- xv = 4;
- yv = 4;
- //How can this work?
- //PickDirection = choose (xv, yv)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement