summaryrefslogtreecommitdiff
path: root/src/koopatlas/player.cpp
blob: 4a15f94e3fd168310d345f090c8a762d8e76965d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "koopatlas/player.h"

daWMPlayer_c *daWMPlayer_c::instance;

int daWMPlayer_c::onCreate() {

	this->modelHandler = new dPlayerModelHandler_c(0);
	// loadModel(u8 player_id, int powerup_id, int unk);
	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();

	pos = (Vec){0.0f,0.0f,3000.0f};
	rot = (S16Vec){0,0,0};
	scale = (Vec){1.6f,1.6f,1.6f};

	current_param = 0;

	hasEffect = false;
	hasSound = false;
	step = false;
	effectName = "";
	soundName = 0;
	timer = 0;
	jumpOffset = 0.0;

	return true;
}

int daWMPlayer_c::onDelete() {
	delete modelHandler;

	return true;
}


int daWMPlayer_c::onExecute() {
	this->modelHandler->update();
	Vec modifiedPos = {pos.x, pos.y + jumpOffset, pos.z};
	this->modelHandler->setSRT(modifiedPos, this->rot, this->scale);	

	if (hasEffect) { effect.spawn(effectName, 0, &pos, &rot, &scale); }

	if (hasSound) {
		timer++;

		if (timer == 12) {
			if (step) { MapSoundPlayer(SoundRelatedClass, soundName, 1); step = false; }
			else { MapSoundPlayer(SoundRelatedClass, soundName+1, 1); step = true; }
			timer = 0;
		}

		if (timer > 12) { timer = 0; }
	}

	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() {

	void *buffer = AllocFromGameHeap1(sizeof(daWMPlayer_c));
	daWMPlayer_c *c = new(buffer) daWMPlayer_c;


	instance = c;
	return c;
}