0
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
| |
#include "stdafx.h"
#include "CellSet.h"
#include <GL/glut.h>
#include "stdlib.h"
#include "math.h"
#define X_POS -20
#define Y_POS 65
#define X_DIV 22
#define Y_DIV 12
CellSet::CellSet(){
this->xpos = X_POS;
this->ypos = Y_POS;
this->wdiv = X_DIV;
this->hdiv = Y_DIV;
cells_a = new Cell[wdiv*hdiv];
cells_b = new Cell[wdiv*hdiv];
int x, y, i;
for( y = 0; y < hdiv; y++ ){
for( x = 0; x < wdiv; x++ ){
i = x+y*wdiv;
cells_a[i].init( (float)x*50, (float)y*60, 30, 0 );
cells_b[i].init( (float)x*50+15, (float)y*60-25, 30, 1 );
}
}
}
CellSet::~CellSet(){
delete []this->cells_a;
delete []this->cells_b;
this->cells_a = 0;
this->cells_b = 0;
}
void CellSet::update(){
int x, y, i;
glPushMatrix();
glTranslatef( xpos, ypos, 0.0 );
for( y = 0; y < hdiv; y++ ){
for( x = 0; x < wdiv; x++ ){
i = x+y*wdiv;
cells_a[i].update();
cells_b[i].update();
}
}
glPopMatrix();
}
void CellSet::draw(){
int x, y, i;
glPushMatrix();
glTranslatef( xpos, ypos, 0.0 );
for( y = 0; y < hdiv; y++ ){
for( x = 0; x < wdiv; x++ ){
i = x+y*wdiv;
cells_a[i].draw();
cells_b[i].draw();
}
}
glPopMatrix();
}
|