diff options
author | Colin Noga <Tempus@Spectrum-Song.local> | 2011-06-19 03:32:22 -0500 |
---|---|---|
committer | Colin Noga <Tempus@Spectrum-Song.local> | 2011-06-19 03:32:22 -0500 |
commit | 8b4c5e87a0a407246d5ee37684105e72283687a5 (patch) | |
tree | 687a5e9a872c23a6730b938cc43f77aac4b42e0b /src/spritespawner.cpp | |
parent | fe5ff40e8e6ab1cdc83df3263d3d16830e4ff18f (diff) | |
download | kamek-8b4c5e87a0a407246d5ee37684105e72283687a5.tar.gz kamek-8b4c5e87a0a407246d5ee37684105e72283687a5.zip |
Added all latest fixes for textures, event looper, and sprite spawner, plus some other odds and ends
Diffstat (limited to '')
-rw-r--r-- | src/spritespawner.cpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/src/spritespawner.cpp b/src/spritespawner.cpp new file mode 100644 index 0000000..d9ee51a --- /dev/null +++ b/src/spritespawner.cpp @@ -0,0 +1,101 @@ +#include <common.h>
+#include <game.h>
+
+struct SpriteSpawner {
+ u32 id; // 0x00
+ u32 settings; // 0x04
+ u16 name; // 0x08
+ u8 _0A[6]; // 0x0A
+ u8 _10[0x9C]; // 0x10
+ float x; // 0xAC
+ float y; // 0xB0
+ float z; // 0xB4
+ u8 _B8[0x318]; // 0xB8
+ // Any variables you add to the class go here; starting at offset 0x3D0
+ u64 eventFlag; // 0x3D0
+ u16 type; // 0x3D4
+ u8 lastEvState; // 0x3D6
+};
+
+struct EventTable_t {
+ u64 events;
+};
+ + +struct VEC {
+ float x;
+ float y;
+ float z;
+};
+ +
+extern EventTable_t *EventTable;
+extern "C" void CreateActor(u16 classID, int settings, VEC pos, char rot, char layer); + +void SpriteSpawner_Update(SpriteSpawner *self);
+ +#define ACTIVATE 1
+#define DEACTIVATE 0
+
+ + +
+bool SpriteSpawner_Create(SpriteSpawner *self) {
+ OSReport("I exist, dammit!");
+ + char eventNum = (self->settings >> 24) & 0xFF;
+ self->eventFlag = (u64)1 << (eventNum - 1);
+
+
+ self->type = (self->settings) & 0xFFFF;
+
+ self->lastEvState = 0xFF;
+
+ SpriteSpawner_Update(self);
+
+ return true;
+}
+
+bool SpriteSpawner_Execute(SpriteSpawner *self) {
+ SpriteSpawner_Update(self);
+ return true;
+}
+
+ +void SpriteSpawner_Update(SpriteSpawner *self) {
+
+ u8 newEvState = 0;
+ if (EventTable->events & self->eventFlag)
+ newEvState = 1;
+
+ if (newEvState == self->lastEvState)
+ return;
+
+ u8 offState;
+ if (newEvState == ACTIVATE) + {
+ offState = (newEvState == 1) ? 1 : 0;
+ + // Put an action for when the event turns on here + + int spriteset = 0; + VEC pos; + pos.x = self->x; + pos.y = self->y; + pos.z = self->z; + + OSReport("Spawning Sprite: %d at %f,%f,%f\n", self->type, pos.x, pos.y, pos.z);
+ + CreateActor(self->type, spriteset, pos, 0, 0); + }
+
+ else + {
+ offState = (newEvState == 1) ? 0 : 1;
+ + // Put an action for when the event turns off here + + }
+ + self->lastEvState = newEvState;
+} |