2021-11-03 20:11:31 +08:00
|
|
|
#include "Arm2D_Element.h"
|
2021-10-05 09:49:52 +08:00
|
|
|
#include "Arm2D_common.h"
|
2021-11-03 20:11:31 +08:00
|
|
|
void Arm2D_Element_update(PikaObj* self) {
|
2021-10-05 09:49:52 +08:00
|
|
|
/* need to be override */
|
2021-11-20 21:25:05 +08:00
|
|
|
args_setErrorCode(self->list, 1);
|
|
|
|
args_setSysOut(self->list, "[error]: update method not be overrided !");
|
2021-11-03 20:11:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Arm2D_Element_init(PikaObj* self) {
|
2021-11-04 23:50:03 +08:00
|
|
|
pika_arm2d_element_info_t elemInfo = {0};
|
|
|
|
elemInfo.alpha = 255;
|
|
|
|
elemInfo.x = 0;
|
|
|
|
elemInfo.y = 0;
|
2021-11-20 21:25:05 +08:00
|
|
|
args_setStruct(self->list, "elemInfo", &elemInfo, sizeof(pika_arm2d_element_info_t));
|
2021-10-05 09:49:52 +08:00
|
|
|
}
|
|
|
|
|
2021-11-03 20:11:31 +08:00
|
|
|
void Arm2D_Element_setAlpha(PikaObj* self, int alpha) {
|
2021-11-20 21:25:05 +08:00
|
|
|
pika_arm2d_element_info_t elemInfo;
|
|
|
|
args_getStruct(self->list, "elemInfo", &elemInfo);
|
|
|
|
elemInfo.alpha_last = elemInfo.alpha;
|
|
|
|
elemInfo.alpha = alpha;
|
|
|
|
args_setStruct(self->list, "elemInfo", &elemInfo, sizeof(pika_arm2d_element_info_t));
|
2021-10-05 09:49:52 +08:00
|
|
|
}
|
|
|
|
|
2021-11-03 20:11:31 +08:00
|
|
|
void Arm2D_Element_up(PikaObj* self, int y) {
|
2021-11-20 21:25:05 +08:00
|
|
|
pika_arm2d_element_info_t elemInfo;
|
|
|
|
args_getStruct(self->list, "elemInfo", &elemInfo);
|
|
|
|
elemInfo.y_last = elemInfo.y;
|
|
|
|
elemInfo.y = elemInfo.y - y;
|
|
|
|
args_setStruct(self->list, "elemInfo", &elemInfo, sizeof(pika_arm2d_element_info_t));
|
2021-10-05 09:49:52 +08:00
|
|
|
}
|
|
|
|
|
2021-11-03 20:11:31 +08:00
|
|
|
void Arm2D_Element_down(PikaObj* self, int y) {
|
2021-11-20 21:25:05 +08:00
|
|
|
pika_arm2d_element_info_t elemInfo;
|
|
|
|
args_getStruct(self->list, "elemInfo", &elemInfo);
|
|
|
|
elemInfo.y_last = elemInfo.y;
|
|
|
|
elemInfo.y = elemInfo.y + y;
|
|
|
|
args_setStruct(self->list, "elemInfo", &elemInfo, sizeof(pika_arm2d_element_info_t));
|
2021-10-05 09:49:52 +08:00
|
|
|
}
|
|
|
|
|
2021-11-03 20:11:31 +08:00
|
|
|
void Arm2D_Element_lift(PikaObj* self, int x) {
|
2021-11-20 21:25:05 +08:00
|
|
|
pika_arm2d_element_info_t elemInfo;
|
|
|
|
args_getStruct(self->list, "elemInfo", &elemInfo);
|
|
|
|
elemInfo.x_last = elemInfo.x;
|
|
|
|
elemInfo.x = elemInfo.x - x;
|
|
|
|
args_setStruct(self->list, "elemInfo", &elemInfo, sizeof(pika_arm2d_element_info_t));
|
2021-10-05 09:49:52 +08:00
|
|
|
}
|
|
|
|
|
2021-11-03 20:11:31 +08:00
|
|
|
void Arm2D_Element_right(PikaObj* self, int x) {
|
2021-11-20 21:25:05 +08:00
|
|
|
pika_arm2d_element_info_t elemInfo;
|
|
|
|
args_getStruct(self->list, "elemInfo", &elemInfo);
|
|
|
|
elemInfo.x_last = elemInfo.x;
|
|
|
|
elemInfo.x = elemInfo.x + x;
|
|
|
|
args_setStruct(self->list, "elemInfo", &elemInfo, sizeof(pika_arm2d_element_info_t));
|
2021-11-04 23:50:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Arm2D_Element_move(PikaObj* self, int x, int y) {
|
2021-11-20 20:23:11 +08:00
|
|
|
pika_arm2d_element_info_t elemInfo;
|
2021-11-20 21:25:05 +08:00
|
|
|
args_getStruct(self->list, "elemInfo", &elemInfo);
|
2021-11-20 20:23:11 +08:00
|
|
|
elemInfo.y_last = elemInfo.y;
|
|
|
|
elemInfo.x_last = elemInfo.x;
|
|
|
|
elemInfo.x = x;
|
|
|
|
elemInfo.y = y;
|
2021-11-20 21:25:05 +08:00
|
|
|
args_setStruct(self->list, "elemInfo", &elemInfo, sizeof(pika_arm2d_element_info_t));
|
2021-10-05 09:49:52 +08:00
|
|
|
}
|