dungeon_crawler
diff prototype/src/level.cc @ 46:f3030df27110
debugging the particles
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Thu, 13 Sep 2012 06:33:51 +0300 |
parents | dfd3a413ef9e |
children | aa9e28670ae2 |
line diff
1.1 --- a/prototype/src/level.cc Wed Sep 12 06:04:20 2012 +0300 1.2 +++ b/prototype/src/level.cc Thu Sep 13 06:33:51 2012 +0300 1.3 @@ -100,8 +100,10 @@ 1.4 1.5 Vector3 Level::get_cell_pos(int x, int y) const 1.6 { 1.7 - float posx = (x - xsz / 2) * cell_size; 1.8 - float posy = (y - ysz / 2) * cell_size; 1.9 + float posx = (float)x * cell_size; 1.10 + float posy = (float)y * cell_size; 1.11 + posx -= cell_size * (float)xsz / 2.0f; 1.12 + posy -= cell_size * (float)ysz / 2.0f; 1.13 return Vector3(posx, 0, posy); 1.14 } 1.15 1.16 @@ -175,6 +177,28 @@ 1.17 } 1.18 } 1.19 1.20 +void Level::draw_post() const 1.21 +{ 1.22 + glMatrixMode(GL_MODELVIEW); 1.23 + 1.24 + for(int i=0; i<ysz; i++) { 1.25 + for(int j=0; j<xsz; j++) { 1.26 + const GridCell *cell = get_cell(j, i); 1.27 + if(cell) { 1.28 + Vector3 pos = get_cell_pos(j, i); 1.29 + glPushMatrix(); 1.30 + glTranslatef(pos.x, pos.y, pos.z); 1.31 + glScalef(cell_size, cell_size, cell_size); 1.32 + 1.33 + unsigned int dmask = get_cell_dirmask(j, i); 1.34 + 1.35 + cell->draw_post(dmask); 1.36 + glPopMatrix(); 1.37 + } 1.38 + } 1.39 + } 1.40 +} 1.41 + 1.42 void Level::draw_grid() const 1.43 { 1.44 float xlen = xsz * cell_size; 1.45 @@ -221,7 +245,7 @@ 1.46 tiles.push_back(tile); 1.47 1.48 /* instanciate any particle systems */ 1.49 - const struct psys_attributes **psattr = tile->get_unique_psys(); 1.50 + const struct psys_attributes * const *psattr = tile->get_unique_psys(); 1.51 int num_psattr = tile->get_unique_psys_count(); 1.52 1.53 for(int i=0; i<num_psattr; i++) { 1.54 @@ -233,9 +257,6 @@ 1.55 1.56 void GridCell::update(unsigned long msec, float dt) 1.57 { 1.58 - for(auto tile : tiles) { 1.59 - tile->update(msec, dt); 1.60 - } 1.61 for(auto ps : psys) { 1.62 psys_update(ps, (float)msec / 1000.0f); 1.63 }