pikapython/package/Arm2D/Arm2D_Element.c

65 lines
2.0 KiB
C
Raw Normal View History

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 20:23:11 +08:00
args_setErrorCode(self->attributeList, 1);
args_setSysOut(self->attributeList, "[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 20:23:11 +08:00
args_setStruct(self->attributeList, "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 20:23:11 +08:00
pika_arm2d_element_info_t* elemInfo = args_getStruct(self->attributeList, "elemInfo");
2021-11-04 23:50:03 +08:00
elemInfo->alpha_last = elemInfo->alpha;
elemInfo->alpha = alpha;
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 20:23:11 +08:00
pika_arm2d_element_info_t* elemInfo = args_getStruct(self->attributeList, "elemInfo");
2021-11-04 23:50:03 +08:00
elemInfo->y_last = elemInfo->y;
elemInfo->y = elemInfo->y - y;
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 20:23:11 +08:00
pika_arm2d_element_info_t* elemInfo = args_getStruct(self->attributeList, "elemInfo");
2021-11-04 23:50:03 +08:00
elemInfo->y_last = elemInfo->y;
elemInfo->y = elemInfo->y + y;
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 20:23:11 +08:00
pika_arm2d_element_info_t* elemInfo = args_getStruct(self->attributeList, "elemInfo");
2021-11-04 23:50:03 +08:00
elemInfo->x_last = elemInfo->x;
2021-10-05 09:49:52 +08:00
2021-11-04 23:50:03 +08:00
elemInfo->x = elemInfo->x - x;
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 20:23:11 +08:00
pika_arm2d_element_info_t* elemInfo = args_getStruct(self->attributeList, "elemInfo");
2021-11-04 23:50:03 +08:00
elemInfo->x_last = elemInfo->x;
elemInfo->x = elemInfo->x + x;
}
void Arm2D_Element_move(PikaObj* self, int x, int y) {
2021-11-20 20:23:11 +08:00
pika_arm2d_element_info_t elemInfo;
memcpy(&elemInfo, args_getStruct(self->attributeList, "elemInfo"),
sizeof(pika_arm2d_element_info_t));
elemInfo.y_last = elemInfo.y;
elemInfo.x_last = elemInfo.x;
2021-11-04 23:50:03 +08:00
2021-11-20 20:23:11 +08:00
elemInfo.x = x;
elemInfo.y = y;
args_setStruct(self->attributeList, "elemInfo", &elemInfo, sizeof(pika_arm2d_box_info_t));
2021-10-05 09:49:52 +08:00
}