Enter level 2-1 after level 1-4, Adds score.
This commit is contained in:
parent
c26299320c
commit
31d857e0cf
4 changed files with 82 additions and 26 deletions
13
index.html
13
index.html
|
@ -48,8 +48,8 @@
|
||||||
<script type="text/javascript">var cpro_id = "u2379481"</script>
|
<script type="text/javascript">var cpro_id = "u2379481"</script>
|
||||||
<script src="http://cpro.baidustatic.com/cpro/ui/cm.js" type="text/javascript"></script>
|
<script src="http://cpro.baidustatic.com/cpro/ui/cm.js" type="text/javascript"></script>
|
||||||
</div>
|
</div>
|
||||||
<canvas id="canvas" width="480" height="640" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>
|
<canvas id="canvas" width="480" height="420" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>
|
||||||
<textarea id="output" rows="8" readonly></textarea>
|
<!--<textarea id="output" rows="8" readonly></textarea>-->
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
var canvas = document.getElementById('canvas');
|
var canvas = document.getElementById('canvas');
|
||||||
|
|
||||||
|
@ -78,12 +78,15 @@
|
||||||
Module.setStatus('Loading...');
|
Module.setStatus('Loading...');
|
||||||
|
|
||||||
window.onerror = function (event) {
|
window.onerror = function (event) {
|
||||||
document.documentElement.innerHTML = event;
|
document.documentElement.innerHTML = event + event.callstack;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (true) {
|
if (document.documentElement.clientWidth <= 480) {
|
||||||
var rect = canvas.getBoundingClientRect();
|
var rect = canvas.getBoundingClientRect();
|
||||||
canvas.height = Math.max(document.documentElement.clientHeight - rect.top, 420);
|
var height = document.documentElement.clientHeight - rect.top;
|
||||||
|
if (height > 600) {
|
||||||
|
canvas.height = height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var angle = 0;
|
var angle = 0;
|
||||||
|
|
1
lib.h
1
lib.h
|
@ -60,4 +60,5 @@ extern "C" {
|
||||||
|
|
||||||
void adshow();
|
void adshow();
|
||||||
void adhide();
|
void adhide();
|
||||||
|
void updatescore(int score, int life);
|
||||||
}
|
}
|
||||||
|
|
25
lib.js
25
lib.js
|
@ -12,6 +12,7 @@ var LibraryDLM = {
|
||||||
images: [],
|
images: [],
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontType: 0,
|
fontType: 0,
|
||||||
|
color: 'white',
|
||||||
},
|
},
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
@ -58,6 +59,7 @@ var LibraryDLM = {
|
||||||
},
|
},
|
||||||
|
|
||||||
clearscreen: function() {
|
clearscreen: function() {
|
||||||
|
gfxContext.fillStyle = DLM.color;
|
||||||
gfxContext.fillRect(0, 0, 480, 420);
|
gfxContext.fillRect(0, 0, 480, 420);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -66,21 +68,24 @@ var LibraryDLM = {
|
||||||
gfxContext.moveTo(x, y);
|
gfxContext.moveTo(x, y);
|
||||||
gfxContext.lineTo(w, h);
|
gfxContext.lineTo(w, h);
|
||||||
gfxContext.closePath();
|
gfxContext.closePath();
|
||||||
|
gfxContext.strokeStyle = DLM.color;
|
||||||
gfxContext.stroke();
|
gfxContext.stroke();
|
||||||
},
|
},
|
||||||
|
|
||||||
drawrect: function(x, y, w, h) {
|
drawrect: function(x, y, w, h) {
|
||||||
|
gfxContext.strokeStyle = DLM.color;
|
||||||
gfxContext.strokeRect(x, y, w, h);
|
gfxContext.strokeRect(x, y, w, h);
|
||||||
},
|
},
|
||||||
|
|
||||||
fillrect: function(x, y, w, h) {
|
fillrect: function(x, y, w, h) {
|
||||||
|
gfxContext.fillStyle = DLM.color;
|
||||||
gfxContext.fillRect(x, y, w, h);
|
gfxContext.fillRect(x, y, w, h);
|
||||||
},
|
},
|
||||||
|
|
||||||
drawarc: function(x, y, w, h) {
|
drawarc: function(x, y, w, h) {
|
||||||
gfxContext.lineWidth = 0.5;
|
gfxContext.lineWidth = 0.5;
|
||||||
gfxContext.strokeStyle = 'black';
|
|
||||||
gfxContext.arc(x, y, w, 0, Math.PI * 2);
|
gfxContext.arc(x, y, w, 0, Math.PI * 2);
|
||||||
|
gfxContext.strokeStyle = DLM.color;
|
||||||
gfxContext.stroke();
|
gfxContext.stroke();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -88,6 +93,7 @@ var LibraryDLM = {
|
||||||
gfxContext.beginPath();
|
gfxContext.beginPath();
|
||||||
gfxContext.arc(x, y, w, 0, Math.PI * 2);
|
gfxContext.arc(x, y, w, 0, Math.PI * 2);
|
||||||
gfxContext.closePath();
|
gfxContext.closePath();
|
||||||
|
gfxContext.fillStyle = DLM.color;
|
||||||
gfxContext.fill();
|
gfxContext.fill();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -135,20 +141,19 @@ var LibraryDLM = {
|
||||||
str = UTF8ToString(str);
|
str = UTF8ToString(str);
|
||||||
gfxContext.font = DLM.fontSize + 'px sans-serif';
|
gfxContext.font = DLM.fontSize + 'px sans-serif';
|
||||||
if (DLM.fontType == 1) {
|
if (DLM.fontType == 1) {
|
||||||
var f = gfxContext.fillStyle;
|
|
||||||
gfxContext.fillStyle = 'black';
|
gfxContext.fillStyle = 'black';
|
||||||
gfxContext.fillText(str, x, y - 1);
|
gfxContext.fillText(str, x, y - 1);
|
||||||
gfxContext.fillText(str, x, y + 1);
|
gfxContext.fillText(str, x, y + 1);
|
||||||
gfxContext.fillText(str, x - 1, y);
|
gfxContext.fillText(str, x - 1, y);
|
||||||
gfxContext.fillText(str, x + 1, y);
|
gfxContext.fillText(str, x + 1, y);
|
||||||
gfxContext.fillStyle = f;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
gfxContext.fillStyle = DLM.color;
|
||||||
gfxContext.fillText(str, x, y);
|
gfxContext.fillText(str, x, y);
|
||||||
},
|
},
|
||||||
|
|
||||||
setcolor: function(r, g, b) {
|
setcolor: function(r, g, b) {
|
||||||
gfxContext.fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + 255 + ')';
|
DLM.color = 'rgba(' + r + ',' + g + ',' + b + ',' + 255 + ')';
|
||||||
},
|
},
|
||||||
|
|
||||||
setmirror: function(mirror) {
|
setmirror: function(mirror) {
|
||||||
|
@ -223,6 +228,7 @@ var LibraryDLM = {
|
||||||
case 39: buttons |= 2; break;
|
case 39: buttons |= 2; break;
|
||||||
case 40: buttons |= 4; break;
|
case 40: buttons |= 4; break;
|
||||||
case 13: buttons |= 32; break;
|
case 13: buttons |= 32; break;
|
||||||
|
case 32: buttons |= 8; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.type == 'keydown') {
|
if (e.type == 'keydown') {
|
||||||
|
@ -297,7 +303,7 @@ var LibraryDLM = {
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
sound_init: function() {
|
sound_init: function() {
|
||||||
return;
|
//return;
|
||||||
var audioCtx;
|
var audioCtx;
|
||||||
try {
|
try {
|
||||||
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
||||||
|
@ -383,7 +389,7 @@ var LibraryDLM = {
|
||||||
soundstop: function(x) {
|
soundstop: function(x) {
|
||||||
var s = DLM.audioSources[x];
|
var s = DLM.audioSources[x];
|
||||||
if (s) {
|
if (s) {
|
||||||
s.stop();
|
try { s.stop(0); } catch (err) {}
|
||||||
DLM.audioSources[x] = null;
|
DLM.audioSources[x] = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -423,12 +429,9 @@ var LibraryDLM = {
|
||||||
// AD
|
// AD
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
adshow: function() {
|
adshow: function() {
|
||||||
console.log('ADSHOW');
|
|
||||||
var ad = document.getElementById('ad');
|
var ad = document.getElementById('ad');
|
||||||
console.log(ad);
|
|
||||||
if (ad) {
|
if (ad) {
|
||||||
DLM.ad = ad;
|
DLM.ad = ad;
|
||||||
console.log(ad);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -465,6 +468,10 @@ var LibraryDLM = {
|
||||||
if (DLM.ad) {
|
if (DLM.ad) {
|
||||||
DLM.ad.hidden = true;
|
DLM.ad.hidden = true;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
updatescore: function(score, life) {
|
||||||
|
console.log("Score: ", score, life);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
autoAddDeps(LibraryDLM, '$DLM', '$gfxContext');
|
autoAddDeps(LibraryDLM, '$DLM', '$gfxContext');
|
||||||
|
|
69
main.cpp
69
main.cpp
|
@ -1,6 +1,8 @@
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
//#define TEST_MODE
|
||||||
|
|
||||||
void loadg();
|
void loadg();
|
||||||
|
|
||||||
static inline int abs(int v) {
|
static inline int abs(int v) {
|
||||||
|
@ -43,8 +45,10 @@ int stageonoff = 0;
|
||||||
void Mainprogram();
|
void Mainprogram();
|
||||||
void rpaint();
|
void rpaint();
|
||||||
int maint;
|
int maint;
|
||||||
|
|
||||||
byte paused = 0;
|
byte paused = 0;
|
||||||
byte waitpause = 0;
|
byte waitpause = 0;
|
||||||
|
int score = 0;
|
||||||
|
|
||||||
//描画
|
//描画
|
||||||
int grap[161][8], mgrap[51];
|
int grap[161][8], mgrap[51];
|
||||||
|
@ -461,8 +465,6 @@ void rpaint() {
|
||||||
|
|
||||||
|
|
||||||
//g.setFlipMode(Graphics.FLIP_NONE);
|
//g.setFlipMode(Graphics.FLIP_NONE);
|
||||||
//}//muteki
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1034,7 +1036,21 @@ void rpaint() {
|
||||||
|
|
||||||
//drawstringf(10,10,GetColor(255,255,255),"X … %d",anobib[0]);
|
//drawstringf(10,10,GetColor(255,255,255),"X … %d",anobib[0]);
|
||||||
|
|
||||||
} //if (mainproc==1){
|
//score
|
||||||
|
{
|
||||||
|
char buff[128];
|
||||||
|
setfonttype(DX_FONTTYPE_EDGE);
|
||||||
|
setc1();
|
||||||
|
snprintf(buff, sizeof(buff), "SCORE: %d", score);
|
||||||
|
drawstring(10, 5, buff);
|
||||||
|
#ifdef TEST_MODE
|
||||||
|
snprintf(buff, sizeof(buff), "st:%d-%d-%d mainproc:%d", sta, stb, stc, mainproc);
|
||||||
|
drawstring(10, 25, buff);
|
||||||
|
#endif
|
||||||
|
setfonttype(DX_FONTTYPE_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //if (mainproc==1)
|
||||||
|
|
||||||
|
|
||||||
if (mainproc == 2) {
|
if (mainproc == 2) {
|
||||||
|
@ -1326,7 +1342,10 @@ void Mainprogram() {
|
||||||
|
|
||||||
//HPがなくなったとき
|
//HPがなくなったとき
|
||||||
if (mhp <= 0 && mhp >= -9) {
|
if (mhp <= 0 && mhp >= -9) {
|
||||||
mkeytm = 12; mhp = -20; mtype = 200; mtm = 0; soundplay(12); bgmstop(); soundstop(11); soundstop(16);
|
#ifdef TEST_MODE
|
||||||
|
if ((key & PAD_INPUT_CLICK) == 0) mhp = 1; else
|
||||||
|
#endif
|
||||||
|
{mkeytm = 12; mhp = -20; mtype = 200; mtm = 0; soundplay(12); bgmstop(); soundstop(11); soundstop(16);}
|
||||||
} //mhp
|
} //mhp
|
||||||
//if (mhp<=-10){
|
//if (mhp<=-10){
|
||||||
if (mtype == 200) {
|
if (mtype == 200) {
|
||||||
|
@ -1403,6 +1422,7 @@ void Mainprogram() {
|
||||||
stc += 10;
|
stc += 10;
|
||||||
} else {
|
} else {
|
||||||
stc++;
|
stc++;
|
||||||
|
fx = 0;
|
||||||
}
|
}
|
||||||
mb = -80000000;
|
mb = -80000000;
|
||||||
mxtype = 0;
|
mxtype = 0;
|
||||||
|
@ -1455,7 +1475,8 @@ void Mainprogram() {
|
||||||
if (mtype == 301) {
|
if (mtype == 301) {
|
||||||
ending = 1;
|
ending = 1;
|
||||||
} else {
|
} else {
|
||||||
sta++; stb = 0; stc = 0;
|
sta++; stb = 1; stc = 0;
|
||||||
|
zxon = 0; tyuukan = 0; mainproc = 10; maintm = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1512,6 +1533,12 @@ void Mainprogram() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TEST_MODE
|
||||||
|
if (mb > 60000) mb = 60000;
|
||||||
|
if (key & PAD_INPUT_UP) { md = 0; mb -= 1000; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//地面判定初期化
|
//地面判定初期化
|
||||||
mzimen = 0;
|
mzimen = 0;
|
||||||
|
@ -1528,8 +1555,6 @@ void Mainprogram() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//ブロック
|
//ブロック
|
||||||
//1-れんが、コイン、無し、土台、7-隠し
|
//1-れんが、コイン、無し、土台、7-隠し
|
||||||
|
|
||||||
|
@ -3201,9 +3226,11 @@ void Mainprogram() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// update score/
|
||||||
|
if (stc < 5) {
|
||||||
} //if (mainproc==1){
|
score = (sta - 1) * 40000 + (stb - 1) * 10000 + stc * 1000 + fx / 1000;
|
||||||
|
}
|
||||||
|
} //if (mainproc==1)
|
||||||
|
|
||||||
|
|
||||||
//スタッフロール
|
//スタッフロール
|
||||||
|
@ -3248,9 +3275,23 @@ void Mainprogram() {
|
||||||
xx[12 + t] -= 100;
|
xx[12 + t] -= 100;
|
||||||
} //t
|
} //t
|
||||||
|
|
||||||
if (xx[30] == -200) {bgmchange(106); }
|
if (xx[30] <= -400) {
|
||||||
if (xx[30] <= -400) {mainproc = 100; nokori = 2; maintm = 0; ending = 0; }
|
if (ending == 1) {
|
||||||
|
ending = 0;
|
||||||
|
maintm = 2;
|
||||||
|
if (sta == 1) { bgmstop(); soundplay(12); }
|
||||||
|
else {
|
||||||
|
updatescore(score, nokori);
|
||||||
|
mainproc = 100; nokori = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ending == 0) {
|
||||||
|
if (maintm > 140) {
|
||||||
|
maintm = 0; zxon = 0; mainproc = 10; mtm = 0; mkeytm = 0; nokori--;
|
||||||
|
}
|
||||||
|
}
|
||||||
} //mainproc==2
|
} //mainproc==2
|
||||||
|
|
||||||
|
|
||||||
|
@ -3265,6 +3306,7 @@ void Mainprogram() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (maintm == 1) {
|
if (maintm == 1) {
|
||||||
|
updatescore(score, nokori);
|
||||||
adshow();
|
adshow();
|
||||||
waitpause = 1;
|
waitpause = 1;
|
||||||
}
|
}
|
||||||
|
@ -3285,6 +3327,9 @@ void Mainprogram() {
|
||||||
maintm++; xx[0] = 0;
|
maintm++; xx[0] = 0;
|
||||||
if (maintm <= 10) {maintm = 11; sta = 1; stb = 1; stc = 0; over = 0; }
|
if (maintm <= 10) {maintm = 11; sta = 1; stb = 1; stc = 0; over = 0; }
|
||||||
|
|
||||||
|
#ifdef TEST_MODE
|
||||||
|
{sta = 1; stb = 3; stc = 0; }
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
if (input_keydown(KEY_INPUT_1) == 1) {sta = 1; stb = 1; stc = 0; }
|
if (input_keydown(KEY_INPUT_1) == 1) {sta = 1; stb = 1; stc = 0; }
|
||||||
if (input_keydown(KEY_INPUT_2) == 1) {sta = 1; stb = 2; stc = 0; }
|
if (input_keydown(KEY_INPUT_2) == 1) {sta = 1; stb = 2; stc = 0; }
|
||||||
|
|
Loading…
Add table
Reference in a new issue