construct mode mob spawns
This commit is contained in:
@@ -40,7 +40,8 @@
|
||||
<div id="health"></div>
|
||||
<div id="dmg"></div>
|
||||
<div id="choose-background"></div>
|
||||
<div id='construct' contenteditable="true"></div>
|
||||
<div id='construct'></div>
|
||||
<!-- contenteditable="true" -->
|
||||
|
||||
<!-- guns -->
|
||||
<!-- <audio id="snare2" src="sounds\guns\snare2.ogg" preload="auto"></audio>
|
||||
|
||||
40
js/game.js
40
js/game.js
@@ -1029,15 +1029,16 @@ const game = {
|
||||
}
|
||||
const x = round(game.constructMouseDownPosition.x)
|
||||
const y = round(game.constructMouseDownPosition.y)
|
||||
const dx = round(game.mouseInGame.x) - x
|
||||
const dy = round(game.mouseInGame.y) - y
|
||||
const dx = Math.max(25, round(game.mouseInGame.x) - x)
|
||||
const dy = Math.max(25, round(game.mouseInGame.y) - y)
|
||||
|
||||
ctx.strokeStyle = "#000"
|
||||
ctx.lineWidth = 2;
|
||||
ctx.strokeRect(x, y, dx, dy);
|
||||
}
|
||||
},
|
||||
outputMapString() {
|
||||
outputMapString(string) {
|
||||
if (string) game.constructMapString.push(string) //store command as a string in the next element of an array
|
||||
let out = "" //combine set of map strings to one string
|
||||
let outHTML = ""
|
||||
for (let i = 0, len = game.constructMapString.length; i < len; i++) {
|
||||
@@ -1052,20 +1053,21 @@ const game = {
|
||||
game.isAutoZoom = false;
|
||||
|
||||
document.body.addEventListener("mouseup", (e) => {
|
||||
if (game.testing && game.constructMouseDownPosition && game.mouseInGame.x > game.constructMouseDownPosition.x && game.mouseInGame.y > game.constructMouseDownPosition.y) { //make sure that the width and height are positive
|
||||
if (game.testing && game.constructMouseDownPosition) {
|
||||
function round(num, round = 25) {
|
||||
return Math.ceil(num / round) * round;
|
||||
}
|
||||
//clean up positions
|
||||
const x = round(game.constructMouseDownPosition.x)
|
||||
const y = round(game.constructMouseDownPosition.y)
|
||||
const dx = round(game.mouseInGame.x) - x
|
||||
const dy = round(game.mouseInGame.y) - y
|
||||
const dx = Math.max(25, round(game.mouseInGame.x) - x)
|
||||
const dy = Math.max(25, round(game.mouseInGame.y) - y)
|
||||
|
||||
console.log(e.which)
|
||||
if (e.which === 2) {
|
||||
game.outputMapString(`spawn.randomMob(${x}, ${y},0.5);`);
|
||||
} else if (game.mouseInGame.x > game.constructMouseDownPosition.x && game.mouseInGame.y > game.constructMouseDownPosition.y) { //make sure that the width and height are positive
|
||||
if (e.which === 1) { //add map
|
||||
game.constructMapString.push(`spawn.mapRect(${x}, ${y}, ${dx}, ${dy});`) //store command as a string in the next element of an array
|
||||
game.outputMapString();
|
||||
game.outputMapString(`spawn.mapRect(${x}, ${y}, ${dx}, ${dy});`);
|
||||
|
||||
//see map in world
|
||||
spawn.mapRect(x, y, dx, dy);
|
||||
@@ -1077,8 +1079,7 @@ const game = {
|
||||
|
||||
game.draw.setPaths() //update map graphics
|
||||
} else if (e.which === 3) { //add body
|
||||
game.constructMapString.push(`spawn.bodyRect(${x}, ${y}, ${dx}, ${dy});`) //store command as a string in the next element of an array
|
||||
game.outputMapString();
|
||||
game.outputMapString(`spawn.bodyRect(${x}, ${y}, ${dx}, ${dy});`);
|
||||
|
||||
//see map in world
|
||||
spawn.bodyRect(x, y, dx, dy);
|
||||
@@ -1086,15 +1087,16 @@ const game = {
|
||||
body[len].collisionFilter.category = cat.body;
|
||||
body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet
|
||||
World.add(engine.world, body[len]); //add to world
|
||||
body[len].classType = "body"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
game.constructMouseDownPosition.x = undefined
|
||||
game.constructMouseDownPosition.y = undefined
|
||||
});
|
||||
game.constructMouseDownPosition.x = undefined
|
||||
game.constructMouseDownPosition.y = undefined
|
||||
document.body.addEventListener("mousedown", () => {
|
||||
document.body.addEventListener("mousedown", (e) => {
|
||||
if (game.testing) {
|
||||
game.constructMouseDownPosition.x = game.mouseInGame.x
|
||||
game.constructMouseDownPosition.y = game.mouseInGame.y
|
||||
@@ -1103,22 +1105,18 @@ const game = {
|
||||
|
||||
document.body.addEventListener("keydown", (e) => { // e.keyCode z=90 m=77 b=66 shift = 16 c = 67
|
||||
if (game.testing && e.keyCode === 90 && game.constructMapString.length) {
|
||||
if (game.constructMapString[game.constructMapString.length - 1][6] === 'm') { //remove map
|
||||
game.constructMapString.pop();
|
||||
game.outputMapString();
|
||||
//remove from current level
|
||||
if (game.constructMapString[game.constructMapString.length - 1][6] === 'm') { //remove map from current level
|
||||
const index = map.length - 1
|
||||
Matter.World.remove(engine.world, map[index]);
|
||||
map.splice(index, 1);
|
||||
game.draw.setPaths() //update map graphics
|
||||
} else if (game.constructMapString[game.constructMapString.length - 1][6] === 'b') { //remove body
|
||||
game.constructMapString.pop();
|
||||
game.outputMapString();
|
||||
//remove from current level
|
||||
} else if (game.constructMapString[game.constructMapString.length - 1][6] === 'b') { //remove body from current level
|
||||
const index = body.length - 1
|
||||
Matter.World.remove(engine.world, body[index]);
|
||||
body.splice(index, 1);
|
||||
}
|
||||
game.constructMapString.pop();
|
||||
game.outputMapString();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@ const level = {
|
||||
start() {
|
||||
if (build.isURLBuild && level.levelsCleared === 0) build.onLoadPowerUps();
|
||||
if (level.levelsCleared === 0) { //this code only runs on the first level
|
||||
game.enableConstructMode() //used to build maps in testing mode
|
||||
// game.enableConstructMode() //used to build maps in testing mode
|
||||
// level.difficultyIncrease(9)
|
||||
// b.giveGuns("foam")
|
||||
// mech.setField("time dilation field")
|
||||
// b.giveMod("renormalization");
|
||||
// b.giveMod("impact shear");
|
||||
b.giveMod("clock gating");
|
||||
// b.giveMod("clock gating");
|
||||
// b.giveGuns("mine")
|
||||
// mech.setField("pilot wave")
|
||||
// mech.setField("perfect diamagnetism")
|
||||
|
||||
10
style.css
10
style.css
@@ -101,17 +101,17 @@ summary {
|
||||
bottom: 0%;
|
||||
right: 0%;
|
||||
z-index: 1;
|
||||
width: 300px;
|
||||
height: 320px;
|
||||
width: 250px;
|
||||
height: 200px;
|
||||
background-color: #fff;
|
||||
color: #000;
|
||||
font-size: 0.9em;
|
||||
user-select: text;
|
||||
/* user-select: text; */
|
||||
white-space: pre;
|
||||
padding: 3px;
|
||||
overflow: scroll;
|
||||
/* overflow: scroll; */
|
||||
/* border-radius: 0px; */
|
||||
border: 2px #333 solid;
|
||||
border: 1px #333 solid;
|
||||
}
|
||||
|
||||
#choose-grid {
|
||||
|
||||
5
todo.txt
5
todo.txt
@@ -1,9 +1,6 @@
|
||||
cardinality now gives 2 selection choices
|
||||
+20% laser damage
|
||||
Mod: When damaged, time slows down
|
||||
************** TODO - n-gon **************
|
||||
|
||||
let people know about n-gon
|
||||
n-gon outreach ideas
|
||||
blips - errant signal on youtube
|
||||
reddit - r/IndieGaming
|
||||
hacker news - show hacker news post
|
||||
|
||||
Reference in New Issue
Block a user