经过一段时间的JavaScript游戏“开发”,我想到了一个好主意,所以听起来似乎很不错。
我当时正在考虑创建一个代表熔岩的实体。该熔岩将使用以下方式沿特定方向移动:
function Lava(pos, ch) {
this.pos = pos;
this.size = new Vector(1, 1);
if(ch == '-') {
this.speed = new Vector(3, 0)
}
}
Run Code Online (Sandbox Code Playgroud)
在哪里var acrotchar = {"-": Lava};
。
整个代码可以在这里或下面看到:
function Lava(pos, ch) {
this.pos = pos;
this.size = new Vector(1, 1);
if(ch == '-') {
this.speed = new Vector(3, 0)
}
}
Run Code Online (Sandbox Code Playgroud)
var LEVELS = [
[" x x",
" xx x",
" xxx x x",
" xx!xx x ox",
" x!!!x x xx", …
Run Code Online (Sandbox Code Playgroud)I am building a JavaScript game, based on Mario.
I have already implemented "physics" for lava, so when the character would fall into it, they would lose 1 life. What I am trying to achieve is that lava drops would act the same, so on contact they would hurt the character and make it respawn at the start of the area / level.
The code can be found here and seen below:
//////////////////////////////
// This is only a demo code …
Run Code Online (Sandbox Code Playgroud)