FRESH AND RAW
[potpourri.git] / include / core / Level.h
blob78b20db9bd45a5c13d5f9812ca786bb67f12d6a7
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/>.
19 // NOTES:
21 // A level is, well, the current level.
23 #ifndef __LEVEL_H
24 #define __LEVEL_H
26 #include <vector>
27 #include <string>
28 #include <map>
30 #include "Actor.h"
31 #include "MediaLoader.h"
32 #include "PluginLoader.h"
33 #include "PhysicsSimulation.h"
34 #include "EventPipeline.h"
35 #include "parselevel.h"
37 #include "../plugins/graphics/Graphics.h"
38 #include "../plugins/script/ScriptVM.h"
39 #include "../plugins/audio/Audio.h"
40 #include "../plugins/input/InputManager.h"
42 namespace fragrant
44 typedef Pair<int> LevelPair;
45 const int PROCESS_TIME = 20;
46 const float PROCESS_PIECE = 0.05;
48 struct LevelActor
50 std::string name;
51 std::string source;
52 float zindex;
53 float angle;
54 LevelPair position;
57 struct LevelGraphic
59 std::string source;
60 float zindex;
61 LevelPair position;
64 class Actor;
65 struct LActor // this bullshit is not cool
67 float zindex;
68 Actor* actor;
71 struct StaticGraphic
73 LevelPair position;
74 float zindex;
75 Drawable* drawable;
78 struct ActorData;
80 struct LevelSlice
82 std::string name;
83 std::string presentation;
84 bool startup;
85 LevelPair viewport;
86 std::vector<LevelActor> actors;
87 std::vector<LevelGraphic> static_graphics;
90 struct LevelData
92 std::string name;
93 std::map<std::string, LevelSlice> slices;
94 std::vector<std::string> presentations;
96 LevelSlice getSlice(std::string);
97 std::string toString();
100 class PhysicsSimulation;
101 class Actor;
102 class Game;
103 class Display;
104 class Level : public ScriptedClass
106 public:
107 Level(LevelSlice, Game& game);
108 Level(LevelSlice, Level&, Game&);
109 ~Level();
111 void init(std::vector<ActorData> actor_defs,
112 EventPipeline* pipeline, Audio& audio, ScriptVM* script_vm);
113 void cycle(Display*);
115 // scripting stuff
117 func getConstructor();
118 void destroy();
120 std::string getClassName();
121 std::vector<std::string> getClassFunctions();
122 Variant* callFunction(std::string funcname,
123 std::vector<Variant*> params, ScriptVM* script_vm);
125 // parse level
127 static LevelData parseXML(std::string source,
128 MediaLoader& media_loader);
129 private:
130 std::string presentation;
131 LevelSlice level_data;
133 PhysicsSimulation* simulation;
135 LevelPair viewport;
137 Game& game;
139 std::vector<ActorData> actor_defs;
140 EventPipeline* pipeline;
141 ScriptVM* script_vm;
142 Audio audio;
144 std::vector<LActor> actors;
145 std::vector<StaticGraphic> static_graphics;
149 #endif