summaryrefslogtreecommitdiff
path: root/src/koopatlas/player.cpp
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-01-15 21:31:34 +0100
committerTreeki <treeki@gmail.com>2012-01-15 21:31:34 +0100
commit83729d2427ebb9a8563dce8ca3c8c19fb9f71c4a (patch)
tree5d48147b1f8e23992fe4a921adcec83da45969cd /src/koopatlas/player.cpp
parent0dabea30d98d175e5d7e0655c10757db99ac8295 (diff)
downloadkamek-83729d2427ebb9a8563dce8ca3c8c19fb9f71c4a.tar.gz
kamek-83729d2427ebb9a8563dce8ca3c8c19fb9f71c4a.zip
initial commit of the Koopatlas engine
Diffstat (limited to '')
-rw-r--r--src/koopatlas/player.cpp143
1 files changed, 143 insertions, 0 deletions
diff --git a/src/koopatlas/player.cpp b/src/koopatlas/player.cpp
new file mode 100644
index 0000000..ee881ab
--- /dev/null
+++ b/src/koopatlas/player.cpp
@@ -0,0 +1,143 @@
+#include "koopatlas/player.h"
+
+daWMPlayer_c *daWMPlayer_c::instance;
+
+int daWMPlayer_c::onCreate() {
+ OSReport("* dWMPlayer_c created\n");
+
+ OSReport("Init handler...\n");
+ this->modelHandler = new dPlayerModelHandler_c(0);
+ this->modelHandler->loadModel(0, 3, 2);
+ this->modelHandler->mdlClass->startAnimation(0, 1.2, 10.0, 0.0);
+ this->modelHandler->setSRT((Vec){0.0,100.0,-100.0}, (S16Vec){0,0,0}, (Vec){2.0,2.0,2.0});
+ this->modelHandler->draw();
+ OSReport("Init done!\n");
+
+ pos = (Vec){0.0f,-32.0f,0.0f};
+ rot = (S16Vec){0,0,0};
+ scale = (Vec){1.0f,1.0f,1.0f};
+
+ current_param = 0;
+
+ return true;
+}
+
+int daWMPlayer_c::onDelete() {
+ delete modelHandler;
+ OSReport("* dWMPlayer_c deleted\n");
+
+ return true;
+}
+
+
+int daWMPlayer_c::onExecute() {
+ this->modelHandler->update();
+ this->modelHandler->setSRT(this->pos, this->rot, this->scale);
+
+#ifdef MARIO_OPTIONS
+ // Before we leave, do the debug movement stuff
+ int heldButtons = Remocon_GetButtons(GetActiveRemocon());
+ int nowPressed = Remocon_GetPressed(GetActiveRemocon());
+ char buf[100];
+ bool updated = false;
+
+ if (nowPressed & WPAD_LEFT) {
+ current_param--;
+ updated = true;
+ }
+
+ if (nowPressed & WPAD_RIGHT) {
+ current_param++;
+ updated = true;
+ }
+
+ if (current_param < 0)
+ current_param = 8;
+
+ if (current_param > 8)
+ current_param = 0;
+
+ float pos_mod = 0.0f;
+ short rot_mod = 0.0f;
+ float scale_mod = 0.0f;
+ if (nowPressed & WPAD_ONE) {
+ pos_mod -= 5.0f;
+ rot_mod -= 0x1000;
+ scale_mod -= 0.1f;
+ updated = true;
+ } else if (nowPressed & WPAD_TWO) {
+ pos_mod += 5.0f;
+ rot_mod += 0x1000;
+ scale_mod += 0.1f;
+ updated = true;
+ }
+
+ if (!updated) return true;
+
+ if (current_param == 0) {
+ pos.x += pos_mod;
+ sprintf(buf, "X position: %f", pos.x);
+ } else if (current_param == 1) {
+ pos.y += pos_mod;
+ sprintf(buf, "Y position: %f", pos.y);
+ } else if (current_param == 2) {
+ pos.z += pos_mod;
+ sprintf(buf, "Z position: %f", pos.z);
+ } else if (current_param == 3) {
+ rot.x += rot_mod;
+ sprintf(buf, "X rotation: 0x%04x", rot.x);
+ } else if (current_param == 4) {
+ rot.y += rot_mod;
+ sprintf(buf, "Y rotation: 0x%04x", rot.y);
+ } else if (current_param == 5) {
+ rot.z += rot_mod;
+ sprintf(buf, "Z rotation: 0x%04x", rot.z);
+ } else if (current_param == 6) {
+ scale.x += scale_mod;
+ sprintf(buf, "X scale: %f", scale.x);
+ } else if (current_param == 7) {
+ scale.y += scale_mod;
+ sprintf(buf, "Y scale: %f", scale.y);
+ } else if (current_param == 8) {
+ scale.z += scale_mod;
+ sprintf(buf, "Z scale: %f", scale.z);
+ }
+
+ dScNewerWorldMap_c::instance->SetTitle(buf);
+#endif
+
+ return true;
+}
+
+int daWMPlayer_c::onDraw() {
+ this->modelHandler->draw();
+
+ return true;
+}
+
+
+void daWMPlayer_c::startAnimation(int id, float frame, float unk, float updateRate) {
+ if (id == currentAnim && frame == currentFrame && unk == currentUnk && updateRate == currentUpdateRate)
+ return;
+
+ currentAnim = id;
+ currentFrame = frame;
+ currentUnk = unk;
+ currentUpdateRate = updateRate;
+ this->modelHandler->mdlClass->startAnimation(id, frame, unk, updateRate);
+}
+
+
+
+daWMPlayer_c *daWMPlayer_c::build() {
+ OSReport("Creating WMPlayer\n");
+
+ void *buffer = AllocFromGameHeap1(sizeof(daWMPlayer_c));
+ daWMPlayer_c *c = new(buffer) daWMPlayer_c;
+
+ OSReport("Created WMPlayer @ %p\n", c);
+
+ instance = c;
+ return c;
+}
+