projects
/
physics.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fd1a93a
)
renamed a few more members and changed some switch statements
author
Patrik Gornicz
<Gornicz.P@gmail.com>
Tue, 1 Sep 2009 02:03:45 +0000
(22:03 -0400)
committer
Patrik Gornicz
<Gornicz.P@gmail.com>
Tue, 1 Sep 2009 02:03:45 +0000
(22:03 -0400)
src/Effects/GravityWell.cpp
patch
|
blob
|
blame
|
history
src/Effects/GravityWell.h
patch
|
blob
|
blame
|
history
src/Entities/Ball.cpp
patch
|
blob
|
blame
|
history
src/Entities/Entity.cpp
patch
|
blob
|
blame
|
history
src/Entities/Entity.h
patch
|
blob
|
blame
|
history
src/Entities/Particle.cpp
patch
|
blob
|
blame
|
history
src/Entities/PhysicsEntity.cpp
patch
|
blob
|
blame
|
history
src/Entities/Point.cpp
patch
|
blob
|
blame
|
history
src/Entities/Point.h
patch
|
blob
|
blame
|
history
src/Entities/WindParticle.h
patch
|
blob
|
blame
|
history
src/input/inputManager.cpp
patch
|
blob
|
blame
|
history
diff --git
a/src/Effects/GravityWell.cpp
b/src/Effects/GravityWell.cpp
index
a573632
..
38711eb
100644
(file)
--- a/
src/Effects/GravityWell.cpp
+++ b/
src/Effects/GravityWell.cpp
@@
-23,7
+23,7
@@
float wellGravity = 0.5;
/// ***** Constructors/Destructors *****
GravityWell::GravityWell(const Vector2& pos)
/// ***** Constructors/Destructors *****
GravityWell::GravityWell(const Vector2& pos)
- : position(pos)
+ :
m_
position(pos)
{
}
{
}
@@
-39,7
+39,7
@@
Vector2 GravityWell::forceDelta(const PhysicsEntity* e, float) const
const Vector2& pos = e->positionRaw();
float mass = e->m_mass;
const Vector2& pos = e->positionRaw();
float mass = e->m_mass;
- Vector2 delta = position - pos;
+ Vector2 delta =
m_
position - pos;
float sqrDist = delta.sqrLength();
Vector2 acc(0,0);
float sqrDist = delta.sqrLength();
Vector2 acc(0,0);
@@
-52,5
+52,5
@@
Vector2 GravityWell::forceDelta(const PhysicsEntity* e, float) const
void GravityWell::setPosition(const Vector2& pos)
{
void GravityWell::setPosition(const Vector2& pos)
{
- position = pos;
+
m_
position = pos;
}
}
diff --git
a/src/Effects/GravityWell.h
b/src/Effects/GravityWell.h
index
1d9f7e5
..
a23574a
100644
(file)
--- a/
src/Effects/GravityWell.h
+++ b/
src/Effects/GravityWell.h
@@
-37,7
+37,7
@@
class GravityWell: public Effect
void setPosition(const Vector2&);
private:
void setPosition(const Vector2&);
private:
- Vector2 position;
+ Vector2
m_
position;
};
#endif // GRAVITYWELL_H
};
#endif // GRAVITYWELL_H
diff --git
a/src/Entities/Ball.cpp
b/src/Entities/Ball.cpp
index
750b2e5
..
e235739
100644
(file)
--- a/
src/Entities/Ball.cpp
+++ b/
src/Entities/Ball.cpp
@@
-40,7
+40,7
@@
Ball::~Ball()
void Ball::draw() const
{
void Ball::draw() const
{
- graphics::drawCircle(m_radius, position, m_color);
+ graphics::drawCircle(m_radius,
m_
position, m_color);
}
float Ball::getRadius() const
}
float Ball::getRadius() const
diff --git
a/src/Entities/Entity.cpp
b/src/Entities/Entity.cpp
index
ae04514
..
9b630a7
100644
(file)
--- a/
src/Entities/Entity.cpp
+++ b/
src/Entities/Entity.cpp
@@
-24,7
+24,7
@@
using namespace bear;
/// ***** Constructors/Destructors *****
Entity::Entity(const Vector2& pos)
/// ***** Constructors/Destructors *****
Entity::Entity(const Vector2& pos)
- :
position(pos),
velocity(0,0)
+ :
m_position(pos), m_
velocity(0,0)
{
}
{
}
@@
-37,10
+37,10
@@
Entity::~Entity()
const Vector2& Entity::positionRaw() const
{
const Vector2& Entity::positionRaw() const
{
- return position;
+ return
m_
position;
}
const Vector2& Entity::velocityRaw() const
{
}
const Vector2& Entity::velocityRaw() const
{
- return velocity;
+ return
m_
velocity;
}
}
diff --git
a/src/Entities/Entity.h
b/src/Entities/Entity.h
index
ff1db58
..
8e70b99
100644
(file)
--- a/
src/Entities/Entity.h
+++ b/
src/Entities/Entity.h
@@
-39,8
+39,8
@@
class Entity
const Vector2& velocityRaw() const;
protected:
const Vector2& velocityRaw() const;
protected:
- Vector2 position;
- Vector2 velocity;
+ Vector2
m_
position;
+ Vector2
m_
velocity;
};
#endif // ENTITY_H
};
#endif // ENTITY_H
diff --git
a/src/Entities/Particle.cpp
b/src/Entities/Particle.cpp
index
d84ce75
..
c978d38
100644
(file)
--- a/
src/Entities/Particle.cpp
+++ b/
src/Entities/Particle.cpp
@@
-50,5
+50,5
@@
void Particle::update(float time_step)
m_lifeTime -= time_step;
m_isDead = m_lifeTime <= 0;
}
m_lifeTime -= time_step;
m_isDead = m_lifeTime <= 0;
}
-
position +=
velocity * time_step;
+
m_position += m_
velocity * time_step;
}
}
diff --git
a/src/Entities/PhysicsEntity.cpp
b/src/Entities/PhysicsEntity.cpp
index
b43874b
..
752d5eb
100644
(file)
--- a/
src/Entities/PhysicsEntity.cpp
+++ b/
src/Entities/PhysicsEntity.cpp
@@
-40,16
+40,16
@@
PhysicsEntity::~PhysicsEntity()
void PhysicsEntity::update(float time_step)
{
void PhysicsEntity::update(float time_step)
{
- position = positionAt(time_step);
- velocity = velocityAt(time_step);
+
m_
position = positionAt(time_step);
+
m_
velocity = velocityAt(time_step);
m_force *= 0;
}
Vector2 PhysicsEntity::positionAt(float time_step) const
{
m_force *= 0;
}
Vector2 PhysicsEntity::positionAt(float time_step) const
{
- Vector2 newPosition = position;
- Vector2 newVelocity = velocity;
+ Vector2 newPosition =
m_
position;
+ Vector2 newVelocity =
m_
velocity;
Vector2 newForce = m_force;
newPosition += effect::positionDelta(this, time_step);
Vector2 newForce = m_force;
newPosition += effect::positionDelta(this, time_step);
@@
-62,7
+62,7
@@
Vector2 PhysicsEntity::positionAt(float time_step) const
Vector2 PhysicsEntity::velocityAt(float time_step) const
{
Vector2 newForce = m_force;
Vector2 PhysicsEntity::velocityAt(float time_step) const
{
Vector2 newForce = m_force;
- Vector2 newVelocity = velocity;
+ Vector2 newVelocity =
m_
velocity;
newForce += effect::forceDelta(this, time_step);
newVelocity += effect::velocityDelta(this, time_step);
newForce += effect::forceDelta(this, time_step);
newVelocity += effect::velocityDelta(this, time_step);
@@
-72,7
+72,7
@@
Vector2 PhysicsEntity::velocityAt(float time_step) const
void PhysicsEntity::applyForce(const Vector2& force)
{
void PhysicsEntity::applyForce(const Vector2& force)
{
- applyForce(force, position);
+ applyForce(force,
m_
position);
}
void PhysicsEntity::applyForce(const Vector2& force, const Vector2& /*at*/)
{
}
void PhysicsEntity::applyForce(const Vector2& force, const Vector2& /*at*/)
{
@@
-81,14
+81,14
@@
void PhysicsEntity::applyForce(const Vector2& force, const Vector2& /*at*/)
void PhysicsEntity::applyImpulse(const Vector2& impulse)
{
void PhysicsEntity::applyImpulse(const Vector2& impulse)
{
- applyImpulse(impulse, position);
+ applyImpulse(impulse,
m_
position);
}
void PhysicsEntity::applyImpulse(const Vector2& impulse, const Vector2& /*at*/)
{
}
void PhysicsEntity::applyImpulse(const Vector2& impulse, const Vector2& /*at*/)
{
- velocity += impulse;
+
m_
velocity += impulse;
}
void PhysicsEntity::applyNudge(const Vector2& vecPush)
{
}
void PhysicsEntity::applyNudge(const Vector2& vecPush)
{
- position += vecPush;
+
m_
position += vecPush;
}
}
diff --git
a/src/Entities/Point.cpp
b/src/Entities/Point.cpp
index
58dd0da
..
b62e894
100644
(file)
--- a/
src/Entities/Point.cpp
+++ b/
src/Entities/Point.cpp
@@
-24,12
+24,12
@@
using namespace bear;
/// ***** Constructors/Destructors *****
Point::Point(const Vector2& org, bool canDie)
/// ***** Constructors/Destructors *****
Point::Point(const Vector2& org, bool canDie)
- : Particle(org, canDie), radius(2)
+ : Particle(org, canDie),
m_
radius(2)
{
}
Point::Point(const Vector2& org, float life_time)
{
}
Point::Point(const Vector2& org, float life_time)
- : Particle(org, life_time), radius(2)
+ : Particle(org, life_time),
m_
radius(2)
{
}
{
}
diff --git
a/src/Entities/Point.h
b/src/Entities/Point.h
index
901040f
..
bfc83f3
100644
(file)
--- a/
src/Entities/Point.h
+++ b/
src/Entities/Point.h
@@
-36,7
+36,7
@@
class Point: public Particle
virtual void draw();
protected:
virtual void draw();
protected:
- float radius;
+ float
m_
radius;
// color
};
// color
};
diff --git
a/src/Entities/WindParticle.h
b/src/Entities/WindParticle.h
index
560e660
..
9893dee
100644
(file)
--- a/
src/Entities/WindParticle.h
+++ b/
src/Entities/WindParticle.h
@@
-35,7
+35,7
@@
class WindParticle: public Point
virtual void update(float);
protected:
virtual void update(float);
protected:
- float radius;
+ float
m_
radius;
// color
};
// color
};
diff --git
a/src/input/inputManager.cpp
b/src/input/inputManager.cpp
index
23b945c
..
1ba4147
100644
(file)
--- a/
src/input/inputManager.cpp
+++ b/
src/input/inputManager.cpp
@@
-42,8
+42,11
@@
static State keyState[keySize];
void input::init()
{
void input::init()
{
+ // default all keys to released
for(int i=0; i< keySize; i++)
for(int i=0; i< keySize; i++)
+ {
keyState[i] = isR;
keyState[i] = isR;
+ }
}
void input::clean()
{
}
void input::clean()
{
@@
-58,29
+61,38
@@
void input::update()
{
SDL_Event event;
{
SDL_Event event;
- for(int i=0; i< keySize; i++)
+ for(int i=0; i
< keySize; i++)
{
{
- if(keyState[i] == wasR)
- keyState[i] = isR;
- else if(keyState[i] == wasP)
- keyState[i] = isP;
+ State newKeyState;
+
+ switch(keyState[i])
+ {
+ case isR: newKeyState = isR; break;
+ case wasR: newKeyState = isR; break;
+ case isP: newKeyState = isP; break;
+ case wasP: newKeyState = isP; break;
+ default: DASSERT(false); return;
+ }
+
+ keyState[i] = newKeyState;
}
while(0 < SDL_PeepEvents(&event, 1, SDL_GETEVENT, eventMask))
{
switch(event.type)
{
}
while(0 < SDL_PeepEvents(&event, 1, SDL_GETEVENT, eventMask))
{
switch(event.type)
{
- case SDL_KEYUP:
- keyState[event.key.keysym.sym] = wasR;
- break;
- case SDL_KEYDOWN:
- keyState[event.key.keysym.sym] = wasP;
- break;
- case SDL_QUIT:
- keyState[key::end] = wasR;
- break;
- default:
- break;
+ case SDL_KEYUP:
+ keyState[event.key.keysym.sym] = wasR;
+ break;
+ case SDL_KEYDOWN:
+ keyState[event.key.keysym.sym] = wasP;
+ break;
+ case SDL_QUIT:
+ // HACK: simulate an SDL_QUIT event as an ESC key press
+ keyState[key::end] = wasR;
+ break;
+ default:
+ break; // somthing I don't care about
}
}
}
}
}
}