1.1.1 • Published 2 years ago

swordengine v1.1.1

Weekly downloads
1
License
MIT
Repository
-
Last release
2 years ago

Sword

Example Game made at here

Test Coverage

Statements Branches Functions Lines

How to install

npm install swordengine

npm version

Example

Look at the example folder

const sword=require("../sword.js")
const world=new sword();

//Create a monster
class Monster extends sword.Entity{
	constructor(){
		super();
		world.emit('velocity', this);
		world.emit('collision', this);
		this.size(1,1)
	}
}

const map=new sword.GameMap();

const monster=map.e(Monster);


monster.setPosition(100,100);

monster.setVelocity(10,0);	//Move right at 10 a second

const grass=map.e(Monster);

grass.setPosition(150,100);

monster.on("collide",(collision)=>{
	console.log("Walking through grass")
})

Class Entity

velocityTimeout(obj,amt,ms)

velocityToward(obj, amt)

setVelocity(x,y)

setPosition(x,y)

box(w, h)

circle(rad)

size(w, h)

setOrigin(x, y)

rotate(rad)

extend(type)

collideWith()

attach(obj)

Class GameMap

e(entity, ...args)

insert(object)

update(object)

update(object)

findNear(object, distance, cb)

destroy(object)

1.1.1

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.1

6 years ago

1.0.0

6 years ago