AnXPyDev d5da09183d Working on looping polygons | 5 years ago | |
---|---|---|
base | 5 years ago | |
icon | 6 years ago | |
scripts | 5 years ago | |
src | 5 years ago | |
tools | 5 years ago | |
.gitignore | 5 years ago | |
LICENSE | 5 years ago | |
README.md | 5 years ago | |
build.sh | 5 years ago | |
compile.sh | 5 years ago | |
package.json | 5 years ago | |
run.sh | 5 years ago | |
tsconfig.json | 5 years ago |
minty is a simple game engine inspired by Game Maker Studio
Node.js + npm (newest version recommended)
Git + Git Bash
Create a folder and open git bash in it, then run these commands
$ git clone https://github.com/AnXPyDev/minty.git
$ cd ./minty
$ npm install
$ bash compile.sh (you may insert the name of a project here)
$ bash run.sh
https://github.com/AnXPyDev/minty-projects
$ bash build.sh (insert name of project here)
You will find the packaged project in the "built" folder inside the folder that contains minty
Creating a simple pong game.
// Initialize a Scene
const s0 = new Scene("s0", v(640, 640),
{
// Spawn objects
paddle:[[]],
paddle_ai:[[]],
ball:[[]]
},
{
// Spawn background
main:["noimage", "solid", "black"]
},() => {
// Resize viewport to custom size
vport.resize(v(640,640));
},() => {}, 60, 60)
GAME.onload = function() {
// Load scene when game is ready to be loaded
s0.load();
}
// Define an actor
def("paddle", class extends Actor {
constructor() {
super(v(-280), "paddle");
this.speed = 8;
this.size = v(8,64);
}
tick() {
this.pos.y = lerp(this.pos.y, Mouse.y, 0.1);
}
draw() {
Draw.rect(this.size, this.pos, "white");
}
}, ["paddle"]);
def("paddle_ai", class extends act.paddle {
constructor() {
super();
this.name = "paddle_ai";
this.pos.x = 280;
}
tick() {
this.pos.y = clamp(approach(this.pos.y, Instance.get("ball", 0).pos.y, this.speed), -320, 320);
}
}, ["paddle"]);
def("ball", class extends Actor {
constructor() {
super(v(), "ball");
this.dir = v(Random.int(4,8),Random.int(4,8));
this.size = v(8,8);
}
tick() {
// Invert direction when hitting paddle
if(collides(this, Instance.filter(["paddle"])).is) {
this.dir.x *= -1;
}
// Check for hitting ceiling or fllor
if (this.pos.y < -320 || this.pos.y > 320) {
this.dir.y *= -1;
}
// Check for going behind a paddle
if(this.pos.x < -320 || this.pos.x > 320) {
s0.load();
}
this.pos.x += this.dir.x;
this.pos.y += this.dir.y;
}
draw() {
Draw.ellipse(this.size, this.pos, "white");
}
});