projects
/
physics.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
46e842c
)
gravity well now follows the mouse
v0.05
author
Patrik Gornicz
<Gornicz.P@gmail.com>
Thu, 21 Aug 2008 20:58:24 +0000
(16:58 -0400)
committer
Patrik Gornicz
<Gornicz.P@gmail.com>
Thu, 21 Aug 2008 20:58:24 +0000
(16:58 -0400)
src/Effects/GravityWell.cpp
patch
|
blob
|
blame
|
history
src/Effects/GravityWell.h
patch
|
blob
|
blame
|
history
src/Effects/Screen.cpp
patch
|
blob
|
blame
|
history
src/effectManager.cpp
patch
|
blob
|
blame
|
history
src/effectManager.h
patch
|
blob
|
blame
|
history
src/entityManager.cpp
patch
|
blob
|
blame
|
history
src/input/inputManager.cpp
patch
|
blob
|
blame
|
history
src/input/inputManager.h
patch
|
blob
|
blame
|
history
diff --git
a/src/Effects/GravityWell.cpp
b/src/Effects/GravityWell.cpp
index
4fcd446
..
68afa27
100644
(file)
--- a/
src/Effects/GravityWell.cpp
+++ b/
src/Effects/GravityWell.cpp
@@
-48,3
+48,8
@@
Vector2 GravityWell::forceDelta(const PhysicsEntity* e, float) const
return acc;
}
return acc;
}
+
+void GravityWell::setPosition(const Vector2& pos)
+{
+ position = pos;
+}
diff --git
a/src/Effects/GravityWell.h
b/src/Effects/GravityWell.h
index
36b9dec
..
d6165d3
100644
(file)
--- a/
src/Effects/GravityWell.h
+++ b/
src/Effects/GravityWell.h
@@
-27,11
+27,13
@@
class GravityWell: public Effect
{
public:
class GravityWell: public Effect
{
public:
- GravityWell(const Vector2&
pos
);
+ GravityWell(const Vector2&);
~GravityWell();
Vector2 forceDelta(const PhysicsEntity*, float) const;
~GravityWell();
Vector2 forceDelta(const PhysicsEntity*, float) const;
+ void setPosition(const Vector2&);
+
private:
Vector2 position;
};
private:
Vector2 position;
};
diff --git
a/src/Effects/Screen.cpp
b/src/Effects/Screen.cpp
index
61108c4
..
f7bf80e
100644
(file)
--- a/
src/Effects/Screen.cpp
+++ b/
src/Effects/Screen.cpp
@@
-37,7
+37,6
@@
Screen::~Screen()
Vector2 Screen::positionDelta(const PhysicsEntity* e, float time_step) const
{
const Vector2& pos = e->positionRaw();
Vector2 Screen::positionDelta(const PhysicsEntity* e, float time_step) const
{
const Vector2& pos = e->positionRaw();
- const Vector2& velo = e->velocityRaw();
Vector2 acc(0,0);
Vector2 acc(0,0);
diff --git
a/src/effectManager.cpp
b/src/effectManager.cpp
index
6ebffdd
..
2e50c65
100644
(file)
--- a/
src/effectManager.cpp
+++ b/
src/effectManager.cpp
@@
-23,12
+23,15
@@
#include "Effects/Screen.h"
#include "Vector2.h"
#include "Effects/Screen.h"
#include "Vector2.h"
+#include "input/inputManager.h"
/// ***** Private Variables *****
Effect** effects;
int numEffects;
/// ***** Private Variables *****
Effect** effects;
int numEffects;
+GravityWell* mouseWell;
+
/// ***** Initializers/Cleaners *****
void effect::init()
/// ***** Initializers/Cleaners *****
void effect::init()
@@
-36,8
+39,10
@@
void effect::init()
numEffects = 3;
effects = new Effect*[numEffects]();
numEffects = 3;
effects = new Effect*[numEffects]();
- effects[0] = new Gravity();
- effects[1] = new GravityWell(Vector2(400,400));
+ mouseWell = new GravityWell(input::mousePosition());
+
+ effects[0] = mouseWell;
+ effects[1] = new Gravity();
effects[2] = new Screen();
}
void effect::clean()
effects[2] = new Screen();
}
void effect::clean()
@@
-52,6
+57,15
@@
void effect::clean()
/// ***** Public Methods *****
/// ***** Public Methods *****
+void effect::update(float)
+{
+
+}
+void effect::handleInput()
+{
+ mouseWell->setPosition(input::mousePosition());
+}
+
Vector2 effect::positionDelta(const PhysicsEntity* e, float time_step)
{
Vector2 acc(0,0);
Vector2 effect::positionDelta(const PhysicsEntity* e, float time_step)
{
Vector2 acc(0,0);
diff --git
a/src/effectManager.h
b/src/effectManager.h
index
089c12a
..
f77e191
100644
(file)
--- a/
src/effectManager.h
+++ b/
src/effectManager.h
@@
-27,6
+27,9
@@
namespace effect
void init();
void clean();
void init();
void clean();
+ void update(float);
+ void handleInput();
+
Vector2 positionDelta(const PhysicsEntity*, float);
Vector2 velocityDelta(const PhysicsEntity*, float);
Vector2 forceDelta(const PhysicsEntity*, float);
Vector2 positionDelta(const PhysicsEntity*, float);
Vector2 velocityDelta(const PhysicsEntity*, float);
Vector2 forceDelta(const PhysicsEntity*, float);
diff --git
a/src/entityManager.cpp
b/src/entityManager.cpp
index
c7fc78b
..
c78a7ce
100644
(file)
--- a/
src/entityManager.cpp
+++ b/
src/entityManager.cpp
@@
-25,6
+25,7
@@
#include "Entities/PhysicsEntity.h"
#include "collisionHandler.h"
#include "Entities/PhysicsEntity.h"
#include "collisionHandler.h"
+#include "effectManager.h"
/// ***** Private Method Headers *****
/// ***** Private Method Headers *****
@@
-107,10
+108,12
@@
void manager::remove(Entity* e)
void manager::handleInput()
{
void manager::handleInput()
{
- // TODO
+ effect::handleInput();
}
void manager::update(float time_step)
{
}
void manager::update(float time_step)
{
+ effect::update(time_step);
+
updateParticles(time_step);
updatePhysics(time_step);
}
updateParticles(time_step);
updatePhysics(time_step);
}
diff --git
a/src/input/inputManager.cpp
b/src/input/inputManager.cpp
index
a8491b1
..
0df4baa
100644
(file)
--- a/
src/input/inputManager.cpp
+++ b/
src/input/inputManager.cpp
@@
-72,6
+72,16
@@
void input::update()
}
}
}
}
+Vector2 input::mousePosition()
+{
+ int x;
+ int y;
+
+ SDL_GetMouseState(&x, &y);
+
+ return Vector2(x,y);
+}
+
bool input::isPressed(Uint8 key)
{
return keyState[key] == isP || keyState[key] == wasP;
bool input::isPressed(Uint8 key)
{
return keyState[key] == isP || keyState[key] == wasP;
diff --git
a/src/input/inputManager.h
b/src/input/inputManager.h
index
a117324
..
3e0e45d
100644
(file)
--- a/
src/input/inputManager.h
+++ b/
src/input/inputManager.h
@@
-19,6
+19,7
@@
#define INPUT_H
#include <SDL/SDL.h>
#define INPUT_H
#include <SDL/SDL.h>
+#include "../Vector2.h"
/// ***** Header Methods *****
/// ***** Header Methods *****
@@
-30,6
+31,8
@@
namespace input
void update();
void update();
+ Vector2 mousePosition();
+
bool isPressed(Uint8);
bool isReleased(Uint8);
bool isPressed(Uint8);
bool isReleased(Uint8);