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