Adds save, score, title screen, etc.

This commit is contained in:
Li Jia 2017-03-01 11:13:35 +08:00
parent c76bd8825b
commit 3d0160ba8a
58 changed files with 1783 additions and 955 deletions

2
.gitignore vendored
View file

@ -1,2 +1,2 @@
.DS_Store
dlm.*
docs/*.map

4
LICENSE Normal file
View file

@ -0,0 +1,4 @@
Files from original project, including C source code, images and sound files are
licensed as original.
Other files is under MIT license.

View file

@ -1,14 +0,0 @@
OPTIONS = -o dlm.js \
-s NO_EXIT_RUNTIME=1 \
--js-library lib.js
SRC = loadg.cpp main.cpp
debug:
emcc -g4 $(OPTIONS) $(SRC)
release:
emcc -O3 -s OUTLINING_LIMIT=2000 --memory-init-file 0 $(OPTIONS) $(SRC)
clean:
rm dlm.js* dlm.data

View file

@ -0,0 +1,7 @@
CAT MARIO
-----------------
The game CatMario, ported to HTML5 for mobile devices.
To play the game, Visit:
[http://tiwb.github.io/catmario/]

View file

@ -1,2 +0,0 @@
call C:\tools\emscripten\emsdk.bat construct_env
call C:\tools\gnuwin32\bin\make.exe %1

22
dlm.sln
View file

@ -1,22 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dlm", "dlm.vcxproj", "{D007FECF-C7E6-40F1-886E-5B065021872B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D007FECF-C7E6-40F1-886E-5B065021872B}.Debug|Win32.ActiveCfg = Debug|Win32
{D007FECF-C7E6-40F1-886E-5B065021872B}.Debug|Win32.Build.0 = Debug|Win32
{D007FECF-C7E6-40F1-886E-5B065021872B}.Release|Win32.ActiveCfg = Release|Win32
{D007FECF-C7E6-40F1-886E-5B065021872B}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View file

@ -1,70 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="loadg.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="lib.h" />
<ClInclude Include="str.h" />
</ItemGroup>
<ItemGroup>
<None Include="index.html" />
<None Include="lib.js" />
<None Include="Makefile" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D007FECF-C7E6-40F1-886E-5B065021872B}</ProjectGuid>
<Keyword>MakeFileProj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(ProjectDir)</OutDir>
<IntDir>$(ProjectDir)</IntDir>
<NMakeBuildCommandLine>build.bat</NMakeBuildCommandLine>
<NMakeCleanCommandLine>build.bat clean</NMakeCleanCommandLine>
<IncludePath>C:\tools\emscripten\emscripten\1.34.1\system\include;C:\tools\emscripten\emscripten\1.34.1\system\include\libc;C:\tools\emscripten\emscripten\1.34.1\system\include\emscripten</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(ProjectDir)</OutDir>
<IntDir>$(ProjectDir)</IntDir>
<NMakeBuildCommandLine>build.bat release</NMakeBuildCommandLine>
<NMakeCleanCommandLine>build.bat clean</NMakeCleanCommandLine>
<IncludePath>C:\tools\emscripten\emscripten\1.34.1\system\include;C:\tools\emscripten\emscripten\1.34.1\system\include\libc;C:\tools\emscripten\emscripten\1.34.1\system\include\emscripten</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="loadg.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="lib.h" />
<ClInclude Include="str.h" />
</ItemGroup>
<ItemGroup>
<None Include="Makefile" />
<None Include="index.html" />
<None Include="lib.js" />
</ItemGroup>
</Project>

354
docs/catmario.css Normal file
View file

@ -0,0 +1,354 @@
html {
height: 100%;
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
body {
font-family: arial;
margin: 0;
padding: 0;
background-color: #5D5C5C;
height: 100%;
user-select: none;
overflow: hidden;
}
btn {
border: 2px solid black;
border-radius: 30px;
padding: 0 40px 0 40px;
background-color: #C3C8C9;
font-size: 28px;
margin: 6px;
padding: 6px 30px;
cursor: pointer;
text-align: center;
}
btn:active {
background-color: #D7DCDD;
}
.left {
text-align: left;
}
.right {
float: right;
text-align: right;
}
#container {
position: relative;
width: 480px;
height: 100%;
max-height:853px;
margin-left: auto;
margin-right: auto;
background-color: #282828;
}
#canvas {
border: 0px none;
outline: none;
padding: 0;
margin-left: auto;
margin-right: auto;
display: block;
width: 100%;
height: 100%;
}
#ad {
position: absolute;
padding: 0;
margin: 0;
width: 480px;
overflow: hidden;
}
#title {
position: absolute;
left:0;
right: 0;
top: 0;
bottom: 0;
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
}
#title header {
flex:1;
display: flex;
flex-direction: column;
justify-content: center;
}
#title content {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
}
#title btn {
width: 200px;
}
#title footer {
line-height: 50px;
font-size: 16px;
text-shadow: 0px 0px 5px #000;
}
#title footer a {
color: white;
text-decoration: none;
}
#settings_window {
height: 450px;
}
#settings_window content {
padding: 25px 95px;
font-size: 26px;
display: flex;
flex-direction: column;
}
#settings_window content div {
margin: 10px;
}
#error {
height: 50%;
}
#error content {
padding: 40px;
}
.mask {
position: fixed;
background-color: rgba(0, 0, 0, 0.5);
width: 100%;
height: 100%;
left: 0;
top: 0;
}
img {
max-width: 100%;
height: auto;
}
figure {
margin: 0;
padding: 10px;
}
figure a {
display: block;
}
mark {
padding: 0 5px;
background-color: #ddd;
}
::backdrop {
background-color: rgba(0, 0, 0, 0.5);
}
.btn {
padding: 10px 45px;
cursor: pointer;
color: #555;
border-width: 1px;
border-style: solid;
border-radius: 3px;
background-color: #f3f3f3;
}
.btn.disabled {
cursor: not-allowed;
color: #ddd;
border-color: #ddd;
}
.btn-group {
padding: 15px 20px;
text-align: right;
background-color: #f5f6f8;
}
.btn-primary {
color: #fff;
border-color: #0066c0;
background-color: #0074d9;
}
.btn-primary:hover {
background-color: #0066c0;
}
.btn-danger {
color: #fff;
font-size: 24px;
border-color: #ab3326;
margin: 8px;
background-color: #c0392b;
}
.start-btn{
width: 210px
}
.setting-btn{
font-size: 18px;
margin: 8px;
width: 200px;
}
.btn-danger:hover {
background-color: #ab3326;
}
.btn-cancel {
color: #999;
border-color: #ddd;
}
.btn-cancel:hover {
background-color: #e6e6e6;
}
.window {
position: absolute;
left: 30px;
top: 30px;
bottom: 30px;
right: 30px;
display: flex;
flex-direction: column;
font-size: 32px;
font-family: 黑体;
width: 416px;
margin: auto;
background-color: #fff;
border-width: 0;
border-radius: 5px;
box-shadow: 0 10px 20px 0 rgba(0, 0, 0, 0.3);
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
.window header {
position: relative;
padding: 8px;
text-align: center;
padding: 12px 20px;
background-color: #434a54;
color: white;
}
.window content {
position: relative;
background-color: #FFF;
flex: 1;
font-size: 22px;
height: 60%;
}
.window footer {
position: relative;
padding: 10px;
background-color: #f5f6f8;
text-align: center;
vertical-align: middle;
}
/**
* Checkbox Four
*/
.checkboxFour {
width: 40px;
height: 40px;
background: #ddd;
margin: 20px 90px;
border-radius: 100%;
position: relative;
-webkit-box-shadow: 0px 1px 3px rgba(0,0,0,0.5);
-moz-box-shadow: 0px 1px 3px rgba(0,0,0,0.5);
box-shadow: 0px 1px 3px rgba(0,0,0,0.5);
float: left;
}
.checkboxFour input{
display: none;
}
.checkboxFourFront{
padding-top: 5px;
}
/**
* Create the checkbox button
*/
.checkboxFour label {
display: block;
width: 30px;
height: 30px;
border-radius: 100px;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
-o-transition: all .5s ease;
-ms-transition: all .5s ease;
transition: all .5s ease;
cursor: pointer;
position: absolute;
top: 5px;
left: 5px;
z-index: 1;
background: #333;
-webkit-box-shadow:inset 0px 1px 3px rgba(0,0,0,0.5);
-moz-box-shadow:inset 0px 1px 3px rgba(0,0,0,0.5);
box-shadow:inset 0px 1px 3px rgba(0,0,0,0.5);
}
/**
* Create the checked state
*/
.checkboxFour input[type=checkbox]:checked + label {
background: #26ca28;
}
.close {
position: absolute;
width: 58px;
height: 54px;
background:#434a54;
opacity:0.5;
display:inline-block;
top: 3px;
right: 3px;
}
.close:hover{
cursor:pointer;
opacity:1;
}
.close::before, .close::after {
content: '';
position: absolute;
width: 80%;
top: 50%;
left: 10%;
height: 12px;
margin-top: -6px;
border-radius: 5px;
background: #ffffff;
}
.close::before {
transform: rotate(45deg);
}
.close::after {
transform: rotate(-45deg);
}

