Skip to main content

Ball Arena

A small arena with twelve coins. Tap Play online and you join the room ARENA. Everyone else who taps it joins the same room, and you see their balls roll about while you collect coins. Play alone is the same game without a room.

It is a tour of the multiplayer blocks: a room with a code of your own, objects that every player sees, and telling your own ball from the others. Everything is an event sheet and project data: there are no code scripts.

Plays right here in your browser. Open full screen ↗

Controls: the joystick rolls your ball (WASD or the arrow keys on a computer). To try it with a friend, open this page on two devices and tap Play online on both.

Open it in the editor​

  1. Download ball-arena.tge (0.1 MB).
  2. Open the editor: editor.jeevagames.com on a computer, or the Android app.
  3. On the home screen tap Import .tge and pick the file, then open Ball Arena (imported).
  4. Press ▶ Play, or open Logic → Main events to read the rules.

How it works​

Finding a room​

Play online runs Quick match. It joins the fullest open room of the game, or, when there is none, makes a public room that the next player will find. Nobody types a code. If it cannot connect, On room failed says why with neterror().

A ball for each player​

Under On room joined, Spawn for everyone makes the Ball prefab at a random spot. Every player in the room sees it. The player who spawned it drives it; the others see a copy that glides to where it is. The Ball prefab has a Net sync component, which sends its position about ten times a second. When you leave, your ball goes for everyone.

Play alone runs the same Spawn for everyone with no room, and it just makes the ball.

Only my ball listens to my finger​

Every ball is called Ball, so the movement event has a second condition: Ball is mine. Only the ball you drive reads the joystick:

  • Every tick and Ball is mine → Set move input Ball to the joystick.

The balls of other players do not run their behaviors on your device, so even without that check they would not move by themselves. The check is there so your joystick does not steer their ball in your own copy of the scene.

Coins and the team count​

Each coin has its own name (Coin0 to Coin11), so every device means the same coin. Your own ball decides when it takes one: when Distance between Ball and Coin3 is under 0.9 (measured flat) and Ball is mine, the coin is destroyed and you score. Then Set shared value coin3 to 1 and Add to shared value team 1.

Everybody else (and you, a moment later) runs On shared coin3 changed and destroys Coin3 too. Because the room remembers shared values, a player who joins late gets coin3 = 1 as soon as they arrive, and the coin is gone for them as well. That is why a coin is a shared value and not a message. On shared team changed keeps the text Team: n / 12 up to date; two players taking coins at the same moment cannot lose a count, because the room does the adding.

Two details came from testing with two phones. A collision would be decided on each device separately, and a spinning coin changes shape and the other player's ball is a little behind, so one device could see a touch and the other not. The distance check looks at the owner's own ball only, which is always exactly where its player sees it.

Make it yours​

  • A round timer: the host sets a shared timeLeft every second; everyone shows it with netshared("timeLeft"). See Multiplayer.
  • Pick up the ball: put a ball with Net sync in the scene and use Take control when a player touches it: they drive it, the others see it glide.
  • Different colours: each player sends the colour they picked with Send message, and everyone sets the colour of that player's ball.
  • A private room: use Create room (not listed) and show netcode() so a friend can Join room with it.