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.

EngineGUI.cpp 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #include "..\C-Engine\CHeader.hpp"
  2. #include"BoatControl.hpp"
  3. #include"EngineGUI.hpp"
  4. extern "C"
  5. {
  6. #include <math.h>
  7. }
  8. void EngineGUI::UpdateEverySecond()
  9. {
  10. VentActuelle->direction = VentActuelle->direction + cos(rand()) * 30;
  11. VentActuelle->force = VentActuelle->force + cos(rand());
  12. if(VentActuelle->direction < 0)VentActuelle->direction += 360;
  13. if(VentActuelle->direction > 360) VentActuelle->direction -= 360;
  14. if(VentActuelle->force > 5) VentActuelle->force = 5;
  15. if(VentActuelle->force < 1) VentActuelle->force = 1;
  16. }
  17. void EngineGUI::Update()
  18. {
  19. float buffer;
  20. const unsigned char Bordure[]={0x40,0x0,0x10,0x80,0x0,0x8,0x80,0x0,0x8,0x80,0x0,0x8,0x80,0x0,0x8,0x80,0x0,0x8,0x80,0x0,0x8,0x80,0x0,0x8,0x80,0x0,0x8,0x80,0x0,0x8,0x80,0x0,0x8,0x80,0x0,0x8,0x80,0x0,0x8,0x80,0x0,0x8,0x80,0x0,0x8,0x80,0x0,0x18,0x7f,0xff,0xe8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x10};
  21. ML_bmp_or(Bordure , 84 , 0, 21 , 64);
  22. ML_rectangle(105 , 0 , 127 , 63 , 1 , ML_WHITE , ML_WHITE);
  23. //************Vent****************//
  24. PrintMini(108 , 1 , "Vent" , 0);
  25. PrintV( 120 , 7 ,VentActuelle->force);
  26. buffer = VentActuelle->direction;
  27. const unsigned char FlecheE[]={0x20,0x10,0xf8,0x10,0x20};
  28. const unsigned char FlecheN[]={0x20,0x70,0xa8,0x20,0x20};
  29. const unsigned char FlecheNE[]={0x78,0x18,0x28,0x48,0x80};
  30. const unsigned char FlecheNO[]={0xf0,0xc0,0xa0,0x90,0x8};
  31. const unsigned char FlecheO[]={0x20,0x40,0xf8,0x40,0x20};
  32. const unsigned char FlecheS[]={0x20,0x20,0xa8,0x70,0x20};
  33. const unsigned char FlecheSE[]={0x80,0x48,0x28,0x18,0x78};
  34. const unsigned char FlecheSO[]={0x8,0x90,0xa0,0xc0,0xf0};
  35. if((buffer >= 0 && buffer < 22)|| (buffer >= 337 && buffer < 360))ML_bmp_or(FlecheE ,109 , 7, 5 , 5);
  36. else if(buffer >= 22 && buffer < 67)ML_bmp_or(FlecheNE ,109 , 7, 5 , 5);
  37. else if(buffer >= 67 && buffer < 112)ML_bmp_or(FlecheN ,109 , 7, 5 , 5);
  38. else if(buffer >= 112 && buffer < 157)ML_bmp_or(FlecheNO ,109 , 7, 5 , 5);
  39. else if(buffer >= 157 && buffer < 202)ML_bmp_or(FlecheO ,109 , 7, 5 , 5);
  40. else if(buffer >= 202 && buffer < 247)ML_bmp_or(FlecheSO ,109 , 7, 5 , 5);
  41. else if(buffer >= 247 && buffer < 292)ML_bmp_or(FlecheS ,109 , 7, 5 , 5);
  42. else if(buffer >= 292 && buffer < 337)ML_bmp_or(FlecheSE ,109 , 7, 5 , 5);
  43. //**********************Voile*************//
  44. const unsigned char Voile0[]={0x18,0xff,0x18,0x18,0x18,0x18,0x18,0x18};
  45. const unsigned char Voile25[]={0x18,0xff,0x81,0xff,0x18,0x18,0x18,0x18};
  46. const unsigned char Voile50[]={0x18,0xff,0x81,0x81,0xff,0x18,0x18,0x18};
  47. const unsigned char Voile75[]={0x18,0xff,0x81,0x81,0x81,0xff,0x18,0x18};
  48. const unsigned char Voile100[]={0x18,0xff,0x81,0x81,0x81,0x81,0xff,0x18};
  49. const unsigned char* SpriteVoile[] = {Voile0,Voile25,Voile50,Voile75,Voile100};
  50. PrintMini(108 , 15 , "Voiles" , 0);
  51. int buffer2 = BateauActuelle->VoilesLateralle.Pourcentage;
  52. int buffer2b = BateauActuelle->VoilesLongitudinal.Pourcentage;
  53. if( buffer2 < 12 )ML_bmp_8_or(SpriteVoile[0] ,108 , 21);
  54. else if(buffer2 >= 12 && buffer2 < 37 )ML_bmp_8_or(SpriteVoile[1] ,108 , 21);
  55. else if(buffer2 >= 37 && buffer2 < 62 )ML_bmp_8_or(SpriteVoile[2] ,108 , 21);
  56. else if(buffer2 >= 62 && buffer2 < 87 )ML_bmp_8_or(SpriteVoile[3] ,108 , 21);
  57. else if(buffer2 >= 87)ML_bmp_8_or(SpriteVoile[4] ,108 , 21);
  58. if( buffer2b < 12 )ML_bmp_8_or(SpriteVoile[0] ,118 , 21);
  59. else if(buffer2b >= 12 && buffer2b < 37 )ML_bmp_8_or(SpriteVoile[1] ,118 , 21);
  60. else if(buffer2b >= 37 && buffer2b < 62 )ML_bmp_8_or(SpriteVoile[2] ,118 , 21);
  61. else if(buffer2b >= 62 && buffer2b < 87 )ML_bmp_8_or(SpriteVoile[3] ,118 , 21);
  62. else if(buffer2b >= 87)ML_bmp_8_or(SpriteVoile[4] ,118 , 21);
  63. //*****************Canons************//
  64. int buffer3, buffer4;
  65. PrintMini(106 , 31 , "Canon" , 0);
  66. buffer3 = 17 - BateauActuelle->CanonDroit.couldown * 17 / 100;
  67. buffer4 = 17 - BateauActuelle->CanonGauche.couldown * 17 / 100;
  68. int affichage = BateauActuelle->vie * 17 / BateauActuelle->viemax;
  69. ML_rectangle(108 , 38 , 125 , 40 , 1 , ML_BLACK , ML_WHITE);
  70. ML_line( 108 , 39 , 108 + buffer3 , 39 , ML_BLACK);
  71. ML_rectangle(108 , 43 , 125 , 45 , 1 , ML_BLACK , ML_WHITE);
  72. ML_line( 108 , 44 , 108 + buffer4 , 44 , ML_BLACK);
  73. //*******************Vie******************//
  74. PrintMini(108 , 50 , "Vie" , 0);
  75. ML_rectangle(108 , 57 , 125 , 59 , 1 , ML_BLACK , ML_WHITE);
  76. ML_line( 108 , 58 , 108 + affichage , 58 , ML_BLACK);
  77. }
  78. void EngineGUI::Initialisation( Vent * v , Boat * b )
  79. {
  80. this->VentActuelle = v;
  81. this->BateauActuelle = b;
  82. }