Make the ball fall with 1400 gravity and land on the ground.
View code
game.physics = true;
game.gravityY = 1400;
ball.gravityScale = 1;
// every frame:
game.collide(ball, ground);
Falling, jumping, moving, and bumping into things: the simple physics a Minimo game can use.
Try each example, then copy the words under it and paste them to your AI. You can also send your AI the link to an example.
Objects that move by themselves once the game gives them a push or a pull.
Make the ball fall with 1400 gravity and land on the ground.
game.physics = true;
game.gravityY = 1400;
ball.gravityScale = 1;
// every frame:
game.collide(ball, ground);
Make the ball move on its own and bounce off the edges of the screen.
ball.vx = 260;
ball.vy = 260;
// every frame:
if (ball.x < 0 || ball.x > game.width) ball.vx *= -1;
if (ball.y < 0 || ball.y > game.height) ball.vy *= -1;
A push upward that gravity then brings back down. The player can only jump again once they have landed.
Tap to jump.
When the player taps, make the character jump, but only if it is standing on the ground.
const hit = game.collide(ball, ground);
if (hit?.grounded && game.isPointerPressed()) {
ball.vy = -800;
}
What happens when two objects meet.
Touching is for collecting and scoring: things pass through each other. Bumping is for walls and floors: things stop.
Make the bar solid, so the ball lands on it and stops.
bar.isStatic = true;
game.collide(ball, bar);
Collisions use an invisible box, not the drawing itself. A box as big as the picture makes hits feel unfair, because corners touch before the shapes do.
Make the ball's collision box 100% of its picture, so hits only count when the shapes really touch.
ball.bodyWidth = ball.width * 100 / 100;
ball.bodyHeight = ball.height * 100 / 100;
game.debugBodies = true; // shows the boxes while testing