/* This file is part of Minitrem. Minitrem is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. Minitrem is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Minitrem. If not, see . */ #include "game.hpp" namespace game { static const struct { render::animated_texture_t *texture; v2f_t mins, maxs; world::cflags_t cflags; v2f_t render_mins, render_maxs; double fps; } decos[ ] = { { &assets::deco.stone, {-0.4f, +0.1f}, {+0.4f, +0.4f}, CF_SOLID, {-0.4f, -0.4f}, {+0.4f, +0.4f}, 0.0 }, { &assets::deco.stone_cracked, {-0.4f, +0.1f}, {+0.4f, +0.4f}, CF_SOLID, {-0.4f, -0.4f}, {+0.4f, +0.4f}, 0.0 }, { &assets::deco.stone, {-0.2f, +0.1f}, {+0.2f, +0.2f}, CF_DECOS, {-0.2f, -0.2f}, {+0.2f, +0.2f}, 0.0 }, { &assets::deco.eyething, {-0.4f, -0.4f}, {+0.4f, +0.4f}, CF_SOLID, {-0.4f, -1.2f}, {+0.4f, +0.4f}, 0.3 }, { &assets::deco.eyething_dead, {-0.4f, -0.4f}, {+0.4f, +0.4f}, CF_DECOS, {-0.4f, -1.2f}, {+0.4f, +0.4f}, 0.3 }, { &assets::deco.spike, {-0.4f, -0.4f}, {+0.4f, +0.4f}, CF_SOLID, {-0.4f, -1.2f}, {+0.4f, +0.4f}, 0.0 }, { &assets::deco.spike_broken, {-0.4f, -0.4f}, {+0.4f, +0.4f}, CF_DECOS, {-0.4f, -1.2f}, {+0.4f, +0.4f}, 0.0 }, { &assets::deco.spike_small, {-0.2f, +0.1f}, {+0.2f, +0.2f}, CF_DECOS, {-0.2f, -0.6f}, {+0.2f, +0.2f}, 0.0 }, { &assets::deco.wart, {-0.2f, +0.1f}, {+0.2f, +0.2f}, CF_DECOS, {-0.2f, -0.2f}, {+0.2f, +0.2f}, 0.0 }, { &assets::deco.crystal, {-0.4f, -0.4f}, {+0.4f, +0.4f}, CF_DECOS, {-0.4f, -0.4f}, {+0.4f, +0.4f}, 0.0 }, { &assets::deco.crystal_broken, {-0.4f, -0.4f}, {+0.4f, +0.4f}, CF_DECOS, {-0.4f, -0.4f}, {+0.4f, +0.4f}, 0.0 } }; deco_t::deco_t(game::state_t *game_, deco_type_t type_) : game::entity_t(game_, ET_DECO) { type = type_; size[0] = decos[type].mins; size[1] = decos[type].maxs; render_size[0] = decos[type].render_mins; render_size[1] = decos[type].render_maxs; cmodel.cflags = decos[type].cflags; } void deco_t::render_to(render::state_t *render) { render->render(game->now * decos[type].fps + phase_shift, decos[type].texture, render_bounds, sf::Color::White); } void deco_t::damage(int points, unit_t *attacker) { switch (type) { case DECO_STONE: type = DECO_STONE_CRACKED; break; case DECO_EYETHING: type = DECO_EYETHING_DEAD; break; case DECO_SPIKE: type = DECO_SPIKE_BROKEN; break; case DECO_CRYSTAL: type = DECO_CRYSTAL_BROKEN; break; case DECO_STONE_CRACKED: case DECO_EYETHING_DEAD: case DECO_SPIKE_BROKEN: case DECO_CRYSTAL_BROKEN: break; default: game->deletion_list.insert(this); return; } cmodel.cflags = decos[type].cflags; } } // namespace game