• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Questions about a couple of the 'tutorials'?

U

Uhfgood

Guest
When going through the GM Basics (beginner) tutorials, you made a sort of break out style game but it had the unique problem of the ball going through and stopping at the paddle, continuously increasing score.

I notice a similar problem with the Coding Breakout tutorial (in the completed version) which is, somethings you can hit the ball with the side of the paddle against the wall and it will sort of get stuck in the paddle because it keeps colliding but have nowhere to move.

Is there no solution with this using game maker itself, or do you need to do some sort of special case code. (my solution would be to make sure if it's below the top of the paddle, that it can't collide with the paddle, because by that time it should mean that the player missed the ball).

Any other thoughts or tips when dealing with this sort of thing?
 
U

Uhfgood

Guest
I haven't done the tutorials, but I'd say you're missing code to move outside the collision.
This happens in the ball and bat collision:
Code:
move_bounce_all( true );
var dir;
dir = point_direction( other.x, other.y, x, y );
motion_add( dir, 5 );
speed = 5;
I suspect it's not really respecting where the ball is, so it might change to a direction that puts it inside the bat.
 

TheouAegis

Member
It's an interesting code, if it's meant to do what I think it is. So you're bouncing off the bat with GM's built-in collision method and then you tell the bat to add a vector that is opposite the vector toward the origin of the bat. With that said, the origin of the ball's sprite needs to be centered and the bat's sprite's origin should be centered horizontally (but left to 0 or at the top of the bat vertically) in order for that code to work properly.

Not sure if speed needs to be set there. The whole code strikes me a bit odd.

move_bounce_all() is already setting the ball's direction and speed after hitting the bat.
The next three lines adjust the ball's direction and speed after hitting the bat.
The last line ignores the ball's adjusted speed and resets it back to 5.

I mean, it all makes sense in a way; it just looks odd.
 

TheouAegis

Member
Well, apparently it wasn't that great of a tutorial. Change the move_bounc_all() in the ball's collision with bat code to move_outside_all(90,-1) and play around with that for a bit.
 
U

Uhfgood

Guest
Thanks, will check it out.

If it's not a very good tutorial maybe someone should review them and decide whether to include them or not :)
 
Top