1 // Copyright 2008 Brian Caine
3 // This file is part of Potpourri.
5 // Potpourri is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Potpourri is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTIBILITY of FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Potpourri. If not, see <http://www.gnu.org/licenses/>.
21 // This is the Actor class.
26 #include "MediaLoader.h"
27 #include "ScriptedClass.h"
28 #include "EventReceiver.h"
33 #include "../Global.h"
35 #include "../plugins/graphics/Graphics.h"
36 #include "../plugins/audio/Audio.h"
37 #include "../plugins/input/InputManager.h"
45 typedef Pair
<float> ActorPair
;
46 typedef Pair
<int> LevelPair
;
48 ActorPair
makePair(float, float);
51 // so, we need to invert y for graphics/physics stuff
52 // 500 is an arbitrary point, and shouldn't really matter
54 // well what about static lines, eh?
56 // yeah, so, fixed it to zero
58 struct ActorGraphics
// fixme
65 // a line fills the first two pairs in PhysicsShape's data member with
66 // the first and second point. The radius of the line is set as the x
69 // Circles have x of one member of data set to the radius
81 std::vector
<ActorPair
> data
;
94 LevelPair base_position
; // it is really only relevant for lines
96 std::vector
<PhysicsShape
> shapes
; // oh god, no!
99 struct ActorGraphic
// fixme: poor choice of naming here
108 class PhysicsSimulation
;
113 std::vector
<ActorGraphics
> graphics
; // fixme: per other fixmes
114 ActorPhysics physics
;
115 std::map
<std::string
, std::string
> scripts
;
120 InputManager
* input_manager
;
121 PhysicsSimulation
* simulation
;
122 MediaLoader
* media_loader
;
127 class Actor
: public ScriptedClass
, public EventReceiver
130 Actor(ActorData data
);
133 void draw(Target
* target
, LevelPair offset
);
134 void setAngle(float);
138 void raiseEvent(Event event
);
142 func
getConstructor();
145 std::string
getClassName();
146 std::vector
<std::string
> getClassFunctions();
147 Variant
* callFunction(std::string funcname
,
148 std::vector
<Variant
*> params
, ScriptVM
* script_vm
);
152 static ActorData
parseXML(std::string source
,
153 MediaLoader
& media_loader
);
156 std::vector
<ActorGraphic
> sprites
;
158 std::map
<std::string
, std::string
> ldata
;
161 ActorData initial_params
;
165 PhysicsObject
* physics_object
;