Loading project...

Properties and methods for working with sprites.
sprite.move(amount): Moves the sprite by the specified amount.Example: sprite.move(10)
sprite.x: The horizontal position of the sprite.Example: sprite.x = 100
sprite.y: The vertical position of the sprite.Example: sprite.y = 200
sprite.rotation: The rotation of the sprite in degrees.Example: sprite.rotation = 45
sprite.pointTowards(x, y): Points sprite towards a specific position.Example: sprite.pointTowards(100, 200)
Properties for sprite appearance.
sprite.visible: Whether the sprite is visible.Example: sprite.visible = false
sprite.size: The size of the sprite.Example: sprite.size = 50
sprite.width: The horizontal stretch of the sprite.Example: sprite.width = 50
sprite.height: The vertical stretch of the sprite.Example: sprite.height = 50
sprite.costume: The current costume name of the sprite.Example: sprite.costume = 'bird'
sprite.layer: The layer of the sprite.Example: sprite.layer = 1
sprite.transparency: The transparency of the sprite (0-100).Example: sprite.transparency = 50
sprite.brightness: The brightness of the sprite (0-100).Example: sprite.brightness = 50
sprite.setCostume("costumeName"): Sets the sprite to a specific costume.Example: sprite.setCostume("bird")
sprite.nextCostume(): Changes to the next costume in sequence.Example: sprite.nextCostume()
sprite.prevCostume(): Changes to the previous costume in sequence.Example: sprite.prevCostume()
sprite.getCostume(): Returns the name of the current costume.Example: let myCostume = sprite.getCostume()
Functions for controlling timing and execution flow.
forever(function () { ... }): Runs the code in the function every frame.Example: forever(function() { sprite.x += 1 })
repeat(n, function () { ... }): Runs the code in the function n times.Example: repeat(10, function() { sprite.x += 1 })
while (condition) { ... } Runs the code in the curly braces repeatedly while the condition is true.Example: while (sprite.x < 100) { sprite.x += 1 }
if (condition) { ... } Executes the block if the condition is true.Example: if (sprite.x > 100) { sprite.visible = false }
if (condition) { ... } else { ... } Executes one block if the condition is true, otherwise runs the else block.Example: if (sprite.x > 100) { sprite.visible = false } else { sprite.visible = true }
sendMessage("messageName") Sends a message to all sprites.Example: sendMessage("gameOver")
sendMessage("messageName", {data: any}) Sends a message to all sprites with specified data.Example: sendMessage("gameOver", { score: 100, level: 1 })
onMessage("messageName", function(data) { ... }) Receives a message and runs the code in the curly braces when the message is received.Example: onMessage("gameOver", function(data) { Game.stop() })
wait(seconds): Waits for specified seconds.Example: function move() { wait(1); sprite.x += 10; }
Functions for handling detection and keyboard and mouse input.
sprite.isTouching("spriteName"): Checks if the sprite is touching the other sprite with the given name.Example: if (sprite.isTouching("Enemy")) { ... }
sprite.touchingMouse(): Checks if the sprite is touching the mouse cursor.Example: if (sprite.touchingMouse()) { ... }
sprite.distanceTo(x, y): Returns the distance from the sprite to the specified coordinates.Example: let dist = sprite.distanceTo(Mouse.x, Mouse.y)
Keyboard.keyDown(key): Returns true if key was just pressed.Example: if (Keyboard.keyDown(Key.Space)) { sprite.y += 10 }
Keyboard.keyHeld(key): Returns true if key is being held down.Example: if (Keyboard.keyHeld(Key.ArrowRight)) { sprite.x += 1 }
Keyboard.keyUp(key): Returns true if key was just released.Example: if (Keyboard.keyUp(Key.Space)) { sprite.y -= 10 }
Mouse.isDown(button): Returns true if mouse button is pressed.Example: if (Mouse.isDown(MouseButton.Left)) { sprite.size += 10 }
Mouse.isHeld(button): Returns true if mouse button is held down.Example: if (Mouse.isHeld(MouseButton.Left)) { sprite.size += 1 }
Mouse.isUp(button): Returns true if mouse button is released.Example: if (Mouse.isUp(MouseButton.Left)) { sprite.size -= 1 }
Mouse.x: The current horizontal position of the mouse cursor.Example: sprite.x = Mouse.x
Mouse.y: The current vertical position of the mouse cursor.Example: sprite.y = Mouse.y
Mathematical functions, comparisons, and constants.
Math.random(min, max): Returns a random number between min and max.Example: let n = Math.random(0, 10)
Math.round(value): Rounds the value to the nearest whole number.Example: Math.round(0.5)
Math.floor(value): Rounds the value down to the nearest whole number.Example: Math.floor(0.5)
Math.ceil(value): Rounds the value up to the nearest whole number.Example: Math.ceil(0.5)
Math.abs(value): Returns the absolute (positive) value.Example: let distance = Math.abs(x - y)
Math.min(num1, num2): Returns the smallest of the provided numbers.Example: let lowest = Math.min(2, 5)
Math.max(num1, num2): Returns the largest of the provided numbers.Example: let highest = Math.max(2, 5)
Math.sqrt(num): Returns the square root of a number.Example: let side = Math.sqrt(16)
Math.pow(base, exponent): Returns the base raised to the power of the exponent.Example: let squared = Math.pow(5, 2)
Math.clamp(value, min, max): Constrains a value between minimum and maximum values.Example: let clamped = Math.clamp(sprite.x, 0, 10)
Math.log(num): Returns the natural logarithm of a number.Example: let ln = Math.log(Math.E)
Math.exp(num): Returns e raised to the power of a number.Example: let result = Math.exp(1)
Math.trunc(num): Returns the integer part by removing fractional digits.Example: let whole = Math.trunc(3.7)
Math.sign(num): Returns the sign of a number (1, -1, or 0).Example: let direction = Math.sign(-5)
< Returns true if the left value is less than the right value.Example: if (x < 10) { ... }
> Returns true if the left value is greater than the right value.Example: if (score > 100) { ... }
<= Returns true if the left value is less than or equal to the right value.Example: if (lives <= 0) { Game.stop() }
>= Returns true if the left value is greater than or equal to the right value.Example: if (score >= 100) { ... }
== Checks if two values are equal.Example: if (level == 2) { ... }
!= Checks if two values are not equal.Example: if (sprite.x != 0) { ... }
&& Returns true if both conditions are true.Example: if (sprite.x > 0 && sprite.y > 0) { ... }
|| Returns true if either condition is true.Example: if (sprite.x < 0 || sprite.y < 0) { ... }
! Returns the opposite of a boolean value.Example: if (!sprite.visible) { ... }
Math.sin(angle): Returns the sine of the angle (in degrees).Example: let y = Math.sin(90)
Math.cos(angle): Returns the cosine of the angle (in degrees).Example: let x = Math.cos(0)
Math.tan(angle): Returns the tangent of the angle (in degrees).Example: let slope = Math.tan(45)
Math.atan2(y, x): Returns the angle (in degrees) from the positive x-axis to the point (x, y).Example: let angle = Math.atan2(sprite.y - Mouse.y, Mouse.x - sprite.x)
Math.asin(num): Returns the arcsine of a number (in degrees).Example: let angle = Math.asin(0.5)
Math.acos(num): Returns the arccosine of a number (in degrees).Example: let angle = Math.acos(0.5)
Math.atan(num): Returns the arctangent of a number (in degrees).Example: let angle = Math.atan(1)
Math.radToDeg(radians): Converts radians to degrees.Example: let degrees = Math.radToDeg(Math.PI)
Math.degToRad(degrees): Converts degrees to radians.Example: let radians = Math.degToRad(180)
Math.PI: Represents the mathematical constant π (~3.14159).Example: let radius = 2 * Math.PI * r
Math.E: Represents Euler’s number (~2.718).Example: let growth = Math.E ** time
Functions for working with sprite clones.
onCloneStart(function(clone){ ... }): Runs when a clone is created.Example: onCloneStart((clone) => { clone.x = 0 })
createClone(): Creates a clone of the current sprite, or the sprite with the given name if provided.Example: let newSprite = createClone()
clone.delete() Deletes the current clone in the onCloneStart.Example: clone.delete()
sprite.clones: List containg all clones of this sprite.Example: let myClones = sprite.clones
Core game functions, properties, and text management.
Game.stop(): Stops the game.Example: Game.stop()
Game.width: The width of the game window.Example: sprite.x = Game.width / 2
Game.height: The height of the game window.Example: sprite.y = Game.height / 2
Game.getSprite(name): Gets a sprite by its name.Example: let bird = Game.getSprite('Bird')
Game.createText(content): Creates a new text object with default styling.Example: Game.createText('Hello World')
Game.createText(content, style): Creates a new text object with custom styling.Example: Game.createText('Hello World', { fontSize: 24, fill: 'Red' })
Game.removeText(text): Removes a text object from the display.Example: Game.removeText(myText)
Declare and work with variables in your code.
let variableName: type = value: Declares a variable with a specific type.Example: let score: number = 0
variableName = newValue: Updates the value of an existing variable.Example: score = score + 1
globals.variableName = value: Declares a global variable that can be changed.Example: globals.playerName = "Wispy"
Create, modify, and access array data.
let array: type[] = []: Creates a new empty array. Types include: number, string, boolean, etc.Example: let scores: number[] = []
array.push(value): Adds a value to the end of the array.Example: scores.push(10)
array.splice(index, 1): Removes the item at the given index.Example: scores.splice(2, 1)
array.splice(index, 0, item): Inserts an item at the specified index.Example: scores.splice(1, 0, 99)
array[index] = item: Replaces the item at the specified index.Example: scores[0] = 42
array[index]: Gets the item at the given index.Example: let value = scores[1]
array.length: Gets the number of items in the array.Example: let count = scores.length
array[0]: Gets the first item in the array.Example: let first = scores[0]
array[array.length - 1]: Gets the last item in the array.Example: let last = scores[scores.length - 1]
array.sort(): Sorts the array alphabetically or numerically.Example: scores.sort()
array.reverse(): Reverses the order of the array.Example: scores.reverse()
array.map(item => ...): Creates a new array by transforming each item.Example: let doubled = scores.map(x => x * 2)
array.filter(item => ...): Creates a new array with only the items that pass the condition.Example: let highScores = scores.filter(x => x > 50)
globals.arrayName = value: Declares a global array that can be changed.Example: globals.playerNames = ["Wispy", "Puff"]
Draw on the screen using pen functionality.
sprite.penDown(): Puts the pen down to start drawing.Example: sprite.penDown()
sprite.penUp(): Lifts the pen up to stop drawing.Example: sprite.penUp()
sprite.erase(): Erases only this sprite's pen drawings.Example: sprite.erase()
sprite.eraseAll(): Erases all pen drawings from all sprites.Example: sprite.eraseAll()
sprite.setPenColor(color): Sets the pen color using a number (0-360).Example: sprite.setPenColor(120)
sprite.changePenColor(amount): Changes the pen color by the specified amount.Example: sprite.changePenColor(60)
sprite.setPenSize(size): Sets the pen size (thickness) in pixels.Example: sprite.setPenSize(5)
sprite.changePenSize(amount): Changes the pen size by the specified amount.Example: sprite.changePenSize(2)
sprite.setPenShape(shape): Sets the pen shape to a circle or square.Example: sprite.setPenShape("circle")
Create real-time multiplayer games where players can connect and play together.
await Multiplayer.connect(): Connects to the multiplayer server using the project ID as the room. Each project has its own isolated multiplayer room.Example: await Multiplayer.connect()
Multiplayer.disconnect(): Disconnects from the multiplayer server.Example: Multiplayer.disconnect()
Multiplayer.isConnected(): Returns true if connected to multiplayer server.Example: if (Multiplayer.isConnected()) { ... }
Multiplayer.sendAll(sprite): Sends all sprite properties to other players once. Automatically registers the sprite for multiplayer if not already registered. Includes position, rotation, visibility, size, transparency, brightness, layer, costume, and data.Example: Multiplayer.sendAll(sprite)
Multiplayer.syncSprite(sprite): Continuously syncs all sprite properties to other players automatically. More efficient than sending individual properties repeatedly.Example: Multiplayer.syncSprite(sprite)
Multiplayer.sendX(sprite): Sends the sprite's current X position to other players once.Example: Multiplayer.sendX(sprite)
Multiplayer.sendY(sprite): Sends the sprite's current Y position to other players once.Example: Multiplayer.sendY(sprite)
Multiplayer.sendPosition(sprite): Sends both X and Y positions to other players once. Automatically registers the sprite for multiplayer if not already registered.Example: Multiplayer.sendPosition(sprite)
Multiplayer.sendRotation(sprite): Sends the sprite's current rotation to other players once.Example: Multiplayer.sendRotation(sprite)
Multiplayer.sendVisible(sprite): Sends the sprite's visibility state to other players once.Example: Multiplayer.sendVisible(sprite)
Multiplayer.sendScaleX(sprite): Sends the sprite's width/scale X to other players once.Example: Multiplayer.sendScaleX(sprite)
Multiplayer.sendScaleY(sprite): Sends the sprite's height/scale Y to other players once.Example: Multiplayer.sendScaleY(sprite)
Multiplayer.sendAlpha(sprite): Sends the sprite's transparency/alpha to other players once.Example: Multiplayer.sendAlpha(sprite)
Multiplayer.sendBrightness(sprite): Sends the sprite's brightness to other players once.Example: Multiplayer.sendBrightness(sprite)
Multiplayer.sendData(sprite): Sends the sprite's data object to other players once.Example: Multiplayer.sendData(sprite)
Multiplayer.sendMessage(message): Sends a custom message to all other players.Example: Multiplayer.sendMessage("playerScored")
Multiplayer.sendMessage(message, data): Sends a custom message to all other players with data.Example: Multiplayer.sendMessage("playerScored", { score: 100 })
Multiplayer.onMessage(message, function(data) { ... }): Handles messages from other players.Example: Multiplayer.onMessage("playerScored", function(data) { myText.text = data.score })
Multiplayer.getOtherPlayers(): Returns an array of other players' data (ID, position, rotation).Example: let players = Multiplayer.getOtherPlayers()
Multiplayer.getMyId(): Returns your unique player ID.Example: let myId = Multiplayer.getMyId()
Multiplayer.onPlayerJoin(function(playerId) { ... }): Runs a function when a new player joins the game.Example: Multiplayer.onPlayerJoin(function(playerId) { sprite.visible = true })
Multiplayer.onPlayerLeave(function(playerId) { ... }): Runs a function when a player leaves the game.Example: Multiplayer.onPlayerLeave(function(playerId) { sprite.visible = false })