2018-08-09 18:11:18 +02:00
|
|
|
//
|
|
|
|
// Created by Wouter Groeneveld on 09/08/18.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <libgba-sprite-engine/background/text_stream.h>
|
|
|
|
#include <libgba-sprite-engine/gba/tonc_bios.h>
|
2018-12-14 19:50:47 +01:00
|
|
|
#include <cmath>
|
|
|
|
#include <libgba-sprite-engine/math.h>
|
2018-08-09 18:11:18 +02:00
|
|
|
#include "bullet.h"
|
|
|
|
|
|
|
|
|
2018-12-14 13:11:13 +01:00
|
|
|
void Bullet::setDestination(VECTOR destination) {
|
|
|
|
auto currentPos = sprite->getPos();
|
|
|
|
this->dest = destination;
|
2018-08-09 18:11:18 +02:00
|
|
|
|
2018-12-14 19:50:47 +01:00
|
|
|
this->coords = Math::bresenhamLineBetween(currentPos, destination);
|
2018-08-09 18:11:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Bullet::tick() {
|
2018-12-14 19:50:47 +01:00
|
|
|
if(coords.empty()) {
|
|
|
|
return;
|
2018-08-09 18:11:18 +02:00
|
|
|
}
|
|
|
|
|
2018-12-14 19:50:47 +01:00
|
|
|
sprite->moveTo(coords.front());
|
|
|
|
coords.pop_front();
|
2018-12-14 13:11:13 +01:00
|
|
|
}
|