Learn CONSTRUCT with Real Code Examples
Updated Nov 24, 2025
Code Sample Descriptions
1
Construct Event Sheet Example
// Event Sheet Example (pseudo-code)
// On start of layout
System -> Set variable score to 0
// On player collision with coin
Player.OnCollision(Coin) -> {
Destroy(Coin);
Add 10 to score;
TextScore.SetText("Score: " + score);
}
// On player collision with enemy
Player.OnCollision(Enemy) -> {
System.RestartLayout();
}
Example of Construct-style event scripting represented in pseudo-code/JS-like syntax for clarity.
2
Construct Jump and Collect Coins
// On start of layout
System -> Set variable score to 0
// On player press space
Keyboard.OnKeyDown(Space) -> {
Player.SetAnimation("Jump");
}
// On collision with coin
Player.OnCollision(Coin) -> {
Destroy(Coin);
Add 5 to score;
TextScore.SetText("Score: " + score);
}
Player jumps and collects coins.
3
Construct Enemy Patrol Example
// On start of layout
System -> Set variable direction to 1
// On every tick
Enemy -> {
Enemy.X += 2 * direction;
If Enemy.X > 400 -> Set direction to -1;
If Enemy.X < 100 -> Set direction to 1;
}
Enemy patrols back and forth.
4
Construct Timer Countdown
// On start of layout
System -> Set variable timeLeft to 60
// Every second
System.OnEverySecond -> {
timeLeft -= 1;
TextTimer.SetText("Time: " + timeLeft);
If timeLeft <= 0 -> System.RestartLayout();
}
Countdown timer event sheet.
5
Construct Player Shooting
// On press key
Keyboard.OnKeyDown(F) -> {
CreateObject(Projectile, Player.X, Player.Y);
Projectile.SetAnimation("Fly");
}
// On projectile collision
Projectile.OnCollision(Enemy) -> {
Destroy(Projectile);
Destroy(Enemy);
}
Player shoots projectiles when pressing a key.
6
Construct Collectibles with Random Spawn
// On start of layout
System -> Set variable score to 0
// Every 3 seconds
System.OnEvery(3 seconds) -> {
CreateObject(Coin, random(50, 450), random(50, 350));
}
// On player collision with coin
Player.OnCollision(Coin) -> {
Destroy(Coin);
Add 10 to score;
TextScore.SetText("Score: " + score);
}
Randomly spawn collectibles over time.
7
Construct Level Complete Event
// On start of layout
System -> Set variable coinsCollected to 0
// On player collision with coin
Player.OnCollision(Coin) -> {
Destroy(Coin);
Add 1 to coinsCollected;
If coinsCollected >= 10 -> System.GoToLayout("NextLevel");
}
Check win condition and go to next level.
8
Construct Enemy Damage Player
// On start of layout
System -> Set variable health to 100
// On player collision with enemy
Player.OnCollision(Enemy) -> {
Subtract 10 from health;
If health <= 0 -> System.RestartLayout();
TextHealth.SetText("Health: " + health);
}
Player loses health on collision with enemy.
9
Construct Moving Platform
// On start of layout
System -> Set variable direction to 1
// Every tick
Platform -> {
Platform.X += 2 * direction;
If Platform.X > 400 -> Set direction to -1;
If Platform.X < 100 -> Set direction to 1;
}
Platform moves back and forth horizontally.
10
Construct Pause and Resume Game
// On key press P
Keyboard.OnKeyDown(P) -> {
If System.Paused -> System.Resume();
Else -> System.Pause();
}
Pause and resume the game with a key press.