Arm2D_Element.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "Arm2D_Element.h"
  2. #include "Arm2D_common.h"
  3. void Arm2D_Element_update(PikaObj* self) {
  4. /* need to be override */
  5. obj_setErrorCode(self, 1);
  6. obj_setSysOut(self, "[error]: update method not be overrided !");
  7. }
  8. void Arm2D_Element___init__(PikaObj* self) {
  9. /* init element info */
  10. obj_setInt(self, "alpha", 255);
  11. obj_setInt(self, "x", 0);
  12. obj_setInt(self, "y", 0);
  13. }
  14. void Arm2D_Element_setAlpha(PikaObj* self, int alpha) {
  15. obj_setInt(self, "alpha_last", obj_getInt(self, "alpha"));
  16. obj_setInt(self, "alpha", alpha);
  17. }
  18. void Arm2D_Element_up(PikaObj* self, int y) {
  19. int y_now = obj_getInt(self, "y");
  20. obj_setInt(self, "y_last", y_now);
  21. obj_setInt(self, "y", y_now - y);
  22. }
  23. void Arm2D_Element_down(PikaObj* self, int y) {
  24. int y_now = obj_getInt(self, "y");
  25. obj_setInt(self, "y_last", y_now);
  26. obj_setInt(self, "y", y_now + y);
  27. }
  28. void Arm2D_Element_lift(PikaObj* self, int x) {
  29. int x_now = obj_getInt(self, "x");
  30. obj_setInt(self, "x_last", x_now);
  31. obj_setInt(self, "x", x_now - x);
  32. }
  33. void Arm2D_Element_right(PikaObj* self, int x) {
  34. int x_now = obj_getInt(self, "x");
  35. obj_setInt(self, "x_last", x_now);
  36. obj_setInt(self, "x", x_now + x);
  37. }
  38. void Arm2D_Element_move(PikaObj* self, int x, int y) {
  39. int x_now = obj_getInt(self, "x");
  40. int y_now = obj_getInt(self, "y");
  41. obj_setInt(self, "x_last", x_now);
  42. obj_setInt(self, "y_last", y_now);
  43. obj_setInt(self, "x", x);
  44. obj_setInt(self, "y", y);
  45. }