Use Canvas2D API for drawing.
3
Makefile
|
@ -1,9 +1,8 @@
|
|||
OPTIONS = -o dlm.js \
|
||||
-s NO_EXIT_RUNTIME=1 \
|
||||
--preload-file res \
|
||||
--js-library lib.js
|
||||
|
||||
SRC = dxlib.cpp loadg.cpp main.cpp
|
||||
SRC = loadg.cpp main.cpp
|
||||
|
||||
debug:
|
||||
emcc -g4 $(OPTIONS) $(SRC)
|
||||
|
|
|
@ -11,12 +11,11 @@
|
|||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dxlib.cpp" />
|
||||
<ClCompile Include="loadg.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="dxlib.h" />
|
||||
<ClInclude Include="lib.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="index.html" />
|
||||
|
@ -53,12 +52,14 @@
|
|||
<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>
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="loadg.cpp" />
|
||||
<ClCompile Include="dxlib.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="dxlib.h" />
|
||||
<ClInclude Include="lib.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Makefile" />
|
||||
|
|
820
dxlib.cpp
|
@ -1,820 +0,0 @@
|
|||
#include "dxlib.h"
|
||||
|
||||
#include <GLES2/gl2.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <SDL/SDL_image.h>
|
||||
#include <SDL/SDL_ttf.h>
|
||||
#include <emscripten/html5.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
static Display *x_display = NULL;
|
||||
static EGLDisplay eglDisplay = NULL;
|
||||
static EGLContext eglContext = NULL;
|
||||
static EGLSurface eglSurface = NULL;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// OpenGL util functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
GLuint esLoadShader ( GLenum type, const char *shaderSrc )
|
||||
{
|
||||
GLuint shader;
|
||||
GLint compiled;
|
||||
|
||||
// Create the shader object
|
||||
shader = glCreateShader ( type );
|
||||
|
||||
if ( shader == 0 )
|
||||
return 0;
|
||||
|
||||
// Load the shader source
|
||||
glShaderSource ( shader, 1, &shaderSrc, NULL );
|
||||
|
||||
// Compile the shader
|
||||
glCompileShader ( shader );
|
||||
|
||||
// Check the compile status
|
||||
glGetShaderiv ( shader, GL_COMPILE_STATUS, &compiled );
|
||||
|
||||
if ( !compiled )
|
||||
{
|
||||
GLint infoLen = 0;
|
||||
glGetShaderiv ( shader, GL_INFO_LOG_LENGTH, &infoLen );
|
||||
|
||||
if ( infoLen > 1 && infoLen < 1024)
|
||||
{
|
||||
char infoLog[infoLen];
|
||||
glGetShaderInfoLog ( shader, infoLen, NULL, infoLog );
|
||||
printf ( "Error compiling shader:\n%s\n", infoLog );
|
||||
}
|
||||
|
||||
glDeleteShader ( shader );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return shader;
|
||||
|
||||
}
|
||||
|
||||
GLuint esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc )
|
||||
{
|
||||
GLuint vertexShader;
|
||||
GLuint fragmentShader;
|
||||
GLuint programObject;
|
||||
GLint linked;
|
||||
|
||||
// Load the vertex/fragment shaders
|
||||
vertexShader = esLoadShader ( GL_VERTEX_SHADER, vertShaderSrc );
|
||||
if ( vertexShader == 0 )
|
||||
return 0;
|
||||
|
||||
fragmentShader = esLoadShader ( GL_FRAGMENT_SHADER, fragShaderSrc );
|
||||
if ( fragmentShader == 0 )
|
||||
{
|
||||
glDeleteShader( vertexShader );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create the program object
|
||||
programObject = glCreateProgram ( );
|
||||
|
||||
if ( programObject == 0 )
|
||||
return 0;
|
||||
|
||||
glAttachShader ( programObject, vertexShader );
|
||||
glAttachShader ( programObject, fragmentShader );
|
||||
|
||||
// Link the program
|
||||
glLinkProgram ( programObject );
|
||||
|
||||
// Check the link status
|
||||
glGetProgramiv ( programObject, GL_LINK_STATUS, &linked );
|
||||
|
||||
if ( !linked )
|
||||
{
|
||||
GLint infoLen = 0;
|
||||
|
||||
glGetProgramiv ( programObject, GL_INFO_LOG_LENGTH, &infoLen );
|
||||
|
||||
if ( infoLen > 1 && infoLen < 1024)
|
||||
{
|
||||
char infoLog[infoLen];
|
||||
glGetProgramInfoLog ( programObject, infoLen, NULL, infoLog );
|
||||
printf ( "Error linking program:\n%s\n", infoLog );
|
||||
}
|
||||
|
||||
glDeleteProgram ( programObject );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Free up no longer needed shader resources
|
||||
glDeleteShader ( vertexShader );
|
||||
glDeleteShader ( fragmentShader );
|
||||
|
||||
return programObject;
|
||||
}
|
||||
|
||||
EGLBoolean CrateWindow(int width, int height)
|
||||
{
|
||||
Window root;
|
||||
XSetWindowAttributes swa;
|
||||
Window win;
|
||||
|
||||
/*
|
||||
* X11 native display initialization
|
||||
*/
|
||||
|
||||
x_display = XOpenDisplay(NULL);
|
||||
if ( x_display == NULL )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
root = DefaultRootWindow(x_display);
|
||||
|
||||
swa.event_mask = ExposureMask | PointerMotionMask | KeyPressMask;
|
||||
win = XCreateWindow(
|
||||
x_display, root,
|
||||
0, 0, width, height, 0,
|
||||
CopyFromParent, InputOutput,
|
||||
CopyFromParent, CWEventMask,
|
||||
&swa );
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
EGLBoolean CreateEGLContext (EGLint attribList[])
|
||||
{
|
||||
EGLint numConfigs;
|
||||
EGLint majorVersion;
|
||||
EGLint minorVersion;
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
EGLSurface surface;
|
||||
EGLConfig config;
|
||||
EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
|
||||
|
||||
// Get Display
|
||||
display = eglGetDisplay(EGL_DEFAULT_DISPLAY );
|
||||
if ( display == EGL_NO_DISPLAY )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
// Initialize EGL
|
||||
if ( !eglInitialize(display, &majorVersion, &minorVersion) )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
// Get configs
|
||||
if ( !eglGetConfigs(display, NULL, 0, &numConfigs) )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
// Choose config
|
||||
if ( !eglChooseConfig(display, attribList, &config, 1, &numConfigs) )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
// Create a surface
|
||||
surface = eglCreateWindowSurface(display, config, NULL, NULL);
|
||||
if ( surface == EGL_NO_SURFACE )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
// Create a GL context
|
||||
context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs );
|
||||
if ( context == EGL_NO_CONTEXT )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
// Make the context current
|
||||
if ( !eglMakeCurrent(display, surface, surface, context) )
|
||||
{
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
eglDisplay = display;
|
||||
eglSurface = surface;
|
||||
eglContext = context;
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Input functions
|
||||
//------------------------------------------------------------------------------
|
||||
static byte key_state[256] = {0};
|
||||
static int joypad_state = 0;
|
||||
|
||||
static EM_BOOL key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *userData)
|
||||
{
|
||||
if (e->repeat)
|
||||
return 1;
|
||||
|
||||
if (e->keyCode <= 0 || e->keyCode >= 256)
|
||||
return 1;
|
||||
|
||||
if (eventType == 2) {
|
||||
key_state[e->keyCode] = 1;
|
||||
}
|
||||
else if (eventType == 3) {
|
||||
key_state[e->keyCode] = 0;
|
||||
}
|
||||
|
||||
joypad_state = 0;
|
||||
if (key_state[37]) joypad_state |= PAD_INPUT_LEFT;
|
||||
if (key_state[38]) joypad_state |= PAD_INPUT_UP;
|
||||
if (key_state[39]) joypad_state |= PAD_INPUT_RIGHT;
|
||||
if (key_state[40]) joypad_state |= PAD_INPUT_DOWN;
|
||||
|
||||
/*
|
||||
printf("%d, key: \"%s\", code: \"%s\", location: %lu,%s%s%s%s repeat: %d, locale: \"%s\", char: \"%s\", charCode: %lu, keyCode: %lu, which: %lu\n",
|
||||
eventType, e->key, e->code, e->location,
|
||||
e->ctrlKey ? " CTRL" : "", e->shiftKey ? " SHIFT" : "", e->altKey ? " ALT" : "", e->metaKey ? " META" : "",
|
||||
e->repeat, e->locale, e->charValue, e->charCode, e->keyCode, e->which);
|
||||
*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent *e, void *userData)
|
||||
{
|
||||
if (eventType == 5) {
|
||||
key_state[KEY_INPUT_RETURN] = 1;
|
||||
}
|
||||
else if (eventType == 6) {
|
||||
key_state[KEY_INPUT_RETURN] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
printf("%d, screen: (%ld,%ld), client: (%ld,%ld),%s%s%s%s button: %hu, buttons: %hu, movement: (%ld,%ld), canvas: (%ld,%ld)\n",
|
||||
eventType, e->screenX, e->screenY, e->clientX, e->clientY,
|
||||
e->ctrlKey ? " CTRL" : "", e->shiftKey ? " SHIFT" : "", e->altKey ? " ALT" : "", e->metaKey ? " META" : "",
|
||||
e->button, e->buttons, e->movementX, e->movementY, e->canvasX, e->canvasY);
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
EM_BOOL touch_callback(int eventType, const EmscriptenTouchEvent *e, void *userData)
|
||||
{
|
||||
if (eventType == 22) {
|
||||
key_state[KEY_INPUT_RETURN] = 1;
|
||||
}
|
||||
else if (eventType == 23) {
|
||||
key_state[KEY_INPUT_RETURN] = 0;
|
||||
}
|
||||
/*
|
||||
printf("%d, numTouches: %d %s%s%s%s\n",
|
||||
eventType, e->numTouches,
|
||||
e->ctrlKey ? " CTRL" : "", e->shiftKey ? " SHIFT" : "", e->altKey ? " ALT" : "", e->metaKey ? " META" : "");
|
||||
for(int i = 0; i < e->numTouches; ++i)
|
||||
{
|
||||
const EmscriptenTouchPoint *t = &e->touches[i];
|
||||
printf(" %ld: screen: (%ld,%ld), client: (%ld,%ld), page: (%ld,%ld), isChanged: %d, onTarget: %d, canvas: (%ld, %ld)\n",
|
||||
t->identifier, t->screenX, t->screenY, t->clientX, t->clientY, t->pageX, t->pageY, t->isChanged, t->onTarget, t->canvasX, t->canvasY);
|
||||
}
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void InputInit() {
|
||||
emscripten_set_keydown_callback(0, 0, 1, key_callback);
|
||||
emscripten_set_keyup_callback(0, 0, 1, key_callback);
|
||||
emscripten_set_mousedown_callback(0, 0, 1, mouse_callback);
|
||||
emscripten_set_mouseup_callback(0, 0, 1, mouse_callback);
|
||||
|
||||
emscripten_set_touchstart_callback(0, 0, 1, touch_callback);
|
||||
emscripten_set_touchend_callback(0, 0, 1, touch_callback);
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Graphics functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
static const char vShaderStr[] =
|
||||
"attribute vec4 a_position;\n"
|
||||
"attribute vec2 a_texCoord;\n"
|
||||
"uniform vec4 u_posTrans;\n"
|
||||
"uniform vec4 u_uvTrans;\n"
|
||||
"varying vec2 v_texCoord;\n"
|
||||
"void main() {\n"
|
||||
" vec2 pos = a_position.xy * u_posTrans.zw + u_posTrans.xy;\n"
|
||||
" gl_Position = vec4(pos, 0, 1);\n"
|
||||
" v_texCoord = a_texCoord * u_uvTrans.zw + u_uvTrans.xy;\n"
|
||||
"}\n";
|
||||
|
||||
static const char fShaderStr[] =
|
||||
"precision mediump float;\n"
|
||||
"varying vec2 v_texCoord;\n"
|
||||
"uniform sampler2D s_texture;\n"
|
||||
"uniform vec4 u_color;\n"
|
||||
"void main() {\n"
|
||||
" gl_FragColor = texture2D(s_texture, v_texCoord) * u_color;\n"
|
||||
//" gl_FragColor = vec4(1, 1, 1, 1);\n"
|
||||
"}\n";
|
||||
|
||||
static GLuint programObject = 0;
|
||||
static GLint a_position = 0;
|
||||
static GLint a_texCoord = 0;
|
||||
static GLint u_posTrans = 0;
|
||||
static GLint u_uvTrans = 0;
|
||||
static GLint u_color = 0;
|
||||
static GLint s_texture = 0;
|
||||
|
||||
static GLuint vertexObject = 0;
|
||||
static GLuint indexObject = 0;
|
||||
static GLuint textureId = 0;
|
||||
static GLuint whiteTexture = 0;
|
||||
|
||||
static int screenSizeX = 100;
|
||||
static int screenSizeY = 100;
|
||||
static int transColor = 0;
|
||||
|
||||
struct GraphData {
|
||||
GLint texture;
|
||||
GLint w;
|
||||
GLint h;
|
||||
float x;
|
||||
float y;
|
||||
float sx;
|
||||
float sy;
|
||||
};
|
||||
|
||||
static GraphData graphArray[128] = {0};
|
||||
static int graphLoadId = 1;
|
||||
|
||||
static TTF_Font *font = NULL;
|
||||
|
||||
|
||||
// 画面モードを設定する
|
||||
int SetGraphMode(int ScreenSizeX, int ScreenSizeY, int ColorBitDepth, int RefreshRate) {
|
||||
screenSizeX = ScreenSizeX;
|
||||
screenSizeY = ScreenSizeY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLuint Create1x1Texture(byte r, byte g, byte b, byte a)
|
||||
{
|
||||
// Texture object handle
|
||||
GLuint textureId;
|
||||
|
||||
// 2x2 Image, 3 bytes per pixel (R, G, B)
|
||||
GLubyte pixels[4 * 4] = {
|
||||
r, g, b, a,
|
||||
r, g, b, a,
|
||||
r, g, b, a,
|
||||
r, g, b, a,
|
||||
};
|
||||
|
||||
// Use tightly packed data
|
||||
glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 );
|
||||
|
||||
// Generate a texture object
|
||||
glGenTextures ( 1, &textureId );
|
||||
|
||||
// Bind the texture object
|
||||
glBindTexture ( GL_TEXTURE_2D, textureId );
|
||||
|
||||
// Load the texture
|
||||
glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels );
|
||||
|
||||
// Set the filtering mode
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
|
||||
|
||||
return textureId;
|
||||
}
|
||||
|
||||
|
||||
// ライブラリ初期化関数
|
||||
int DxLib_Init(void) {
|
||||
EGLint attribList[] =
|
||||
{
|
||||
EGL_RED_SIZE, 5,
|
||||
EGL_GREEN_SIZE, 6,
|
||||
EGL_BLUE_SIZE, 5,
|
||||
EGL_ALPHA_SIZE, EGL_DONT_CARE,
|
||||
EGL_DEPTH_SIZE, EGL_DONT_CARE,
|
||||
EGL_STENCIL_SIZE, EGL_DONT_CARE,
|
||||
EGL_SAMPLE_BUFFERS, 0,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
if ( !CrateWindow (screenSizeX, screenSizeY) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( !CreateEGLContext (attribList) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Load the shaders and get a linked program object
|
||||
programObject = esLoadProgram ( vShaderStr, fShaderStr );
|
||||
|
||||
// Get the attribute locations
|
||||
a_position = glGetAttribLocation ( programObject, "a_position" );
|
||||
a_texCoord = glGetAttribLocation ( programObject, "a_texCoord" );
|
||||
u_posTrans = glGetUniformLocation ( programObject, "u_posTrans" );
|
||||
u_uvTrans = glGetUniformLocation ( programObject, "u_uvTrans" );
|
||||
u_color = glGetUniformLocation ( programObject, "u_color" );
|
||||
|
||||
// Get the sampler location
|
||||
s_texture = glGetUniformLocation ( programObject, "s_texture" );
|
||||
|
||||
// Load the texture
|
||||
whiteTexture = Create1x1Texture(255, 255, 255, 255);
|
||||
|
||||
// Setup the vertex data
|
||||
GLfloat vVertices[(20 + 16) * 5] = {
|
||||
// normal
|
||||
0, 0, 0, 0, 0,
|
||||
0, 1, 0, 0, 1,
|
||||
1, 0, 0, 1, 0,
|
||||
1, 1, 0, 1, 1,
|
||||
|
||||
// flip
|
||||
0, 0, 0, 1, 0,
|
||||
0, 1, 0, 1, 1,
|
||||
1, 0, 0, 0, 0,
|
||||
1, 1, 0, 0, 1,
|
||||
|
||||
// flip horizontal
|
||||
0, 0, 0, 0, 1,
|
||||
0, 1, 0, 0, 0,
|
||||
1, 0, 0, 1, 1,
|
||||
1, 1, 0, 1, 0,
|
||||
|
||||
// line loop
|
||||
0, 0, 0, 1, 0,
|
||||
0, 1, 0, 1, 1,
|
||||
1, 1, 0, 0, 1,
|
||||
1, 0, 0, 0, 0,
|
||||
|
||||
// line
|
||||
0, 0, 0, 0, 0,
|
||||
1, 1, 0, 1, 1,
|
||||
|
||||
// not used
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
};
|
||||
GLushort indices[] = { 0, 1, 2, 1, 2, 3 };
|
||||
|
||||
// build circle vertices
|
||||
for (int i = 0; i < 16; i++) {
|
||||
float x = cosf(M_PI * 2 * i / 15);
|
||||
float y = sinf(M_PI * 2 * i / 15);
|
||||
GLfloat *v = vVertices + (20 + i)* 5;
|
||||
v[0] = x;
|
||||
v[1] = y;
|
||||
}
|
||||
|
||||
glGenBuffers(1, &vertexObject);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertexObject );
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vVertices), vVertices, GL_STATIC_DRAW );
|
||||
|
||||
glGenBuffers(1, &indexObject);
|
||||
glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER, indexObject );
|
||||
glBufferData ( GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW );
|
||||
|
||||
// Use the program object
|
||||
glUseProgram ( programObject );
|
||||
|
||||
// Load the vertex position
|
||||
glBindBuffer (GL_ARRAY_BUFFER, vertexObject );
|
||||
glVertexAttribPointer ( a_position, 3, GL_FLOAT, GL_FALSE, 5 * 4, 0 );
|
||||
glVertexAttribPointer ( a_texCoord, 2, GL_FLOAT, GL_FALSE, 5 * 4, (void*)(3 * 4) );
|
||||
|
||||
glEnableVertexAttribArray ( a_position );
|
||||
glEnableVertexAttribArray ( a_texCoord );
|
||||
|
||||
// Bind the texture
|
||||
glActiveTexture ( GL_TEXTURE0 );
|
||||
glBindTexture ( GL_TEXTURE_2D, textureId );
|
||||
|
||||
// Alpha blend
|
||||
glEnable ( GL_BLEND );
|
||||
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
||||
|
||||
// Set the sampler texture unit to 0
|
||||
glUniform1i ( s_texture, 0 );
|
||||
glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER, indexObject );
|
||||
|
||||
// Font
|
||||
font = TTF_OpenFont("sans-serif", 40);
|
||||
|
||||
InputInit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ライブラリ使用の終了関数
|
||||
int DxLib_End(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// 画像ファイルのメモリへの読みこみ
|
||||
int LoadGraph(const char *FileName, int NotUse3DFlag) {
|
||||
if (graphLoadId >= sizeof(graphArray) / sizeof(graphArray[0])) {
|
||||
printf("Too many images.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_Surface *surface = IMG_Load(FileName);
|
||||
if (surface == NULL) {
|
||||
printf("Failed to load image: %s\n", FileName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
byte* data = (byte*)surface->pixels;
|
||||
int size = surface->w * surface->h;
|
||||
while (size > 0) {
|
||||
if (data[0] == 153 && data[1] == 255 && data[2] == 255) {
|
||||
data[3] = 0;
|
||||
}
|
||||
data += 4;
|
||||
size--;
|
||||
}
|
||||
|
||||
GLuint texture = 0;
|
||||
glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 );
|
||||
glGenTextures( 1, &texture );
|
||||
glBindTexture( GL_TEXTURE_2D, texture );
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels );
|
||||
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
|
||||
|
||||
|
||||
GraphData *g = &graphArray[graphLoadId];
|
||||
g->texture = texture;
|
||||
g->w = surface->w;
|
||||
g->h = surface->h;
|
||||
g->x = 0;
|
||||
g->y = 0;
|
||||
g->sx = 1;
|
||||
g->sy = 1;
|
||||
|
||||
return graphLoadId++;
|
||||
}
|
||||
|
||||
// 指定のグラフィックの指定部分だけを抜き出して新たなグラフィックハンドルを作成する
|
||||
int DerivationGraph(int SrcX, int SrcY, int Width, int Height, int SrcGraphHandle) {
|
||||
if (graphLoadId >= sizeof(graphArray) / sizeof(graphArray[0])) {
|
||||
printf("Too many images.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
GraphData *g1 = &graphArray[SrcGraphHandle];
|
||||
GraphData *g = &graphArray[graphLoadId];
|
||||
|
||||
g->texture = g1->texture;
|
||||
g->w = Width;
|
||||
g->h = Height;
|
||||
g->x = (float)SrcX / g1->w;
|
||||
g->y = (float)SrcY / g1->h;
|
||||
g->sx = (float)Width / g1->w;
|
||||
g->sy = (float)Height / g1->h;
|
||||
|
||||
return graphLoadId++;
|
||||
}
|
||||
|
||||
// グラフィックのサイズを得る
|
||||
int GetGraphSize(int GrHandle, int *SizeXBuf, int *SizeYBuf) {
|
||||
GraphData *g = &graphArray[GrHandle];
|
||||
*SizeXBuf = g->w;
|
||||
*SizeYBuf = g->h;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 作成するサウンドのデータ形式を設定する( DX_SOUNDDATATYPE_MEMNOPRESS 等 )
|
||||
int SetCreateSoundDataType(int SoundDataType) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// サウンドデータを追加する
|
||||
int LoadSoundMem(const char *WaveName, int BufferNum, int UnionHandle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// メモリに読みこんだWAVEデータの再生にボリュームを設定する( パーセント指定 )
|
||||
int ChangeVolumeSoundMem(int VolumePal, int SoundHandle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 描画するフォントのサイズをセットする
|
||||
int SetFontSize(int FontSize) {
|
||||
return 0;
|
||||
}
|
||||
// フォントの太さをセット
|
||||
int SetFontThickness(int ThickPal) {
|
||||
return 0;
|
||||
}
|
||||
// 描画先画面のセット
|
||||
int SetDrawScreen(int DrawScreen) {
|
||||
return 0;
|
||||
}
|
||||
// 画面の状態を初期化する
|
||||
int ClearDrawScreen() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 3原色値から現在の画面モードに対応した色データ値を得る
|
||||
uint32_t GetColor(int Red, int Green, int Blue) {
|
||||
byte Alpha = 0xff;
|
||||
return Red | (Green << 8) | (Blue << 16) | (Alpha << 24);
|
||||
}
|
||||
|
||||
// 書式指定文字列を描画する
|
||||
int DrawFormatString(int x, int y, int Color, const char *FormatString, ...) {
|
||||
return 0;
|
||||
}
|
||||
// フォントタイプの変更
|
||||
int ChangeFontType(int FontType) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// キーの入力待ち
|
||||
int WaitKey(void) {
|
||||
return 0;
|
||||
}
|
||||
// 裏画面と表画面を交換する
|
||||
int ScreenFlip(void) {
|
||||
return 0;
|
||||
}
|
||||
// ミリ秒単位の精度を持つカウンタの現在値を得る
|
||||
int GetNowCount(int UseRDTSCFlag) {
|
||||
struct timeval t1;
|
||||
struct timezone tz;
|
||||
gettimeofday(&t1, &tz);
|
||||
return ((t1.tv_sec & 0x0fffffff) * 1000 + (t1.tv_usec) / 1000);
|
||||
}
|
||||
// ジョイバッドの入力状態取得
|
||||
int GetJoypadInputState(int InputType) {
|
||||
return joypad_state;
|
||||
}
|
||||
// メモリに読み込んだWAVEデータの再生を止める
|
||||
int StopSoundMem(int SoundHandle) {
|
||||
return 0;
|
||||
}
|
||||
// メモリに読みこんだWAVEデータを再生する
|
||||
int PlaySoundMem(int SoundHandle, int PlayType, int TopPositionFlag) {
|
||||
return 0;
|
||||
}
|
||||
// キーボードの入力状態取得
|
||||
int CheckHitKey(int KeyCode) {
|
||||
if (KeyCode > 0 && KeyCode < 256) {
|
||||
return key_state[KeyCode];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// 指定の時間だけ処理をとめる
|
||||
int WaitTimer(int WaitTime) {
|
||||
return 0;
|
||||
}
|
||||
// 乱数を取得する( RandMax : 返って来る値の最大値 )
|
||||
int GetRand(int RandMax) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 文字列の描画
|
||||
int DrawString(int x, int y, const char *String, int Color, int EdgeColor) {
|
||||
return 0;
|
||||
}
|
||||
// メモリに読みこんだWAVEデータが再生中か調べる
|
||||
int CheckSoundMem(int SoundHandle) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int color;
|
||||
int mirror;
|
||||
int prevtexture = 0;
|
||||
|
||||
//画像関係
|
||||
//{
|
||||
//色かえ(指定)
|
||||
void setcolor(int red, int green, int blue) {
|
||||
color = GetColor(red, green, blue);
|
||||
}
|
||||
|
||||
void clearscreen() {
|
||||
float r = (color & 0xff) / 255.0f;
|
||||
float g = ((color >> 8) & 0xff) / 255.0f;
|
||||
float b = ((color >> 16) & 0xff) / 255.0f;
|
||||
glClearColor(r, g, b, 1);
|
||||
glClear ( GL_COLOR_BUFFER_BIT );
|
||||
prevtexture = 0;
|
||||
}
|
||||
|
||||
//色かえ(黒)(白)
|
||||
void setc0() {color = GetColor(0, 0, 0); }
|
||||
void setc1() {color = GetColor(255, 255, 255); }
|
||||
|
||||
static void set_texture(int id) {
|
||||
if (prevtexture != id) {
|
||||
prevtexture = id;
|
||||
glBindTexture ( GL_TEXTURE_2D, id );
|
||||
}
|
||||
}
|
||||
|
||||
static void set_transform(float x, float y, float w, float h) {
|
||||
float sx = 2.0f / screenSizeX;
|
||||
float sy = -2.0f / screenSizeY;
|
||||
glUniform4f (u_posTrans, x * sx - 1, y * sy + 1, w * sx, h * sy);
|
||||
}
|
||||
static void set_color(int color) {
|
||||
float r = (color & 0xff) / 255.0f;
|
||||
float g = ((color >> 8) & 0xff) / 255.0f;
|
||||
float b = ((color >> 16) & 0xff) / 255.0f;
|
||||
glUniform4f (u_color, r, g, b, 1);
|
||||
}
|
||||
|
||||
//線
|
||||
void drawline(int x, int y, int w, int h) {
|
||||
set_texture(whiteTexture);
|
||||
set_transform(x, y, w - x, h - y);
|
||||
set_color(color);
|
||||
glDrawArrays(GL_LINES, 16, 2);
|
||||
}
|
||||
|
||||
//四角形(塗り無し)
|
||||
void drawrect(int x, int y, int w, int h) {
|
||||
set_texture(whiteTexture);
|
||||
set_transform(x, y, w, h);
|
||||
set_color(color);
|
||||
|
||||
glDrawArrays(GL_LINE_LOOP, 12, 4);
|
||||
}
|
||||
|
||||
//四角形(塗り有り)
|
||||
void fillrect(int x, int y, int w, int h) {
|
||||
set_texture(whiteTexture);
|
||||
set_transform(x, y, w, h);
|
||||
set_color(color);
|
||||
glDrawArrays ( GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
//円(塗り無し)
|
||||
void drawarc(int x, int y, int w, int h) {
|
||||
set_texture(whiteTexture);
|
||||
set_transform(x, y, w, h);
|
||||
set_color(color);
|
||||
glDrawArrays (GL_LINE_LOOP, 20, 15);
|
||||
}
|
||||
//円(塗り有り)
|
||||
void fillarc(int x, int y, int w, int h) {
|
||||
set_texture(whiteTexture);
|
||||
set_transform(x, y, w, h);
|
||||
set_color(color);
|
||||
glDrawArrays (GL_TRIANGLE_FAN, 20, 15);
|
||||
}
|
||||
|
||||
//画像表示
|
||||
void drawimage(int mx, int x, int y) {
|
||||
GraphData *g = &graphArray[mx];
|
||||
set_texture(g->texture);
|
||||
set_transform(x, y, g->w, g->h);
|
||||
glUniform4f (u_uvTrans, g->x, g->y, g->sx, g->sy);
|
||||
glUniform4f (u_color, 1, 1, 1, 1);
|
||||
|
||||
if (mirror == 0)
|
||||
glDrawArrays ( GL_TRIANGLE_STRIP, 0, 4);
|
||||
if (mirror == 1)
|
||||
glDrawArrays ( GL_TRIANGLE_STRIP, 4, 4);
|
||||
}
|
||||
|
||||
// グラフィックの回転描画
|
||||
void drawimageflip(int mx, int x, int y) {
|
||||
GraphData *g = &graphArray[mx];
|
||||
set_texture(g->texture);
|
||||
set_transform(x, y, g->w, g->h);
|
||||
glUniform4f (u_uvTrans, g->x, g->y, g->sx, g->sy);
|
||||
glUniform4f (u_color, 1, 1, 1, 1);
|
||||
|
||||
glDrawArrays ( GL_TRIANGLE_STRIP, 8, 4);
|
||||
}
|
||||
|
||||
//反転
|
||||
void setre() {} //g.setFlipMode(Graphics.FLIP_HORIZONTAL);}
|
||||
void setre2() {} //g.setFlipMode(Graphics.FLIP_VERTICAL);}
|
||||
void setno() {} //g.setFlipMode(Graphics.FLIP_NONE);}
|
||||
|
122
dxlib.h
|
@ -1,122 +0,0 @@
|
|||
#include <stdint.h>
|
||||
#include <emscripten.h>
|
||||
|
||||
typedef uint8_t byte;
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
|
||||
#define DX_SOUNDDATATYPE_MEMPRESS (2) // 圧縮された全データはシステムメモリに格納され、再生する部分だけ逐次解凍しながらサウンドメモリに格納する(鳴らし終わると解凍したデータは破棄されるので何度も解凍処理が行われる)
|
||||
#define DX_SOUNDDATATYPE_MEMNOPRESS (0) // 圧縮された全データは再生が始まる前にサウンドメモリにすべて解凍され、格納される
|
||||
|
||||
#define DX_SCREEN_BACK (0xfffffffe)
|
||||
#define DX_FONTTYPE_EDGE (1) // エッジつきフォント
|
||||
#define DX_FONTTYPE_NORMAL (0) // ノーマルフォント
|
||||
#define DX_INPUT_KEY_PAD1 (0x1001) // キー入力とパッド1入力
|
||||
|
||||
|
||||
#define DX_PLAYTYPE_LOOPBIT (0x0002) // ループ再生ビット
|
||||
#define DX_PLAYTYPE_BACKBIT (0x0001) // バックグラウンド再生ビット
|
||||
|
||||
#define DX_PLAYTYPE_NORMAL (0) // ノーマル再生
|
||||
#define DX_PLAYTYPE_BACK (DX_PLAYTYPE_BACKBIT) // バックグラウンド再生
|
||||
#define DX_PLAYTYPE_LOOP (DX_PLAYTYPE_LOOPBIT | DX_PLAYTYPE_BACKBIT) // ループ再生
|
||||
|
||||
|
||||
|
||||
#define PAD_INPUT_DOWN (0x00000001)
|
||||
#define PAD_INPUT_LEFT (0x00000002)
|
||||
#define PAD_INPUT_RIGHT (0x00000004)
|
||||
#define PAD_INPUT_UP (0x00000008)
|
||||
|
||||
#define KEY_INPUT_F1 1
|
||||
#define KEY_INPUT_0 48
|
||||
#define KEY_INPUT_1 49
|
||||
#define KEY_INPUT_O 79
|
||||
#define KEY_INPUT_Z 90
|
||||
#define KEY_INPUT_ESCAPE 27
|
||||
#define KEY_INPUT_SPACE 32
|
||||
#define KEY_INPUT_RETURN 13
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 画像ファイルのメモリへの読みこみ
|
||||
extern int LoadGraph(const char *FileName, int NotUse3DFlag = false);
|
||||
|
||||
// 指定のグラフィックの指定部分だけを抜き出して新たなグラフィックハンドルを作成する
|
||||
extern int DerivationGraph(int SrcX, int SrcY, int Width, int Height, int SrcGraphHandle);
|
||||
|
||||
// グラフィックのサイズを得る
|
||||
extern int GetGraphSize(int GrHandle, int *SizeXBuf, int *SizeYBuf);
|
||||
|
||||
// 作成するサウンドのデータ形式を設定する( DX_SOUNDDATATYPE_MEMNOPRESS 等 )
|
||||
extern int SetCreateSoundDataType(int SoundDataType);
|
||||
|
||||
// サウンドデータを追加する
|
||||
extern int LoadSoundMem(const char *WaveName, int BufferNum = 3, int UnionHandle = -1);
|
||||
|
||||
// メモリに読みこんだWAVEデータの再生にボリュームを設定する( パーセント指定 )
|
||||
extern int ChangeVolumeSoundMem(int VolumePal, int SoundHandle);
|
||||
|
||||
// 画面モードを設定する
|
||||
extern int SetGraphMode(int ScreenSizeX, int ScreenSizeY, int ColorBitDepth, int RefreshRate = 60);
|
||||
|
||||
// ライブラリ初期化関数
|
||||
extern int DxLib_Init(void);
|
||||
// ライブラリ使用の終了関数
|
||||
extern int DxLib_End(void);
|
||||
|
||||
|
||||
// 描画するフォントのサイズをセットする
|
||||
extern int SetFontSize(int FontSize);
|
||||
// フォントの太さをセット
|
||||
extern int SetFontThickness(int ThickPal);
|
||||
|
||||
// 3原色値から現在の画面モードに対応した色データ値を得る
|
||||
extern uint32_t GetColor(int Red, int Green, int Blue);
|
||||
|
||||
// 書式指定文字列を描画する
|
||||
extern int DrawFormatString(int x, int y, int Color, const char *FormatString, ...);
|
||||
// グラフィックの回転描画
|
||||
extern void DrawRotaGraph(int x, int y, double ExRate, double Angle, int GrHandle, int TransFlag, int TurnFlag = FALSE);
|
||||
// フォントタイプの変更
|
||||
extern int ChangeFontType(int FontType);
|
||||
|
||||
// キーの入力待ち
|
||||
extern int WaitKey(void);
|
||||
// 裏画面と表画面を交換する
|
||||
extern int ScreenFlip(void);
|
||||
// ミリ秒単位の精度を持つカウンタの現在値を得る
|
||||
extern int GetNowCount(int UseRDTSCFlag = FALSE);
|
||||
// ジョイバッドの入力状態取得
|
||||
extern int GetJoypadInputState(int InputType);
|
||||
// メモリに読み込んだWAVEデータの再生を止める
|
||||
extern int StopSoundMem(int SoundHandle);
|
||||
// メモリに読みこんだWAVEデータを再生する
|
||||
extern int PlaySoundMem(int SoundHandle, int PlayType, int TopPositionFlag = TRUE);
|
||||
// キーボードの入力状態取得
|
||||
extern int CheckHitKey(int KeyCode);
|
||||
// 指定の時間だけ処理をとめる
|
||||
extern int WaitTimer(int WaitTime);
|
||||
// 乱数を取得する( RandMax : 返って来る値の最大値 )
|
||||
extern int GetRand(int RandMax);
|
||||
|
||||
// 点を描画する
|
||||
extern int DrawPixel(int x, int y, int Color);
|
||||
// 線を描画
|
||||
extern int DrawLine(int x1, int y1, int x2, int y2, int Color, int Thickness = 1);
|
||||
// 四角形の描画
|
||||
extern int DrawBox(int x1, int y1, int x2, int y2, int Color, int FillFlag);
|
||||
// 楕円を描く
|
||||
extern int DrawOval(int x, int y, int rx, int ry, int Color, int FillFlag);
|
||||
// グラフィックの描画
|
||||
extern int DrawGraph(int x, int y, int GrHandle, int TransFlag);
|
||||
// 画像の左右反転描画
|
||||
extern int DrawTurnGraph(int x, int y, int GrHandle, int TransFlag);
|
||||
// 文字列の描画
|
||||
extern int DrawString(int x, int y, const char *String, int Color, int EdgeColor = 0);
|
||||
// メモリに読みこんだWAVEデータが再生中か調べる
|
||||
extern int CheckSoundMem(int SoundHandle);
|
14
index.html
|
@ -91,8 +91,11 @@
|
|||
<progress value="0" max="100" id="progress" hidden=1></progress>
|
||||
</div>
|
||||
|
||||
<span><input type="checkbox" id="resize" onchange="Module.enableSound=event.target.value">Sound</span>
|
||||
|
||||
<canvas class="emscripten" id="canvas" width="480" height="420" oncontextmenu="event.preventDefault()"></canvas>
|
||||
<div id="container">
|
||||
<canvas class="emscripten" id="canvas" width="480" height="420" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>
|
||||
</div>
|
||||
<textarea id="output" rows="8"></textarea>
|
||||
|
||||
<script type='text/javascript'>
|
||||
|
@ -129,14 +132,7 @@
|
|||
}
|
||||
},
|
||||
canvas: (function () {
|
||||
var canvas = document.getElementById('canvas');
|
||||
|
||||
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
|
||||
// application robust, you may want to override this behavior before shipping!
|
||||
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
|
||||
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
|
||||
|
||||
return canvas;
|
||||
return document.getElementById('canvas');
|
||||
})(),
|
||||
setStatus: function(text) {
|
||||
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
|
||||
|
|
72
lib.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
#include <stdint.h>
|
||||
#include <emscripten.h>
|
||||
|
||||
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_DOWN (0x00000001)
|
||||
#define PAD_INPUT_LEFT (0x00000002)
|
||||
#define PAD_INPUT_RIGHT (0x00000004)
|
||||
#define PAD_INPUT_UP (0x00000008)
|
||||
|
||||
#define KEY_INPUT_F1 1
|
||||
#define KEY_INPUT_0 48
|
||||
#define KEY_INPUT_1 49
|
||||
#define KEY_INPUT_O 79
|
||||
#define KEY_INPUT_Z 90
|
||||
#define KEY_INPUT_ESCAPE 27
|
||||
#define KEY_INPUT_SPACE 32
|
||||
#define KEY_INPUT_RETURN 13
|
||||
|
||||
|
||||
|
||||
|
||||
extern "C" {
|
||||
void input_init();
|
||||
int input_waitkey(void);
|
||||
int input_keydown(int keycode);
|
||||
int input_getjoypad();
|
||||
|
||||
int graphics_init();
|
||||
|
||||
int loadimage(const char *FileName);
|
||||
int subimage(int SrcX, int SrcY, int Width, int Height, int SrcGraphHandle);
|
||||
void getimagesize(int GrHandle, int *SizeXBuf, int *SizeYBuf);
|
||||
|
||||
void clearscreen();
|
||||
void drawline(int a, int b, int c, int d);
|
||||
void drawrect(int a, int b, int c, int d);
|
||||
void fillrect(int a, int b, int c, int d);
|
||||
void drawarc(int a, int b, int c, int d);
|
||||
void fillarc(int a, int b, int c, int d);
|
||||
|
||||
void setcolor(int red, int green, int blue);
|
||||
void setc0();
|
||||
void setc1();
|
||||
void setmirror(int mirror);
|
||||
void drawimage(int mx, int a, int b);
|
||||
void drawimageflip(int mx, int a, int b);
|
||||
|
||||
void setfont(int x, int y);
|
||||
int setfonttype(int FontType);
|
||||
int drawstring(int x, int y, const char *String);
|
||||
|
||||
void sound_init();
|
||||
void soundplay(int x);
|
||||
void soundstop(int x);
|
||||
int soundcheck(int x);
|
||||
void bgmchange(int x);
|
||||
void bgmplay();
|
||||
void bgmstop();
|
||||
|
||||
int getrand(int value);
|
||||
int gettime();
|
||||
}
|
202
lib.js
|
@ -1,16 +1,214 @@
|
|||
//"use strict";
|
||||
|
||||
var LibraryDLM = {
|
||||
$gfxContext: null,
|
||||
$DLM: {
|
||||
audioCtx: null,
|
||||
audioBuffer: [],
|
||||
audioSources: [],
|
||||
bgmPlayer: null,
|
||||
currentBgm: 0,
|
||||
mirror: false,
|
||||
images: [],
|
||||
fontSize: 14,
|
||||
fontType: 0,
|
||||
},
|
||||
|
||||
sound_init: function() {
|
||||
//------------------------------------------------------------------------------
|
||||
// Graphics
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
graphics_init: function() {
|
||||
var canvas = Module['canvas'];
|
||||
gfxContext = canvas.getContext('2d');
|
||||
gfxContext.textBaseline = 'top';
|
||||
gfxContext.strokeStyle = 'black';
|
||||
},
|
||||
|
||||
loadimage: function(filename) {
|
||||
filename = UTF8ToString(filename);
|
||||
var img = new Image();
|
||||
img.src = filename;
|
||||
DLM.images.push({
|
||||
img: img,
|
||||
x: 0,
|
||||
y: 0,
|
||||
w: 1,
|
||||
h: 1,
|
||||
});
|
||||
return DLM.images.length - 1;
|
||||
},
|
||||
|
||||
subimage: function(x, y, w, h, img) {
|
||||
var src = DLM.images[img];
|
||||
DLM.images.push({
|
||||
img: src.img,
|
||||
x: x,
|
||||
y: y,
|
||||
w: w,
|
||||
h: h
|
||||
});
|
||||
return DLM.images.length - 1;
|
||||
},
|
||||
|
||||
getimagesize: function(img, pw, ph) {
|
||||
var src = DLM.images[img];
|
||||
setValue(pw, src.w, 'i32');
|
||||
setValue(ph, src.h, 'i32');
|
||||
},
|
||||
|
||||
clearscreen: function() {
|
||||
gfxContext.fillRect(0, 0, 480, 420);
|
||||
},
|
||||
|
||||
drawline: function(x, y, w, h) {
|
||||
gfxContext.beginPath();
|
||||
gfxContext.moveTo(x, y);
|
||||
gfxContext.lineTo(w, h);
|
||||
gfxContext.closePath();
|
||||
gfxContext.stroke();
|
||||
},
|
||||
|
||||
drawrect: function(x, y, w, h) {
|
||||
gfxContext.strokeRect(x, y, w, h);
|
||||
},
|
||||
|
||||
fillrect: function(x, y, w, h) {
|
||||
gfxContext.fillRect(x, y, w, h);
|
||||
},
|
||||
|
||||
drawarc: function(x, y, w, h) {
|
||||
gfxContext.lineWidth = 0.5;
|
||||
gfxContext.strokeStyle = 'black';
|
||||
gfxContext.arc(x, y, w, 0, Math.PI * 2);
|
||||
gfxContext.stroke();
|
||||
},
|
||||
|
||||
fillarc: function(x, y, w, h) {
|
||||
gfxContext.beginPath();
|
||||
gfxContext.arc(x, y, w, 0, Math.PI * 2);
|
||||
gfxContext.closePath();
|
||||
gfxContext.fill();
|
||||
},
|
||||
|
||||
|
||||
drawimage: function(img, x, y) {
|
||||
var src = DLM.images[img];
|
||||
if (!src)
|
||||
return;
|
||||
|
||||
gfxContext.fillStyle = 'white';
|
||||
if (DLM.mirror) {
|
||||
gfxContext.save();
|
||||
gfxContext.translate(x + src.w, y);
|
||||
gfxContext.scale(-1, 1);
|
||||
gfxContext.drawImage(src.img, src.x, src.y, src.w, src.h, 0, 0, src.w, src.h);
|
||||
gfxContext.restore();
|
||||
}
|
||||
else {
|
||||
gfxContext.drawImage(src.img, src.x, src.y, src.w, src.h, x, y, src.w, src.h);
|
||||
}
|
||||
},
|
||||
|
||||
drawimageflip: function(img, x, y) {
|
||||
var src = DLM.images[img];
|
||||
if (!src)
|
||||
return;
|
||||
|
||||
gfxContext.fillStyle = 'white';
|
||||
gfxContext.save();
|
||||
gfxContext.translate(x, y + src.h);
|
||||
gfxContext.scale(1, -1);
|
||||
gfxContext.drawImage(src.img, src.x, src.y, src.w, src.h, 0, 0, src.w, src.h);
|
||||
gfxContext.restore();
|
||||
},
|
||||
|
||||
setfont: function (size, thick) {
|
||||
DLM.fontSize = size;
|
||||
},
|
||||
|
||||
setfonttype: function(type) {
|
||||
DLM.fontType = type;
|
||||
},
|
||||
|
||||
drawstring: function(x, y, str) {
|
||||
str = UTF8ToString(str);
|
||||
gfxContext.font = DLM.fontSize + 'px sans-serif';
|
||||
if (DLM.fontType == 1) {
|
||||
var f = gfxContext.fillStyle;
|
||||
gfxContext.fillStyle = 'black';
|
||||
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.fillStyle = f;
|
||||
|
||||
}
|
||||
gfxContext.fillText(str, x, y);
|
||||
},
|
||||
|
||||
setcolor: function(r, g, b) {
|
||||
gfxContext.fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + 255 + ')';
|
||||
},
|
||||
|
||||
setmirror: function(mirror) {
|
||||
DLM.mirror = (mirror != 0);
|
||||
},
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Input
|
||||
//------------------------------------------------------------------------------
|
||||
input_init: function() {
|
||||
var canvas = Module['canvas'];
|
||||
var keydown_callback = function (e) {
|
||||
e.preventDefault();
|
||||
if (e.repeat)
|
||||
return;
|
||||
|
||||
if (e.type == 'keydown') {
|
||||
DLM.keyboard[e.keyCode] = 1;
|
||||
}
|
||||
else if (e.type == 'keyup') {
|
||||
DLM.keyboard[e.keyCode] = 0;
|
||||
}
|
||||
};
|
||||
canvas.addEventListener('keydown', keydown_callback, true);
|
||||
canvas.addEventListener('keyup', keydown_callback, true);
|
||||
DLM.keyboard = [];
|
||||
},
|
||||
|
||||
input_waitkey: function() {
|
||||
},
|
||||
|
||||
input_keydown: function(key) {
|
||||
return DLM.keyboard[key] | 0;
|
||||
},
|
||||
|
||||
input_getjoypad: function() {
|
||||
joypad = 0;
|
||||
var key = DLM.keyboard;
|
||||
if (key[37]) joypad |= 2;
|
||||
if (key[38]) joypad |= 8;
|
||||
if (key[39]) joypad |= 4;
|
||||
if (key[40]) joypad |= 1;
|
||||
|
||||
return joypad;
|
||||
},
|
||||
|
||||
getrand: function(maxValue) {
|
||||
return Math.floor(Math.random() * maxValue);
|
||||
},
|
||||
|
||||
gettime: function() {
|
||||
var t = new Date().getTime();
|
||||
return t % 0xfffffff;
|
||||
},
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Sound
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
sound_init: function() {
|
||||
var audioCtx;
|
||||
try {
|
||||
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
||||
|
@ -129,5 +327,5 @@ var LibraryDLM = {
|
|||
player.play();
|
||||
}
|
||||
};
|
||||
autoAddDeps(LibraryDLM, '$DLM');
|
||||
autoAddDeps(LibraryDLM, '$DLM', '$gfxContext');
|
||||
mergeInto(LibraryManager.library, LibraryDLM);
|
||||
|
|
168
loadg.cpp
|
@ -1,7 +1,4 @@
|
|||
#include "DxLib.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void end();
|
||||
#include "lib.h"
|
||||
|
||||
extern int ma, t, tt;
|
||||
extern int grap[161][8], mgrap[51];
|
||||
|
@ -10,140 +7,125 @@ extern int oto[151];
|
|||
extern int anx[160], any[160];
|
||||
extern int ne[40], nf[40];
|
||||
|
||||
extern "C" {
|
||||
void sound_init();
|
||||
}
|
||||
|
||||
void loadg(void) {
|
||||
|
||||
for (t = 0; t < 7; t++) {
|
||||
mgrap[t] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
for (t=0;t<161;t++){
|
||||
for (tt=0;tt<8;tt++){
|
||||
grap[t][tt]=0;
|
||||
}}
|
||||
*/
|
||||
|
||||
//ma-=100;//mb==5000;
|
||||
//end();
|
||||
|
||||
|
||||
//画像読み込み
|
||||
|
||||
//プレイヤー
|
||||
mgrap[0] = LoadGraph("res/player.png");
|
||||
mgrap[0] = loadimage("res/player.png");
|
||||
//ブロック
|
||||
mgrap[1] = LoadGraph("res/brock.png");
|
||||
mgrap[1] = loadimage("res/brock.png");
|
||||
//アイテム
|
||||
mgrap[2] = LoadGraph("res/item.png");
|
||||
mgrap[2] = loadimage("res/item.png");
|
||||
//敵
|
||||
mgrap[3] = LoadGraph("res/teki.png");
|
||||
mgrap[3] = loadimage("res/teki.png");
|
||||
//背景
|
||||
mgrap[4] = LoadGraph("res/haikei.png");
|
||||
mgrap[4] = loadimage("res/haikei.png");
|
||||
//ブロック2
|
||||
mgrap[5] = LoadGraph("res/brock2.png");
|
||||
mgrap[5] = loadimage("res/brock2.png");
|
||||
//おまけ
|
||||
mgrap[6] = LoadGraph("res/omake.png");
|
||||
mgrap[6] = loadimage("res/omake.png");
|
||||
//おまけ2
|
||||
mgrap[7] = LoadGraph("res/omake2.png");
|
||||
mgrap[7] = loadimage("res/omake2.png");
|
||||
//タイトル
|
||||
mgrap[30] = LoadGraph("res/syobon3.png");
|
||||
mgrap[30] = loadimage("res/syobon3.png");
|
||||
|
||||
|
||||
//プレイヤー読み込み
|
||||
grap[40][0] = DerivationGraph(0, 0, 30, 36, mgrap[0]);
|
||||
grap[0][0] = DerivationGraph(31 * 4, 0, 30, 36, mgrap[0]);
|
||||
grap[1][0] = DerivationGraph(31 * 1, 0, 30, 36, mgrap[0]);
|
||||
grap[2][0] = DerivationGraph(31 * 2, 0, 30, 36, mgrap[0]);
|
||||
grap[3][0] = DerivationGraph(31 * 3, 0, 30, 36, mgrap[0]);
|
||||
grap[41][0] = DerivationGraph(50, 0, 51, 73, mgrap[6]);
|
||||
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] = DerivationGraph(33 * t, 0, 30, 30, mgrap[1]);
|
||||
grap[t + 30][1] = DerivationGraph(33 * t, 33, 30, 30, mgrap[1]);
|
||||
grap[t + 60][1] = DerivationGraph(33 * t, 66, 30, 30, mgrap[1]);
|
||||
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] = DerivationGraph(33 * 7, 0, 30, 30, mgrap[1]);
|
||||
grap[16][1] = DerivationGraph(33 * 6, 0, 24, 27, mgrap[2]);
|
||||
grap[10][1] = DerivationGraph(33 * 9, 0, 30, 30, mgrap[1]);
|
||||
grap[40][1] = DerivationGraph(33 * 9, 33, 30, 30, mgrap[1]);
|
||||
grap[70][1] = DerivationGraph(33 * 9, 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] = DerivationGraph(33 * t, 0, 30, 30, mgrap[5]);
|
||||
grap[t][5] = subimage(33 * t, 0, 30, 30, mgrap[5]);
|
||||
}
|
||||
grap[10][5] = DerivationGraph(33 * 1, 33, 30, 30, mgrap[5]);
|
||||
grap[11][5] = DerivationGraph(33 * 2, 33, 30, 30, mgrap[5]);
|
||||
grap[12][5] = DerivationGraph(33 * 0, 66, 30, 30, mgrap[5]);
|
||||
grap[13][5] = DerivationGraph(33 * 1, 66, 30, 30, mgrap[5]);
|
||||
grap[14][5] = DerivationGraph(33 * 2, 66, 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] = DerivationGraph(33 * t, 0, 30, 30, mgrap[2]);
|
||||
grap[t][2] = subimage(33 * t, 0, 30, 30, mgrap[2]);
|
||||
}
|
||||
|
||||
//敵キャラ読み込み
|
||||
grap[0][3] = DerivationGraph(33 * 0, 0, 30, 30, mgrap[3]);
|
||||
grap[1][3] = DerivationGraph(33 * 1, 0, 30, 43, mgrap[3]);
|
||||
grap[2][3] = DerivationGraph(33 * 2, 0, 30, 30, mgrap[3]);
|
||||
grap[3][3] = DerivationGraph(33 * 3, 0, 30, 44, mgrap[3]);
|
||||
grap[4][3] = DerivationGraph(33 * 4, 0, 33, 35, mgrap[3]);
|
||||
grap[5][3] = DerivationGraph(0, 0, 37, 55, mgrap[7]);
|
||||
grap[6][3] = DerivationGraph(38 * 2, 0, 36, 50, mgrap[7]);
|
||||
grap[150][3] = DerivationGraph(38 * 2 + 37 * 2, 0, 36, 50, mgrap[7]);
|
||||
grap[7][3] = DerivationGraph(33 * 6 + 1, 0, 32, 32, mgrap[3]);
|
||||
grap[8][3] = DerivationGraph(38 * 2 + 37 * 3, 0, 37, 47, mgrap[7]);
|
||||
grap[151][3] = DerivationGraph(38 * 3 + 37 * 3, 0, 37, 47, mgrap[7]);
|
||||
grap[9][3] = DerivationGraph(33 * 7 + 1, 0, 26, 30, mgrap[3]);
|
||||
grap[10][3] = DerivationGraph(214, 0, 46, 16, mgrap[6]);
|
||||
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] = DerivationGraph(0, 56, 30, 36, mgrap[7]);
|
||||
grap[155][3] = DerivationGraph(31 * 3, 56, 30, 36, mgrap[7]);
|
||||
grap[31][3] = DerivationGraph(50, 74, 49, 79, 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] = DerivationGraph(151, 31, 70, 40, mgrap[4]);
|
||||
grap[81][3] = DerivationGraph(151, 72, 70, 40, mgrap[4]);
|
||||
grap[130][3] = DerivationGraph(151 + 71, 72, 70, 40, mgrap[4]);
|
||||
grap[82][3] = DerivationGraph(33 * 1, 0, 30, 30, mgrap[5]);
|
||||
grap[83][3] = DerivationGraph(0, 0, 49, 48, mgrap[6]);
|
||||
grap[84][3] = DerivationGraph(33 * 5 + 1, 0, 30, 30, mgrap[3]);
|
||||
grap[86][3] = DerivationGraph(102, 66, 49, 59, mgrap[6]);
|
||||
grap[152][3] = DerivationGraph(152, 66, 49, 59, 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] = DerivationGraph(102, 0, 64, 63, mgrap[6]);
|
||||
grap[90][3] = subimage(102, 0, 64, 63, mgrap[6]);
|
||||
|
||||
grap[100][3] = DerivationGraph(33 * 1, 0, 30, 30, mgrap[2]);
|
||||
grap[101][3] = DerivationGraph(33 * 7, 0, 30, 30, mgrap[2]);
|
||||
grap[102][3] = DerivationGraph(33 * 3, 0, 30, 30, mgrap[2]);
|
||||
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] = DerivationGraph( 33*2, 0, 30, 30, mgrap[5]) ;
|
||||
grap[105][3] = DerivationGraph(33 * 5, 0, 30, 30, mgrap[2]);
|
||||
grap[110][3] = DerivationGraph(33 * 4, 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] = DerivationGraph(0, 0, 150, 90, mgrap[4]);
|
||||
grap[1][4] = DerivationGraph(151, 0, 65, 29, mgrap[4]);
|
||||
grap[2][4] = DerivationGraph(151, 31, 70, 40, mgrap[4]);
|
||||
grap[3][4] = DerivationGraph(0, 91, 100, 90, mgrap[4]);
|
||||
grap[4][4] = DerivationGraph(151, 113, 51, 29, mgrap[4]);
|
||||
grap[5][4] = DerivationGraph(222, 0, 28, 60, mgrap[4]);
|
||||
grap[6][4] = DerivationGraph(151, 143, 90, 40, mgrap[4]);
|
||||
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] = DerivationGraph(40, 182, 40, 60, mgrap[4]);
|
||||
grap[20][4] = subimage(40, 182, 40, 60, mgrap[4]);
|
||||
|
||||
|
||||
//グラ
|
||||
grap[0][5] = DerivationGraph(167, 0, 45, 45, mgrap[6]);
|
||||
grap[0][5] = subimage(167, 0, 45, 45, mgrap[6]);
|
||||
|
||||
|
||||
|
||||
|
@ -156,7 +138,7 @@ void loadg(void) {
|
|||
//敵サイズ収得
|
||||
//int GrHandle=0;
|
||||
for (t = 0; t <= 140; t++) {
|
||||
GetGraphSize(grap[t][3], &anx[t], &any[t]);
|
||||
getimagesize(grap[t][3], &anx[t], &any[t]);
|
||||
anx[t] *= 100; any[t] *= 100;
|
||||
}
|
||||
anx[79] = 120 * 100; any[79] = 15 * 100;
|
||||
|
@ -164,7 +146,7 @@ void loadg(void) {
|
|||
|
||||
//背景サイズ収得
|
||||
for (t = 0; t < 40; t++) {
|
||||
GetGraphSize(grap[t][4], &ne[t], &nf[t]);
|
||||
getimagesize(grap[t][4], &ne[t], &nf[t]);
|
||||
//ne[t]*=100;nf[t]*=100;
|
||||
}
|
||||
|
||||
|
@ -178,8 +160,6 @@ void loadg(void) {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
SetCreateSoundDataType(DX_SOUNDDATATYPE_MEMNOPRESS);
|
||||
oto[1] = LoadSoundMem("se/jump.mp3");
|
||||
|
@ -211,6 +191,4 @@ void loadg(void) {
|
|||
//SetLoopPosSoundMem( 1,oto[104]) ;
|
||||
//SetLoopSamplePosSoundMem(44100,oto[104]);
|
||||
//SetLoopSamplePosSoundMem(22050,oto[104]);
|
||||
|
||||
sound_init();
|
||||
}
|
||||
|
|
235
main.cpp
|
@ -1,5 +1,4 @@
|
|||
#include "DxLib.h"
|
||||
#include <stdio.h>
|
||||
#include "lib.h"
|
||||
#include <math.h>
|
||||
|
||||
void loadg();
|
||||
|
@ -45,43 +44,8 @@ void Mainprogram();
|
|||
void rpaint();
|
||||
int maint;
|
||||
|
||||
|
||||
//サブクラス
|
||||
//(ウエイト系
|
||||
static void wait(int interval);
|
||||
static void wait2(long stime, long etime, int FLAME_TIME);
|
||||
static int rand(int Rand);
|
||||
void end();
|
||||
|
||||
//描画
|
||||
extern int color;
|
||||
extern int mirror;
|
||||
void setfont(int a);
|
||||
void setcolor(int red, int green, int blue);
|
||||
void clearscreen();
|
||||
void setc0();
|
||||
void setc1();
|
||||
void drawpixel(int a, int b);
|
||||
void drawline(int a, int b, int c, int d);
|
||||
void drawrect(int a, int b, int c, int d);
|
||||
void fillrect(int a, int b, int c, int d);
|
||||
void drawarc(int a, int b, int c, int d);
|
||||
void fillarc(int a, int b, int c, int d);
|
||||
int grap[161][8], mgrap[51];
|
||||
void drawimage(int mx, int a, int b);
|
||||
void drawimageflip(int mx, int a, int b);
|
||||
void setre();
|
||||
void setre2();
|
||||
void setno();
|
||||
|
||||
extern "C" {
|
||||
void bgmchange(int x);
|
||||
void bgmplay();
|
||||
void bgmstop();
|
||||
void soundplay(int x);
|
||||
void soundstop(int x);
|
||||
int soundcheck(int x);
|
||||
}
|
||||
|
||||
//文字
|
||||
void str(const char* c, int a, int b);
|
||||
|
@ -154,7 +118,6 @@ int titem[tmax], txtype[tmax];
|
|||
//メッセージブロック
|
||||
int tmsgtm, tmsgtype, tmsgx, tmsgy, tmsgnobix, tmsgnobiy, tmsg;
|
||||
void ttmsg(); void txmsg(const char* x, int a);
|
||||
void setfont(int x, int y);
|
||||
|
||||
//効果を持たないグラ
|
||||
void eyobi(int xa, int xb, int xc, int xd, int xe, int xf, int xnobia, int xnobib, int xgtype, int xtm);
|
||||
|
@ -237,19 +200,13 @@ long stime;
|
|||
|
||||
// プログラムは WinMain から始まります
|
||||
int main() {
|
||||
//画面サイズ設定
|
||||
SetGraphMode(fxmax / 100, fymax / 100, 16);
|
||||
|
||||
// DXライブラリ初期化処理(エラーが起きたら直ちに終了)
|
||||
if (DxLib_Init() == -1) return -1;
|
||||
graphics_init();
|
||||
sound_init();
|
||||
input_init();
|
||||
|
||||
//全ロード
|
||||
loadg();
|
||||
|
||||
//フォント
|
||||
SetFontSize(16);
|
||||
SetFontThickness(4);
|
||||
|
||||
// Main loop
|
||||
emscripten_set_main_loop(Mainprogram, 0, 1);
|
||||
|
||||
|
@ -302,14 +259,15 @@ void rpaint() {
|
|||
drawimage(grap[ntype[t]][4], xx[0] / 100 - 5, xx[1] / 100);
|
||||
|
||||
//51
|
||||
setcolor(255, 255, 255);
|
||||
if (ntype[t] == 100) {
|
||||
DrawFormatString(xx[0] / 100 + fma1, xx[1] / 100 + fmb, GetColor(255, 255, 255), "51");
|
||||
drawstring(xx[0] / 100 + fma1, xx[1] / 100 + fmb, "51");
|
||||
}
|
||||
|
||||
if (ntype[t] == 101)
|
||||
DrawFormatString(xx[0] / 100 + fma1, xx[1] / 100 + fmb, GetColor(255, 255, 255), "ゲームクリアー");
|
||||
drawstring(xx[0] / 100 + fma1, xx[1] / 100 + fmb, "ゲームクリアー");
|
||||
if (ntype[t] == 102)
|
||||
DrawFormatString(xx[0] / 100 + fma1, xx[1] / 100 + fmb, GetColor(255, 255, 255), "プレイしてくれてありがとー");
|
||||
drawstring(xx[0] / 100 + fma1, xx[1] / 100 + fmb, "プレイしてくれてありがとー");
|
||||
|
||||
}
|
||||
} //t
|
||||
|
@ -339,9 +297,9 @@ void rpaint() {
|
|||
|
||||
//リフトの破片
|
||||
if (egtype[t] == 2 || egtype[t] == 3) {
|
||||
if (egtype[t] == 3) mirror = 1;
|
||||
if (egtype[t] == 3) setmirror(1);
|
||||
drawimage(grap[0][5], xx[0] / 100, xx[1] / 100);
|
||||
mirror = 0;
|
||||
setmirror(0);
|
||||
}
|
||||
|
||||
//ポール
|
||||
|
@ -472,10 +430,10 @@ void rpaint() {
|
|||
|
||||
//プレイヤー描画
|
||||
setcolor(0, 0, 255);
|
||||
//mirror=1;
|
||||
//setmirror(1);
|
||||
|
||||
if (mactp >= 2000) {mactp -= 2000; if (mact == 0) {mact = 1; } else {mact = 0; }}
|
||||
if (mmuki == 0) mirror = 1;
|
||||
if (mmuki == 0) setmirror(1);
|
||||
|
||||
if (mtype != 200 && mtype != 1) {
|
||||
if (mzimen == 1) {
|
||||
|
@ -495,7 +453,7 @@ void rpaint() {
|
|||
drawimage(grap[3][0], ma / 100, mb / 100);
|
||||
}
|
||||
|
||||
mirror = 0;
|
||||
setmirror(0);
|
||||
|
||||
//drawrect(ma/100,mb/100,30,36);
|
||||
|
||||
|
@ -506,7 +464,7 @@ void rpaint() {
|
|||
|
||||
|
||||
|
||||
//for (t=0;t<bmax;t++){DrawFormatString((ba[t]-fx)/100+40,(bb[t]-fy)/100,GetColor(250,250,250),"%d",t);}
|
||||
//for (t=0;t<bmax;t++){drawstringf((ba[t]-fx)/100+40,(bb[t]-fy)/100,GetColor(250,250,250),"%d",t);}
|
||||
|
||||
//敵キャラ
|
||||
for (t = 0; t < amax; t++) {
|
||||
|
@ -515,10 +473,10 @@ void rpaint() {
|
|||
xx[2] = anobia[t] / 100; xx[3] = anobib[t] / 100; xx[14] = 3000; xx[16] = 0;
|
||||
if (xx[0] + xx[2] * 100 >= -10 - xx[14] && xx[1] <= fxmax + xx[14] && xx[1] + xx[3] * 100 >= -10 && xx[3] <= fymax) {
|
||||
//if (atype[t]>=100)amuki[t]=0;
|
||||
if (amuki[t] == 1) {mirror = 1; }
|
||||
if (amuki[t] == 1) {setmirror(1); }
|
||||
if (atype[t] == 3 && axtype[t] == 1) {drawimageflip(grap[atype[t]][3], xx[0] / 100, xx[1] / 100); xx[16] = 1; }
|
||||
if (atype[t] == 9 && ad[t] >= 1) {drawimageflip(grap[atype[t]][3], xx[0] / 100, xx[1] / 100); xx[16] = 1; }
|
||||
if (atype[t] >= 100 && amuki[t] == 1) mirror = 0;
|
||||
if (atype[t] >= 100 && amuki[t] == 1) setmirror(0);
|
||||
|
||||
//tekikaki(atype[t]);
|
||||
|
||||
|
@ -526,7 +484,7 @@ void rpaint() {
|
|||
//drawrect(xx[0]/100,xx[1]/100,30,30);
|
||||
|
||||
|
||||
//DrawFormatString(xx[0]/100+40,xx[1]/100,GetColor(0,0,0),"%d",axzimen[t]);
|
||||
//drawstringf(xx[0]/100+40,xx[1]/100,GetColor(0,0,0),"%d",axzimen[t]);
|
||||
//drawstring(grap[atype[t]][3],xx[0]/100,xx[1]/100);
|
||||
|
||||
|
||||
|
@ -628,7 +586,7 @@ void rpaint() {
|
|||
drawimage(grap[0][3], xx[0] / 100, xx[1] / 100);
|
||||
|
||||
|
||||
mirror = 0;
|
||||
setmirror(0);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1020,10 +978,10 @@ void rpaint() {
|
|||
|
||||
//setc0();
|
||||
//str(xs[0],xx[5]-1,xx[6]-1);str(xs[0],xx[5]+1,xx[6]+1);
|
||||
ChangeFontType(DX_FONTTYPE_EDGE);
|
||||
setfonttype(DX_FONTTYPE_EDGE);
|
||||
setc1();
|
||||
str(xs[0], xx[5], xx[6]);
|
||||
ChangeFontType(DX_FONTTYPE_NORMAL);
|
||||
setfonttype(DX_FONTTYPE_NORMAL);
|
||||
|
||||
|
||||
} //amsgtm
|
||||
|
@ -1044,7 +1002,7 @@ void rpaint() {
|
|||
} else if (tmsgtype == 3) {
|
||||
xx[0] = 1200;
|
||||
tmsgy += xx[0];
|
||||
if (tmsgtm == 15) WaitKey();
|
||||
if (tmsgtm == 15) input_waitkey();
|
||||
if (tmsgtm == 1) {tmsgtm = 0; tmsgtype = 0; tmsgy = 0; }
|
||||
} //1
|
||||
|
||||
|
@ -1055,8 +1013,9 @@ void rpaint() {
|
|||
//メッセージ
|
||||
if (mainmsgtype >= 1) {
|
||||
setfont(20, 4);
|
||||
if (mainmsgtype == 1) {DrawFormatString(126, 100, GetColor(255, 255, 255), "WELCOME TO OWATA ZONE"); }
|
||||
if (mainmsgtype == 1) {for (t2 = 0; t2 <= 2; t2++) DrawFormatString(88 + t2 * 143, 210, GetColor(255, 255, 255), "1"); }
|
||||
setcolor(255, 255, 255);
|
||||
if (mainmsgtype == 1) {drawstring(126, 100, "WELCOME TO OWATA ZONE"); }
|
||||
if (mainmsgtype == 1) {for (t2 = 0; t2 <= 2; t2++) drawstring(88 + t2 * 143, 210, "1"); }
|
||||
setfont(20, 5);
|
||||
} //mainmsgtype>=1
|
||||
|
||||
|
@ -1071,7 +1030,7 @@ void rpaint() {
|
|||
|
||||
} //blacktm
|
||||
|
||||
//DrawFormatString(10,10,GetColor(255,255,255),"X … %d",anobib[0]);
|
||||
//drawstringf(10,10,GetColor(255,255,255),"X … %d",anobib[0]);
|
||||
|
||||
} //if (mainproc==1){
|
||||
|
||||
|
@ -1108,11 +1067,13 @@ void rpaint() {
|
|||
setc0();
|
||||
fillrect(0, 0, fxmax, fymax);
|
||||
|
||||
SetFontSize(16);
|
||||
SetFontThickness(4);
|
||||
setfont(16, 4);
|
||||
|
||||
drawimage(grap[0][0], 190, 190);
|
||||
DrawFormatString(230, 200, GetColor(255, 255, 255), " × %d", nokori);
|
||||
setcolor(255, 255, 255);
|
||||
char buff[256];
|
||||
snprintf(buff, sizeof(buff), " x %d", nokori);
|
||||
drawstring(230, 200, buff);
|
||||
|
||||
|
||||
} //if (mainproc==10){
|
||||
|
@ -1144,9 +1105,7 @@ void rpaint() {
|
|||
|
||||
|
||||
|
||||
//DrawFormatString(230,200,GetColor(255,255,255)," × %d,%d,%d",sta,stb,stc);
|
||||
|
||||
ScreenFlip();
|
||||
//drawstringf(230,200,GetColor(255,255,255)," × %d,%d,%d",sta,stb,stc);
|
||||
|
||||
} //rpaint()
|
||||
|
||||
|
@ -1159,7 +1118,7 @@ void rpaint() {
|
|||
|
||||
//メインプログラム
|
||||
void Mainprogram() {
|
||||
int time = GetNowCount();
|
||||
int time = gettime();
|
||||
if (time - stime < 1000 / 30)
|
||||
return;
|
||||
|
||||
|
@ -1169,7 +1128,7 @@ void Mainprogram() {
|
|||
|
||||
|
||||
//キー
|
||||
key = GetJoypadInputState(DX_INPUT_KEY_PAD1);
|
||||
key = input_getjoypad();
|
||||
|
||||
|
||||
if (mainproc == 1 && tmsgtype == 0) {
|
||||
|
@ -1204,19 +1163,19 @@ void Mainprogram() {
|
|||
|
||||
//ランダムにさせる
|
||||
if (over == 1) {
|
||||
//for (t=0;t<;t++){na[t]=rand(300000);nb[t]=rand(3000);}
|
||||
//for (t=0;t<;t++){na[t]=getrand(300000);nb[t]=getrand(3000);}
|
||||
for (t = 0; t < tmax; t++) {
|
||||
if (rand(3) <= 1) {
|
||||
ta[t] = (rand(500) - 1) * 29 * 100; tb[t] = rand(14) * 100 * 29 - 1200; ttype[t] = rand(142); if (ttype[t] >= 9 && ttype[t] <= 99) {
|
||||
ttype[t] = rand(8);
|
||||
if (getrand(3) <= 1) {
|
||||
ta[t] = (getrand(500) - 1) * 29 * 100; tb[t] = getrand(14) * 100 * 29 - 1200; ttype[t] = getrand(142); if (ttype[t] >= 9 && ttype[t] <= 99) {
|
||||
ttype[t] = getrand(8);
|
||||
}
|
||||
txtype[t] = rand(4);
|
||||
txtype[t] = getrand(4);
|
||||
}
|
||||
}
|
||||
for (t = 0; t < bmax; t++) {
|
||||
if (rand(2) <= 1) {
|
||||
ba[t] = (rand(500) - 1) * 29 * 100; bb[t] = rand(15) * 100 * 29 - 1200 - 3000; if (rand(6) == 0) {
|
||||
btype[t] = rand(9);
|
||||
if (getrand(2) <= 1) {
|
||||
ba[t] = (getrand(500) - 1) * 29 * 100; bb[t] = getrand(15) * 100 * 29 - 1200 - 3000; if (getrand(6) == 0) {
|
||||
btype[t] = getrand(9);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1224,7 +1183,7 @@ void Mainprogram() {
|
|||
srco = 0;
|
||||
t = srco; sra[t] = ma + fx; srb[t] = (13 * 29 - 12) * 100; src[t] = 30 * 100; srtype[t] = 0; sracttype[t] = 0; sre[t] = 0; srsp[t] = 0; srco++;
|
||||
|
||||
if (rand(4) == 0) stagecolor = rand(4);
|
||||
if (getrand(4) == 0) stagecolor = getrand(4);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1234,7 +1193,7 @@ void Mainprogram() {
|
|||
|
||||
} //zxon
|
||||
|
||||
//xx[1]=rand(100);
|
||||
//xx[1]=getrand(100);
|
||||
|
||||
|
||||
|
||||
|
@ -1250,20 +1209,20 @@ void Mainprogram() {
|
|||
if (key & PAD_INPUT_DOWN) {actaon[3] = 1; }
|
||||
}
|
||||
|
||||
//if (CheckHitKey(KEY_INPUT_F1)==1){end();}
|
||||
if (CheckHitKey(KEY_INPUT_F1) == 1) {mainproc = 100; }
|
||||
//if (CheckHitKey(KEY_INPUT_Q)==1){mkeytm=0;}
|
||||
if (CheckHitKey(KEY_INPUT_O) == 1) {if (mhp >= 1) mhp = 0; if (stc >= 5) {stc = 0; stagepoint = 0; }}
|
||||
//if (input_keydown(KEY_INPUT_F1)==1){end();}
|
||||
//if (input_keydown(KEY_INPUT_F1) == 1) {mainproc = 100; }
|
||||
//if (input_keydown(KEY_INPUT_Q)==1){mkeytm=0;}
|
||||
//if (input_keydown(KEY_INPUT_O) == 1) {if (mhp >= 1) mhp = 0; if (stc >= 5) {stc = 0; stagepoint = 0; }}
|
||||
|
||||
|
||||
if (mkeytm <= 0) {
|
||||
if (key & PAD_INPUT_UP || CheckHitKey(KEY_INPUT_Z) == 1) { //end();
|
||||
if (key & PAD_INPUT_UP) { //end();
|
||||
if (actaon[1] == 10) {actaon[1] = 1; xx[0] = 1; }
|
||||
actaon[2] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (key & PAD_INPUT_UP || CheckHitKey(KEY_INPUT_Z) == 1) {
|
||||
if (key & PAD_INPUT_UP) {
|
||||
if (mjumptm == 8 && md >= -900) {
|
||||
md = -1300;
|
||||
//ダッシュ中
|
||||
|
@ -2149,7 +2108,7 @@ void Mainprogram() {
|
|||
sr[t]++;
|
||||
if (sr[t] >= sgtype[t]) {
|
||||
sr[t] = 0;
|
||||
ayobi(sa[t], 30000, rand(600) - 300, -1600 - rand(900), 0, 84, 0);
|
||||
ayobi(sa[t], 30000, getrand(600) - 300, -1600 - getrand(900), 0, 84, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2861,7 +2820,7 @@ void Mainprogram() {
|
|||
|
||||
case 6:
|
||||
atm[t]+=1;xx[10]=0;
|
||||
if (axtype[t]==1)atm[t]+=(rand(9)-4);
|
||||
if (axtype[t]==1)atm[t]+=(getrand(9)-4);
|
||||
if (axtype[t]==2)xx[10]=100;
|
||||
if (atm[t]>=40){
|
||||
xx[22]=360;if (amuki[t]==0)xx[22]=-xx[22];
|
||||
|
@ -2889,9 +2848,9 @@ void Mainprogram() {
|
|||
|
||||
if (atm[t]>=xx[15]){
|
||||
for (t3=0;t3<=xx[17];t3++){
|
||||
xx[16]=300;xx[22]=rand(xx[16])*5/4-xx[16]/4;
|
||||
xx[16]=300;xx[22]=getrand(xx[16])*5/4-xx[16]/4;
|
||||
a2tm[t]+=1;if (a2tm[t]>=1){xx[22]=-xx[22];a2tm[t]=-1;}
|
||||
cyobi(aa[t]+amuki[t]*anobia[t]/2,ab[t]+600,xx[22],-400-rand(600),0,80,1,60);
|
||||
cyobi(aa[t]+amuki[t]*anobia[t]/2,ab[t]+600,xx[22],-400-getrand(600),0,80,1,60);
|
||||
//if ((xx[16]==0) || t3==xx[16])atm[t]=0;
|
||||
}//t
|
||||
atm[t]=0;
|
||||
|
@ -3070,11 +3029,11 @@ void Mainprogram() {
|
|||
if (mhp == 0) {
|
||||
|
||||
if (atype[t] == 0 || atype[t] == 7) {
|
||||
amsgtm[t] = 60; amsgtype[t] = rand(7) + 1 + 1000 + (stb - 1) * 10;
|
||||
amsgtm[t] = 60; amsgtype[t] = getrand(7) + 1 + 1000 + (stb - 1) * 10;
|
||||
}
|
||||
|
||||
if (atype[t] == 1) {
|
||||
amsgtm[t] = 60; amsgtype[t] = rand(2) + 15;
|
||||
amsgtm[t] = 60; amsgtype[t] = getrand(2) + 15;
|
||||
}
|
||||
|
||||
if (atype[t] == 2 && axtype[t] >= 1 && mmutekitm <= 0) {
|
||||
|
@ -3086,7 +3045,7 @@ void Mainprogram() {
|
|||
}
|
||||
|
||||
if (atype[t] == 4) {
|
||||
amsgtm[t] = 60; amsgtype[t] = rand(7) + 1 + 1000 + (stb - 1) * 10;
|
||||
amsgtm[t] = 60; amsgtype[t] = getrand(7) + 1 + 1000 + (stb - 1) * 10;
|
||||
}
|
||||
|
||||
if (atype[t] == 5) {
|
||||
|
@ -3109,7 +3068,7 @@ void Mainprogram() {
|
|||
}
|
||||
|
||||
if (atype[t] == 82) {
|
||||
amsgtm[t] = 20; amsgtype[t] = rand(1) + 31;
|
||||
amsgtm[t] = 20; amsgtype[t] = getrand(1) + 31;
|
||||
xx[24] = 900; atype[t] = 83; aa[t] -= xx[24] + 100; ab[t] -= xx[24] - 100 * 0;
|
||||
} //82
|
||||
|
||||
|
@ -3118,7 +3077,7 @@ void Mainprogram() {
|
|||
}
|
||||
|
||||
if (atype[t] == 85) {
|
||||
amsgtm[t] = 60; amsgtype[t] = rand(1) + 85;
|
||||
amsgtm[t] = 60; amsgtype[t] = getrand(1) + 85;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3247,8 +3206,8 @@ void Mainprogram() {
|
|||
maintm++;
|
||||
|
||||
xx[7] = 46;
|
||||
if (CheckHitKey(KEY_INPUT_1) == 1) {end(); }
|
||||
if (CheckHitKey(KEY_INPUT_SPACE) == 1) {
|
||||
//if (input_keydown(KEY_INPUT_1) == 1) {end(); }
|
||||
if (input_keydown(KEY_INPUT_SPACE) == 1) {
|
||||
for (t = 0; t <= xx[7]; t += 1) {
|
||||
xx[12 + t] -= 300;
|
||||
}
|
||||
|
@ -3304,23 +3263,22 @@ void Mainprogram() {
|
|||
if (maintm <= 10) {maintm = 11; sta = 1; stb = 1; stc = 0; over = 0; }
|
||||
|
||||
/*
|
||||
if (CheckHitKey(KEY_INPUT_1) == 1) {sta = 1; stb = 1; stc = 0; }
|
||||
if (CheckHitKey(KEY_INPUT_2) == 1) {sta = 1; stb = 2; stc = 0; }
|
||||
if (CheckHitKey(KEY_INPUT_3) == 1) {sta = 1; stb = 3; stc = 0; }
|
||||
if (CheckHitKey(KEY_INPUT_4) == 1) {sta = 1; stb = 4; stc = 0; }
|
||||
if (CheckHitKey(KEY_INPUT_5) == 1) {sta = 2; stb = 1; stc = 0; }
|
||||
if (CheckHitKey(KEY_INPUT_6) == 1) {sta = 2; stb = 2; stc = 0; }
|
||||
if (CheckHitKey(KEY_INPUT_7) == 1) {sta = 2; stb = 3; stc = 0; }
|
||||
if (CheckHitKey(KEY_INPUT_8) == 1) {sta = 2; stb = 4; 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_3) == 1) {sta = 1; stb = 3; stc = 0; }
|
||||
if (input_keydown(KEY_INPUT_4) == 1) {sta = 1; stb = 4; stc = 0; }
|
||||
if (input_keydown(KEY_INPUT_5) == 1) {sta = 2; stb = 1; stc = 0; }
|
||||
if (input_keydown(KEY_INPUT_6) == 1) {sta = 2; stb = 2; stc = 0; }
|
||||
if (input_keydown(KEY_INPUT_7) == 1) {sta = 2; stb = 3; stc = 0; }
|
||||
if (input_keydown(KEY_INPUT_8) == 1) {sta = 2; stb = 4; stc = 0; }
|
||||
if (input_keydown(KEY_INPUT_9) == 1) {sta = 3; stb = 1; stc = 0; }
|
||||
if (input_keydown(KEY_INPUT_0) == 1) {xx[0] = 1; over = 1; }
|
||||
*/
|
||||
//if (CheckHitKey(KEY_INPUT_9)==1){sta=3;stb=1;stc=0;}
|
||||
if (CheckHitKey(KEY_INPUT_0) == 1) {xx[0] = 1; over = 1; }
|
||||
|
||||
|
||||
//if (CheckHitKeyAll() == 0){end();}
|
||||
if (CheckHitKey(KEY_INPUT_RETURN) == 1) {xx[0] = 1; }
|
||||
//if (CheckHitKey(KEY_INPUT_SPACE)==1){xx[0]=1;}
|
||||
if (CheckHitKey(KEY_INPUT_Z) == 1) {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; }
|
||||
|
||||
if (xx[0] == 1) {
|
||||
mainproc = 10; zxon = 0; maintm = 0;
|
||||
|
@ -3336,13 +3294,6 @@ void Mainprogram() {
|
|||
//描画
|
||||
rpaint();
|
||||
|
||||
|
||||
//30-fps
|
||||
xx[0] = 30;
|
||||
if (CheckHitKey(KEY_INPUT_SPACE) == 1) {xx[0] = 60; }
|
||||
wait2(stime, GetNowCount(), 1000 / xx[0]);
|
||||
//wait(20);
|
||||
|
||||
} //Mainprogram()
|
||||
|
||||
|
||||
|
@ -3455,43 +3406,20 @@ void tekizimen() {
|
|||
|
||||
|
||||
|
||||
//スリープ
|
||||
static void wait(int interval) {
|
||||
WaitTimer(interval);
|
||||
}
|
||||
|
||||
//タイマー測定
|
||||
static void wait2(long stime, long etime, int FLAME_TIME) {
|
||||
if (etime - stime < FLAME_TIME)
|
||||
wait(FLAME_TIME - (etime - stime));
|
||||
}
|
||||
|
||||
|
||||
//乱数作成
|
||||
static int rand(int Rand) {
|
||||
return GetRand(Rand);
|
||||
}
|
||||
|
||||
//終了
|
||||
void end() {
|
||||
//maint=3;
|
||||
DxLib_End();
|
||||
}
|
||||
|
||||
//色かえ(黒)(白)
|
||||
void setc0() { setcolor(0, 0, 0); }
|
||||
void setc1() { setcolor(255, 255, 255); }
|
||||
|
||||
//文字
|
||||
void str(const char *x, int a, int b) {
|
||||
//char d[]="あ";
|
||||
DrawString(a, b, x, color);
|
||||
//DrawString(10,10,xs[3].c_str(),color);
|
||||
|
||||
drawstring(a, b, x);
|
||||
xx[2] = 4;
|
||||
}
|
||||
|
||||
//文字ラベル変更
|
||||
void setfont(int a) {
|
||||
}
|
||||
|
||||
//音楽再生
|
||||
|
||||
void stagecls() {
|
||||
|
@ -5453,13 +5381,6 @@ void txmsg(const char *x, int a) {
|
|||
} //txmsg
|
||||
|
||||
|
||||
//フォント変更
|
||||
void setfont(int x, int y) {
|
||||
SetFontSize(x);
|
||||
SetFontThickness(y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//グラ作成
|
||||
void eyobi(int xa, int xb, int xc, int xd, int xe, int xf, int xnobia, int xnobib, int xgtype, int xtm) {
|
||||
|
@ -5553,7 +5474,7 @@ void ayobi(int xa, int xb, int xc, int xd, int xnotm, int xtype, int xxtype) {
|
|||
*/
|
||||
}
|
||||
|
||||
if (xtype == 87) {atm[aco] = rand(179) + (-90); }
|
||||
if (xtype == 87) {atm[aco] = getrand(179) + (-90); }
|
||||
|
||||
aco += 1; if (aco >= amax - 1) {aco = 0; }
|
||||
} //t1
|
||||
|
|
BIN
res/brock.png
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 5.7 KiB |
BIN
res/brock2.png
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 4.8 KiB |
BIN
res/haikei.png
Before Width: | Height: | Size: 4 KiB After Width: | Height: | Size: 8 KiB |
BIN
res/item.png
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 6.5 KiB |
BIN
res/omake.png
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 8.5 KiB |
BIN
res/omake2.png
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 7.1 KiB |
BIN
res/player.png
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 2.4 KiB |
BIN
res/teki.png
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 4.7 KiB |