summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/engine.h2
-rw-r--r--include/glsprite.h3
-rw-r--r--include/sprite.h8
-rw-r--r--lib/base.cc2
-rw-r--r--lib/engine.cc22
-rw-r--r--lib/glbase.cc2
-rw-r--r--lib/glsprite.cc26
-rw-r--r--lib/sprite.cc4
-rw-r--r--src/test.cc576
9 files changed, 576 insertions, 69 deletions
diff --git a/include/engine.h b/include/engine.h
index b39841d..420f576 100644
--- a/include/engine.h
+++ b/include/engine.h
@@ -27,6 +27,7 @@ namespace mogltk {
static bool quitrequested();
static int mouseX();
static int mouseY();
+ static int mouseZ();
static int mousebuttons();
static double FPS();
static void lockmouse();
@@ -42,6 +43,7 @@ namespace mogltk {
static bool quitrequest;
static int mx;
static int my;
+ static int mz;
static int mbuttons;
static int frames;
static double curfps;
diff --git a/include/glsprite.h b/include/glsprite.h
index 77d0d7f..237a922 100644
--- a/include/glsprite.h
+++ b/include/glsprite.h
@@ -14,7 +14,8 @@ namespace mogltk {
glSprite(Handle *, int, int);
glSprite(Uint8 *, int, int);
virtual ~glSprite();
- virtual void draw(int, int, ColorP = WHITE);
+ virtual void draw(int, int, ColorP = WHITE, float = 1.0, float = 1.0);
+ void bindcorner(float, float);
virtual void drawrotate(int, int, double, ColorP = WHITE);
};
};
diff --git a/include/sprite.h b/include/sprite.h
index feb9e51..b4ef54a 100644
--- a/include/sprite.h
+++ b/include/sprite.h
@@ -13,11 +13,11 @@ namespace mogltk {
Sprite(Handle *, int, int);
Sprite(Uint8 *, int, int);
virtual ~Sprite();
- virtual void draw(int, int, ColorP = WHITE);
- protected:
- void Bind();
- int GetSX();
+ virtual void draw(int, int, ColorP = WHITE, float = 1.0, float = 1.0);
+ int GetSX();
int GetSY();
+ protected:
+ void Bind();
int GetPX();
int GetPY();
private:
diff --git a/lib/base.cc b/lib/base.cc
index 7891d50..49e883e 100644
--- a/lib/base.cc
+++ b/lib/base.cc
@@ -55,7 +55,7 @@ void mogltk::base::Flip() {
mogltk::base::base(int w, int h, int flags, int) : surface(0) {
width = w;
height = h;
-
+
SDL_ShowCursor(SDL_DISABLE);
}
diff --git a/lib/engine.cc b/lib/engine.cc
index 6792706..40426c1 100644
--- a/lib/engine.cc
+++ b/lib/engine.cc
@@ -10,7 +10,7 @@
bool mogltk::engine::inited = false, mogltk::engine::postsetuped = false;
bool mogltk::engine::appactive = false, mogltk::engine::cursorvisible = false, mogltk::engine::quitrequest = false;
-int mogltk::engine::mx, mogltk::engine::my, mogltk::engine::mbuttons;
+int mogltk::engine::mx, mogltk::engine::my, mogltk::engine::mz = 0, mogltk::engine::mbuttons;
int mogltk::engine::frames, mogltk::engine::locked = 0;
double mogltk::engine::curfps = -1;
Uint32 mogltk::engine::curticks;
@@ -133,7 +133,7 @@ SDL_RWops * mogltk::engine::RWFromHandle(Handle * h) throw (GeneralException) {
return r;
}
-void mogltk::engine::pollevents() {
+void mogltk::engine::pollevents() throw (GeneralException) {
SDL_Event event;
bool hastoreturn = appactive;
@@ -158,7 +158,9 @@ void mogltk::engine::pollevents() {
updatemouse();
return;
}
- SDL_WaitEvent(&event);
+ if (!SDL_WaitEvent(&event)) {
+ throw GeneralException("Error polling for SDL Event");
+ }
switch(event.type) {
case SDL_ACTIVEEVENT:
switch (event.active.state) {
@@ -205,7 +207,15 @@ void mogltk::engine::pollevents() {
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
- printm(M_INFO, String("Mouse button %02x ") + (event.button.state == SDL_PRESSED ? "pressed" : "released") + " at (%i, %i)\n", event.button.button, event.button.x, event.button.y);
+ printm(M_INFO, String().set("Mouse button %02x ", event.button.button) + String((event.button.state == SDL_PRESSED ? "pressed" : "released")) + " at (" + event.button.x + ", " + event.button.y + ")\n");
+ if (event.button.state == SDL_PRESSED) {
+ if (event.button.button == 4) {
+ mz--;
+ }
+ if (event.button.button == 5) {
+ mz++;
+ }
+ }
break;
case SDL_QUIT:
printm(M_INFO, "Quit requested\n");
@@ -254,6 +264,10 @@ int mogltk::engine::mouseY() {
return my;
}
+int mogltk::engine::mouseZ() {
+ return mz;
+}
+
int mogltk::engine::mousebuttons() {
return mbuttons;
}
diff --git a/lib/glbase.cc b/lib/glbase.cc
index 3808620..b6d41ef 100644
--- a/lib/glbase.cc
+++ b/lib/glbase.cc
@@ -60,6 +60,8 @@ mogltk::glbase::glbase(int w, int h, int flags) throw (GeneralException) : moglt
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapBuffers();
+ SDL_ShowCursor(SDL_DISABLE);
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
setsurface(surface);
diff --git a/lib/glsprite.cc b/lib/glsprite.cc
index 18df7eb..f60c3a2 100644
--- a/lib/glsprite.cc
+++ b/lib/glsprite.cc
@@ -14,28 +14,38 @@ mogltk::glSprite::glSprite(Uint8 * p, int asx, int asy) : Sprite(p, asx, asy) {
mogltk::glSprite::~glSprite() {
}
-void mogltk::glSprite::draw(int dx, int dy, ColorP c) {
+void mogltk::glSprite::draw(int dx, int dy, ColorP c, float sx, float sy) {
bool was2D;
- was2D = mogltk::engine::glbase_o->is2D();
-
- if (!was2D)
+ if (!(was2D = mogltk::engine::glbase_o->is2D()))
mogltk::engine::glbase_o->Enter2DMode();
c.Bind();
Bind();
glBegin(GL_TRIANGLE_STRIP);
- glTexCoord2i(GetPX() , GetPY() ); glVertex2i(dx , dy );
- glTexCoord2i(GetPX() + GetSX(), GetPY() ); glVertex2i(dx + GetSX(), dy );
- glTexCoord2i(GetPX() , GetPY() + GetSY()); glVertex2i(dx , dy + GetSY());
- glTexCoord2i(GetPX() + GetSX(), GetPY() + GetSY()); glVertex2i(dx + GetSX(), dy + GetSY());
+ glTexCoord2i(GetPX() , GetPY() ); glVertex2i(dx , dy );
+ glTexCoord2i(GetPX() + GetSX(), GetPY() ); glVertex2i(dx + GetSX() * sx, dy );
+ glTexCoord2i(GetPX() , GetPY() + GetSY()); glVertex2i(dx , dy + GetSY() * sy);
+ glTexCoord2i(GetPX() + GetSX(), GetPY() + GetSY()); glVertex2i(dx + GetSX() * sx, dy + GetSY() * sy);
glEnd();
if (!was2D)
mogltk::engine::glbase_o->Leave2DMode();
}
+void mogltk::glSprite::bindcorner(float fx, float fy) {
+ if (fx > 1)
+ fx = 1;
+ if (fy > 1)
+ fy = 1;
+ if (fx < 0)
+ fx = 0;
+ if (fy < 0)
+ fy = 0;
+ glTexCoord2i(GetPX() + fx * GetSX(), GetPY() + fy * GetSY());
+}
+
void mogltk::glSprite::drawrotate(int cx, int cy, double a, ColorP c) {
bool was2D;
diff --git a/lib/sprite.cc b/lib/sprite.cc
index 9c1a320..e62fb1b 100644
--- a/lib/sprite.cc
+++ b/lib/sprite.cc
@@ -127,9 +127,9 @@ bool mogltk::Sprite::canfit(int x1, int y1, int x2, int y2) const {
return false;
}
-void mogltk::Sprite::draw(int dx, int dy, ColorP c) {
+void mogltk::Sprite::draw(int dx, int dy, ColorP c, float sx, float sy) {
bool locked = false;
-
+
if (SDL_MUSTLOCK(mogltk::engine::base_o->getsurface())) {
locked = true;
SDL_LockSurface(mogltk::engine::base_o->getsurface());
diff --git a/src/test.cc b/src/test.cc
index ec00bfe..0ef8a57 100644
--- a/src/test.cc
+++ b/src/test.cc
@@ -1,6 +1,13 @@
#include <sys/types.h>
+#define _USE_MATH_DEFINES
#include <math.h>
#include <SDL.h>
+#include <vector>
+extern "C" {
+#include <lua.h>
+#include <lauxlib.h>
+#include <lualib.h>
+}
#ifdef HAVE_CONFIG_H
#include "config.h"
#else
@@ -19,24 +26,495 @@
#include "glsprite.h"
#include "glshape.h"
+#define SPIN .50
+#define TILT .20
+
+#define NBSTARS 10000
+#define STARSRATE 300.0
+
+#define LUA
+
+int zoom = 1;
+
+#define centerx 320
+#define centery 240
+
+struct tdvect {
+ double x, y, z;
+};
+
+std::vector<tdvect> points;
+std::vector<tdvect> ppoints;
+
+static int myprint(lua_State * L) {
+ const char * t = lua_tostring(L, -1);
+
+ Base::printm(M_INFO, "From LUA: %s\n", t);
+
+ return 0;
+}
+
+static int myluaputstar(lua_State * L) {
+ tdvect t;
+
+ t.x = lua_tonumber(L, -3);
+ t.y = lua_tonumber(L, -2);
+ t.z = lua_tonumber(L, -1);
+
+ points.push_back(t);
+
+ return 0;
+}
+
+int myluaerror(lua_State * L) {
+ int n = lua_gettop(L);
+ int i;
+ String t;
+
+ Base::printm(M_ERROR, "Got an LUA error\n");
+ Base::printm(M_ERROR, "Inspecting LUA stack\n");
+
+ if (n == 0) {
+ Base::printm(M_ERROR, "Stack empty\n");
+ return 0;
+ }
+
+ for (i = 1; i <= n; i++) {
+ switch(lua_type(L, i)) {
+ case LUA_TNONE:
+ t = "Invalid";
+ break;
+ case LUA_TNIL:
+ t = "(Nil)";
+ break;
+ case LUA_TNUMBER:
+ t.set("(Number) %f", lua_tonumber(L, i));
+ break;
+ case LUA_TBOOLEAN:
+ t.set("(Bool) %s", lua_toboolean(L, i) ? "true" : "false");
+ break;
+ case LUA_TSTRING:
+ t.set("(String) %s", lua_tostring(L, i));
+ break;
+ case LUA_TTABLE:
+ t.set("(Table)");
+ break;
+ case LUA_TFUNCTION:
+ t = "(Function)";
+ break;
+ default:
+ t = "Unknown";
+ }
+
+ Base::printm(M_ERROR, String(i) + ": " + t + "\n");
+ }
+
+ return 0;
+
+ getchar();
+}
+
+unsigned int swap32(unsigned int w) {
+ return (w >> 24) | ((w >> 8) & 0x0000ff00) | ((w << 8) & 0x00ff0000) | (w << 24);
+}
+
+unsigned int readB32(FILE * f) {
+ unsigned int r;
+ fread(&r, 1, 4, f);
+ return swap32(r);
+}
+
+unsigned short readB16(FILE * f) {
+ unsigned char t[2];
+ fread(t, 1, 2, f);
+ return t[1] | (t[0] << 8);
+}
+
+float tofloat(unsigned int w) {
+ return *((float *) &w);
+}
+
+char * sread(FILE * f) {
+ char temp[256], * p = temp;
+
+ do {
+ *p = fgetc(f);
+ } while (*(p++));
+
+ return strdup(temp);
+}
+
+char * pname[16] = {
+ "Unknown (not a float)",
+ "ScalX",
+ "ScalY",
+ "ScalZ",
+ "Unknown (not a float)",
+ "Unknown (not a float)",
+ "TransX",
+ "TransY",
+ "TransZ",
+ "Unknown",
+ "Unknown",
+ "Unknown",
+ "Unknown",
+ "Unknown",
+ "Unknown",
+ "Unknown"
+};
+
+#define OUTPUT stdout
+
+unsigned short entries;
+struct tdvect * mesh;
+
+int bdlload(char * name) {
+ FILE * bdl;
+ int i, j;
+ char sig[9], sec[5], ** bnames;
+ unsigned int length, fpos, namespos, tpos, npos, r;
+ unsigned short * unks;
+ float f;
+
+ if (!(bdl = fopen(name, "rb")))
+ exit(-1);
+
+ fread(sig, 1, 8, bdl);
+ sig[8] = 0;
+
+ if (strcmp(sig, "J3D2bdl4")) {
+ fprintf(OUTPUT, "File not bdl.\n");
+ exit(-1);
+ }
+
+ fprintf(OUTPUT, "Looking for section JNT1...\n");
+
+ fseek(bdl, 32, SEEK_SET);
+
+ do {
+ fread(sec, 1, 4, bdl);
+ sec[4] = 0;
+ length = readB32(bdl);
+ fprintf(OUTPUT, "Found section `%s' @ %08x, size %08x\n", sec, ftell(bdl) - 8, length);
+ fseek(bdl, length - 8, SEEK_CUR);
+ } while (strcmp(sec, "JNT1"));
+
+ fseek(bdl, -length, SEEK_CUR);
+ fpos = ftell(bdl);
+
+ fprintf(OUTPUT, "Found it at 0x%08x\n", fpos);
+
+ fseek(bdl, 8, SEEK_CUR);
+
+ entries = readB16(bdl);
+ if (readB16(bdl) != 0xffff) {
+ fprintf(OUTPUT, "Something's wrong, not found FFFF\n");
+ }
+ if (readB32(bdl) != 0x18) {
+ fprintf(OUTPUT, "Something's wrong, bones not at 0x18, can't go on.\n");
+ exit(-1);
+ }
+ if (readB32(bdl) != (0x18 + entries * 0x40)) {
+ fprintf(OUTPUT, "Something's wrong, bone index not at expected place, can't go on.\n");
+ exit(-1);
+ }
+
+ namespos = readB32(bdl);
+
+ fprintf(OUTPUT, "Reading names.\n");
+
+ bnames = (char **) malloc(entries * sizeof(char *));
+ unks = (unsigned short *) malloc(entries * sizeof(unsigned short));
+ mesh = (struct tdvect *) malloc(entries * sizeof(struct tdvect));
+
+ fseek(bdl, namespos + fpos + 4, SEEK_SET);
+
+ for (i = 0; i < entries; i++) {
+ unks[i] = readB16(bdl);
+ npos = readB16(bdl) + fpos + namespos;
+ tpos = ftell(bdl);
+ fseek(bdl, npos, SEEK_SET);
+ bnames[i] = sread(bdl);
+ fseek(bdl, tpos, SEEK_SET);
+ }
+ for (i = 0; i < entries; i++) {
+ fprintf(OUTPUT, "%02x: (%04x) `%s'\n", i, unks[i], bnames[i]);
+ }
+
+ fprintf(OUTPUT, "Dumping bones\n");
+
+ fseek(bdl, fpos + 0x18, SEEK_SET);
+
+ for (i = 0; i < entries; i++) {
+ fprintf(OUTPUT, "Bone #%02x (%s):\n", i, bnames[i]);
+ for (j = 0; j < 16; j++) {
+ r = readB32(bdl);
+ f = tofloat(r);
+ fprintf(OUTPUT, "%x: %08x - %9.5f - %s\n", j, r, f, pname[j]);
+ switch(j) {
+ case 6:
+ mesh[i].x = f;
+ break;
+ case 7:
+ mesh[i].y = f;
+ break;
+ case 8:
+ mesh[i].z = f;
+ break;
+ }
+ }
+ }
+
+ return 0;
+}
+
+
CODE_BEGINS
+
+void checkluastack(lua_State * L) {
+ int n = lua_gettop(L);
+ int i;
+ String t;
+
+ printm(M_INFO, "Inspecting LUA stack\n");
+
+ if (n == 0) {
+ printm(M_INFO, "Stack empty\n");
+ return;
+ }
+
+ for (i = 1; i <= n; i++) {
+ switch(lua_type(L, i)) {
+ case LUA_TNONE:
+ t = "Invalid";
+ break;
+ case LUA_TNIL:
+ t = "(Nil)";
+ break;
+ case LUA_TNUMBER:
+ t.set("(Number) %f", lua_tonumber(L, i));
+ break;
+ case LUA_TBOOLEAN:
+ t.set("(Bool) %s", lua_toboolean(L, i) ? "true" : "false");
+ break;
+ case LUA_TSTRING:
+ t.set("(String) %s", lua_tostring(L, i));
+ break;
+ case LUA_TTABLE:
+ t.set("(Table)");
+ break;
+ case LUA_TFUNCTION:
+ t = "(Function)";
+ break;
+ default:
+ t = "Unknown";
+ }
+
+ printm(M_INFO, String(i) + ": " + t + "\n");
+ }
+}
+
+void putstar(double x, double y, double z, mogltk::Sprite * s) {
+ double tx, ty, tz;
+ double spin, tilt;
+
+ spin = (mogltk::engine::mouseX() - centerx) / 80.0;
+ tilt = (mogltk::engine::mouseY() - centery) / 80.0;
+
+ // Spin --> around y
+
+ tx = x * cos(spin) + z * sin(spin);
+ tz = -x * sin(spin) + z * cos(spin);
+
+ x = tx;
+ z = tz;
+
+
+ // tilt --> around x
+
+ ty = y * cos(tilt) + z * sin(tilt);
+ tz = -y * sin(tilt) + z * cos(tilt);
+
+ y = ty;
+ z = tz;
+
+ tdvect t;
+ t.x = x;
+ t.y = y;
+ t.z = z;
+
+// s->draw(centerx + t.x * zoom * mogltk::engine::mouseZ() - s->GetSX() / 2, centery + t.y * zoom * mogltk::engine::mouseZ() - s->GetSY() / 2);
+ ppoints.push_back(t);
+}
+
+double t;
+
+#ifdef STARSCAPE
+int starsx[NBSTARS];
+int starsy[NBSTARS];
+#endif
+
+#ifdef SPHERE
+double starst[NBSTARS];
+double starso[NBSTARS];
+#endif
+
+lua_State * L;
+
+void initstars() {
+ int i;
+#ifdef STARSCAPE
+ for (i = 0; i < NBSTARS; i++) {
+ starsx[i] = rand() % 640;
+ starsy[i] = rand() % 480;
+ }
+
+ t = 0;
+#endif
+#ifdef RING
+ t = 0;
+#endif
+#ifdef SPHERE
+ t = 0;
+ for (i = 0; i < NBSTARS; i++) {
+ starst[i] = -(rand() % 3000) / 1000.0;
+ starso[i] = 2 * ((rand() % 1000) / 1000.0) * M_PI;
+ }
+#endif
+#ifdef LUA
+ L = lua_open();
+ luaopen_math(L);
+ lua_atpanic(L, myluaerror);
+ luaL_loadfile(L, "particules.lua");
+ lua_call(L, 0, 0);
+ lua_pushstring(L, "putstar");
+ lua_pushcfunction(L, myluaputstar);
+ lua_settable(L, LUA_GLOBALSINDEX);
+ lua_pushstring(L, "print");
+ lua_pushcfunction(L, myprint);
+ lua_settable(L, LUA_GLOBALSINDEX);
+ lua_pushstring(L, "initstars");
+ lua_gettable(L, LUA_GLOBALSINDEX);
+ lua_call(L, 0, 0);
+#endif
+}
+
+void displaystars(mogltk::Sprite * s) {
+ int i;
+ double x, y, z, st;
+ tdvect tv;
+
+#ifdef STARSCAPE
+ for (i = 0; i < NBSTARS; i++) {
+ s->draw(starsx[i], starsy[i]);
+ }
+#endif
+#ifdef RING
+ for (i = 0; i < NBSTARS; i++) {
+ putstar(cos(t + i * 2 * M_PI / NBSTARS), 0, sin(t + i * 2 * M_PI / NBSTARS), s);
+ }
+#endif
+#ifdef SPHERE
+ for (i = 0; i < NBSTARS; i++) {
+ st = t - starst[i];
+
+ y = st / 3.0;
+
+ x = cos(st * 2 * M_PI + starso[i]) * sin(y * M_PI);
+ z = sin(st * 2 * M_PI + starso[i]) * sin(y * M_PI);
+
+ y = cos(y * M_PI);
+
+ putstar(x, y, z, s);
+ }
+#endif
+#ifdef LUA
+ lua_pushstring(L, "displaystars");
+ lua_gettable(L, LUA_GLOBALSINDEX);
+ lua_call(L, 0, 0);
+
+ for (std::vector<tdvect>::iterator i = points.begin(); i != points.end(); i++) {
+ tv = *i;
+ putstar(tv.x, tv.y, tv.z, s);
+ }
+ points.clear();
+#endif
+#ifdef BDL
+ for (i = 0; i < entries; i++) {
+ putstar(mesh[i].x / 20, mesh[i].y / 20, mesh[i].z / 20, s);
+ }
+#endif
+ while (!ppoints.empty()) {
+ std::vector<tdvect>::iterator m = ppoints.begin();
+ for (std::vector<tdvect>::iterator i = ppoints.begin(); i != ppoints.end(); i++) {
+ if (i->z > m->z)
+ m = i;
+ }
+ tv = *m;
+ ppoints.erase(m);
+ // Only bare projecting... for now...
+ s->draw(centerx + tv.x * zoom * mogltk::engine::mouseZ() - s->GetSX() / 2, centery + tv.y * zoom * mogltk::engine::mouseZ() - s->GetSY() / 2);
+ }
+}
+
+void incrementstars(double nt) {
+ int i;
+
+#ifdef STARSCAPE
+ while ((t + (1 / STARSRATE)) <= nt) {
+ t += 1 / STARSRATE;
+
+ for (i = 0; i < NBSTARS; i++) {
+ if ((++starsx[i]) >= 640) {
+ starsx[i] = 0;
+ starsy[i] = rand() % 480;
+ }
+ }
+ }
+#endif
+#ifdef RING
+ t = nt;
+#endif
+#ifdef SPHERE
+ t = nt;
+
+ for (i = 0; i < NBSTARS; i++) {
+ if ((starst[i] + 3) < t) {
+ starst[i] += 3.0;
+ starso[i] = 2 * ((rand() % 1000) / 1000.0) * M_PI;
+ }
+ }
+#endif
+#ifdef LUA
+ t = nt;
+
+ lua_pushstring(L, "incstars");
+ lua_gettable(L, LUA_GLOBALSINDEX);
+ lua_pushnumber(L, t);
+ lua_call(L, 1, 0);
+#endif
+}
+
virtual int startup() throw (GeneralException) {
int sx1, sx2, sy1, sy2;
double t = 0;
verbosity = M_INFO;
new Archive("datas.paq");
+ bdlload("cl.bdl");
#if 1
- mogltk::glbase * gl = new mogltk::glbase();
- mogltk::glshape * sh = new mogltk::glshape();
- mogltk::glfont * font = new mogltk::glfont(&Input("font-2.bin"));
- mogltk::glSprite * s = new mogltk::glSprite(&Input("cursor.rgba"), 25, 25);
+ mogltk::base * gl = new mogltk::glbase();
+ mogltk::shape * sh = new mogltk::glshape();
+ mogltk::font * font = new mogltk::glfont(&Input("font-2.bin"));
+ mogltk::Sprite * s = new mogltk::glSprite(&Input("cursor.rgba"), 25, 25);
+ mogltk::Sprite * p = new mogltk::glSprite(&Input("particule.rgba"), 16, 16);
#else
mogltk::base * gl = new mogltk::base();
mogltk::shape * sh = new mogltk::shape();
mogltk::font * font = new mogltk::font(&Input("font-2.bin"));
mogltk::Sprite * s = new mogltk::Sprite(&Input("cursor.rgba"), 25, 25);
+ mogltk::Sprite * p = new mogltk::Sprite(&Input("particule.rgba"), 16, 16);
#endif
mogltk::engine::setcursorvisible(true);
@@ -47,69 +525,69 @@ virtual int startup() throw (GeneralException) {
Color AlphaBlue(AQUA);
AlphaBlue.A = 50;
- mogltk::fill * f = sh->fcircle(320, 240, 50);
+// mogltk::fill * f = sh->fcircle(320, 240, 50);
+
+ initstars();
while (!mogltk::engine::quitrequested()) {
- sx1 = 320 + 320 * sin(0.983 * t + 3.15);
- sx2 = 320 + 320 * sin(0.537 * t + 5.32);
- sy1 = 240 + 240 * sin(0.692 * t + 8.21);
- sy2 = 240 + 240 * sin(1.029 * t + 2.42);
+// sx1 = 320 + 320 * sin(0.983 * t + 3.15);
+// sx2 = 320 + 320 * sin(0.537 * t + 5.32);
+// sy1 = 240 + 240 * sin(0.692 * t + 8.21);
+// sy2 = 240 + 240 * sin(1.029 * t + 2.42);
gl->Enter2DMode();
sh->tbox(mytex, 50, 50, 561, 561, BLACK, RED, LIME, BLUE);
- sh->box(400, 100, 450, 150, BLACK, RED, LIME, BLUE);
-
- sh->box(5, 5, 150, 80, CORNFLOWERBLUE, DEEPSKYBLUE, MIDNIGHTBLUE, NAVY);
- font->setshadow(1);
- font->putcursor(10, 30);
- font->setcolor(WHITE);
- font->printf(
- "PixelPawa!\n"
- "It works!!\n"
- "I can't believe it!\n"
- );
+// sh->box(400, 100, 450, 150, BLACK, RED, LIME, BLUE);
+
+// sh->box(5, 5, 150, 80, CORNFLOWERBLUE, DEEPSKYBLUE, MIDNIGHTBLUE, NAVY);
+ mogltk::ColorP::Max.A = 100;
+ sh->box(5, 5, 400, 300, CORNFLOWERBLUE, DEEPSKYBLUE, MIDNIGHTBLUE, NAVY);
+ mogltk::ColorP::Max.A = 255;
+// font->setshadow(1);
+// font->putcursor(10, 30);
+// font->setcolor(WHITE);
+// font->printf(
+// "PixelPawa!\n"
+// "It works!!\n"
+// "I can't believe it!\n"
+// );
- sh->box3d(50, 150, 150, 200);
- sh->obox3d(50, 250, 150, 300);
- sh->window(50, 350, 150, 400, "Titre plus beau ;)");
- sh->box3d(180, 130, 320, 220);
- sh->button(200, 150, 300, 200, "Bouton");
-
- sh->fdraw(f, BLUE);
- sh->sdraw(f);
+// sh->box3d(50, 150, 150, 200);
+// sh->obox3d(50, 250, 150, 300);
+// sh->window(50, 350, 150, 400, "Titre plus beau ;)");
+// sh->box3d(180, 130, 320, 220);
+// sh->button(200, 150, 300, 200, "Bouton");
+
+// sh->fdraw(f, BLUE);
+// sh->sdraw(f);
- sh->box(MIN(sx1, sx2), MIN(sy1, sy2), MAX(sx1, sx2), MAX(sy1, sy2), AlphaBlue);
- mogltk::ColorP::Min.A = 200;
- sh->obox(MIN(sx1, sx2), MIN(sy1, sy2), MAX(sx1, sx2), MAX(sy1, sy2), AlphaBlue);
- mogltk::ColorP::Min.A = 0;
+// sh->box(MIN(sx1, sx2), MIN(sy1, sy2), MAX(sx1, sx2), MAX(sy1, sy2), AlphaBlue);
+// mogltk::ColorP::Min.A = 200;
+// sh->obox(MIN(sx1, sx2), MIN(sy1, sy2), MAX(sx1, sx2), MAX(sy1, sy2), AlphaBlue);
+// mogltk::ColorP::Min.A = 0;
font->putcursor(550, 400);
font->printf("FPS: %.2f\n", mogltk::engine::FPS());
font->printf("mx: %i\n", mogltk::engine::mouseX());
font->printf("my: %i\n", mogltk::engine::mouseY());
- font->printf("t: %.2fs\n", (double) SDL_GetTicks() / 1000);
-
- double sx, sy, l, a;
- sx = mogltk::engine::mouseX() - 320;
- sy = mogltk::engine::mouseY() - 240;
- l = sqrt(sx * sx + sy * sy);
- sx /= l;
- sy /= l;
- a = acos(sx);
- if (sy < 0)
- a = -a;
-
- font->printf("a: %.2f\n", a);
- sh->line(320, 240, mogltk::engine::mouseX(), mogltk::engine::mouseY());
- s->drawrotate(320, 240, a);
+ font->printf("t: %.2fs\n", SDL_GetTicks() / 1000.0);
+
+ p->draw(mogltk::engine::mouseX() - 8, mogltk::engine::mouseY() - 8);
s->draw(mogltk::engine::mouseX() - 8, mogltk::engine::mouseY() - 6);
+// sh->line(320, 240, mogltk::engine::mouseX(), mogltk::engine::mouseY());
- gl->Leave2DMode();
+ mogltk::ColorP::Min.A = 200;
+// p->draw(sx1, sy1, AlphaBlue);
+// p->draw(sx2, sy2, AlphaBlue);
+ displaystars(p);
+ incrementstars(t);
+
+ gl->Leave2DMode();
gl->Flip();
- t = (double) SDL_GetTicks() / 1000;
+ t = (double) SDL_GetTicks() / 1000.0;
}
delete mytex;