pikapython/package/Arm2D/Arm2D_Element.c

53 lines
1.5 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 */
2022-07-02 00:04:57 +08:00
obj_setErrorCode(self, 1);
obj_setSysOut(self, "[error]: update method not be overrided !");
2021-11-03 20:11:31 +08:00
}
2022-09-07 01:14:27 +08:00
void Arm2D_Element___init__(PikaObj* self) {
/* init element info */
obj_setInt(self, "alpha", 255);
obj_setInt(self, "x", 0);
obj_setInt(self, "y", 0);
2021-10-05 09:49:52 +08:00
}
2021-11-03 20:11:31 +08:00
void Arm2D_Element_setAlpha(PikaObj* self, int alpha) {
obj_setInt(self, "alpha_last", obj_getInt(self, "alpha"));
obj_setInt(self, "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) {
int y_now = obj_getInt(self, "y");
obj_setInt(self, "y_last", y_now);
obj_setInt(self, "y", y_now - 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) {
int y_now = obj_getInt(self, "y");
obj_setInt(self, "y_last", y_now);
obj_setInt(self, "y", y_now + 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) {
int x_now = obj_getInt(self, "x");
obj_setInt(self, "x_last", x_now);
obj_setInt(self, "x", x_now - 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) {
int x_now = obj_getInt(self, "x");
obj_setInt(self, "x_last", x_now);
obj_setInt(self, "x", x_now + x);
2021-11-04 23:50:03 +08:00
}
void Arm2D_Element_move(PikaObj* self, int x, int y) {
int x_now = obj_getInt(self, "x");
int y_now = obj_getInt(self, "y");
obj_setInt(self, "x_last", x_now);
obj_setInt(self, "y_last", y_now);
obj_setInt(self, "x", x);
obj_setInt(self, "y", y);
2021-10-05 09:49:52 +08:00
}