dungeon_crawler
diff prototype/src/level.cc @ 45:dfd3a413ef9e
particle system 1
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 12 Sep 2012 06:04:20 +0300 |
parents | 862461b686f4 |
children | f3030df27110 |
line diff
1.1 --- a/prototype/src/level.cc Thu Aug 30 06:08:22 2012 +0300 1.2 +++ b/prototype/src/level.cc Wed Sep 12 06:04:20 2012 +0300 1.3 @@ -208,13 +208,27 @@ 1.4 GridCell::GridCell(Tile *tile) 1.5 { 1.6 if(tile) { 1.7 - tiles.push_back(tile); 1.8 + add_tile(tile); 1.9 } 1.10 } 1.11 1.12 void GridCell::add_tile(Tile *tile) 1.13 { 1.14 + if(!tile) { 1.15 + return; 1.16 + } 1.17 + 1.18 tiles.push_back(tile); 1.19 + 1.20 + /* instanciate any particle systems */ 1.21 + const struct psys_attributes **psattr = tile->get_unique_psys(); 1.22 + int num_psattr = tile->get_unique_psys_count(); 1.23 + 1.24 + for(int i=0; i<num_psattr; i++) { 1.25 + struct psys_emitter *emitter = psys_create(); 1.26 + emitter->attr = *psattr[i]; 1.27 + psys.push_back(emitter); 1.28 + } 1.29 } 1.30 1.31 void GridCell::update(unsigned long msec, float dt) 1.32 @@ -222,6 +236,9 @@ 1.33 for(auto tile : tiles) { 1.34 tile->update(msec, dt); 1.35 } 1.36 + for(auto ps : psys) { 1.37 + psys_update(ps, (float)msec / 1000.0f); 1.38 + } 1.39 } 1.40 1.41 void GridCell::draw(unsigned int draw_mask) const 1.42 @@ -237,3 +254,13 @@ 1.43 tile->draw_lights(draw_mask); 1.44 } 1.45 } 1.46 + 1.47 +void GridCell::draw_post(unsigned int draw_mask) const 1.48 +{ 1.49 + for(auto tile : tiles) { 1.50 + tile->draw_post(draw_mask); 1.51 + } 1.52 + for(auto ps : psys) { 1.53 + psys_draw(ps); 1.54 + } 1.55 +}