diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2018-04-13 17:27:44 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2018-04-13 17:27:44 +0200 |
commit | a055c2aa0aba2a3b80a37c49f3f89cc64d86abd6 (patch) | |
tree | 57bbdd5c9045760d3a94f8ec3b28ccac10620b07 /src/game/rocket.cpp | |
parent | e77c5b1e01eeb55625d8cf072bedd5a34658b865 (diff) |
Half-assed rockets.
Diffstat (limited to 'src/game/rocket.cpp')
-rw-r--r-- | src/game/rocket.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/game/rocket.cpp b/src/game/rocket.cpp new file mode 100644 index 0000000..e88f599 --- /dev/null +++ b/src/game/rocket.cpp @@ -0,0 +1,76 @@ +/* +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 <http://www.gnu.org/licenses/>. +*/ + +#include "game.hpp" + +namespace game { + +/* + class rocket_t : public game::entity_t { + unit_t *shooter; + v2f_t v; + + public: + rocket_t(game::state_t *game, v2f_t x, v2f_t v, unit_t *shooter_); + void render_to(render::state_t *render); + void render_late_to(render::state_t *render) {}; + + void on_think(void); + void on_spawn(void) {}; + void on_wake(void) {}; + void damage(int points, unit_t *attacker) {}; + } +*/ + +const v2f_t rocket_radius(1.0f, 1.0f); + +rocket_t::rocket_t(game::state_t *game, v2f_t x_, v2f_t v_, unit_t *shooter_) : entity_t(game, ET_ROCKET) +{ + x = x_; + v = v_; + shooter = shooter_; + + size = rectf_t(v2f_t(-0.1f, -0.1f), v2f_t(0.1f, 0.1f)); + render_size = size; + cmodel.cflags = CF_BACKGROUND; + + wake(); +} + +void rocket_t::on_think(void) +{ + v2f_t end; + world::trace_t trace; + + end = x + v * game->dt; + trace = world->ray_v_all(x, end, CF_SOLID|CF_BODY|CF_BODY_SMALL, shooter); + if (trace.frac < 1.0f) { + game->explosion(x); + delete this; + return; + } + + x = trace.end; + place(world, x); +} + +void rocket_t::render_to(render::state_t *render) +{ + render->render(game->now, &assets::soldier.rocket, render_bounds); +} + +}
\ No newline at end of file |