Agar.io is a very simple yet engaging game. The point of the game is to increase your mass by eating food and other players and to avoid players larger than you. The larger you are, the slower you move. You can also eject half of your mass to capture/eat other players!
-
Wireframes
-
Gameplay
-
- Configured a camera object that tracks and focuses on the player as they navigate a playfield larger than the display. Delegated animation to the camera object, significantly reducing intensive logic calculations on portions of the playfield unseen by the player
- Developed computer players that make real-time decisions with information from their environment
- Utilized the players state to trigger DOM manipulation of the start, pause, and game over modals
class Camera {
constructor(board, canvasWidth, canvasHeight, context, dpi) {
...
}
updatePos() {
this.boardX = this.player.boardX - (this.canvasWidth / 2);
this.boardY = this.player.boardY - (this.canvasHeight / 2);
}
within() {
this.matter = [];
for (let idx = 0; idx < this.allMatter.length; idx += 1) {
if (this.allMatter[idx].boardX < this.boardX || this.allMatter[idx].boardX > this.boardX + this.canvasWidth) {
continue;
} else if (this.allMatter[idx].boardY < this.boardY || this.allMatter[idx].boardY > this.boardY + this.canvasHeight) {
continue;
} else if (this.allMatter[idx].consumed === false) {
this.matter.push(this.allMatter[idx]);
}
}
this.computers = [];
for (let idx = 0; idx < this.allComputers.length; idx += 1) {
if (this.allComputers[idx].boardX + this.allComputers[idx].radius < this.boardX - 200 || this.allComputers[idx].boardX - this.allComputers[idx].radius > this.boardX + this.canvasWidth + 200) {
continue;
} else if (this.allComputers[idx].boardY + this.allComputers[idx].radius < this.boardY - 200 || this.allComputers[idx].boardY - this.allComputers[idx].radius > this.boardY + this.canvasHeight + 200) {
continue;
} else if (this.allComputers[idx].consumed === false) {
this.computers.push(this.allComputers[idx]);
}
}
}
draw() {
//grab all objects within frame, check for collisions, and relimit data
this.within();
this.checkCollisions();
this.within();
//draw in-frame matter
this.drawMatter();
//draw in-frame computers
this.drawComputers();
//draw player
this.drawPlayer();
}
}
-
Basic App Framework
- Background
- Color Pallete
- Playfield
- Personal Links
-
Player Object and Movement
- Field of view stays centered on player object
- Player can navigate the space with a mouse or keyboard
-
Player's Mass Can Increase
- Create inanimate mass objects that the player can eat
- Eating inanimate mass objects increases the players mass
- Increasing the player's mass increases the player's size
- The player's speed is dependent on the player's weight
-
BONUS - A.I. Enemies
- A.I. will avoid any enemy players larger than themselves
- A.I. will approach any enemy players smaller than themselves
-
BONUS - Split Mass
- Players can eject half of their mass in the direction of movement
- Players can control both masses
- After a certain amount of time, split masses will merge
-
BONUS - Human Opponents
- You can play against other people in real time
- Add unique identifying features to human players (usernames)
-
BONUS - High Scores
- A player's mass is equivalent to their score
- High scores are persisted and presented on the app
-
- JavaScript for overall structure and game logic
- HTML5 Canvas for DOM manipulation and rendering
-
-
Thursday
- Create the App Framework, Background, & Game View Port
-
Friday
- Create the Player Object/Movement
-
Weekend/Monday
- Create and continuously populate the board with inanimate mass objects
- A player's mass/size increase when a player consumes an inanimate mass object
-