AD added.

This commit is contained in:
Li Jia 2015-11-01 14:28:46 +08:00
parent 7e0c2825c3
commit c26299320c
4 changed files with 98 additions and 20 deletions

View file

@ -34,9 +34,20 @@
outline: none;
border: none;
}
#ad {
position: absolute;
padding: 0;
margin: 0;
width: 480px;
overflow: hidden;
}
</style>
</head>
<body>
<div id="ad" hidden>
<script type="text/javascript">var cpro_id = "u2379481"</script>
<script src="http://cpro.baidustatic.com/cpro/ui/cm.js" type="text/javascript"></script>
</div>
<canvas id="canvas" width="480" height="640" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>
<textarea id="output" rows="8" readonly></textarea>
<script type='text/javascript'>

10
lib.h
View file

@ -5,19 +5,16 @@ typedef uint8_t byte;
#define TRUE 1
#define FALSE 0
#define DX_FONTTYPE_EDGE (1) // ¥¨¥Ã¥¸¤Ä¤­¥Õ¥©¥ó¥È
#define DX_FONTTYPE_NORMAL (0) // ¥Î©`¥Þ¥ë¥Õ¥©¥ó¥È
#define DX_INPUT_KEY_PAD1 (0x1001) // ¥­©`ÈëÁ¦¤È¥Ñ¥Ã¥É£±ÈëÁ¦
#define PAD_INPUT_LEFT (0x01)
#define PAD_INPUT_RIGHT (0x02)
#define PAD_INPUT_DOWN (0x04)
#define PAD_INPUT_UP (0x08)
#define PAD_INPUT_JUMP (0x10)
#define PAD_INPUT_DECIDE (0x20)
#define PAD_INPUT_CLICK (0x20)
#define PAD_INPUT_ACTION (PAD_INPUT_JUMP | PAD_INPUT_CLICK)
extern "C" {
void input_init();
@ -60,4 +57,7 @@ extern "C" {
int getrand(int value);
int gettime();
void adshow();
void adhide();
}

48
lib.js
View file

@ -417,6 +417,54 @@ var LibraryDLM = {
player.loop = true;
player.play();
},
//------------------------------------------------------------------------------
// AD
//------------------------------------------------------------------------------
adshow: function() {
console.log('ADSHOW');
var ad = document.getElementById('ad');
console.log(ad);
if (ad) {
DLM.ad = ad;
console.log(ad);
}
/*
if (!DLM.ad) {
var ad = document.createElement('DIV');
DLM.ad = ad;
document.body.appendChild(ad);
ad.innerHTML = '<script type="text/javascript">var cpro_id = "u2379481"</script><script src="http://cpro.baidustatic.com/cpro/ui/cm.js" type="text/javascript"></script>';
ad.style.position = 'absolute';
ad.style.color = 'white';
ad.style.padding = '0';
ad.style.margin = '0';
var sc = document.createElement('SCRIPT');
sc.src = "http://cpro.baidustatic.com/cpro/ui/cm.js";
sc.type = "text/javascript";
ad.appendChild(sc);
}
*/
if (DLM.ad) {
var ad = DLM.ad;
var canvas = Module['canvas'];
var rect = canvas.getBoundingClientRect();
ad.style.left = rect.left + 'px';
ad.style.top = rect.top + 'px';
ad.style.width = rect.width + 'px';
ad.style.height = 100;
DLM.ad.hidden = false;
}
},
adhide: function() {
if (DLM.ad) {
DLM.ad.hidden = true;
}
}
};
autoAddDeps(LibraryDLM, '$DLM', '$gfxContext');

View file

@ -43,6 +43,8 @@ int stageonoff = 0;
void Mainprogram();
void rpaint();
int maint;
byte paused = 0;
byte waitpause = 0;
//描画
int grap[161][8], mgrap[51];
@ -998,12 +1000,8 @@ void rpaint() {
if (tmsgtm == 1) {tmsgtm = 80000000; tmsgtype = 2; }
} //1
else if (tmsgtype == 2) {
if (key & (PAD_INPUT_DECIDE | PAD_INPUT_JUMP)) {
paused = 1;
tmsgy = 0; tmsgtype = 3; tmsgtm = 15 + 1;
}
else {
tmsgtm++;
}
} else if (tmsgtype == 3) {
xx[0] = 1200;
tmsgy += xx[0];
@ -1128,12 +1126,15 @@ void Mainprogram() {
stime = time;
if (ending == 1) mainproc = 2;
//キー
key = input_get();
if (paused) {
if (key) paused = 0;
return;
}
if (ending == 1) mainproc = 2;
if (mainproc == 1 && tmsgtype == 0) {
@ -3255,9 +3256,27 @@ void Mainprogram() {
if (mainproc == 10) {
maintm++;
if (fast == 1) maintm += 2;
if (maintm >= 30) {maintm = 0; mainproc = 1; zxon = 0; }
if (nokori == 2) {
if (maintm >= 30) {
maintm = 0; mainproc = 1; zxon = 0;
}
}
else {
if (maintm == 1) {
adshow();
waitpause = 1;
}
if (key) waitpause = 0;
if (maintm == 29) {
if (waitpause) paused = 1;
}
if (maintm >= 30) {
adhide();
maintm = 0; mainproc = 1; zxon = 0;
}
}
} //if (mainproc==10){
@ -3280,7 +3299,7 @@ void Mainprogram() {
*/
//if (CheckHitKeyAll() == 0){end();}
if (key & (PAD_INPUT_DECIDE | PAD_INPUT_JUMP)) { xx[0] = 1; }
if (key & PAD_INPUT_ACTION) { xx[0] = 1; }
//if (input_keydown(KEY_INPUT_RETURN) == 1) {xx[0] = 1; }
//if (input_keydown(KEY_INPUT_SPACE)==1){xx[0]=1;}
//if (input_keydown(KEY_INPUT_Z) == 1) {xx[0] = 1; }