Skip to content

Instantly share code, notes, and snippets.

@ultr7A
Created July 7, 2019 03:11
Show Gist options
  • Save ultr7A/5bd7b02636e77dc690e7defd761df01a to your computer and use it in GitHub Desktop.
Save ultr7A/5bd7b02636e77dc690e7defd761df01a to your computer and use it in GitHub Desktop.
int health = 100,
lives = 3;
score = 0;
float difficulty = 1.5;
float multiplier = 1.0;
array shapes = ["box", "cylinder", "octahedron", "sphere", "hexagon", "cone", "torus"];
array colors = [65280, 10526880, 33023, 16711680, 16744448, 8388863, 65535 ];
array center = [0,0];
let pilot = {};
Component.events.seat.sit -> fn(Entity user){
pilot = user;
center = [pilot.position[0], pilot.position[1]];
user.mount(Entity);
start_game();
}
Component.events.destructable.damage -> fn(int damage) {
health = health - damage;
if (health < 1) {
lives = lives -1;
}
if (lives < 1) {
pilot.unMount(Entity);
}
};
Component.events.control.use -> fn(Object control) {
};
function start_game = fn() {
multiplier = 1.5;
difficulty = 1;
spawn_enemy(Math.random(7));
}
function spawn_enemy = fn(int ofType) {
Component body = make_shape(ofType);
Entity shape = new Entity({
components: [body]
});
sleep(Math.floor(5000 / difficulty)) {
if (lives > 0) {
spawn_enemy(Math.random(7));
}
}
}
function make_shape(int ofShape) {
return new Component({
attrs: {
npc: {
temperment: "evil"
}
},
weapon: {},
geometry: {
shape: shapes[ofShape],
size: [2,2,2]
},
material: {
color: colors[ofShape],
name: "basic",
wireframe: true
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment