Created
July 7, 2019 03:11
-
-
Save ultr7A/5bd7b02636e77dc690e7defd761df01a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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