-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlsystem.h
66 lines (59 loc) · 1.44 KB
/
lsystem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <map>
#include <string>
#include <stack>
#include <iostream>
using std::cout; using std::endl;
using std::string;
#include <SDL/SDL.h>
#include "ioManager.h"
#include "parseLsysXML.h"
class LSystem {
public:
LSystem(const string &filename);
~LSystem();
void buildSentence();
void draw() const;
void fillSprite();
void displaySystem() const;
SDL_Surface* getSurface() const { return spriteSurface; }
void changeColor(Uint32);
void changeStrokeLength(int newLength) {
strokeLength = newLength;
}
private:
struct State {
State() : facing(0), x(0), y(0) {}
int facing;
int x;
int y;
};
private:
SDL_Surface *screen;
ParseLsysXML parser;
std::map<string, string> xmlData;
SDL_Surface *spriteSurface;
unsigned width, height;
State state;
const Uint32 BLACK;
const Uint32 MAGENTA;
const Uint32 WHITE;
int levels;
int angle;
int startX;
int startY;
int strokeLength;
int strokeWidth;
int facing;
Uint32 strokeColor;
char startSymbol;
std::multimap<char, string> grammar;
std::stack<State> stateStack;
string sentence;
unsigned findXmlVal( const string& val ) const;
void printGrammar() const;
void line32(int x1, int y1, int x2, int y2, Uint32 color);
void loadSpecification();
void drawSprite() const;
LSystem(const LSystem&);
LSystem& operator=(const LSystem&);
};