📖 Full reference & examples
Movement methods
move.bound(obj)
Prevents an object from leaving the canvas edges. Clamps both x and y to the visible area.
move.bound(player); // Keeps player on screen
move.boundTo(obj, left, right, top, bottom)
Clamps an object to custom boundaries. Pass false for any side you don’t want to restrict.
move.boundTo(player, 50, 750, 100, 500); // Confined to arena
move.forward(obj, steps) / move.backward(obj, steps)
Moves the object along its current angle. Inspired by Python Turtle – very intuitive for angular movement.
move.forward(player, 5); // Moves 5 pixels in direction of .angle
move.turnLeft(obj, radians) / move.turnRight(obj, radians)
Rotates the object by a given angle. Works with .changeAngle = true (the default).
move.turnLeft(turret, 0.1); // Rotate left by 0.1 rad
move.teleport(obj, x, y)
Instantly moves the object to new coordinates.
move.teleport(player, 400, 300); // Center the player
move.stamp(obj)
Creates a clone of the object at its current position. Useful for particle‑like duplication.
const clone = move.stamp(enemy);
move.glideX(obj, durationMs, targetX)
Moves the object horizontally from its current x to targetX over durationMs milliseconds. Uses cubic ease‑out for smooth deceleration.
move.glideX(coin, 500, 800); // Glide to x=800 in 0.5 seconds
move.glideY(obj, durationMs, targetY)
Same as glideX but for vertical movement.
move.glideY(platform, 1000, 400); // Move down to y=400 in 1 second
move.glideTo(obj, durationMs, targetX, targetY)
Simultaneous X and Y glide. Smoothly moves the object to a point. Ideal for enemy movement or UI animations.
move.glideTo(player, 800, 600, 300);
move.project(obj, speed, angleDeg, gravity, groundY)
Launches the object as a projectile. speed in pixels per second, angleDeg from horizontal (0° = right, 90° = up). gravity is added each frame. Optionally bounces off groundY.
move.project(arrow, 300, 45, 0.5); // Arcing arrow
move.pointTo(obj, targetX, targetY)
Rotates the object to face the given world coordinates. Uses Math.atan2 and sets the .angle property.
move.pointTo(turret, mouse.x, mouse.y);
move.circle(obj, angularSpeedRad)
Updates the object's angle for circular motion. Use with angularMovement = true to create orbiting or circular motion.
move.circle(orbiter, 0.05);
move.accelerate(obj, accelX, accelY, maxSpeedX, maxSpeedY)
Adds acceleration to the object's speed, capping at maximum values. Perfect for smooth vehicle movement or wind effects.
move.accelerate(player, 0.5, 0, 8, 8);
move.decelerate(obj, decelX, decelY)
Reduces speed toward zero by the given amounts per frame. Useful for friction or braking.
move.decelerate(player, 0.3, 0.3); // Slows down gradually
move.position(obj, direction, offset)
Snaps the object to a screen edge or the centre. Directions: "top", "bottom", "left", "right", "center". Offset is optional margin.
move.position(healthBar, "top", 20); // Place near top edge