PongCredits.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. #include <math.h>
  5. const char *creditsText[] = {
  6. #ifdef MY_OS_MEEGO
  7. "epong 1.1", // For Ovi Store requirements, version number has to be here.
  8. #else
  9. "epong",
  10. #endif
  11. "",
  12. "produced by",
  13. "forum nokia",
  14. "",
  15. "producer",
  16. "mika pesonen",
  17. "",
  18. "executive",
  19. "producers",
  20. "jarkko aura",
  21. "tommi kenttamies",
  22. "",
  23. "programming",
  24. "jarno heikkinen",
  25. "tuomo hirvonen",
  26. "",
  27. "graphics",
  28. "kari kantola",
  29. "",
  30. "music and sound",
  31. "freesound.org",
  32. "",
  33. "scrum master",
  34. "markus pelkonen",
  35. "",
  36. "feedback",
  37. "kimmo tokkari",
  38. "tomi paananen",
  39. "",
  40. "management",
  41. "tapio laitinen",
  42. "",
  43. "testing",
  44. "antti krats",
  45. "tero paananen",
  46. "",
  47. "image codec",
  48. "music codec",
  49. "sean barrett",
  50. "",
  51. 0};
  52. #include "PongApp.h"
  53. #include "PongCredits.h"
  54. PongCredits::PongCredits( PongApp *app ) {
  55. dead = false;
  56. fade = 0.0f;
  57. lifeTime = 0.0f;
  58. pongApp = app;
  59. }
  60. PongCredits::~PongCredits() {
  61. }
  62. bool PongCredits::update( const float frameTime ) {
  63. lifeTime += frameTime;
  64. if (!dead) fade+=frameTime;
  65. if (fade>1.0f) fade = 1.0f;
  66. if (dead) fade-=frameTime;
  67. if (dead && lifeTime>1.0f && fade<0.025f) return false;
  68. return true;
  69. }
  70. #define CREDIT_TEXT_SIZE 0.08f
  71. #define CREDIT_TEXT_YSPACING 0.20f
  72. void PongCredits::render() {
  73. FontWriter *fw = pongApp->getFontWriter();
  74. int textLine = 0;
  75. while (1) {
  76. const char *line = creditsText[textLine];
  77. if (!line) break;
  78. float lypos = -pongApp->getTop() + lifeTime/6.0f - CREDIT_TEXT_YSPACING * textLine;
  79. float a = 1.0f - lypos*10.0f*lypos;
  80. if (a<0.0f) a = 0.0f;
  81. float xinc = -sinf( lypos*2.0f )*lypos*lypos*4.0f;
  82. a*=fade;
  83. fw->setColor(1.0f, 1.0f, 1.0f, a );
  84. fw->writeText( line, xinc-fw->getTextWidth(line, CREDIT_TEXT_SIZE)/2.0f,lypos , CREDIT_TEXT_SIZE );
  85. textLine++;
  86. };
  87. }