23
docs/catmario.js Normal file

File diff suppressed because one or more lines are too long

BIN
docs/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

75
docs/index.html Normal file
View file

@ -0,0 +1,75 @@
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=480,user-scalable=no" />
<meta name="screen-orientation" content="portrait">
<meta name="x5-orientation" content="portrait">
<title>超级猫里奥</title>
<link rel="stylesheet" href="catmario.css"/>
<script type="text/javascript" src="jquery-3.1.1.min.js"></script>
</head>
<body oncontextmenu="event.preventDefault()">
<div style='display:none'><img src='res/wxicon.jpg'/></div>
<div id="container">
<div id="title" style="display:none">
<header><div><img class="titleimg" src="res/logo.png" /></div></header>
<content>
<button class="btn btn-danger start-btn" id="startgame">开始游戏</button>
<button class="btn btn-danger start-btn" id="settings">游戏设置</button>
</content>
<footer><div><a href="http://tiwb.com">游戏版权归原作者所有</a></div></footer>
</div>
<div id="error" class="window" style="display:none">
<div class="mask"></div>
<header>错误</header>
<content id="error_text"></content>
<footer>
<button class="btn btn-danger start-btn" id="error_close">确定</button>
</footer>
</div>
<div id="settings_window" class="window" style="display:none">
<div class="mask"></div>
<header>设置 <span id ="settings_back" class="close"></span></header>
<content>
<div>
<div class="checkboxFour">
<input type="checkbox" id="settings_se" name="" />
<label for="settings_se"></label>
</div>
<div class="checkboxFourFront">
<label for="settings_se">播放音效</label>
</div>
</div>
<div>
<div class="checkboxFour">
<input type="checkbox" id="settings_bgm" name="" />
<label for="settings_bgm"></label>
</div>
<div class="checkboxFourFront">
<label for="settings_bgm">播放音乐</label>
</div>
</div>
<div>
<div class="checkboxFour">
<input type="checkbox" id="settings_onehand" name="" />
<label for="settings_onehand"></label>
</div>
<div class="checkboxFourFront">
<label for="settings_onehand">单手模式</label>
</div>
</div>
<div>
<button class="btn btn-cancel setting-btn" id="settings_cleardata" >清除游戏数据</button>
</div>
</content>
</div>
<canvas id="canvas" width="480" height="420" tabindex="0"></canvas>
<script type='text/javascript' src="load.js"></script>
<script async type="text/javascript" src="catmario.js"></script>
</div>
</body>
</html>

4
docs/jquery-3.1.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

159
docs/load.js Normal file
View file

