diff --git a/Makefile b/Makefile index dfd7801..6f108af 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ debug: - emcc -g4 dxlib.cpp loadg.cpp main.cpp -o dlm.html --preload-file res + emcc -g4 -s NO_EXIT_RUNTIME=1 dxlib.cpp loadg.cpp main.cpp -o dlm.html --preload-file res release: - emcc -o2 dxlib.cpp loadg.cpp main.cpp -o dlm.html --preload-file res + emcc -O3 -s NO_EXIT_RUNTIME=1 -s OUTLINING_LIMIT=2000 dxlib.cpp loadg.cpp main.cpp -o dlm.html --preload-file res diff --git a/dxlib.cpp b/dxlib.cpp index ffb0442..6a60aed 100644 --- a/dxlib.cpp +++ b/dxlib.cpp @@ -11,6 +11,7 @@ #include #include #include +#include static Display *x_display = NULL; @@ -324,6 +325,7 @@ static const char fShaderStr[] = "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; @@ -440,7 +442,7 @@ int DxLib_Init(void) { whiteTexture = Create1x1Texture(255, 255, 255, 255); // Setup the vertex data - GLfloat vVertices[] = { + GLfloat vVertices[(20 + 16) * 5] = { // normal 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, @@ -453,14 +455,37 @@ int DxLib_Init(void) { 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, - // loop + // 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 ); @@ -623,10 +648,6 @@ uint32_t GetColor(int Red, int Green, int Blue) { int DrawFormatString(int x, int y, int Color, const char *FormatString, ...) { return 0; } -// グラフィックの回転描画 -int DrawRotaGraph(int x, int y, double ExRate, double Angle, int GrHandle, int TransFlag, int TurnFlag) { - return 0; -} // フォントタイプの変更 int ChangeFontType(int FontType) { return 0; @@ -645,7 +666,7 @@ int GetNowCount(int UseRDTSCFlag) { struct timeval t1; struct timezone tz; gettimeofday(&t1, &tz); - return ((t1.tv_sec) * 1000 + (t1.tv_usec) / 1000); + return ((t1.tv_sec & 0x0fffffff) * 1000 + (t1.tv_usec) / 1000); } // ジョイバッドの入力状態取得 int GetJoypadInputState(int InputType) { @@ -675,30 +696,6 @@ int GetRand(int RandMax) { return 0; } -// 点を描画する -int DrawPixel(int x, int y, int Color) { - return 0; -} -// 線を描画 -int DrawLine(int x1, int y1, int x2, int y2, int Color, int Thickness) { - return 0; -} -// 四角形の描画 -int DrawBox(int x1, int y1, int x2, int y2, int Color, int FillFlag) { - return 0; -} -// 楕円を描く -int DrawOval(int x, int y, int rx, int ry, int Color, int FillFlag) { - return 0; -} -// グラフィックの描画 -int DrawGraph(int x, int y, int GrHandle, int TransFlag) { - return 0; -} -// 画像の左右反転描画 -int DrawTurnGraph(int x, int y, int GrHandle, int TransFlag) { - return 0; -} // 文字列の描画 int DrawString(int x, int y, const char *String, int Color, int EdgeColor) { return 0; @@ -744,43 +741,58 @@ static void set_transform(float x, float y, float w, float h) { float sy = -2.0f / screenSizeY; glUniform4f (u_posTrans, x * sx - 1, y * sy + 1, w * sx, h * sy); } - -//線 -void drawline(int a, int b, int c, int d) {DrawLine(a, b, c, d, color); } -//四角形(塗り無し) -void drawrect(int x, int y, int w, int h) { - set_texture(whiteTexture); - set_transform(x, y, w, h); - +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); - glDrawArrays ( GL_LINE_LOOP, 8, 4); +} + +//線 +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); - - 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); + set_color(color); glDrawArrays ( GL_TRIANGLE_STRIP, 0, 4); } //円(塗り無し) -void drawarc(int a, int b, int c, int d) {DrawOval(a, b, c, d, color, FALSE); } +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 a, int b, int c, int d) {DrawOval(a, b, c, d, color, TRUE); } +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 a, int b) { +void drawimage(int mx, int x, int y) { GraphData *g = &graphArray[mx]; set_texture(g->texture); - set_transform(a, b, g->w, g->h); + 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); @@ -790,6 +802,17 @@ void drawimage(int mx, int a, int b) { 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);} diff --git a/dxlib.h b/dxlib.h index 821cfeb..6943810 100644 --- a/dxlib.h +++ b/dxlib.h @@ -81,7 +81,7 @@ extern uint32_t GetColor(int Red, int Green, int Blue); // 書式指定文字列を描画する extern int DrawFormatString(int x, int y, int Color, const char *FormatString, ...); // グラフィックの回転描画 -extern int DrawRotaGraph(int x, int y, double ExRate, double Angle, int GrHandle, int TransFlag, int TurnFlag = FALSE); +extern void DrawRotaGraph(int x, int y, double ExRate, double Angle, int GrHandle, int TransFlag, int TurnFlag = FALSE); // フォントタイプの変更 extern int ChangeFontType(int FontType); diff --git a/loadg.cpp b/loadg.cpp index fbb6780..2397579 100644 --- a/loadg.cpp +++ b/loadg.cpp @@ -4,7 +4,6 @@ void end(); extern int ma, t, tt; extern int grap[161][8], mgrap[51]; -int x1; extern int oto[151]; extern int anx[160], any[160]; @@ -57,95 +56,89 @@ void loadg(void) { grap[3][0] = DerivationGraph(31 * 3, 0, 30, 36, mgrap[0]); grap[41][0] = DerivationGraph(50, 0, 51, 73, mgrap[6]); - x1 = 1; //ブロック読み込み for (t = 0; t <= 6; t++) { - grap[t][x1] = DerivationGraph(33 * t, 0, 30, 30, mgrap[x1]); - grap[t + 30][x1] = DerivationGraph(33 * t, 33, 30, 30, mgrap[x1]); - grap[t + 60][x1] = DerivationGraph(33 * t, 66, 30, 30, mgrap[x1]); + 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[8][x1] = DerivationGraph(33 * 7, 0, 30, 30, mgrap[x1]); - grap[16][x1] = DerivationGraph(33 * 6, 0, 24, 27, mgrap[2]); - grap[10][x1] = DerivationGraph(33 * 9, 0, 30, 30, mgrap[x1]); - grap[40][x1] = DerivationGraph(33 * 9, 33, 30, 30, mgrap[x1]); - grap[70][x1] = DerivationGraph(33 * 9, 66, 30, 30, mgrap[x1]); + 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]); //ブロック読み込み2 - x1 = 5; for (t = 0; t <= 6; t++) { - grap[t][x1] = DerivationGraph(33 * t, 0, 30, 30, mgrap[x1]); + grap[t][5] = DerivationGraph(33 * t, 0, 30, 30, mgrap[5]); } - grap[10][5] = DerivationGraph(33 * 1, 33, 30, 30, mgrap[x1]); - grap[11][5] = DerivationGraph(33 * 2, 33, 30, 30, mgrap[x1]); - grap[12][5] = DerivationGraph(33 * 0, 66, 30, 30, mgrap[x1]); - grap[13][5] = DerivationGraph(33 * 1, 66, 30, 30, mgrap[x1]); - grap[14][5] = DerivationGraph(33 * 2, 66, 30, 30, mgrap[x1]); + 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]); //アイテム読み込み - x1 = 2; for (t = 0; t <= 5; t++) { - grap[t][x1] = DerivationGraph(33 * t, 0, 30, 30, mgrap[x1]); + grap[t][2] = DerivationGraph(33 * t, 0, 30, 30, mgrap[2]); } //敵キャラ読み込み - x1 = 3; - grap[0][x1] = DerivationGraph(33 * 0, 0, 30, 30, mgrap[x1]); - grap[1][x1] = DerivationGraph(33 * 1, 0, 30, 43, mgrap[x1]); - grap[2][x1] = DerivationGraph(33 * 2, 0, 30, 30, mgrap[x1]); - grap[3][x1] = DerivationGraph(33 * 3, 0, 30, 44, mgrap[x1]); - grap[4][x1] = DerivationGraph(33 * 4, 0, 33, 35, mgrap[x1]); - grap[5][x1] = DerivationGraph(0, 0, 37, 55, mgrap[7]); - grap[6][x1] = DerivationGraph(38 * 2, 0, 36, 50, mgrap[7]); - grap[150][x1] = DerivationGraph(38 * 2 + 37 * 2, 0, 36, 50, mgrap[7]); - grap[7][x1] = DerivationGraph(33 * 6 + 1, 0, 32, 32, mgrap[x1]); - grap[8][x1] = DerivationGraph(38 * 2 + 37 * 3, 0, 37, 47, mgrap[7]); - grap[151][x1] = DerivationGraph(38 * 3 + 37 * 3, 0, 37, 47, mgrap[7]); - grap[9][x1] = DerivationGraph(33 * 7 + 1, 0, 26, 30, mgrap[x1]); - grap[10][x1] = DerivationGraph(214, 0, 46, 16, mgrap[6]); + 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[30][x1] = DerivationGraph(0, 56, 30, 36, mgrap[7]); - grap[155][x1] = DerivationGraph(31 * 3, 56, 30, 36, mgrap[7]); - grap[31][x1] = DerivationGraph(50, 74, 49, 79, 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[80][x1] = DerivationGraph(151, 31, 70, 40, mgrap[4]); - grap[81][x1] = DerivationGraph(151, 72, 70, 40, mgrap[4]); - grap[130][x1] = DerivationGraph(151 + 71, 72, 70, 40, mgrap[4]); - grap[82][x1] = DerivationGraph(33 * 1, 0, 30, 30, mgrap[5]); - grap[83][x1] = DerivationGraph(0, 0, 49, 48, mgrap[6]); - grap[84][x1] = DerivationGraph(33 * 5 + 1, 0, 30, 30, mgrap[x1]); - grap[86][x1] = DerivationGraph(102, 66, 49, 59, mgrap[6]); - grap[152][x1] = DerivationGraph(152, 66, 49, 59, 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[90][x1] = DerivationGraph(102, 0, 64, 63, mgrap[6]); + grap[90][3] = DerivationGraph(102, 0, 64, 63, mgrap[6]); - grap[100][x1] = DerivationGraph(33 * 1, 0, 30, 30, mgrap[2]); - grap[101][x1] = DerivationGraph(33 * 7, 0, 30, 30, mgrap[2]); - grap[102][x1] = DerivationGraph(33 * 3, 0, 30, 30, mgrap[2]); + 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[104][x1] = DerivationGraph( 33*2, 0, 30, 30, mgrap[5]) ; - grap[105][x1] = DerivationGraph(33 * 5, 0, 30, 30, mgrap[2]); - grap[110][x1] = DerivationGraph(33 * 4, 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]); //背景読み込み - x1 = 4; - grap[0][x1] = DerivationGraph(0, 0, 150, 90, mgrap[x1]); - grap[1][x1] = DerivationGraph(151, 0, 65, 29, mgrap[x1]); - grap[2][x1] = DerivationGraph(151, 31, 70, 40, mgrap[x1]); - grap[3][x1] = DerivationGraph(0, 91, 100, 90, mgrap[x1]); - grap[4][x1] = DerivationGraph(151, 113, 51, 29, mgrap[x1]); - grap[5][x1] = DerivationGraph(222, 0, 28, 60, mgrap[x1]); - grap[6][x1] = DerivationGraph(151, 143, 90, 40, mgrap[x1]); + 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[20][x1] = DerivationGraph(40, 182, 40, 60, mgrap[x1]); + grap[20][4] = DerivationGraph(40, 182, 40, 60, mgrap[4]); //グラ - x1 = 5; - grap[0][x1] = DerivationGraph(167, 0, 45, 45, mgrap[6]); + grap[0][5] = DerivationGraph(167, 0, 45, 45, mgrap[6]); @@ -157,18 +150,16 @@ void loadg(void) { //敵サイズ収得 //int GrHandle=0; - x1 = 3; for (t = 0; t <= 140; t++) { - GetGraphSize(grap[t][x1], &anx[t], &any[t]); + GetGraphSize(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; //背景サイズ収得 - x1 = 4; for (t = 0; t < 40; t++) { - GetGraphSize(grap[t][x1], &ne[t], &nf[t]); + GetGraphSize(grap[t][4], &ne[t], &nf[t]); //ne[t]*=100;nf[t]*=100; } @@ -225,8 +216,7 @@ void loadg(void) { //}catch( int num){end();} - x1 = 40; - ChangeVolumeSoundMem(255 * x1 / 100, oto[103]); + ChangeVolumeSoundMem(255 * 40 / 100, oto[103]); //ループ設定-20000-20秒 diff --git a/main.cpp b/main.cpp index fd24fa5..a379872 100644 --- a/main.cpp +++ b/main.cpp @@ -69,6 +69,7 @@ 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(); @@ -508,8 +509,8 @@ void rpaint() { 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 (atype[t] == 3 && axtype[t] == 1) {DrawRotaGraph(xx[0] / 100 + 13, xx[1] / 100 + 15, 1.0f, pai / 1, grap[atype[t]][3], TRUE); xx[16] = 1; } - if (atype[t] == 9 && ad[t] >= 1) {DrawRotaGraph(xx[0] / 100 + 13, xx[1] / 100 + 15, 1.0f, pai / 1, grap[atype[t]][3], TRUE); xx[16] = 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; //tekikaki(atype[t]); @@ -1131,7 +1132,7 @@ void rpaint() { setcolor(0, 0, 0); str("Enterキーを押せ!!", 240 - 8 * 20 / 2, 250); - + } //if (mainproc==100)