master^2
barney 2 years ago
parent 87e2f3690e
commit 12f353e895
  1. 1
      index.html
  2. BIN
      static/audios/bgm.m4a
  3. 1
      static/css/base.css
  4. 24
      static/js/game_map/base.js

@ -11,6 +11,7 @@
<body>
<div id="kof">
</div>
<script type="module">
import {KOF} from '/static/js/base.js';
let kof = new KOF('kof');

Binary file not shown.

@ -82,4 +82,3 @@
font-weight: bold;
color: blue;
}

@ -23,31 +23,39 @@ class GameMap extends AcGameObject {
</div>
</div>`));
this.root.$kof.append($(`
<audio id="player" autoplay>
<source src="./static/audios/bgm.m4a" type="audio/mpeg">
</audio>`));
this.time_left = 60000; // 剩余时间
this.$timer = this.root.$kof.find('.kof-head-timer');
this.$bgm = this.root.$kof.find('#player')[0];
this.$bgm.currentTime = 0;
this.$bgm.play();
}
start() {
}
update_timer() { // 更新时间
let [a,b] = this.root.players;
let [a, b] = this.root.players;
if (a.status === 6 || b.status === 6) {
this.$bgm.pause();
return;
}
this.time_left -= this.time_delta;
if (this.time_left < 0) {
this.time_left = 0;
this.$bgm.pause();
if (a.status !== 6 && b.status !== 6) {
a.status = b.status = 6;
a.current_frame_cnt = b.current_frame_cnt = 0;
a.current_frame_cnt = b.current_frame_cnt = 0;
a.vx = b.vx = 0;
}
}
}
this.$timer.text(parseInt(this.time_left / 1000));
this.$timer.text(parseInt(this.time_left / 1000));
}
update() {
@ -56,7 +64,7 @@ class GameMap extends AcGameObject {
}
render() {
this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height);
this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
// console.log(this.ctx.canvas.width,this.ctx.canvas.height); // 打印canvas的宽高
// console.log(this.$canvas.width());
// this.ctx.fillStyle = "#21252b"; // 画布的颜色

Loading…
Cancel
Save