Advertisement
Guest User

Untitled

a guest
Aug 15th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.75 KB | None | 0 0
  1. ERROR
  2. =====
  3.  
  4. libsupertux2.a(fireworks.cpp.o): In function `void __gnu_cxx::new_allocator<PhysicsParticles>::construct<PhysicsParticles, Vector&, int, int, int, int, int, Color, int, float, int, float, float, float, float, float, bool>(PhysicsParticles*, Vector&, int&&, int&&, int&&, int&&, int&&, Color&&, int&&, float&&, int&&, float&&, float&&, float&&, float&&, float&&, bool&&)':
  5. fireworks.cpp:(.text._ZN9__gnu_cxx13new_allocatorI16PhysicsParticlesE9constructIS1_JR6Vectoriiiii5ColorififffffbEEEvPT_DpOT0_[_ZN9__gnu_cxx13new_allocatorI16PhysicsParticlesE9constructIS1_JR6Vectoriiiii5ColorififffffbEEEvPT_DpOT0_]+0x301): undefined reference to `PhysicsParticles::PhysicsParticles(Vector const&, int, int, float, float, int, Color, int, float, int, float, float, float, float, float, bool)'
  6. collect2: error: ld returned 1 exit status
  7. CMakeFiles/supertux2.dir/build.make:112: recipe for target 'supertux2' failed
  8. make[2]: *** [supertux2] Error 1
  9. CMakeFiles/Makefile2:68: recipe for target 'CMakeFiles/supertux2.dir/all' failed
  10. make[1]: *** [CMakeFiles/supertux2.dir/all] Error 2
  11. Makefile:151: recipe for target 'all' failed
  12. make: *** [all] Error 2
  13.  
  14. =====================
  15. physics_particles.hpp
  16. =====================
  17. #ifndef HEADER_SUPERTUX_OBJECT_PHYSICS_PARTICLES_HPP
  18. #define HEADER_SUPERTUX_OBJECT_PHYSICS_PARTICLES_HPP
  19.  
  20. #include "object/particles.hpp"
  21.  
  22. class PhysicsParticles : public Particles
  23. {
  24. private:
  25. struct Particle
  26. {
  27. Vector pos, vel;
  28.  
  29. Particle() :
  30. pos(),
  31. vel()
  32. {
  33.  
  34. }
  35. };
  36.  
  37. float m_gravity = -9.8f; // adjust as needed
  38.  
  39. public:
  40. PhysicsParticles(const Vector& epicenter, int min_angle, int max_angle,
  41. const float min_initial_velocity, const float max_initial_velocity,
  42. int number, Color color,
  43. int size, float life_time, int drawing_layer,
  44. float a, float b, float c, float sin_coeff, float cos_coeff,
  45. bool use_gravity);
  46. virtual bool is_saveable() const {
  47. return false;
  48. }
  49.  
  50. virtual void update(float elapsed_time);
  51. virtual void draw(DrawingContext& context);
  52.  
  53. Color m_color;
  54. Timer m_timer;
  55. bool m_live_forever;
  56. float m_size;
  57. int m_drawing_layer;
  58. std::vector<std::unique_ptr<Particle>> m_particles;
  59.  
  60. float m_a;
  61. float m_b;
  62. float m_c;
  63. float m_sin_coeff;
  64. float m_cos_coeff;
  65. bool m_use_gravity;
  66. };
  67.  
  68. #endif
  69.  
  70. /* EOF */
  71.  
  72. ==============
  73. physics_particles.cpp
  74. =====================
  75. #include "object/physics_particles.hpp"
  76.  
  77. #include <math.h>
  78.  
  79. #include "math/random_generator.hpp"
  80. #include "math/util.hpp"
  81. #include "object/camera.hpp"
  82. #include "supertux/sector.hpp"
  83. #include "video/drawing_context.hpp"
  84. #include "video/video_system.hpp"
  85. #include "video/viewport.hpp"
  86.  
  87.  
  88. PhysicsParticles::PhysicsParticles(const Vector& epicenter, int min_angle, int max_angle,
  89. const float min_initial_velocity, const float max_initial_velocity,
  90. int number, Color color,
  91. int size, float life_time, int drawing_layer,
  92. float a, float b, float c, float sin_coeff, float cos_coeff,
  93. bool use_gravity);
  94. m_timer(),
  95. m_live_forever(),
  96. m_color(color_),
  97. m_size(static_cast<float>(size_)),
  98. m_drawing_layer(drawing_layer),
  99. m_a(a),
  100. m_b(b),
  101. m_c(c),
  102. m_sin_coeff(sin_coeff),
  103. m_cos_coeff(cos_coeff),
  104. m_use_gravity(use_gravity),
  105. particles()
  106. {
  107. if(life_time == 0)
  108. {
  109. m_live_forever = true;
  110. }
  111.  
  112. else
  113. {
  114. m_live_forever = false;
  115. timer.start(life_time);
  116. }
  117.  
  118. // create particles
  119. for(int i = 0; i < number; i++)
  120. {
  121. Particle particle = std::unique_ptr<Particle>(new Particle);
  122. particle->pos = epicenter;
  123.  
  124. float velocity = (min_initial_velocity == max_initial_velocity) ? min_initial_velocity :
  125. graphicsRandom.randf(min_initial_velocity, max_initial_velocity);
  126. float angle = (min_angle == max_angle) ? static_cast<float>(min_angle) * (math::PI / 180.0f) :
  127. graphicsRandom.randf(static_cast<float>(min_angle), static_cast<float>(max_angle)) * (math::PI / 180.0f); // convert to radians
  128.  
  129. // vel.x = a * x^3 + b * x^2 + cx + m_sin_coeff(sin(x)) + m_cos_coeff(cos(x))
  130. particle->vel.x = (sinf(angle)) * velocity;
  131. particle->vel.y = (-cosf(angle)) * velocity;
  132. particles.push_back(std::move(particle));
  133. }
  134. }
  135.  
  136. void
  137. ParticlesParticles::update(float dt)
  138. {
  139. // first pass will update particle velocities
  140. for(int i = 0; i < m_particles.size(); i++)
  141. {
  142. m_particles[i]->vel.x += m_a * powf(dt, 3.0f) + m_b * powf(dt, 2.0f) + m_c * dt +
  143. m_sin_coeff * sin(particle->pos.x) + m_cos_coeff * cos(particle->pos.x);
  144. m_particles[i]->vel.y += m_a * powf(dt, 3.0f) + m_b * powf(dt, 2.0f) + m_c * dt +
  145. m_sin_coeff * sin(particle->pos.y) + m_cos_coeff * cos(particle->pos.y);
  146. if(m_use_gravity)
  147. {
  148. m_particles[i]->vel.y += m_gravity * powf(dt, 2.0f);
  149. }
  150.  
  151. }
  152.  
  153. // now we can update positions based on velocity
  154. for(int i = 0; i < m_particles.size(); i++)
  155. {
  156. m_particles[i]->pos.x += m_particles[i]->vel.x * dt;
  157. m_particles[i]->pos.y += m_particles[i]->vel.y * dt;
  158.  
  159. if(m_particles[i]->pos.x < camera.x || m_particles[i]->pos.x > static_cast<float>(SCREEN_WIDTH) + camera.x ||
  160. m_particles[i]->pos.y < camera.y || m_particles[i]->pos.y > static_cast<float>(SCREEN_HEIGHT) + camera.y)
  161. {
  162. m_particles.erase(i);
  163. }
  164. }
  165.  
  166.  
  167. /*
  168. Vector camera = Sector::current()->camera->get_translation();
  169.  
  170.  
  171.  
  172.  
  173. // update particles
  174. for(auto i = particles.begin(); i != particles.end(); ) {
  175. (*i)->pos.x += (*i)->vel.x * dt;
  176. (*i)->pos.y += (*i)->vel.y * dt;
  177.  
  178. (*i)->vel.x += accel.x * dt;
  179. (*i)->vel.y += accel.y * dt;
  180.  
  181. if((*i)->pos.x < camera.x || (*i)->pos.x > static_cast<float>(SCREEN_WIDTH) + camera.x ||
  182. (*i)->pos.y < camera.y || (*i)->pos.y > static_cast<float>(SCREEN_HEIGHT) + camera.y) {
  183. i = particles.erase(i);
  184. } else {
  185. ++i;
  186. }
  187. }
  188.  
  189. if((timer.check() && !live_forever) || particles.size() == 0)
  190. remove_me(); */
  191. }
  192.  
  193. ===========================
  194. fireworks.cpp modifications
  195. ===========================
  196. /*sector->add_object(std::make_shared<Particles>(pos, 0, 360, 140, 140,
  197. Vector(0, 0), 45, Color(red, green, 0), 3, 1.3f,
  198. LAYER_FOREGROUND1+1));*/
  199. sector->add_object(std::make_shared<PhysicsParticles>(pos, 0, 360, 140, 140,
  200. 45, Color(red, green, 0), 3, 1.3f,
  201. LAYER_FOREGROUND1+1,
  202. .01f, .02f, .03f, 0.0f, 0.0f, true));
  203. ===========================
  204. ERROR (repeated from above)
  205. ===========================
  206.  
  207. libsupertux2.a(fireworks.cpp.o): In function `void __gnu_cxx::new_allocator<PhysicsParticles>::construct<PhysicsParticles, Vector&, int, int, int, int, int, Color, int, float, int, float, float, float, float, float, bool>(PhysicsParticles*, Vector&, int&&, int&&, int&&, int&&, int&&, Color&&, int&&, float&&, int&&, float&&, float&&, float&&, float&&, float&&, bool&&)':
  208. fireworks.cpp:(.text._ZN9__gnu_cxx13new_allocatorI16PhysicsParticlesE9constructIS1_JR6Vectoriiiii5ColorififffffbEEEvPT_DpOT0_[_ZN9__gnu_cxx13new_allocatorI16PhysicsParticlesE9constructIS1_JR6Vectoriiiii5ColorififffffbEEEvPT_DpOT0_]+0x301): undefined reference to `PhysicsParticles::PhysicsParticles(Vector const&, int, int, float, float, int, Color, int, float, int, float, float, float, float, float, bool)'
  209. collect2: error: ld returned 1 exit status
  210. CMakeFiles/supertux2.dir/build.make:112: recipe for target 'supertux2' failed
  211. make[2]: *** [supertux2] Error 1
  212. CMakeFiles/Makefile2:68: recipe for target 'CMakeFiles/supertux2.dir/all' failed
  213. make[1]: *** [CMakeFiles/supertux2.dir/all] Error 2
  214. Makefile:151: recipe for target 'all' failed
  215. make: *** [all] Error 2
  216. -----------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement