fork download
  1.  
  2. struct Player {
  3. Animated<sf::Vector2> position;
  4. Animated<float> radius;
  5. Animated<cf::Color> color;
  6.  
  7. void tick(int deltaTime) {
  8. position.tick(deltaTime);
  9. radius.tick(deltaTime);
  10. color.tick(deltaTime);
  11. }
  12. };
  13.  
  14. template <typename T>
  15. Animation<T> *moveBy(const T &initial, const T &delta)
  16. {
  17. return new LinearAnimation(initial, initial + delta);
  18. }
  19.  
  20. template <typename T>
  21. Animation<T> *moveTo(const T &initial, const T &final)
  22. {
  23. return new LinearAnimation(initial, final);
  24. }
  25.  
  26.  
  27. Player player;
  28.  
  29. player.position.animate(moveBy(player.position.value(), sf::Vector2(50.0f, 0.0f)))
  30. player.radius.animate(moveTo(75.0f, 50.0f));
  31. player.color.animate(moveTo(RED_COLOR, WHITE_COLOR));
  32.  
  33. while(...) {
  34. deltaTime = ...;
  35. player.tick(deltaTime)
  36. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:5: error: 'Animated' does not name a type
     Animated<sf::Vector2> position;
     ^
prog.cpp:4:5: error: 'Animated' does not name a type
     Animated<float> radius;
     ^
prog.cpp:5:5: error: 'Animated' does not name a type
     Animated<cf::Color> color;
     ^
prog.cpp: In member function 'void Player::tick(int)':
prog.cpp:8:9: error: 'position' was not declared in this scope
         position.tick(deltaTime);
         ^
prog.cpp:9:9: error: 'radius' was not declared in this scope
         radius.tick(deltaTime);
         ^
prog.cpp:10:9: error: 'color' was not declared in this scope
         color.tick(deltaTime);
         ^
prog.cpp: At global scope:
prog.cpp:15:1: error: 'Animation' does not name a type
 Animation<T> *moveBy(const T &initial, const T &delta)
 ^
prog.cpp:21:1: error: 'Animation' does not name a type
 Animation<T> *moveTo(const T &initial, const T &final)
 ^
prog.cpp:29:1: error: 'player' does not name a type
 player.position.animate(moveBy(player.position.value(), sf::Vector2(50.0f, 0.0f)))
 ^
prog.cpp:31:1: error: 'player' does not name a type
 player.color.animate(moveTo(RED_COLOR, WHITE_COLOR));
 ^
prog.cpp:33:1: error: expected unqualified-id before 'while'
 while(...) {
 ^
stdout
Standard output is empty