Skip to content
AI-powered appsNewChat, vision, voice, generationBookings & schedulingAppointments that book themselvesShops & sellingA storefront in every pocketClient & businessRun the operation from one placeCommunities & clubsA home that is not a group chat
Health & wellnessHabits, tracking and calmGames2D, 3D and multiplayerPersonal & toolsThe tool you wish existedInternal toolsThe tool ops never had time for
See all use cases
ArcadeNewPricingSecurity
EngineThe game engine and World EditorHow it worksFrom one sentence to a live productDocsGuides for building and publishingBlogStories, guides and newsChangelogWhat shipped latelyStatusUptime of every serviceSupportGet help from the team
AI-powered appsBookings & schedulingShops & sellingClient & businessCommunities & clubsHealth & wellnessGamesPersonal & toolsInternal tools
See all use cases
ArcadeNewPricingSecurity
EngineHow it worksDocsBlogChangelogStatusSupport
Language
Blog
Game mechanicsNovember 22, 20266 min read

Grid-Based Movement

Moving one tile at a time sounds simple until inputs get lost mid-step and two enemies walk into the same square. Here is how to build it cleanly.

Startbase Team
Editorial ink illustration of a carved pawn sliding one square forward on a wooden grid, the pawn in ember orange

Key takeaways

  • Keep a logical tile position and a visual position. Logic jumps to the new tile instantly; the sprite slides there over 0.1 to 0.2 seconds.
  • Buffer the next input during a step and repeat held keys with a short initial delay, or grid movement feels laggy.
  • Reserve the target tile at the start of a move so two movers can never enter the same square.

Grid-based movement means characters move in whole tiles: one press, one square. It is the movement of puzzle games, classic RPG overworlds, roguelikes, tactics games and snake. The clean way to build it is to separate the character's logical position (which tile it occupies, an integer pair) from its visual position (where the sprite is drawn). Logic changes instantly when a move starts; the sprite slides between tiles over a short, fixed time. Most grid movement bugs come from blurring those two.

Logical position versus visual position

Store `tileX` and `tileY` as integers. All game rules (collision, pickups, triggers, enemy turns) read them. The sprite has its own `drawX` and `drawY`, which interpolate from the old tile to the new one. When the player presses right:

  1. 01Check the target tile: is it walkable, is anything there?
  2. 02If yes, update `tileX` immediately and start a step animation from the old tile to the new one.
  3. 03Trigger tile events (pickups, traps) either at the start of the step or when it finishes. Choose once; finishing feels more natural for pickups, starting is safer for collision.
  4. 04When the step completes, snap `drawX` and `drawY` exactly to the tile, to avoid floating point drift.

If the target tile is blocked, do not move, but still turn to face that direction and maybe play a small bump (2 to 4 pixels toward the wall and back, with a soft thud). That tiny feedback stops the game from feeling unresponsive.

Step timing

  • Step duration: 0.1 to 0.2 seconds per tile for player characters. Under 0.1 feels like teleporting; over 0.25 feels sluggish in action games, though slow cozy games can go to 0.3.
  • Ease the step with a slight ease-out, or keep it linear while the key is held so chained steps flow without a stutter at each tile.
  • Add a hop or a squash of 2 to 4 pixels on each step for character. Puzzle games often bounce on every move; it makes each step countable.
  • Running: a held run button halves the step duration. Simple and effective.

Input that never gets lost

The most common complaint about grid movement is that it ignores presses. That happens because the game only reads input when a step is not in progress. Two fixes:

  • Buffer one input during a step. If the player presses a direction while moving, store it and execute it the moment the current step ends. Keep only the latest press, and only during the last half of the step or so, or the character will run an old command.
  • Held key repeat. While a direction is held, keep stepping. Use a short initial delay before repeating (0.1 to 0.2 seconds) only if your game needs precise single steps, like a puzzle game; in an overworld, step continuously with no delay.
  • Tap to turn. Many RPG overworlds turn the character on a very short tap (under 0.08 seconds) and only move on a longer press. It lets players face a sign without stepping. Useful in games with interaction; annoying in puzzle games.
  • Most recent direction wins. When two directions are held, use the one pressed last. It makes corners feel responsive on keyboards.

On phones, swipes map well to grid steps: one swipe, one tile, with a threshold of about 20 to 30 pixels and the dominant axis winning. A held virtual stick also works, stepping in the direction it points. Our touch controls guide covers dead zones and swipe detection.

Many movers on one grid

With enemies, NPCs or several snakes on the same grid, collisions between movers need rules:

  • Reserve tiles. When a mover starts a step, it claims the target tile immediately (and releases the old tile when the step finishes, or immediately if you allow following closely). Another mover checking that tile sees it occupied. Without reservation, two enemies walk into the same square on the same frame.
  • An occupancy grid. Keep a 2D array of what is on each tile, updated on every move. Checking it is much cheaper than looping over every entity, and it is the same grid that pathfinding and line of sight read.
  • Swaps. Two movers trading tiles head-on pass through each other unless you check for it. Decide whether swaps are allowed; usually they are not.
  • Turn-based grids (roguelikes, tactics) resolve moves in order: the player moves, then each enemy in turn. Real-time grids need the reservation rule. Our roguelike guide covers turn order.

