You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

monstres.cpp 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "..\C-Engine\CEngine.hpp"
  2. #include "monstres.hpp"
  3. void IaSlime::Start()
  4. {
  5. GetObject()->AddRigidBody();
  6. Direction = 0;
  7. }
  8. void IaSlime::UpdateEverySecond()
  9. {
  10. Direction = rand_int_ab(1, 5);
  11. switch(Direction)
  12. {
  13. case 1 : GetObject()->GetRigidBody()->Move(0,3);GetObject()->GetRender()->SetIt(1);break;
  14. case 2 : GetObject()->GetRigidBody()->Move(3,0);GetObject()->GetRender()->SetIt(2);GetObject()->GetRender()->ReverseRender(true); break;
  15. case 3 : GetObject()->GetRigidBody()->Move(0,-3);GetObject()->GetRender()->SetIt(0);break;
  16. case 4 : GetObject()->GetRigidBody()->Move(-3,0);GetObject()->GetRender()->SetIt(2);GetObject()->GetRender()->ReverseRender(false); break;
  17. }
  18. }
  19. void IaSlime::Update()
  20. {
  21. if(GetObject()->GetCollisionTag("Epee"))
  22. {
  23. GetEngine()->DelObject(GetObject());
  24. }
  25. }
  26. void IaSacPV::Start()
  27. {
  28. GetObject()->AddRigidBody();
  29. int vie=5;
  30. Direction = 0;
  31. }
  32. void IaSacPV::UpdateEverySecond()
  33. {
  34. Direction = rand_int_ab(1, 5);
  35. switch(Direction)
  36. {
  37. case 1 : GetObject()->GetRigidBody()->Move(0,3);GetObject()->GetRender()->SetIt(1);break;
  38. case 4 : GetObject()->GetRigidBody()->Move(3,0);GetObject()->GetRender()->SetIt(2);GetObject()->GetRender()->ReverseRender(true); break;
  39. case 3 : GetObject()->GetRigidBody()->Move(0,-3);GetObject()->GetRender()->SetIt(0);break;
  40. case 2 : GetObject()->GetRigidBody()->Move(-3,0);GetObject()->GetRender()->SetIt(2);GetObject()->GetRender()->ReverseRender(false); break;
  41. }
  42. }
  43. void IaSacPV::Update()
  44. {
  45. if(GetObject()->GetCollisionTag("Epee"))
  46. {
  47. vie--;
  48. }
  49. if (vie<=0)GetEngine()->DelObject(GetObject());
  50. }