aboutsummaryrefslogtreecommitdiff
path: root/sons_of_sol/private_db/Projectile.cpp
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2025-12-23 12:59:23 -0700
committerJosh Rahm <rahm@google.com>2025-12-23 12:59:23 -0700
commit46efbf05fcade8199035f956e20a63ca91fc88fd (patch)
tree9e3f3e297ea66e442e1a11b5ad16ad8ed6fc7fb7 /sons_of_sol/private_db/Projectile.cpp
parent306bb687414f54177eb37ab7cd744e491c397c31 (diff)
downloadSonsOfSol-46efbf05fcade8199035f956e20a63ca91fc88fd.tar.gz
SonsOfSol-46efbf05fcade8199035f956e20a63ca91fc88fd.tar.bz2
SonsOfSol-46efbf05fcade8199035f956e20a63ca91fc88fd.zip
Run clang-format and add .clang-format
Diffstat (limited to 'sons_of_sol/private_db/Projectile.cpp')
-rw-r--r--sons_of_sol/private_db/Projectile.cpp98
1 files changed, 48 insertions, 50 deletions
diff --git a/sons_of_sol/private_db/Projectile.cpp b/sons_of_sol/private_db/Projectile.cpp
index 7819a0c..339c1de 100644
--- a/sons_of_sol/private_db/Projectile.cpp
+++ b/sons_of_sol/private_db/Projectile.cpp
@@ -2,72 +2,70 @@
#include "glox/GloxColor.hpp"
#include "glox/GloxScopedRotation.hpp"
-using namespace glox ;
-using namespace std ;
+using namespace glox;
+using namespace std;
GloxCube* Projectile::m_model;
-void Projectile::loadModel( ) {
- if( ! m_model ) {
- m_model = new GloxCube( 10, 0.1, 0.1, GloxColor( 255, 255, 0 ) );
- }
+void Projectile::loadModel() {
+ if (!m_model) {
+ m_model = new GloxCube(10, 0.1, 0.1, GloxColor(255, 255, 0));
+ }
}
inline float jitter() {
- return (2 * rand() & 0xFF) / 256.0 ;
+ return (2 * rand() & 0xFF) / 256.0;
}
void Projectile::draw() {
- GloxPoint<> next = m_position + (m_dpos) * 0.2 + GloxPointf(jitter(),jitter(),jitter());
- GloxScopedAttributes __glsa( GL_CURRENT_BIT );
+ GloxPoint<> next =
+ m_position + (m_dpos) * 0.2 + GloxPointf(jitter(), jitter(), jitter());
+ GloxScopedAttributes __glsa(GL_CURRENT_BIT);
- GloxColor(
- (uint8_t)(255.0f / TTL * m_ttl ),
- (uint8_t)(250.0f / pow(TTL,2) * pow(m_ttl,2)),
- (uint8_t)(200.0f / pow(TTL,4) * pow(m_ttl,4)),
- (uint8_t)(100.0)
- ).render();
+ GloxColor((uint8_t)(255.0f / TTL * m_ttl),
+ (uint8_t)(250.0f / pow(TTL, 2) * pow(m_ttl, 2)),
+ (uint8_t)(200.0f / pow(TTL, 4) * pow(m_ttl, 4)), (uint8_t)(100.0))
+ .render();
- glLineWidth( m_ttl / 10.0f );
- GloxWith( GL_LINES,
- m_position.plot();
- GloxColor(
- (uint8_t)(255.0f / TTL * (m_ttl-1) ),
- (uint8_t)(200.0f / pow(TTL,2) * pow(m_ttl-1,2)),
- (uint8_t)(100.0f / pow(TTL,4) * pow(m_ttl-1,4))).render();
- next.plot();
- );
+ glLineWidth(m_ttl / 10.0f);
+ GloxWith(GL_LINES, m_position.plot();
+ GloxColor((uint8_t)(255.0f / TTL * (m_ttl - 1)),
+ (uint8_t)(200.0f / pow(TTL, 2) * pow(m_ttl - 1, 2)),
+ (uint8_t)(100.0f / pow(TTL, 4) * pow(m_ttl - 1, 4)))
+ .render();
+ next.plot(););
}
-Projectile::Projectile( const glox::GloxPoint<>& position, const glox::GloxPoint<>& vec ) {
- m_position = position;
- m_dpos = vec ;
- m_ttl = TTL;
+Projectile::Projectile(const glox::GloxPoint<>& position,
+ const glox::GloxPoint<>& vec) {
+ m_position = position;
+ m_dpos = vec;
+ m_ttl = TTL;
- loadModel();
+ loadModel();
- /* Project the point onto the x,y plane */
- GloxPoint<> first( m_dpos.getX(), m_dpos.getY(), 0 );
- /* A point that represents the x axis */
- GloxPoint<> xaxis( 1, 0, 0 );
+ /* Project the point onto the x,y plane */
+ GloxPoint<> first(m_dpos.getX(), m_dpos.getY(), 0);
+ /* A point that represents the x axis */
+ GloxPoint<> xaxis(1, 0, 0);
- /* Rotation around the z axis */
- float dot = first.dot( xaxis ) ;
- float rot = GloxToDegrees(acos( dot )) ;
+ /* Rotation around the z axis */
+ float dot = first.dot(xaxis);
+ float rot = GloxToDegrees(acos(dot));
- if( first.getY() < 0 ) {
- rot = - rot;
- }
- rot = rot + 180 ;
- m_roty = rot;
- /* x axis now follows *first* vector */
- /* Rotate around y axis to get x to follow *dpos* vector */
- dot = first.dot( m_dpos );
- rot = acos( dot );
- rot = GloxToDegrees( rot );
+ if (first.getY() < 0) {
+ rot = -rot;
+ }
+ rot = rot + 180;
+ m_roty = rot;
+ /* x axis now follows *first* vector */
+ /* Rotate around y axis to get x to follow *dpos* vector */
+ dot = first.dot(m_dpos);
+ rot = acos(dot);
+ rot = GloxToDegrees(rot);
- if( m_dpos.getZ() < 0 ) {
- rot = - rot;
- }
- m_rotz = rot;
+ if (m_dpos.getZ() < 0) {
+ rot = -rot;
+ }
+ m_rotz = rot;
}