File: level.cc

package info (click to toggle)
enemylines3 1.2-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,380 kB
  • ctags: 1,444
  • sloc: cpp: 16,323; makefile: 74; sh: 52
file content (79 lines) | stat: -rw-r--r-- 1,245 bytes parent folder | download | duplicates (6)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <sstream>


#include "level.h"

#include "../font_ogl.h"

#include "../util.h"

namespace PRJID {

	Level::Level() {
		label_dl=0;
		reset();
	}

	Level::~Level() {
		if (label_dl!=0) { glDeleteLists(label_dl,1); label_dl=0;}
	}


	void Level::reset() {
		current=1;
	}

	unsigned int Level::get() {
		return current;
	}

	void Level::set_current(unsigned int c) {
		current=c;
	}
	void Level::gain(unsigned int g) {
		current+=g;
	}
	void Level::reduce(unsigned int g) {
		if (g>=current) { 
			current=0;
		} else {
			current-=g;
		}
	}
	void Level::change(int g) {
		if (g>0) gain(g);
		if (g<0) reduce(g*-1);
	}

	void Level::label(std::string l,C3 p) {
			label_dl=glGenLists(1);
			glNewList(label_dl,GL_COMPILE);
			glColor3ub(250,250,250);
			Font_ogl::write(p,l);
			glEndList();
	}

	void Level::dim(C3 p,unsigned int w,unsigned int f) {
		pos=p;
		width=w;
		font=f;
	}

	void Level::draw() {
		std::ostringstream sstr;
		sstr.str("");
		sstr.setf ( std::ios_base::right, std::ios_base::basefield );
		sstr.setf(std::ios_base::showbase);
		sstr.width ( width );
		sstr << current;
		glColor3ub(250,250,250);
		Font_ogl::write(pos,sstr.str());

		if (label_dl!=0) {
			glCallList(label_dl);
		}
		error();

	}

} //namespace