Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.
/ Atlantis.js Public archive

A game engine written in JavaScript with an API close to XNA/MonoGame

License

Notifications You must be signed in to change notification settings

demonixis/Atlantis.js

Repository files navigation

AtlantisEngine.js

Summary

AtlantisEngine.js is a work in progress JavaScript 2D Game Engine using HTML5 and canvas 2D. It is mainly inspired by XNA and Flixel. This project is separated in two parts: A Framework which is very close to XNA api, and an engine which is inspired by Flixel.

The first game using Atlantis.js is live !

Play it here

Some demos

The Framework

  • Preloader
  • Content Manager
  • Sprite batch (most of XNA's SpriteBatch functions are supported)
  • Upscaling
  • Game components
  • Helpers (Ajax, Custom events)
  • Input (Keyboard, Mouse, Gamepad, Touch)
  • Math tools (Vector, Matrix, etc.)

The Engine (still need work)

  • Audio manager
  • Camera
  • Input manager
  • Sprite with an easy animation system
  • SpriteGroup
  • SpriteText
  • Tilemap (Tiled JSON export)
  • Level manager

More to come later !

Docs and demos

You can browse the online documentation here (its generated by yuidoc) and check some demos here.

Example

// The Game class
var AwesomeGame = function () {
	Atlantis.Game.call(this, 800, 600);
	this.content.setRootDirectory("Content/");
	this.spriteBatch = new Atlantis.SpriteBatch(this.graphicsDevice);
	this.spriteA = null;
	this.textA = null;
	this.position = { x: 50, y: 50 };
	this.rotation = 0;
};

AwesomeGame.prototype = Object.create(Atlantis.Game.prototype);

// Initialize your objects here. 
AwesomeGame.prototype.initialize = function () {
	Atlantis.Game.prototype.initialize.call(this);
};

// Load you assets here.
AwesomeGame.prototype.loadContent = function () {
	Atlantis.Game.prototype.loadContent.call(this);
	this.spriteA = this.content.load("atlantis_logo.jpg");
	this.textA = new Atlantis.SpriteFont();
};

// Update the game logic here as Input, Physics, etc.
AwesomeGame.prototype.update = function (gameTime) {
	Atlantis.Game.prototype.update.call(this, gameTime);

	var state = this.keyboard.getState();
  
	if (state.isKeyDown(Atlantis.Keys.Up))
		this.position.y -= 5;
	else if (state.isKeyDown(Atlantis.Keys.Down))
		this.position.y += 5;
	
	if (state.isKeyDown(Atlantis.Keys.Left))
		this.position.x -= 5;
	else if (state.isKeyDown(Atlantis.Keys.Right))
		this.position.x += 5;
	
	if (state.isKeyDown(Atlantis.Keys.Space))
		this.rotation += 0.1;
	else if (state.isKeyDown(Atlantis.Keys.Tab))
		this.rotation -= 0.1;
};

// Draw sprites and text here.
AwesomeGame.prototype.draw = function (gameTime, context) {
	Atlantis.Game.prototype.draw.call(this, gameTime, context);
	this.graphicsDevice.clear(); 
 
	this.spriteBatch.begin();
	
	// Draw simple texts.
	this.spriteBatch.drawString(this.textA, "SpriteBatch test", { x: 10, y: 15 }, "#459999");

	// Draw the sprite.
	this.spriteBatch.draw(this.spriteA, this.position, null, null, this.rotation, { x: this.spriteA.width >> 1, y: this.spriteA.height >> 1 });
	
	// Draw all of this in the screen
	this.spriteBatch.end();
};

// Start the game !
var game = new AwesomeGame();
game.run();

License

MIT License, please read the LICENSE file for more informations.

About

A game engine written in JavaScript with an API close to XNA/MonoGame

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published