@ -0,0 +1,159 @@
var Dlm;
var Module = {
ios: !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
screen: document.getElementById('container'),
canvas: document.getElementById('canvas'),
pause: false,
ready: false,
status: 'loading',
setStatus: function (text) {
Module.status = text;
}
};
window.onerror = function (event) {
$('#error').show();
$('#error_text').text(event);
};
window.onpopstate = function() {
if (history.state == 'title') {
if (Module.ready) Module["_dlm_title"]();
$('#title').show();
$('#settings_window').hide();
Module.pause = false;
}
}
history.replaceState('title', '', location.pathname);
(function (Module) {
var canvas = Module.canvas;
var mainTask = null;
var canvasRect = canvas.getBoundingClientRect();
canvas.height = canvas.width * canvasRect.height / canvasRect.width;
var angle = 0;
function loading() {
if (!Module.dlm && Dlm) {
Module.dlm = Dlm(Module);
}
if (!Module.loading && Module.status == '') {
Module.ready = true;
Module["_dlm_init"]();
Module["_dlm_frame"]();
mainTask = game;
if (Module.autoEnterGame) {
Module.startGame();
}
else {
$('#title').show();
}
return;
}
var ctx = canvas.getContext('2d');
ctx.save();
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.translate(canvas.width / 2, canvas.height / 2);
ctx.font = '20px sans-serif';
ctx.lineWidth = 4;
ctx.strokeStyle = 'white';
ctx.fillStyle = 'white';
ctx.textAlign = 'center';
ctx.textBaseline = 'top';
ctx.globalAlpha = 0.5;
ctx.fillText('加载中...', 0, 40);
var t = Math.PI * 2 * 0.9;
var step = t / 20;
ctx.rotate(angle);
for (var i = 0; i < t; i += step) {
ctx.globalAlpha = i / t * 0.5;
ctx.beginPath();
ctx.arc(0, 0, 20, i, i + step);
ctx.stroke();
}
angle += 0.1;
ctx.restore();
}
function game() {
if (Module.pause === false) {
Module["_dlm_frame"]();
}
}
mainTask = loading;
function runFrame() {
if (mainTask) mainTask();
window.requestAnimationFrame(runFrame);
}
runFrame();
})(Module);
$('#startgame').click(function () {
history.pushState('game', '', location.href);
Module["_dlm_start"]();
$('#title').hide();
$('#canvas').focus();
if (Module.unlockAudio) {
Module.unlockAudio();
Module.unlockAudio = null;
}
});
$('#settings').click(function () {
$('#settings_se').prop('checked', !localStorage.disableSe);
$('#settings_bgm').prop('checked', !localStorage.disableBgm);
$('#settings_onehand').prop('checked', !!localStorage.onehandMode);
$('#settings_window').show();
});
$('#settings_back').click(function () {
$('#settings_window').hide();
});
$('#settings_se').change(function() {
localStorage.setItem('disableSe', $(this).prop('checked') ? '' : '1');
});
$('#settings_bgm').change(function() {
localStorage.setItem('disableBgm', $(this).prop('checked') ? '' : '1');
});
$('#settings_onehand').change(function() {
localStorage.setItem('onehandMode', $(this).prop('checked') ? '1' : '');
});
$('#settings_cleardata').click(function() {
if (confirm('游戏进度将被删除,确定吗?')) {
Module['_dlm_reset']();
}
});
$('#error_close').click(function() {
$('#error').hide();
location.reload();
});
// 不允许屏幕移动
$(function() {
var supportsPassiveOption = false;
try {
addEventListener("test", null, Object.defineProperty({}, 'passive', {
get: function () {
supportsPassiveOption = true;
}
}));
} catch(e) {}
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, supportsPassiveOption ? {
capture: false,
passive: false
} : false);
});

View file

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View file

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View file

Before

Width:  |  Height:  |  Size: 8 KiB

After

Width:  |  Height:  |  Size: 8 KiB

View file

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
docs/res/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View file

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View file

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View file

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View file

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
docs/res/wxicon.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View file

@ -1,131 +0,0 @@
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=480,user-scalable=no" />
<title>变态马里奥</title>
<style>
body {
font-family: arial;
margin: 0;
padding: 0;
background-color: #282828;
}
#canvas {
border: 0px none;
outline: none;
padding: 0;
margin-left: auto;
margin-right: auto;
display: block;
}
#output {
width: 470px;
height: 200px;
margin: 0 auto;
margin-top: 10px;
display: block;
background-color: black;
color: white;
font-family: 'Lucida Console', Monaco, monospace;
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="420" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>
<!--<textarea id="output" rows="8" readonly></textarea>-->
<script type='text/javascript'>
var canvas = document.getElementById('canvas');
var Module = {
preRun: [],
postRun: [],
canvas: canvas,
setStatus: function (text) {
Module.setStatus.text = text;
console.log(text);
},
print: (function () {
var element = document.getElementById('output');
if (element) element.value = '';
return function (text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
console.log(text);
if (element) {
element.value += text + "\n";
element.scrollTop = element.scrollHeight;
}
};
})(),
};
Module.setStatus('Loading...');
window.onerror = function (event) {
document.documentElement.innerHTML = event + event.callstack;
};
if (document.documentElement.clientWidth <= 480) {
var rect = canvas.getBoundingClientRect();
var height = document.documentElement.clientHeight - rect.top;
if (height > 600) {
canvas.height = height;
}
}
var angle = 0;
var drawLoading = function () {
if (Module.setStatus.text == '')
return;
var ctx = canvas.getContext('2d');
ctx.save();
ctx.clearRect(0, 0, 480, 420);
ctx.translate(480 / 2, 420 / 2);
ctx.font = '12px sans-serif';
ctx.lineWidth = 4;
ctx.strokeStyle = 'white';
ctx.fillStyle = 'white';
ctx.textAlign = 'center';
ctx.textBaseline = 'top';
ctx.globalAlpha = 0.5;
ctx.fillText('Loading...', 0, 18);
var t = Math.PI * 2 * 0.9;
var step = t / 20;
ctx.rotate(angle);
for (var i = 0; i < t; i += step) {
ctx.globalAlpha = i / t * 0.5;
ctx.beginPath();
ctx.arc(0, 0, 10, i, i + step);
ctx.stroke();
}
angle += 0.1;
ctx.restore();
window.requestAnimationFrame(drawLoading);
}
drawLoading();
</script>
<script async type="text/javascript" src="dlm.js"></script>
</body>
</html>

194
loadg.cpp
View file

