Physics2D
Soft-Body Slimes
A slime is a complete squishy character made with one line. MAKO handles the hidden dots and springs for you. It can run, jump, stretch, squash, and turn back into a blob after landing.
New to coding?
Copy the examples exactly first. Run them. Then change one number or word and run them again. You are not expected to memorize the command lists.
1
Make and move a slime
First make the slime. Each frame, tell it which way to move. Ask it to jump when the jump button is pressed. The default settings already work.
Try this code
# Make one slime at x 300, y 200, with a size of 50
slime = Physics2D.slime(world, 300, 200, 50);
# Put these lines inside your game loop
Physics2D.slime_move(world, slime, move_direction); # Walk left or right
if jump_pressed { Physics2D.slime_jump(world, slime); } # Jump once
Physics2D.slime_hold_jump(world, slime, jump_held); # Hold for a taller jump
info = Physics2D.slime_info(world, slime); # Ask where and how squished it is2
All slime commands
These are the slime commands in one place. slime_info tells you where the slime is and how squished it is.
Try this code
slime(world, x, y, radius, options={})
slime_move(world, slime, direction, speed=240, force=8000)
slime_jump(world, slime, speed=380)
slime_hold_jump(world, slime, held, force=1200)
slime_set_position(world, slime, x, y, reset_velocity=true)
slime_reset(world, slime, x, y, reset_velocity=true)
slime_info(world, slime)
remove_slime(world, slime)3
Later: springs
A spring ties two objects together with an invisible stretchy rope. This is an advanced tool; normal slime games do not need it.
Try this code
spring(world, a, b, rest=-1, stiffness=120, damping=12, ax=0, ay=0, bx=0, by=0)
spring_info(world, spring)
set_spring(world, spring, rest, stiffness, damping)
remove_spring(world, spring)