File: score.cc

package info (click to toggle)
enemylines3 1.2-6
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,384 kB
  • ctags: 1,445
  • sloc: cpp: 16,323; makefile: 70; sh: 52
file content (77 lines) | stat: -rw-r--r-- 1,218 bytes parent folder | download | duplicates (11)
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
#include <sstream>


#include "score.h"

#include "../font_ogl.h"

namespace PRJID {

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

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


	void Score::reset() {
		current=0;
	}


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

	void Score::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 Score::dim(C3 p,unsigned int w,unsigned int f) {
		pos=p;
		width=w;
		font=f;
	}

	void Score::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);
		}

	}

std::ostream& operator<<(std::ostream&s, Score sk) {
	return s;
}

} //namespace