@ -1,194 +0,0 @@
#include "lib.h"
extern int ma, t, tt;
extern int grap[161][8], mgrap[51];
extern int oto[151];
extern int anx[160], any[160];
extern int ne[40], nf[40];
void loadg(void) {
for (t = 0; t < 7; t++) {
mgrap[t] = 0;
}
//画像読み込み
//プレイヤー
mgrap[0] = loadimage("res/player.png");
//ブロック
mgrap[1] = loadimage("res/brock.png");
//アイテム
mgrap[2] = loadimage("res/item.png");
//敵
mgrap[3] = loadimage("res/teki.png");
//背景
mgrap[4] = loadimage("res/haikei.png");
//ブロック2
mgrap[5] = loadimage("res/brock2.png");
//おまけ
mgrap[6] = loadimage("res/omake.png");
//おまけ2
mgrap[7] = loadimage("res/omake2.png");
//タイトル
mgrap[30] = loadimage("res/syobon3.png");
//プレイヤー読み込み
grap[40][0] = subimage(0, 0, 30, 36, mgrap[0]);
grap[0][0] = subimage(31 * 4, 0, 30, 36, mgrap[0]);
grap[1][0] = subimage(31 * 1, 0, 30, 36, mgrap[0]);
grap[2][0] = subimage(31 * 2, 0, 30, 36, mgrap[0]);
grap[3][0] = subimage(31 * 3, 0, 30, 36, mgrap[0]);
grap[41][0] = subimage(50, 0, 51, 73, mgrap[6]);
//ブロック読み込み
for (t = 0; t <= 6; t++) {
grap[t][1] = subimage(33 * t, 0, 30, 30, mgrap[1]);
grap[t + 30][1] = subimage(33 * t, 33, 30, 30, mgrap[1]);
grap[t + 60][1] = subimage(33 * t, 66, 30, 30, mgrap[1]);
}
grap[8][1] = subimage(33 * 7, 0, 30, 30, mgrap[1]);
grap[16][1] = subimage(33 * 6, 0, 24, 27, mgrap[2]);
grap[10][1] = subimage(33 * 9, 0, 30, 30, mgrap[1]);
grap[40][1] = subimage(33 * 9, 33, 30, 30, mgrap[1]);
grap[70][1] = subimage(33 * 9, 66, 30, 30, mgrap[1]);
//ブロック読み込み2
for (t = 0; t <= 6; t++) {
grap[t][5] = subimage(33 * t, 0, 30, 30, mgrap[5]);
}
grap[10][5] = subimage(33 * 1, 33, 30, 30, mgrap[5]);
grap[11][5] = subimage(33 * 2, 33, 30, 30, mgrap[5]);
grap[12][5] = subimage(33 * 0, 66, 30, 30, mgrap[5]);
grap[13][5] = subimage(33 * 1, 66, 30, 30, mgrap[5]);
grap[14][5] = subimage(33 * 2, 66, 30, 30, mgrap[5]);
//アイテム読み込み
for (t = 0; t <= 5; t++) {
grap[t][2] = subimage(33 * t, 0, 30, 30, mgrap[2]);
}
//敵キャラ読み込み
grap[0][3] = subimage(33 * 0, 0, 30, 30, mgrap[3]);
grap[1][3] = subimage(33 * 1, 0, 30, 43, mgrap[3]);
grap[2][3] = subimage(33 * 2, 0, 30, 30, mgrap[3]);
grap[3][3] = subimage(33 * 3, 0, 30, 44, mgrap[3]);
grap[4][3] = subimage(33 * 4, 0, 33, 35, mgrap[3]);
grap[5][3] = subimage(0, 0, 37, 55, mgrap[7]);
grap[6][3] = subimage(38 * 2, 0, 36, 50, mgrap[7]);
grap[150][3] = subimage(38 * 2 + 37 * 2, 0, 36, 50, mgrap[7]);
grap[7][3] = subimage(33 * 6 + 1, 0, 32, 32, mgrap[3]);
grap[8][3] = subimage(38 * 2 + 37 * 3, 0, 37, 47, mgrap[7]);
grap[151][3] = subimage(38 * 3 + 37 * 3, 0, 37, 47, mgrap[7]);
grap[9][3] = subimage(33 * 7 + 1, 0, 26, 30, mgrap[3]);
grap[10][3] = subimage(214, 0, 46, 16, mgrap[6]);
//モララー
grap[30][3] = subimage(0, 56, 30, 36, mgrap[7]);
grap[155][3] = subimage(31 * 3, 56, 30, 36, mgrap[7]);
grap[31][3] = subimage(50, 74, 49, 79, mgrap[6]);
grap[80][3] = subimage(151, 31, 70, 40, mgrap[4]);
grap[81][3] = subimage(151, 72, 70, 40, mgrap[4]);
grap[130][3] = subimage(151 + 71, 72, 70, 40, mgrap[4]);
grap[82][3] = subimage(33 * 1, 0, 30, 30, mgrap[5]);
grap[83][3] = subimage(0, 0, 49, 48, mgrap[6]);
grap[84][3] = subimage(33 * 5 + 1, 0, 30, 30, mgrap[3]);
grap[86][3] = subimage(102, 66, 49, 59, mgrap[6]);
grap[152][3] = subimage(152, 66, 49, 59, mgrap[6]);
grap[90][3] = subimage(102, 0, 64, 63, mgrap[6]);
grap[100][3] = subimage(33 * 1, 0, 30, 30, mgrap[2]);
grap[101][3] = subimage(33 * 7, 0, 30, 30, mgrap[2]);
grap[102][3] = subimage(33 * 3, 0, 30, 30, mgrap[2]);
//grap[104][3] = subimage( 33*2, 0, 30, 30, mgrap[5]) ;
grap[105][3] = subimage(33 * 5, 0, 30, 30, mgrap[2]);
grap[110][3] = subimage(33 * 4, 0, 30, 30, mgrap[2]);
//背景読み込み
grap[0][4] = subimage(0, 0, 150, 90, mgrap[4]);
grap[1][4] = subimage(151, 0, 65, 29, mgrap[4]);
grap[2][4] = subimage(151, 31, 70, 40, mgrap[4]);
grap[3][4] = subimage(0, 91, 100, 90, mgrap[4]);
grap[4][4] = subimage(151, 113, 51, 29, mgrap[4]);
grap[5][4] = subimage(222, 0, 28, 60, mgrap[4]);
grap[6][4] = subimage(151, 143, 90, 40, mgrap[4]);
//中間フラグ
grap[20][4] = subimage(40, 182, 40, 60, mgrap[4]);
//グラ
grap[0][5] = subimage(167, 0, 45, 45, mgrap[6]);
//敵サイズ収得
//int GrHandle=0;
for (t = 0; t <= 140; t++) {
getimagesize(grap[t][3], &anx[t], &any[t]);
anx[t] *= 100; any[t] *= 100;
}
anx[79] = 120 * 100; any[79] = 15 * 100;
anx[85] = 25 * 100; any[85] = 30 * 10 * 100;
//背景サイズ収得
for (t = 0; t < 40; t++) {
getimagesize(grap[t][4], &ne[t], &nf[t]);
//ne[t]*=100;nf[t]*=100;
}
/*
anx[0]=30;any[0]=30;
anx[1]=30;any[1]=43;
anx[2]=30;any[2]=30;
anx[3]=30;any[3]=44;
*/
/*
SetCreateSoundDataType(DX_SOUNDDATATYPE_MEMNOPRESS);
oto[1] = LoadSoundMem("se/jump.mp3");
//oto[2] = LoadSoundMem("se/brockcoin.mp3");
oto[3] = LoadSoundMem("se/brockbreak.mp3");
oto[4] = LoadSoundMem("se/coin.mp3");
oto[5] = LoadSoundMem("se/humi.mp3");
oto[6] = LoadSoundMem("se/koura.mp3");
oto[7] = LoadSoundMem("se/dokan.mp3");
oto[8] = LoadSoundMem("se/brockkinoko.mp3");
oto[9] = LoadSoundMem("se/powerup.mp3");
oto[10] = LoadSoundMem("se/kirra.mp3");
oto[11] = LoadSoundMem("se/goal.mp3");
oto[12] = LoadSoundMem("se/death.mp3");
oto[13] = LoadSoundMem("se/Pswitch.mp3");
oto[14] = LoadSoundMem("se/jumpBlock.mp3");
oto[15] = LoadSoundMem("se/hintBlock.mp3");
oto[16] = LoadSoundMem("se/4-clear.mp3");
oto[17] = LoadSoundMem("se/allclear.mp3");
oto[18] = LoadSoundMem("se/tekifire.mp3");
//}catch( int num){end();}
ChangeVolumeSoundMem(255 * 40 / 100, oto[103]);
*/
//ループ設定-20000-20秒
//SetLoopPosSoundMem( 1,oto[104]) ;
//SetLoopSamplePosSoundMem(44100,oto[104]);
//SetLoopSamplePosSoundMem(22050,oto[104]);
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

16
src/build.bat Normal file
View file

@ -0,0 +1,16 @@
@echo off
if "%1" == "debug" (
set OPTIONS=-g4
) else (
set OPTIONS=-O3 -s OUTLINING_LIMIT=2000
)
set OPTIONS=%OPTIONS% --memory-init-file 0 ^
-s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[] ^
-s EXPORTED_RUNTIME_METHODS=[] ^
-s NO_EXIT_RUNTIME=1 ^
-s NO_BROWSER=1 ^
-s NO_DYNAMIC_EXECUTION=1 ^
-s MODULARIZE=1 ^
-s EXPORT_NAME='Dlm'
emcc %OPTIONS% -o ../docs/catmario.js --js-library lib.js main.cpp

View file

@ -5,8 +5,8 @@ typedef uint8_t byte;
#define TRUE 1
#define FALSE 0
#define DX_FONTTYPE_EDGE (1) // ¥¨¥Ã¥¸¤Ä¤­¥Õ¥©¥ó¥È
#define DX_FONTTYPE_NORMAL (0) // ¥Î©`¥Þ¥ë¥Õ¥©¥ó¥È
#define DX_FONTTYPE_EDGE (1) // <EFBFBD><EFBFBD><EFBFBD>å<EFBFBD><EFBFBD>Ĥ<EFBFBD><EFBFBD>ե<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define DX_FONTTYPE_NORMAL (0) // <EFBFBD>Ω`<60>ޥ<EFBFBD><DEA5>ե<EFBFBD><D5A5><EFBFBD><EFBFBD><EFBFBD>
#define PAD_INPUT_LEFT (0x01)
#define PAD_INPUT_RIGHT (0x02)
@ -17,16 +17,27 @@ typedef uint8_t byte;
#define PAD_INPUT_ACTION (PAD_INPUT_JUMP | PAD_INPUT_CLICK)
extern "C" {
void dlm_init();
void dlm_frame();
void dlm_score(int type, int score);
void dlm_start();
void dlm_reset();
void dlm_title();
int dlm_mainproc();
void input_init();
int input_waitkey(void);
int input_get();
int graphics_init();
void graphics_init();
void begindraw();
void enddraw();
void drawpad();
int getscreenheight();
int loadimage(const char *FileName);
int subimage(int SrcX, int SrcY, int Width, int Height, int SrcGraphHandle);
int subimage(int x, int y, int w, int h, int imgid);
void getimagesize(int GrHandle, int *SizeXBuf, int *SizeYBuf);
void clearscreen();
@ -61,5 +72,4 @@ extern "C" {
void adshow();
void adhide();
void updatescore(int score, int life);
}

View file

@ -1,18 +1,23 @@
//"use strict";
var LibraryDLM = {
$gfxContext: null,
$DLM: {
audioCtx: null,
audioBuffer: [],
audioSources: [],
bgmPlayer: null,
currentBgm: 0,
bgmId: 0,
bgmPlaying: 0,
bgmCurrent: 0,
bgmSource: null,
mirror: false,
images: [],
fontSize: 14,
fontType: 0,
color: 'white',
mouse: 0,
touch: 0,
key: 0,
},
//------------------------------------------------------------------------------
@ -20,10 +25,11 @@ var LibraryDLM = {
//------------------------------------------------------------------------------
graphics_init: function() {
var canvas = Module['canvas'];
gfxContext = canvas.getContext('2d');
gfxContext.textBaseline = 'top';
gfxContext.strokeStyle = 'black';
DLM.images.push(null);
},
getscreenheight: function () {
return Module['canvas'].height;
},
loadimage: function(filename) {
@ -34,8 +40,8 @@ var LibraryDLM = {
img: img,
x: 0,
y: 0,
w: 1,
h: 1,
w: 0,
h: 0,
});
return DLM.images.length - 1;
},
@ -54,13 +60,19 @@ var LibraryDLM = {
getimagesize: function(img, pw, ph) {
var src = DLM.images[img];
setValue(pw, src.w, 'i32');
setValue(ph, src.h, 'i32');
if (src) {
setValue(pw, src.w, 'i32');
setValue(ph, src.h, 'i32');
}
else {
setValue(pw, 0, 'i32');
setValue(ph, 0, 'i32');
}
},
clearscreen: function() {
gfxContext.fillStyle = DLM.color;
gfxContext.fillRect(0, 0, 480, 420);
gfxContext.fillRect(0, 0, 480, Module['canvas'].height);
},
drawline: function(x, y, w, h) {
@ -73,11 +85,15 @@ var LibraryDLM = {
},
drawrect: function(x, y, w, h) {
if (x + w < 0 || x > 480)
return;
gfxContext.strokeStyle = DLM.color;
gfxContext.strokeRect(x, y, w, h);
},
fillrect: function(x, y, w, h) {
if (x + w < 0 || x > 480)
return;
gfxContext.fillStyle = DLM.color;
gfxContext.fillRect(x, y, w, h);
},
@ -103,6 +119,9 @@ var LibraryDLM = {
if (!src)
return;
if (x + src.w < 0 || x > 480)
return;
gfxContext.fillStyle = 'white';
if (DLM.mirror) {
gfxContext.save();
@ -121,6 +140,9 @@ var LibraryDLM = {
if (!src)
return;
if (x + src.w < 0 || x > 480)
return;
gfxContext.fillStyle = 'white';
gfxContext.save();
gfxContext.translate(x, y + src.h);
@ -178,30 +200,44 @@ var LibraryDLM = {
},
begindraw: function() {
var canvas = Module['canvas'];
gfxContext = canvas.getContext('2d');
gfxContext.textBaseline = 'top';
gfxContext.strokeStyle = 'black';
},
enddraw: function() {
},
drawpad : function() {
var canvas = Module['canvas'];
var h = canvas.height;
if (h <= 420)
return;
var drawArrow = function () {
}
gfxContext.clearRect(0, 420, canvas.width, h - 420);
gfxContext.save();
var key = [];
key[0] = (DLM.touch & 1) != 0;
key[1] = (DLM.touch & 8) != 0;
key[2] = (DLM.touch & 2) != 0;
key[3] = (DLM.touch & 4) != 0;
var k = DLM.touch | DLM.mouse;
key[0] = (k & 1) != 0;
key[1] = (k & 8) != 0;
key[2] = (k & 2) != 0;
key[3] = (k & 4) != 0;
gfxContext.fillStyle = 'white';
gfxContext.strokeStyle = 'black';
gfxContext.strokeWidth = 2;
gfxContext.translate(140, 420 + (h - 420) / 2);
var singleHand = localStorage.onehandMode;
if (singleHand) {
key[1] = (k & 0x10) != 0;
gfxContext.translate(240, 420 + (h - 420) / 2);
}
else {
gfxContext.translate(120, 420 + (h - 420) / 2);
}
for (var i = 0; i < 4; i++) {
gfxContext.globalAlpha = key[i] ? 0.6 : 0.3;
gfxContext.beginPath();
@ -216,10 +252,12 @@ var LibraryDLM = {
gfxContext.rotate(Math.PI / 2);
}
gfxContext.setTransform(1, 0, 0, 1, 340, 420 + (h - 420) / 2);
gfxContext.globalAlpha = (DLM.touch & 0x10) != 0 ? 0.6 : 0.3;
gfxContext.fillRect(-40, -40, 80, 80);
gfxContext.strokeRect(-40, -40, 80, 80);
if (!singleHand) {
gfxContext.translate(260, 0);
gfxContext.globalAlpha = (k & 0x10) != 0 ? 0.6 : 0.3;
gfxContext.fillRect(-40, -40, 80, 80);
gfxContext.strokeRect(-40, -40, 80, 80);
}
gfxContext.restore();
},
@ -245,7 +283,7 @@ var LibraryDLM = {
case 39: buttons |= 2; break;
case 40: buttons |= 4; break;
case 13: buttons |= 32; break;
case 32: buttons |= 8; break;
case 32: buttons |= 16; break;
}
if (e.type == 'keydown') {
@ -256,35 +294,62 @@ var LibraryDLM = {
}
};
var mouse_callback = function (e) {
switch (e.type) {
case 'mousedown': DLM.mouse |= 32; break;
case 'mouseup': DLM.mouse &= (~32); break;
}
}
var check_touch = function (x, y, x1, y1, x2, y2) {
return (x > x1 && x < x2 && y > y1 && y < y2);
}
var check_pad = function (px, py) {
var rect = canvas.getBoundingClientRect();
var x = (px - rect.left) / (rect.right - rect.left) * canvas.width;
var y = (py - rect.top) / (rect.bottom - rect.top) * canvas.height;
var touch = 0;
var cy = 420 + (canvas.height - 420) / 2;
var singleHand = localStorage.onehandMode;
if (check_touch(x, y, 0, 0, 480, 420)) {
touch |= 0x20;
} else if (singleHand) {
var cx = 240;
var w1 = 40 * 1.0;
var w2 = 200 * 1.0;
if (check_touch(x, y, cx - w1, cy + w1, cx + w1, cy + w2)) touch |= 4; // down
if (check_touch(x, y, cx - w1, cy - w2, cx + w1, cy - w1)) touch |= 16; // up
if (check_touch(x, y, cx - w2, cy - w1, cx, cy + w1)) touch |= 1; // left
if (check_touch(x, y, cx, cy - w1, cx + w2, cy + w1)) touch |= 2; // right
if (check_touch(x, y, cx - w2, cy - w2, cx - w1, cy - w1)) touch |= (16 | 1); // upleft
if (check_touch(x, y, cx + w1, cy - w2, cx + w2, cy - w1)) touch |= (16 | 2); // upright
if (check_touch(x, y, cx - w2, cy + w1, cx - w1, cy + w2)) touch |= (4 | 1); // downleft
if (check_touch(x, y, cx + w1, cy + w1, cx + w2, cy + w2)) touch |= (4 | 2); // downright
}
else {
var cx = 120;
var w1 = 40;
var w2 = 120;
if (check_touch(x, y, 380 - 80, cy - 80, 380 + 80, cy + 80)) touch |= 0x10; // jump
else if (check_touch(x, y, cx - w1, cy + w1, cx + w1, cy + w2)) touch |= 4; // down
else if (check_touch(x, y, cx - w1, cy - w2, cx + w1, cy - w1)) touch |= 8; // up
else if (check_touch(x, y, cx - w2, cy - w1, cx, cy + w1)) touch |= 1; // left
else if (check_touch(x, y, cx, cy - w1, cx + w2, cy + w1)) touch |= 2; // right
}
return touch;
}
var mouse_callback = function (e) {
DLM.mouse = 0;
if (e.buttons) {
DLM.mouse = check_pad(e.clientX, e.clientY);
}
}
var touch_callback = function (e) {
e.preventDefault();
var touch = 0;
var centerY = 420 + (canvas.height - 420) / 2;
var rect = canvas.getBoundingClientRect();
for (var i = 0; i < e.touches.length; i++) {
var t = e.touches.item(i);
var x = (t.clientX - rect.left) / (rect.right - rect.left) * canvas.width;
var y = (t.clientY - rect.top) / (rect.bottom - rect.top) * canvas.height;
if (check_touch(x, y, 140 - 40, centerY + 20, 140 + 40, centerY + 100)) touch |= 4;
else if (check_touch(x, y, 140 - 40, centerY - 100, 140 + 40, centerY - 40)) touch |= 8;
else if (check_touch(x, y, 140 - 100, centerY - 40, 140, centerY + 40)) touch |= 1;
else if (check_touch(x, y, 140, centerY - 40, 140 + 100, centerY + 40)) touch |= 2;
if (check_touch(x, y, 340 - 100, centerY - 100, 340 + 100, centerY + 100)) touch |= 0x10;
if (check_touch(x, y, 0, 0, 480, 420)) touch |= 0x20;
touch |= check_pad(t.clientX, t.clientY);
}
DLM.touch = touch;
}
@ -293,10 +358,20 @@ var LibraryDLM = {
canvas.addEventListener('keyup', key_callback, true);
canvas.addEventListener('mousedown', mouse_callback, true);
canvas.addEventListener('mouseup', mouse_callback, true);
canvas.addEventListener('mousemove', mouse_callback, true);
canvas.addEventListener('touchstart', touch_callback, true);
canvas.addEventListener('touchend', touch_callback, true);
canvas.addEventListener('touchmove', touch_callback, true);
canvas.addEventListener('touchcancel', touch_callback, true);
if (Module.ios) {
canvas.addEventListener('touchend', function() {
if (Module.unlockAudio) {
Module.unlockAudio();
Module.unlockAudio = null;
}
}, true);
}
},
input_waitkey: function() {
@ -318,15 +393,85 @@ var LibraryDLM = {
//------------------------------------------------------------------------------
// Sound
//------------------------------------------------------------------------------
sound_init: function() {
//return;
Module.unlockAudio = function() {
if (!DLM.audioCtx)
return;
// create empty buffer
var buffer = DLM.audioCtx.createBuffer(1, 1, 22050);
var source = DLM.audioCtx.createBufferSource();
source.buffer = buffer;
// connect to output (your speakers)
source.connect(DLM.audioCtx.destination);
// play the file
source.start(0);
};
DLM.loadAudio = function (id, url, cb) {
if (!DLM.audioCtx)
return;
if (DLM.audioBuffer[id]) {
if (cb) cb(id);
return;
}
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function (e) {
DLM.audioCtx.decodeAudioData(this.response, function (buffer) {
DLM.audioBuffer[id] = buffer;
if (cb) cb(id);
});
};
DLM.audioBuffer[id] = xhr;
xhr.send();
};
DLM.bgmUpdate = function() {
if (!DLM.audioCtx)
return;
if (DLM.bgmPlaying == DLM.bgmCurrent)
return;
// stop current bgm
if (DLM.bgmSource) {
try {DLM.bgmSource.stop(0)} catch (err) {}
DLM.bgmSource = null;
}
if (localStorage.disableBgm)
return;
var buf = DLM.audioBuffer[DLM.bgmPlaying];
if (buf instanceof AudioBuffer) {
var audioCtx = DLM.audioCtx;
var source = audioCtx.createBufferSource();
source.buffer = buf;
source.loop = true;
var gainNode = audioCtx.createGain();
source.connect(gainNode);
gainNode.connect(audioCtx.destination);
gainNode.gain.value = 0.5;
source.start(0);
DLM.bgmSource = source;
DLM.bgmCurrent = DLM.bgmPlaying;
}
}
DLM.loadSe = function() {
DLM.loadAudio(1, 'snd/se1.mp3');
DLM.loadAudio(2, 'snd/se2.mp3');
DLM.loadSe = null;
};
var audioCtx;
try {
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
}
catch (e) {
}
try { audioCtx = new (window.AudioContext || window.webkitAudioContext)(); } catch (e) {}
if (audioCtx) {
DLM.audioCtx = audioCtx;
@ -334,30 +479,31 @@ var LibraryDLM = {
// Old Web Audio API (e.g. Safari 6.0.5) had an inconsistently named createGainNode function.
if (typeof (audioCtx.createGain) === 'undefined') audioCtx.createGain = audioCtx.createGainNode;
var loadAudio = function (id, url) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function (e) {
audioCtx.decodeAudioData(this.response, function (buffer) {
DLM.audioBuffer[id] = buffer;
});
};
xhr.send();
}
loadAudio(1, 'bgm/se1.mp3');
loadAudio(2, 'bgm/se2.mp3');
}
var player = document.createElement("AUDIO");
if (player) {
player.volume = 0.5;
DLM.bgmPlayer = player;
var visibilitychange = function () {
if (document.visibilityState == 'visible') {
audioCtx.resume();
}
else {
audioCtx.suspend();
}
};
document.addEventListener("visibilitychange", visibilitychange);
}
},
soundplay: function(x) {
if (localStorage.disableSe) {
return;
}
var audioCtx = DLM.audioCtx;
if (!audioCtx)
return;
if (DLM.loadSe)
DLM.loadSe();
var i = 0;
var s = 0;
var d = 0;
@ -383,12 +529,8 @@ var LibraryDLM = {
}
if (i > 0) {
var audioCtx = DLM.audioCtx;
if (audioCtx == null)
return;
var buf = DLM.audioBuffer[i];
if (buf) {
if (buf instanceof AudioBuffer) {
var source = audioCtx.createBufferSource();
source.buffer = buf;
source.connect(audioCtx.destination);
@ -416,30 +558,37 @@ var LibraryDLM = {
},
bgmchange: function (x) {
DLM.currentBgm = x;
DLM.bgmId = x;
if (localStorage.disableBgm) {
return;
}
var buf = DLM.audioBuffer[x];
if (!buf) {
var src;
switch (DLM.bgmId) {
case 100: src = "snd/field.mp3"; break;
case 103: src = "snd/dungeon.mp3"; break;
case 104: src = "snd/star4.mp3"; break;
case 105: src = "snd/castle.mp3"; break;
case 106: src = "snd/puyo.mp3"; break;
default: return;
}
DLM.loadAudio(DLM.bgmId, src, function (id) {
DLM.bgmUpdate();
});
}
},
bgmstop: function (x) {
if (DLM.bgmPlayer) {
DLM.bgmPlayer.pause();
}
DLM.bgmPlaying = 0;
DLM.bgmUpdate();
},
bgmplay: function(x) {
var player = DLM.bgmPlayer;
if (!player) return;
switch (DLM.currentBgm) {
case 100: player.src = "bgm/field.mp3"; break;
case 103: player.src = "bgm/dungeon.mp3"; break;
case 104: player.src = "bgm/star4.mp3"; break;
case 105: player.src = "bgm/castle.mp3"; break;
case 106: player.src = "bgm/puyo.mp3"; break;
default: return;
}
player.loop = true;
player.play();
DLM.bgmPlaying = DLM.bgmId;
DLM.bgmCurrent = 0;
DLM.bgmUpdate();
},
//------------------------------------------------------------------------------
@ -450,25 +599,6 @@ var LibraryDLM = {
if (ad) {
DLM.ad = 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'];
@ -487,8 +617,7 @@ var LibraryDLM = {
}
},
updatescore: function(score, life) {
console.log("Score: ", score, life);
dlm_score: function(type, score) {
}
};
autoAddDeps(LibraryDLM, '$DLM', '$gfxContext');

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,13 @@
#ifndef JP
#ifndef JP
#define JP(id, str)
#endif
#ifndef CN
#define CN(id, str)
#endif
JP(IDS_1, "51")
CN(IDS_1, "51")
JP(IDS_2, "ゲームクリアー")
CN(IDS_2, "恭喜您通关了")
@ -12,10 +15,16 @@ JP(IDS_3, "プレイしてくれてありがとー")
CN(IDS_3, "感谢您体验我们的游戏")
JP(IDS_4, "WELCOME TO OWATA ZONE")
CN(IDS_4, "WELCOME TO OWATA ZONE")
CN(IDS_4, "貌似发现了隐藏的关卡")
JP(IDS_SCORE, "SCORE")
CN(IDS_SCORE, "SCORE")
CN(IDS_SCORE, "分数")
JP(IDS_LEVEL, "LEVEL %d-%d")
CN(IDS_LEVEL, "关卡 %d-%d")
JP(IDS_HISCORE, "HISCORE")
CN(IDS_HISCORE, "最高分")
// 碰到云时
JP(IDS_MSG_1, "お、おいしい!!")
@ -264,6 +273,9 @@ CN(IDS_STAFF_19, "感谢您的参与~")
JP(IDS_START, "Enterキーを押せ!!")
CN(IDS_START, "按任意键开始游戏!!")
JP(IDS_STAGE, "Stage %d-%d")
CN(IDS_STAGE, "第 %d-%d 关")
JP(IDS_TMSG_0, "テスト hoge")
CN(IDS_TMSG_0, "Test hoge")
@ -272,11 +284,11 @@ JP(IDS_TMSG_12, "特殊的なものが増えたので")
JP(IDS_TMSG_13, "気をつけてくれよ~")
JP(IDS_TMSG_14, "後、アイテムの一部を利用するかも…")
JP(IDS_TMSG_15, " ちく より")
CN(IDS_TMSG_11, "从这一关开始")
CN(IDS_TMSG_12, "因为特殊的东西增加了")
CN(IDS_TMSG_13, "要当心一点~")
CN(IDS_TMSG_14, "稍后或许可以用道具…")
CN(IDS_TMSG_15, " 作者 ちく")
CN(IDS_TMSG_11, "居然可以通过第一关")
CN(IDS_TMSG_12, "看来有点实力啊")
CN(IDS_TMSG_13, "接下来要当心一点~")
CN(IDS_TMSG_14, "因为真正的挑战才刚刚开始...")
CN(IDS_TMSG_15, " 哇哈哈哈哈")
JP(IDS_TMSG_21, " ?が必要です ")
JP(IDS_TMSG_22, " m9(^Д^)")
@ -285,7 +297,7 @@ CN(IDS_TMSG_22, " m9(^Д^)")
JP(IDS_TMSG_31, " 別にコインに意味ないけどね ")
JP(IDS_TMSG_32, " (・ω・ )ノシ")
CN(IDS_TMSG_31, " 金币什么的毫无意义 ")
CN(IDS_TMSG_31, " 吃再多的金币,也不会增加分数.. ")
CN(IDS_TMSG_32, " (・ω・ )ノシ")
JP(IDS_TMSG_41, "この先に隠しブロックがあります ")
@ -298,7 +310,7 @@ JP(IDS_TMSG_52, " 気楽にプレイしてください")
JP(IDS_TMSG_53, " ちく より")
CN(IDS_TMSG_51, " 比上一关玩难度更低了")
CN(IDS_TMSG_52, " 请随便玩玩吧")
CN(IDS_TMSG_53, " 作者 ちく")
CN(IDS_TMSG_53, " 作者")
JP(IDS_TMSG_61, " そこにいる敵のそばによると、 ")
JP(IDS_TMSG_62, " 自分と一緒にジャンプしてくれます。")
@ -337,7 +349,7 @@ CN(IDS_TMSG_1001, "诶?是我吗? ")
CN(IDS_TMSG_1002, "不是的, 我只是一个路过的提示框")
CN(IDS_TMSG_1003, "不是很奇怪的方块~")
CN(IDS_TMSG_1004, "")
CN(IDS_TMSG_1005, " (…チッ)")
CN(IDS_TMSG_1005, " ")
#undef CN
#undef JP