/*
Copyright (C) 2009 Facundo DomÃnguez
This file is part of Spacejunk.
Spacejunk 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 3 of the License, or
(at your option) any later version.
Foobar 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 Foobar. If not, see .
*/
#ifndef STARSHIP_H
#define STARSHIP_H
#include "gamebody.h"
#include
struct TrashData {
public:
real mass;
TrashData(real mass): mass(mass) {};
};
class Starship : public GameBody, public GraphicSeq {
public:
real getFuel();
void setFuel(real fuel);
void setFuelNoMass(real fuel);
/**
* maximum amount of fuel the ship can carry. Its unit is kgs.
*/
real maxFuel;
/**
* The trash the ship is carrying.
*/
std::list collected;
/**
* Builds a ship.
* @param pos Ship initial position.
* @param vel Ship initial velocity.
* @param m Ship mass.
* @param graphicid Identifier of the image for this ship.
*/
Starship(const std::string & graphicid,Vector2d pos=Vector2d(0,0),Vector2d vel=Vector2d(0,0),real m=1e3,real w=0);
int mitime;
int auxtime;
/**
* Starts impulsing the ship.
*/
void turn_on_engine();
/**
* Stops impulsing the ship.
*/
void turn_off_engine();
void turn_left();
void turn_right();
void stop_turning();
/**
* Tells whether the engine is on or not
* @returns true iff the engine is on.
*/
bool powerOn() {
return power;
}
void collectTrash(GameBody* t);
TrashData popTrash();
int getTrashCount();
void stepShip(int delta);
void saveState();
Vector2d getAcceleration(real delta);
Vector2d getDirection();
void setAngle(real a);
void draw(int x,int y,real zoom,real angle);
void accelerate();
real timeToFuel(real delta);
real fuelToTime(real fuel);
PhysicBody * clone();
void copy(PhysicBody * pb) const;
std::ostream & serialize(std::ostream & o) const;
private:
/** Amount of fuel on ship. Its unit is kgs. */
real fuel;
real shipMass;
bool power;
Vector2d dir;
int previous_turnoff_delta;
real previous_fuel;
Graphic flame;
int initcount;
};
#endif // STARSHIP_H