Pushing, sliding and undo

Grid movement is the basis of many puzzle games, which add a few standard mechanics:

  • Pushing blocks. Moving into a block checks the tile beyond it; if free, both move. Chains (pushing two blocks) either work recursively or are forbidden. Decide, and teach it.
  • Ice sliding. On ice, the mover keeps going in the same direction until it hits something. Implement it as repeated steps, so the same collision and event code runs on every tile.
  • Undo. Puzzle players expect undo. Record each move as the list of changes it caused (who moved from where to where, what was collected), push it on a stack, and pop to undo. Storing full board snapshots works too for small boards. Undo should be instant, with no animation or a very fast one.
  • Restart returns to the level start in one press, without a confirmation dialog.

Bugs to expect

  • Position drift. Moving the sprite by speed times frame time without snapping leaves it at 47.9999 instead of 48. Always snap to the tile at the end of a step.
  • Diagonal corner cutting. If diagonals are allowed, moving diagonally between two blocked tiles squeezes through a wall corner. Usually forbid diagonal moves when either side tile is blocked.
  • Triggers firing twice. A trap checked every frame while the player stands on it hurts every frame. Fire tile events on entering a tile, once.
  • Logic ahead of visuals. Because logic moves first, an enemy can be hit at its new tile while still drawn at the old one. For most games that is fine; for fast action, resolve combat when steps complete.
  • Frame-rate dependent steps. Steps timed in frames take half as long on a 120 Hz phone. Use elapsed time.

How it combines with other systems

Grid movement makes several other systems simpler. Pathfinding runs directly on the tile grid. Fog of war and line of sight are computed per tile. Turn-based combat often uses it for positioning. And a snake game is grid movement with a body that follows the head's previous tiles. Free movement with optional snapping is a different design; see our guide to smooth top-down movement for that side.

A brief to paste

A grid-based block-pushing puzzle game with 48 px tiles. The player has an integer tile position for all rules and a sprite that slides between tiles over 0.14 s with a small 3 px hop. Moving into a wall turns the player and plays a tiny bump and thud. Buffer one direction pressed during the last half of a step. Held keys repeat after 0.15 s. On phones, swipes of 25 px or more step one tile, dominant axis wins. Pushing a crate moves it if the tile beyond is free; no chains. Ice tiles slide the player and crates until they hit something. Keep an occupancy grid. Undo (Z or a button) is instant and unlimited, restart (R) returns to the start with no dialog. Snap sprites to tiles at the end of every step. Ten levels that each teach one idea.

Frequently asked questions

How do you make grid movement smooth instead of jumpy?

Keep the logical position on whole tiles but slide the sprite between tiles over about 0.1 to 0.2 seconds. Buffer inputs pressed during a step so held or quick presses chain without stopping.

How do I stop two enemies moving into the same tile?

Have each mover reserve its target tile at the start of its step, and check reservations in an occupancy grid before any move begins.

Is grid-based movement good for phone games?

Yes. Swipes map naturally to one-tile steps, and grid games are easy to read on small screens. Use a swipe threshold of about 20 to 30 pixels and let the dominant axis decide the direction.

On this page

  • Logical position versus visual position
  • Step timing
  • Input that never gets lost
  • Many movers on one grid
  • Pushing, sliding and undo
  • Bugs to expect
  • How it combines with other systems
  • A brief to paste

Keep reading

More in Game mechanics
Editorial ink illustration of a wooden toy figure in mid-air above a gap, the puff cloud under its feet in ember orange
Game mechanicsNovember 22, 2026

How to Add a Double Jump to Your Game

A double jump is one counter and one reset rule, but the details decide whether it feels like control or like cheating. Here are the values and the bugs to watch for.

8 min read
Editorial ink illustration of a small figure streaking along a stone floor with faded ghost copies behind it, the front figure's scarf in ember orange
Game mechanicsNovember 22, 2026

How to Add a Dash Move

A dash is a short burst of fixed speed that overrides normal movement. Get its distance, its ending and its refill rule right and it becomes the move players use most.

7 min read

Read less. Ship more.

Everything in this post is one prompt away. Describe your app and watch it build.

Start building

Apps, games, backends and publishing from one conversation.

Product

  • Features
  • Use cases
  • Pricing
  • Changelog

Resources

  • Blog
  • Docs
  • Support
  • Status
  • Security

Contact

  • w@startbase.ai
  • X / Twitter
  • LinkedIn
  • Instagram

Legal

  • Terms
  • Privacy

© 2026 Startbase. All rights reserved.