3
* Copyright (C) Remigiusz Dybka 2009 <remigiusz.dybka@gmail.com>
5
Zaz is free software: you can redistribute it and/or modify it
6
under the terms of the GNU General Public License as published by the
7
Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
10
Zaz is distributed in the hope that it will be useful, but
11
WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
See the GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License along
16
with this program. If not, see <http://www.gnu.org/licenses/>.
24
#include "textureloader.h"
26
Level::Level(Bezier paths[], int npaths, bool loop, bool invert, string name)
27
:loop(loop), name(name), invert(invert), startFeedRate(1), endFeedRate(1),
28
ballsToDraw(10), ballsFromStart(0), colors(3), backgroundTex(0)
37
glDeleteTextures(1, &backgroundTex);
41
void Level::NewLevel()
57
Save(savePhilename.c_str());
60
void Level::Save(const char *philename)
62
std::ofstream out(philename);
67
out << paths.size() << endl;
69
for (uint i = 0; i < paths.size(); ++i)
72
out << paths[i].points.size() << endl;
73
for (uint p = 0; p < paths[i].points.size(); ++p)
75
BezierPoint pt = paths[i].points[p];
76
out << pt.x << " " << pt.y << " " << pt.cx << " " << pt.cy << endl;
81
out << invert << endl;
82
out << startFeedRate << endl;
83
out << endFeedRate << endl;
84
out << ballsToDraw << endl;
85
out << ballsFromStart << endl;
86
out << colors << endl;
91
void Level::LoadData(string philename)
93
savePhilename = philename;
95
std::ifstream in(philename.c_str());
119
for (int i = 0; i < npaths; ++i)
121
paths.push_back(Bezier());
131
for (int p = 0; p < pl; ++p)
138
sl >> x >> y >> cx >> cy;
139
paths[i].points.push_back(BezierPoint (x, y, cx, cy));
178
sl >> ballsFromStart;
194
Level::Level(const char *philename, bool skipGfx)
198
string phn(philename);
199
// strip philename of extensions
200
phn = phn.substr(0, phn.find_last_of("."));
202
LoadData(phn + ".lvl");
207
backgroundTex = LoadTextureFile(phn.c_str());