summaryrefslogtreecommitdiff
path: root/src/shyguy.cpp
diff options
context:
space:
mode:
authorColin Noga <Tempus@chronometry.ca>2012-02-18 20:19:35 -0600
committerColin Noga <Tempus@chronometry.ca>2012-02-18 20:19:35 -0600
commitb778836efa61a521af06552004ff879692158043 (patch)
treed52faae31e84f0a8f3a4b437c23757eee2e91193 /src/shyguy.cpp
parentf0a71e19c6234d6654e87e836107c6c1ed5f4e58 (diff)
downloadkamek-b778836efa61a521af06552004ff879692158043.tar.gz
kamek-b778836efa61a521af06552004ff879692158043.zip
Shyguy initial commit
Diffstat (limited to '')
-rw-r--r--src/shyguy.cpp219
1 files changed, 219 insertions, 0 deletions
diff --git a/src/shyguy.cpp b/src/shyguy.cpp
new file mode 100644
index 0000000..0e4024a
--- /dev/null
+++ b/src/shyguy.cpp
@@ -0,0 +1,219 @@
+#include <common.h>
+#include <game.h>
+#include <g3dhax.h>
+#include <sfx.h>
+#include <stage.h>
+#include "effects.h"
+#include "player.h"
+
+
+class daShyGuy : public dEn_c {
+ int onCreate();
+ int onDelete();
+ int onExecute();
+ int onDraw();
+
+ mHeapAllocator_c allocator;
+ nw4r::g3d::ResFile resFile;
+
+ m3d::mdl_c body_h;
+ m3d::mdl_c body_m;
+ m3d::mdl_c body_l;
+ m3d::mdl_c body_s;
+
+ // m3d::anmChr_c animationChr;
+
+ static daShyGuy *build();
+
+ // void bindAnimChr_and_setUpdateRate(const char* name, int unk, float unk2, float rate);
+ void setupBodyModel();
+ void updateModelMatrices();
+
+ // USING_STATES(daShyGuy);
+ // DECLARE_STATE(Grow);
+};
+
+daShyGuy *daShyGuy::build() {
+ void *buffer = AllocFromGameHeap1(sizeof(daShyGuy));
+ return new(buffer) daShyGuy;
+}
+
+
+extern "C" void *PlaySound(daShyGuy *, int soundID);
+extern "C" void *StopSound(int soundID);
+
+extern "C" u32 GenerateRandomNumber(int max);
+extern "C" dStageActor_c *CreateActor(u16 classID, int settings, Vec pos, char rot, char layer);
+extern "C" u8 dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(daShyGuy *, Vec pos);
+extern "C" dStageActor_c *GetSpecificPlayerActor(int number);
+
+
+// CREATE_STATE(daShyGuy, Grow);
+
+
+// void daShyGuy::bindAnimChr_and_setUpdateRate(const char* name, int unk, float unk2, float rate) {
+// nw4r::g3d::ResAnmChr anmChr = this->resFile.GetResAnmChr(name);
+// this->animationChr.bind(&this->bodyModel, anmChr, unk);
+// this->bodyModel.bindAnim(&this->animationChr, unk2);
+// this->animationChr.setUpdateRate(rate);
+// }
+
+
+void daShyGuy::setupBodyModel() {
+ allocator.link(-1, GameHeaps[0], 0, 0x20);
+
+ // body_h # Maybe Head and body
+ // body_m # Same as h
+ // body_l # Just head
+ // body_s # A shadow?
+
+ this->resFile.data = getResource("block_snake", "g3d/ShyGuyRed.brres");
+
+ nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("body_h");
+ body_h.setup(mdl, &allocator, 0x224, 1, 0);
+ SetupTextures_Enemy(&body_h, 0);
+
+ nw4r::g3d::ResMdl mdlb = this->resFile.GetResMdl("body_m");
+ body_m.setup(mdlb, &allocator, 0x224, 1, 0);
+ SetupTextures_Enemy(&body_m, 0);
+
+ nw4r::g3d::ResMdl mdlc = this->resFile.GetResMdl("body_l");
+ body_l.setup(mdlc, &allocator, 0x224, 1, 0);
+ SetupTextures_Enemy(&body_l, 0);
+
+ nw4r::g3d::ResMdl mdld = this->resFile.GetResMdl("body_s");
+ body_s.setup(mdld, &allocator, 0x224, 1, 0);
+ SetupTextures_Enemy(&body_s, 0);
+
+
+ //Animations start here
+ // nw4r::g3d::ResAnmChr anmChr = this->resFile.GetResAnmChr("run");
+ // ret = this->animationChr.setup(mdl, anmChr, &this->allocator, 0);
+
+ allocator.unlink();
+}
+
+
+int daShyGuy::onCreate() {
+
+ OSReport("Creating the ShyGuy Model");
+ setupBodyModel();
+
+ int tscale = this->settings >> 28;
+ float scale = (float)tscale * 2.0;
+
+ OSReport("Setting ShyGuy's Size to 1.0");
+ this->scale = (Vec){scale, scale, scale};
+
+ OSReport("Creating ShyGuy's Physics Struct");
+
+ ActivePhysics::Info HitMeBaby;
+ HitMeBaby.xDistToCenter = 0.0;
+ HitMeBaby.yDistToCenter = 0.0;
+
+ HitMeBaby.xDistToEdge = 32.0;
+ HitMeBaby.yDistToEdge = 32.0;
+
+ HitMeBaby.category1 = 0x3;
+ HitMeBaby.category2 = 0x0;
+ HitMeBaby.bitfield1 = 0x4F;
+ HitMeBaby.bitfield2 = 0x8828E;
+ HitMeBaby.unkShort1C = 0;
+ HitMeBaby.callback = &dEn_c::collisionCallback;
+
+ OSReport("Making the Physics Class and adding to the list");
+ this->aPhysics.initWithStruct(this, &HitMeBaby);
+ this->aPhysics.addToList();
+
+ OSReport("Setting up ShyGuy's Box of Goodies");
+ this->rot.x = 0; // X is vertical axis
+ this->rot.y = 0; // Y is horizontal axis
+ this->rot.z = 0; // Z is ... an axis >.>
+ this->direction = 0; // Heading left.
+
+ this->speed.x = 0;
+
+ // bindAnimChr_and_setUpdateRate("run", 1, 0.0, 1.0);
+
+ // OSReport("Setting ShyGuy's State");
+ // doStateChange(&StateID_Grow);
+
+ OSReport("Going to Execute ShyGuy");
+ this->onExecute();
+ return true;
+}
+
+int daShyGuy::onDelete() {
+ return true;
+}
+
+int daShyGuy::onExecute() {
+ acState.execute();
+ updateModelMatrices();
+
+ this->rot.x = this->rot.x + 10;
+ this->rot.y = this->rot.y + 5;
+ this->rot.z = this->rot.z + 15;
+
+ // if(this->animationChr.isAnimationDone())
+ // this->animationChr.setCurrentFrame(0.0);
+
+ // if (this->aPhysics.result1 == 1) {
+ // char PlayerID = NearestPlayer(this);
+ // dStageActor_c *Player = GetSpecificPlayerActor(PlayerID);
+
+ // this->_vf220(Player);
+ // }
+
+ return true;
+}
+
+
+int daShyGuy::onDraw() {
+ body_h.scheduleForDrawing();
+ body_h._vf1C();
+
+ body_m.scheduleForDrawing();
+ body_m._vf1C();
+
+ body_l.scheduleForDrawing();
+ body_l._vf1C();
+
+ body_s.scheduleForDrawing();
+ body_s._vf1C();
+
+ return true;
+}
+
+void daShyGuy::updateModelMatrices() {
+ // This won't work with wrap because I'm lazy.
+ matrix.translation(pos.x, pos.y, pos.z);
+ matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z);
+
+ body_h.setDrawMatrix(matrix);
+ body_h.setScale(&scale);
+ body_h.calcWorld(false);
+
+ matrix.translation(pos.x+40.0, pos.y, pos.z);
+
+ body_m.setDrawMatrix(matrix);
+ body_m.setScale(&scale);
+ body_m.calcWorld(false);
+
+ matrix.translation(pos.x+80.0, pos.y, pos.z);
+
+ body_l.setDrawMatrix(matrix);
+ body_l.setScale(&scale);
+ body_l.calcWorld(false);
+
+ matrix.translation(pos.x+120.0, pos.y, pos.z);
+
+ body_s.setDrawMatrix(matrix);
+ body_s.setScale(&scale);
+ body_s.calcWorld(false);
+
+}
+
+
+
+