This is a simple 2D top-down game built with Next.js and React, featuring characters that change color based on movement direction.
- Top-down view with grid background
- Two players:
- Human player controlled with WASD keys
- AI player that moves randomly around the map
- Both characters change color based on movement direction
- Visual direction indicators showing which way each player is moving
- Player identification labels (P1 for human, AI for computer)
- Human Player:
- W (Up): Red
- S (Down): Teal
- A (Left): Yellow
- D (Right): Purple
- Has a 30-degree vision cone in the direction it's facing
- Vision extends to twice its body size
- Changes behavior based on what it sees:
- If it can't see the player: moves randomly around the map
- If it can see the player: follows and chases the player
- Vision cone changes color when it detects the player
- Changes direction when hitting walls
- Different color scheme:
- Up: Purple
- Down: Blue
- Left: Orange
- Right: Green
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.
The arena layout can be authored in the free Tiled editor (.tmj JSON). Runtime loads public/maps/arena.tmj.
Layers:
- Walls (object layer): rectangle objects with
type = wallbecome collision boxes. - Spawns (object layer): point objects with
type = spawnand propertyspawnType=userorai.
Edit workflow:
- Open
public/maps/arena.tmjin Tiled. - Adjust wall rectangles (map size 20x15 tiles @ 40px -> 800x600 px).
- Move / add spawn points (set property
spawnType). - Save and refresh the browser.
If loading the TMJ fails the game falls back to the hardcoded layout in MapLayout.ts.
Add new maps by placing another .tmj in public/maps/ and calling loadMapFromTiled('/maps/yourmap.tmj') early (e.g., in a custom init hook).
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.