--- rafkill-1.2.2.orig/config.log +++ rafkill-1.2.2/config.log @@ -0,0 +1,2 @@ +file /home/user/NEW/rafkill-1.2.2/SConstruct,line 5: + Configure(confdir = .sconf_temp) --- rafkill-1.2.2.orig/build/booster.h +++ rafkill-1.2.2/build/booster.h @@ -0,0 +1,36 @@ +#ifndef _booster_h +#define _booster_h + +#include "bitmap.h" + +class PixelList{ +public: + + PixelList( int ax, int ay, int l, PixelList * nx ); + + int Update(); + void Draw( const Bitmap & work, int * shade, int offset )const; + + int x, y; + int life; + PixelList * next; +}; + +class Booster{ +public: + + Booster(); + + void add( int x, int y ); + void Draw( const Bitmap & work, int offset )const; + + void Update(); + + ~Booster(); + + PixelList * head; + int * shade; + +}; + +#endif --- rafkill-1.2.2.orig/build/shipobj.cpp +++ rafkill-1.2.2/build/shipobj.cpp @@ -0,0 +1,254 @@ +#include "shipobj.h" +#include "hull.h" +#include "raptor.h" +#include "bitmap.h" +#include "trigtable.h" +#include "explode.h" +//#include "explode_slim.h" +#include "explode_animate.h" +#include "gunobj.h" +#include "sound.h" +#include "move.h" +#include "defs.h" +#include "strings.h" +#include "booster.h" +#include "section.h" + +#include "hulls/hull_num_show.h" +#include "hulls/hull_player.h" + +#include + +//{ +ShipObject::ShipObject( int qx, int qy, int spc, HullObject * hnew, Group * _group, Move * movey, int al ): +SpaceObject(qx,qy, 0, 0, hnew, _group, PLANE_AIR, al ), +special( spc ) { + style = movey; +} + +void ShipObject::Died( SpaceObject * check, ExplosionClass ** explr, int ME ){ + if ( check != NULL ){ + check->IncScore( special + (int)(hull->original_life * 10) ); + } + this->Explode( explr, ME ); + + Util::playSound( SND_EXPLODE_2, 180 ); +} + +bool ShipObject::powerUp() { + return true; +} + + +double ShipObject::Hurt() { + if ( getLife() >= hull->Hurt() ) return hull->Hurt(); + if ( getLife() > 0 ) return getLife(); + return 1; +} + +/* PONDER: + * Should I extract movement from AI? + * Maybe they could be seperate functions which might make + * scripting a little easier.. + */ +void ShipObject::MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ){ + + double sdx = getDX(); + double sdy = getDY(); + + if ( style ) + style->action( fight, getX(), getY(), sdx, sdy ); + setDX( sdx ); + setDY( sdy ); + + MoveReal(); + + if ( hull ) hull->Moved( this->getDX(), this->getDY(), this->getAccelX(), this->getAccelY() ); + + int middle_x = this->getX() + this->getMaxX() / 2; + int middle_y = this->getY() + this->getMaxY() / 2; + + middle_x = getX(); + middle_y = getY(); + + if ( getY() > -10 ) { + + WeaponObject ** myGun = hull->Guns(); + if ( myGun != NULL ) { + for ( int q = 0; q < hull->maxGuns(); q++ ) + if ( myGun[q] != NULL ){ + if ( myGun[q]->getShotCounter() > 0 ) + myGun[q]->Wait( 1 ); + else myGun[q]->MakeShot( middle_x, middle_y, Ammo, fight ); + } + + } + } + +} + + +void ShipObject::Explode( ExplosionClass ** explr, int ME ) { + int mx = getX(); + int my = getY(); + ExplosionClass * w_expl = new ExplosionAnimate( mx, my, this->getDX()/2, this->getDY()/2, EXPLODE_1, EXPLODE_A_30 ); + addExplode( explr, ME, w_expl ); +} + + +ShipObject::~ShipObject() { + if ( style != NULL ) delete style; +} + + +//} +//{ +MeteorObject::MeteorObject( int qx, int qy, int spc, HullObject * hnew, Move * hmove ): +ShipObject( qx, qy, spc, hnew, NULL, hmove, TEAM_ENEMY ){} + +void MeteorObject::Explode( ExplosionClass ** explr, int ME ) { + int middle_x = this->getX() + this->getMaxX() / 2; + int middle_y = this->getY() + this->getMaxY() / 2; + ExplosionClass * w_expl = new ExplosionAnimate( middle_x, middle_y, this->getDX()/2, this->getDY()/2, GR_EXPLODE_01, GR_EXPLODE_29 ); + addExplode( explr, ME, w_expl ); +} + + +//{ + +//} +//{ +EnemyGeneric::EnemyGeneric( int qx, int qy, HullObject * hnew, WeaponObject * myW, Move * movey, Group * _group ): +ShipObject(qx,qy,100,hnew, _group, movey,TEAM_ENEMY) { + //WeaponObject ** myGun = hull->Guns(); + //if ( myGun != NULL ) + // myGun[0] = myW; + hull->giveWeapon( myW, 0 ); +} + + +void EnemyGeneric::Radar( const Bitmap & rad ) const{ + //putpixel( rad, (int)( (float)actualx / ( (float)screen_x / (float)rad->w ) ), (int)( (float)actualy / ( (float)screen_y / (float)rad->h ) ), makecol(200,100,0) ); + // circlefill( rad, (int)( (float)getX() / ( (float)screen_x / (float)rad->w ) ), (int)( (float)getY() / ( (float)screen_y / (float)rad->h ) ), 1, makecol(200,100,0) ); + int x = (int)( (float)getX() / ( (float) Util::screen_x / (float)rad.getWidth() ) ); + int y = (int)( (float)getY() / ( (float) Util::screen_y / (float)rad.getHeight() ) ); + + rad.circleFill( x, y, 1, Bitmap::makeColor(200,100,0) ); + /* test */ + +} + + +//} +//{ +Money::Money( int qx, int qy, int m, HullObject * hnew, Move * movey ): +PowerUp( qx, qy, hnew, movey ) { + str = 0; + special = m; +} + +void Money::Died( SpaceObject * check, ExplosionClass ** explr, int ME ){ + if ( check != NULL ){ + check->IncScore( special ); + } + + Util::playSound( SND_POWER, 255 ); +} + +bool Money::Damage( double much ) { + delete hull; + hull = new HullShow( special ); + // style->setD( 0, 0 ); + delete style; + style = NULL; + return true; +} + + +//} +//{ +PowerUp::PowerUp( int qx, int qy, HullObject * hnew, Move * movey ): +ShipObject( qx, qy, 0, hnew, NULL, movey,TEAM_ENEMY ) { + str = 0; +} + + +void PowerUp::Died( SpaceObject * check, ExplosionClass ** explr, int ME ){ + if ( check != NULL ) { + + /* + WeaponObject ** gz = check->hull->Guns(); + if ( pcount( (char **)gz, check->hull->maxGuns()-1 ) == 0 ) return; + int q = rnd( check->hull->maxGuns()-1 ); + while ( gz[q] == NULL ) q = rnd(check->hull->maxGuns()-1); + gz[q]->IncreasePower( 1 ); + */ + WeaponObject * gz[ check->getHull()->maxGuns() - 1 ]; + for ( int q = 0; q < check->getHull()->maxGuns()-1; q++ ) { + gz[q] = NULL; + if ( check->getHull()->Guns()[q] != NULL && (check->getHull()->Guns()[q]->getPower() < check->getHull()->Guns()[q]->maxPower() || check->getHull()->Guns()[q]->maxPower() == -1) ) + gz[q] = check->getHull()->Guns()[q]; + } + int q = Util::rnd( check->getHull()->maxGuns()-1 ); + if ( Util::pcount( (char **)gz, check->getHull()->maxGuns()-1 ) == 0 ) { + // delete[] gz; + return; + } + while ( gz[q] == NULL ) q = Util::rnd( check->getHull()->maxGuns()-1 ); + gz[q]->IncreasePower( 1 ); + + } + + Util::playSound( SND_POWER, 255 ); +} + + +bool PowerUp::Damage( double much ) { + getHull()->takeDamage( getLife()+1 ); + return true; +} + + +void PowerUp::Radar( const Bitmap & rad ) const{ +} + + +bool PowerUp::isSpecial() const { + return true; +} + + +bool PowerUp::powerUp() { + return false; +} + + +//} +Health::Health( int qx, int qy, HullObject * hnew, Move * movey ): +PowerUp( qx, qy, hnew, movey ) { +} + +void Health::Died( SpaceObject * check, ExplosionClass ** explr, int ME ){ + if ( check != NULL ) { + + check->getHull()->life += 20; + if ( check->getHull()->life > ((PlayerHull *)check->getHull())->getMaxLife() ) + check->getHull()->life = ((PlayerHull *)check->getHull())->getMaxLife(); + + } + + Util::playSound( SND_HEALTH, 255 ); +} + + +Cloak::Cloak( int qx, int qy, HullObject * hnew, Move * movey ): +PowerUp( qx, qy, hnew, movey ) { +} + +void Cloak::Died( SpaceObject * check, ExplosionClass ** explr, int ME ){ + if ( check != NULL ) { + ((PlayerHull *)check->getHull())->cloak = 300; + } + + Util::playSound( SND_POWER, 255 ); +} --- rafkill-1.2.2.orig/build/spaceobj.cpp +++ rafkill-1.2.2/build/spaceobj.cpp @@ -0,0 +1,629 @@ +#include +#include "defs.h" +#include "spaceobj.h" +#include "gunobj.h" +#include "hull.h" +#include "group.h" +#include "section.h" +#include +#include "bitmap.h" +#include + +using namespace std; + +/* Constructor: + * Parameters are: + * sx - X coordinate of object + * sy - Y coordinate of object + * qx - X velocity of object + * qy - Y velocity of object + * mhull - Hullobject of the object + * PLANE - drawing level of the object + * ali - TEAM of the object + */ +SpaceObject::SpaceObject( int sx, int sy, double qx, double qy, HullObject * mhull, Group * _group, int _plane, int ali ): +actualx(sx), +actualy(sy), +old_x(sx), +old_y(sy), +virtualx(sx), +virtualy(sy), +dx(qx), +dy(qy), +score( 0 ), +offset_x( 0 ), +offset_y( 0 ), +plane( _plane ), +alignment( ali ) { + + hull = mhull; + + // collide_list = new vector< SpaceObject * >(); + + my_group = _group; + if ( my_group != NULL ) + my_group->add( this ); +} + +SpaceObject::SpaceObject( const SpaceObject & s ){ + cout<<"SpaceObject copy constructor run. This should not happen"<Inside( actualx, actualy, ax, ay ); +} + + +/* MoveMe: + * Allows the object to move and use all of its resources. + * It is passed the list of the ammo it can shot, a list of its enemies, + * an object which stores its position on the screen for collision detection, + * and a sound datafile. + */ + +void SpaceObject::MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ){ + MoveReal(); + if ( hull ) hull->Moved( this->getDX(), this->getDY(), this->getAccelX(), this->getAccelY() ); + // if ( hull ) hull->addSection( this, onscreen, actualx, actualy ); + // return ( actualx < -20 || actualx > screen_x + 20 || actualy < -10 || actualy > screen_y + 20 ); +} + +void SpaceObject::addSection( Section * onscreen ){ + if ( hull ) hull->addSection( this, onscreen, actualx, actualy ); +} + + +/* CanbeHit: + * Returns true if there could be a collision between the this object + * and the object passed to it. + * Returns true unless one of the following is true: + * Hull is translucent + * Teams are the same + * If this doesnt accept powerups and the other object gives them + * The planes are different + */ +bool SpaceObject::CanbeHit( const SpaceObject * ht ) const { + if ( ht == NULL ) return false; + if ( ht == this ) return false; + if ( hull ) + if ( hull->Translucent() ) return false; + if ( getTeam() == ht->getTeam() ) return false; + if ( isSpecial() && !ht->acceptSpecial() ) return false; + if ( ht->isSpecial() && !acceptSpecial() ) return false; + return plane & ht->plane; +} + +int SpaceObject::lookPlane() const{ + if ( !hull ) return 0; + return hull->drawLevel; +} + +bool SpaceObject::Destroyable() const{ + return true; +} + +/* AccelX: + * returns the X acceleration + */ +double SpaceObject::getAccelX(){ + return accel_x; +} + +/* AccelY: + * returns the Y acceleration + */ +double SpaceObject::getAccelY(){ + return accel_y; +} + +/* DX: + * returns the dx instance of the object. + * DX is the x velocity. + */ +double SpaceObject::getDX() { + return dx; +} + + +/* DY: + * returns the dy instance of th object + * DY is the y velocity. + */ +double SpaceObject::getDY() { + return dy; +} + + +/* Hurt: + * Returns how much damage the hull will do when it collides with + * something. + */ +double SpaceObject::Hurt() { + if ( !hull ) return 0; + return hull->Hurt(); +} + + +/* PowerUp: + * Returns true if this object will produce a powerup when destroyed + */ +bool SpaceObject::powerUp() { + return false; +} + + +/* isSpecial: + * Returns true if object is a powerup. Is only true for the powerup class. + */ +bool SpaceObject::isSpecial() const { + return false; +} + + +/* Collided: + * If the object collides with something, this method is run to do + * any special things necessary. Default is nothing. + */ +void SpaceObject::Collided( SpaceObject * who, ExplosionClass ** explr, int M_EX ) { + if ( hull ) hull->Collided(); +} + + +/* acceptSpecial: + * Returns true if the object can accept powerups. Should only be true for + * the player class. + */ +bool SpaceObject::acceptSpecial() const { + return false; +} + + +/* Died: + * Called when the object dies, which technically means its hull->life is below 0. + * If it goes offscreen and is out of the 'universe', the died method is not called and + * the object is simply destroyed. The parameter 'check' is the object that will be + * that the object affects when destroyed. Should always be a pointer to the player object. + */ +void SpaceObject::Died( SpaceObject * check, ExplosionClass ** explr, int ME ){ +} + + +/* lookPlane: + * Returns the drawing level of the object. + * The drawing level determines in what order the object will be drawn. Lower + * numbers will be drawn first, and higher numbers last. So far, the maximum + * drawing level is 20 and the minimum is 1. + */ + /* +int SpaceObject::lookPlane() { + if ( !hull ) return 0; + return hull->drawLevel; +} +*/ + + +/* giveHull: + * Destroys the hull the object currently contains and give is a new one. + */ +void SpaceObject::giveHull( HullObject * hnew ) { + if ( hull ) delete hull; + hull = hnew; +} + + +/* giveWeapon: + * Gives the hull a new weapon at the specified weapon bay. + * See hull.cpp for further details on this method. + */ +void SpaceObject::giveWeapon( WeaponObject * weap, int num ) { + + if ( !hull ){ + delete weap; + return; + } + if ( num >= hull->maxGuns() || num < 0 ) return; + hull->giveWeapon( weap, num ); + +} + + +/* eraseWeapon: + * Destroys a weapon at the specified weapon bay. + * See hull.cpp for further details on this method. + */ +void SpaceObject::eraseWeapon( int num ) { + if ( hull ) + hull->eraseWeapon( num ); +} + + +/* IncScore: + * increments the score of the object. Mainly only used for the player + * object as enemies dont need score. :P + */ +void SpaceObject::IncScore( int j ) { + score += j; +} + + +/* Team: + * returns the team that the object is on. So far, there are only two teams: + * TEAM_ENEMY and TEAM_PLAYER. When an object produces another object, it will + * always produce an object of the same TEAM. + */ + /* +int SpaceObject::getTeam() { + return alignment; +} +*/ + +void SpaceObject::savePosition(){ + save_ax = getX(); + save_ay = getY(); + save_vx = getVX(); + save_vy = getVY(); +} + +void SpaceObject::restorePosition(){ + setX( save_vx ); + setY( save_vy ); +} + +bool SpaceObject::hullCollide( ECollide * col, int x, int y ){ + if ( hull ) return hull->hullCollide( col, getX(), getY(), x, y ); + return false; +} + +/* Collide: + * Returns true if this object has actually collided with 'check'. + * See hull.cpp for further details on this method. + */ +bool SpaceObject::Collide( SpaceObject * check ){ + // if ( !CanbeHit( check ) ) return false; + + int mx1 = old_x; + int my1 = old_y; + int mx2 = getX(); + int my2 = getY(); + + int ax1 = check->old_x; + int ay1 = check->old_y; + int ax2 = check->getX(); + int ay2 = check->getY(); + + double cur_mx = mx1; + double cur_my = my1; + double my_slope = my2 - my1; + double mx_slope = mx2 - mx1; + + double cur_ax = ax1; + double cur_ay = ay1; + double ay_slope = ay2 - ay1; + double ax_slope = ax2 - ax1; + + int mtotal = (int)(fabs(my_slope) + fabs(mx_slope)); + int atotal = (int)(fabs(ay_slope) + fabs(ax_slope)); + + int div = 1; + if ( atotal > mtotal ){ + div = atotal / 3; + } else { + div = mtotal / 3; + } + div = atotal > mtotal ? (atotal>>1) : (mtotal>>1); + if ( div == 0 ) div = 1; + my_slope /= (double)div; + mx_slope /= (double)div; + ay_slope /= (double)div; + ax_slope /= (double)div; + + check->savePosition(); + bool cy = false; + // int count = 0; + if ( div > 1 ){ + + for ( int q = 0; q < div && !cy; q++ ){ + check->setX( cur_ax ); + check->setY( cur_ay ); + cy = hull->Collide( (int)cur_mx, (int)cur_my, check ); + cur_ax += ax_slope; + cur_ay += ay_slope; + cur_mx += mx_slope; + cur_my += my_slope; + + // count++; + } + } else { + cy = hull->Collide( (int)cur_mx, (int)cur_my, check ); + } + // printf("Max counts = %d\n", count ); + + check->restorePosition(); + return cy; + + // return hull->Collide( getX(), getY(), check ); +} + + +/* getLife: + * Returns the amount of life the hull currently has left. + * See hull.cpp for further details about this method. + */ +double SpaceObject::getLife() const{ + if (!hull) return 0; + return hull->GetLife(); +} + + +/* Damage: + * Forces the hull to take some damage. Before the hull takes the damage, + * it is allowed to operate on the amount of damage taken with the + * hull->Damage( int ) method. Mildly confusing, but hull->takeDamage will + * always enforce the amount of damage taken while hull->Damage can change what + * this number will be. Returns true if after life is less than or equal to 0 + * after damage is 0. + */ +bool SpaceObject::Damage( double much ) { + if ( !hull ) return true; + hull->takeDamage( hull->Damage( much ) ); + return ( getLife() <= 0 ); +} + + +/* +void SpaceObject::Draw( const Bitmap & work, ExplosionClass ** _expl, int MAX_EXPLR, int g, int offset ) const{ + this->Draw( &work, _expl, MAX_EXPLR, g, offset ); +} +*/ + +/* Draw: + * Allows the object to draw itself on the specified Bitmap. + * Will only draw if the drawLevel( g ) passed to it is equal to the + * objects drawlevel. + * See hull.cpp for further details on this method. + */ +void SpaceObject::Draw( const Bitmap & less, ExplosionClass ** _expl, int MAX_EXPLR, int g, int offset ) const{ + if ( hull ){ + if ( g == hull->drawLevel ) { + // hull->Draw( less, actualx, actualy+offset ); + hull->Draw( less, getX(), getY() + offset ); + } + } +} + + +/* Shadow: + * Allows the object to draw its own shadow on the Bitmap. + * Almost the same as the Draw method. + */ +void SpaceObject::Shadow( const Bitmap & less, int g, int offset ) const { + if ( hull ) + if ( g == hull->drawLevel ) { + // hull->Shadow( less, actualx, actualy+offset ); + hull->Shadow( less, getX(), getY() + offset ); + } +} + + +/* addCollide: + * Adds the specified object to the list of objects this + * object has already collided with. + */ +void SpaceObject::addCollide( SpaceObject * who ) { + + collide_list.push_back( who ); + +} + + +/* haveCollide: + * Returns true if the object is in the list of objects + * this object has already collided with. + */ +bool SpaceObject::haveCollide( const SpaceObject * who ) { + for ( vector< SpaceObject * >::iterator it = collide_list.begin(); it != collide_list.end(); it++ ){ + if ( *it == who ) return true; + } + return false; +} + + +/* clearCollide: + * Clears the list of objects this object has collided with. + */ +void SpaceObject::clearCollide() { + + collide_list.clear(); + +} + + +/* MoveReal: + * Moves the object relative to its velocity. The equation is simple: + * new x = old x + velocity x + * new y = old y + velocity y + */ +void SpaceObject::MoveReal() { + + old_x = actualx; + old_y = actualy; + + virtualx += dx; + virtualy += dy; + actualx = (int)virtualx; + actualy = (int)virtualy; + +} + + +/* SetCoordXY: + * Sets the X and Y coordinates of the object in the universe. + */ +void SpaceObject::SetCoordXY( int ax, int ay ) { + virtualx = ax; + virtualy = ay; + actualx = ax; + actualy = ay; +} + + +/* group: + * Returns the group associated with this object + */ +Group * SpaceObject::getGroup() { + return my_group; +} + + +/* Radar: + * Draws self on radar + * Defualt is to not draw + */ +void SpaceObject::Radar( const Bitmap & rad ) const{ +} + + +/* copy: + * Returns a copy of the object with all the same points as this object + */ +SpaceObject * SpaceObject::copy() { + return new SpaceObject( actualx, actualy, dx, dy, hull->copy(), my_group, plane, alignment ); + // return new SpaceObject( actualx, actualy, dx, dy, NULL, NULL, plane, alignment ); +} + +/* Independent: + * Forces object to have no group + */ +void SpaceObject::Independent(){ + my_group = NULL; +} + +/* +void SpaceObject::setX( int x ){ + actualx = x; + virtualx = x; +} + +void SpaceObject::setY( int y ){ + actualy = y; + virtualy = y; +} + +void SpaceObject::setX( double x ){ + actualx = (int)x; + virtualx = x; +} + +void SpaceObject::setY( double y ){ + actualy = (int)y; + virtualy = y; +} +*/ + +void SpaceObject::setDX( double x ){ + dx = x; +} + +void SpaceObject::setDY( double y ){ + dy = y; +} + +void SpaceObject::setAccelX( double x ){ + accel_x = x; +} + +void SpaceObject::setAccelY( double y ){ + accel_y = y; +} + +void SpaceObject::setScore( int s ){ + score = s; +} + +void SpaceObject::setStrength( int s ){ + str = s; +} + +void SpaceObject::setPlane( int p ){ + plane = p; +} + +void SpaceObject::setAlignment( int a ){ + alignment = a; +} + +HullObject * SpaceObject::getHull() const{ + return hull; +} + +int SpaceObject::getMaxX(){ + if ( hull ) + return hull->getWidth(); + return 0; +} + +int SpaceObject::getMaxY(){ + if ( hull ) + return hull->getHeight(); + return 0; +} + +/* +int SpaceObject::getX(){ + return actualx; +} + +int SpaceObject::getY(){ + return actualy; +} + +double SpaceObject::getVX(){ + return virtualx; +} + +double SpaceObject::getVY(){ + return virtualy; +} + +int SpaceObject::getScore(){ + return score; +} + +int SpaceObject::getStrength(){ + return str; +} + +int SpaceObject::getPlane(){ + return plane; +} + +int SpaceObject::getAlignment(){ + return alignment; +} +*/ + +/* Destructor: + * Deletes the hull and the collide list. + */ +SpaceObject::~SpaceObject() { + if ( hull != NULL ) delete hull; //delete hull + //collide_list->clear(); + // delete collide_list; + + //delete the group that contains this object if there is one + if ( my_group != NULL ) { + my_group->drop( this ); + + //if group is empty, delete the group + if ( my_group->size() == 0 ) { + delete my_group; + } + } +} --- rafkill-1.2.2.orig/build/hull.cpp +++ rafkill-1.2.2/build/hull.cpp @@ -0,0 +1,407 @@ +#include "defs.h" +#include "hull.h" +#include "trigtable.h" +#include "spaceobj.h" +#include "gunobj.h" +#include "ebox.h" +#include "section.h" +#include "bitmap.h" + +#include + +using namespace std; + +/* Constructor: + * parameters are: + * _drawNum - the drawing number of the object. Used for determing which Bitmap + * out of the datafile to draw from. + * _life - the amount of life of the object + * _strength - the amount of damage the object will do when it collides with something + * num_guns - the maximum number of guns allowed in this object + * level - the level number of the game + * _drawing_plane - the drawing level of the object + * ec - an ECollide object use for collision detection. + */ +HullObject::HullObject( Bitmap * _drawBitmap, double _life, double _strength, int num_guns, int level, int _drawing_plane, bool _trans, ECollide * ec): +crash( false ), +trans( _trans ), +strength( _strength ), +drawLevel( _drawing_plane ), +guns( NULL ), +max_guns( num_guns ) { + myBitmap = _drawBitmap; + Shadow_Bitmap = NULL; + if ( myBitmap != NULL ) + Shadow_Bitmap = getShadow(); + life = _life; + original_life = _life; + collide = ec; + //life = (int)( (double)l * ( 1.0 + (double)level / 3.8 ) ); + guns = NULL; + if ( max_guns != 0 ) { + guns = new WeaponObject*[ max_guns ]; + for ( int q = 0; q < max_guns; q++ ) + guns[q] = NULL; + } + dx = 0; + dy = 0; +} + + +/* setLife: + * Sets the life of the object according to a parameter, zx, which + * usually refers to the game level give in the constructor. + */ +void HullObject::setLife( double zx ) { + life = zx; + /* + //life = (int)( (double)life * ( 1.0 + (double)zx / 3.1 ) ); + life = (double)life * ( 1.0 + (double)zx / 3.1 ); + original_life = life; + */ +} + + +/* Moved: + * Called the container object, spaceobject, has its method MoveMe called. + * Default is to do nothing. + */ +void HullObject::Moved( double _dx, double _dy, double _ax, double _ay ) { + + dx = _dx; + dy = _dy; + +} + + +/* Hurt: + * Returns the amount of damage the object will do when it collides with something. + */ +double HullObject::Hurt() { + return strength; +} + +/* +int HullObject::getHeight(){ + if ( Bitmap ) return Bitmap->h; + if ( collide ) return collide->getHeight(); + return 0; +} + +int HullObject::getWidth(){ + if ( Bitmap ) return Bitmap->w; + if ( collide ) return collide->getWidth(); + return 0; +} +*/ + +/* +int HullObject::getLife(){ + return (int)life; +} +*/ + +/* Draw: + * Draws the object onto the specified Bitmap. For most objects, this will + * consist of drawing the Bitmap at data[ drawNum ] at the + * X coordinate - half the width of the bitamp and the + * Y coordinate - half the height of the Bitmap. If the object does not have a Bitmap + * to draw from, it needs to override this method with its own drawing routine. + */ +void HullObject::Draw( const Bitmap & who, int x, int y ) { + //int mx = ((Bitmap *)dat[ drawNum ].dat)->w/2; + //int my = ((Bitmap *)dat[ drawNum ].dat)->h/2; + //draw_character(who, (Bitmap *)dat[drawNum].dat, x-mx+mx*3/2, y-my+my*3/2, makecol(30,30,30) ); + //draw_trans_sprite( who, (Bitmap *)dat[ drawNum ].dat, x-mx+mx*5/4, y-my+my*3/2 ); + //draw_sprite( who, (Bitmap *)dat[ drawNum ].dat, x-mx, y-my ); + if ( myBitmap == NULL ) return; + int mx = myBitmap->getWidth()/2; + int my = myBitmap->getHeight()/2; + + if ( trans ) + myBitmap->drawTrans( x-mx, y-my, who ); + else + myBitmap->draw( x-mx, y-my, who ); + + /* + if ( collide ){ + collide->draw( who, x-mx, y-my ); + } + */ + +} + +Bitmap * HullObject::getShadow(){ + + if ( Shadow_Bitmap == NULL && myBitmap != NULL ){ + + // Shadow_Bitmap = create_Bitmap( Bitmap->w, Bitmap->h ); + Shadow_Bitmap = new Bitmap( myBitmap->getWidth(), myBitmap->getHeight() ); + //clear_to_color( Shadow_Bitmap, makecol(255,0,255) ); + //draw_lit_sprite( Shadow_Bitmap, Bitmap, 0, 0, 255 ); + int m = 35; + // clear_to_color( Shadow_Bitmap, makecol(m,m,m) ); + Shadow_Bitmap->fill( Bitmap::makeColor(m,m,m) ); + //draw_character( Shadow_Bitmap, Bitmap, 0, 0, 1 ); + + + // draw_mask( Shadow_Bitmap, Bitmap, 0, 0 ); + if ( myBitmap ) + myBitmap->drawMask( 0, 0, *Shadow_Bitmap ); + + } + + return Shadow_Bitmap; +} + +/* Shadow: + * Draws a shadow of the picture almost the same as the Draw() method except + * using draw_lit_sprite instead. + */ +void HullObject::Shadow( const Bitmap & who, int x, int y ) { + if ( (Shadow_Bitmap = getShadow()) == NULL ) return; + + /* + int mx = Bitmap->w/2; + int my = Bitmap->h/2; + int tx = (x - mx) - ( screen_x/2 - (x-mx) ) / 9; + int ty = ( screen_y/2 + (y-my) ) / 15 + y-my; + ty = y + my; + draw_lit_sprite( who, Bitmap, tx, ty, 255 ); + */ + + Shadow_Bitmap = getShadow(); + + int mx = Shadow_Bitmap->getWidth()/2; + int my = Shadow_Bitmap->getHeight()/2; + // mx = 0; + my = Shadow_Bitmap->getHeight() / 3; + int tx = (x - mx) - ( Util::screen_x/2 - (x-mx) ) / 9; + int ty = y + my; + + Shadow_Bitmap->drawTrans( tx, ty, who ); + + /* TODO: fix */ + // draw_trans_sprite( who, Shadow_Bitmap, tx, ty ); + + //draw_lit_sprite( who, Bitmap, (int)(x-mx+dx*9), (int)(y-my+dy*9), 250 ); + //fblend_add( (Bitmap *)dat[ drawNum ].dat, who, (int)(x-mx+dx*11), (int)(y-my+dy*11), 20 ); +} + + +/* Inside: + * Returns true if the specified coordinate (ax,ay) is within the + * space of the hull centered at (mx,my) + * See ebox.cpp for further details on the Single() method. + */ +bool HullObject::Inside( int mx, int my, int ax, int ay ) { + // if ( collide ) return collide->Single( mx, my, ax, ay ); + if ( collide ) return collide->Collision( mx, my, ax, ay ); + return ( mx == ax && my == ay ); +} + + +/* giveWeapon: + * Gives the hull a gunobject at the specified bay. + * WARNING: does not delete the previous object. To do this call + * eraseweapon. + */ +void HullObject::giveWeapon( WeaponObject * weap, int num ) { + guns[ num ] = weap; +} + + +/* eraseWeapon: + * Deletes the object at the specified bay. + * Sets the bay to NULL. + */ +void HullObject::eraseWeapon( int num ) { + if ( num < 0 || num >= max_guns ) return; + if ( guns[num] != NULL ) delete guns[num]; + guns[num] = NULL; +} + +bool HullObject::hullCollide( ECollide * col, int mx, int my, int ax, int ay ){ + + if ( col && collide ) + return collide->Collision( col, mx-getWidth()/2, my-getHeight()/2, ax, ay ); + + return Inside( mx-getWidth()/2, my-getHeight()/2, ax, ay ); + +} + +/* Collide: + * Can only detect a collision if this object and the other object have a + * collide object in it. Returns true if ECollide->Collision() returns true. + * See ebox.cpp for further details. + */ +bool HullObject::Collide( int mx, int my, SpaceObject * check ) { + + return check->hullCollide( collide, mx-getWidth()/2, my-getHeight()/2 ); + + /* + if ( collide && check->getHull() && check->getHull()->collide ) + return collide->Collision( check->getHull()->collide, mx, my, check->getX(), check->getY() ); + */ + //return check->HitMe( mx, my ); + return false; +} + + +/* debug: + * Debugging crap for knowing where the object is on the screen. + */ + /* +void HullObject::debug( Bitmap * work, int x, int y ) { + circlefill( work, x, y, 4, makecol(255,255,255) ); +} +*/ + + +/* guns: + * Returns the array of weaponobjects the object contains. + */ +WeaponObject ** HullObject::Guns() { + return guns; +} + + +/* maxGuns: + * Returns the maximum number of guns the object can possibly contain. + */ +int HullObject::maxGuns() { + return max_guns; +} + + +/* haveBeenHit: + * Returns true if the hull has collided with something since the last call to + * haveBeenHit. The flag is initially false, so the first call will return true + * the first time the hull collides with something. + */ +bool HullObject::haveBeenHit() { + bool cy = crash; + crash = false; + return cy; +} + + +/* addSection: + * Puts the object into the Section object which is used for speeding up + * collision detection. This is calculated by determining the upper most corner + * and the lower most corner. Given this height, each y coordinate in a specific range + * given by Section->spacer() will be used to add the object into the Section's database + * of objects it should know about. The object will not add itself if it is translucent. + * See section.cpp for further details about this method. + */ +void HullObject::addSection( SpaceObject * who, Section * onscreen, int x, int y ) { + + if ( Translucent() ) return; + if ( onscreen == NULL ) return; + + int y1 = y; + int y2 = y; + int x1 = x; + int x2 = x; + if ( collide ) { + /* + y1 = collide->CY1( collide->ul_y + y ); + y2 = collide->CY1( collide->lr_y + y ); + */ + y1 = collide->getMinHeight() + y - getHeight()/2; + y2 = collide->getMaxHeight() + y - getHeight()/2; + x1 = collide->getMinWidth() + x - getWidth()/2; + x2 = collide->getMaxWidth() + x - getWidth()/2; + } + + /* + onscreen->add( who, x, y1 ); + for ( int q = y1+onscreen->spacer(); q < y2; q += onscreen->spacer() ) + onscreen->add( who, x, q ); + if ( y2 != y1 ) + onscreen->add( who, x, y2 ); + */ + + for ( int ay = y1; ay <= y2; ay += onscreen->spacerY() ) + for ( int ax = x1; ax <= x2; ax += onscreen->spacerX() ) + onscreen->add( who, ax, ay ); + /* + for ( int ay = y1; ay <= y2; ay += onscreen->spacer() ) + onscreen->add( who, x, ay ); + */ + +} + + +/* takeDamage: + * Enforces that the hull take so much damage. This method SHOULD NOT be overwritten. + */ +void HullObject::takeDamage( double r ) { + life -= r; +} + + +/* Damage: + * Allows the hull to operate on how much damage it is going to take. + * Default is to just take the damage specified. + */ +double HullObject::Damage( double much ) { + return much; +} + + +/* GetLife: + * Returns how much life this object has left. + */ +double HullObject::GetLife() { + return life; +} + + +/* Translucent: + * Returns true if the object is translucent. Translucent means that it cannot + * collide with any other object. + */ +bool HullObject::Translucent() { + return trans; +} + + +/* Collided: + * Does something when hull collides with another hull + */ +void HullObject::Collided() { +} + + +HullObject * HullObject::copy() { + + HullObject * who = new HullObject( myBitmap, life, strength, this->maxGuns(), 1, drawLevel, trans, collide ); + for ( int q = 0; q < this->maxGuns(); q++ ) + if ( this->Guns()[q] != NULL ) + who->guns[q] = this->Guns()[q]->copy(); + else who->guns[q] = NULL; + return who; +} + + +/* Destructor: + * Deletes all the guns the object contains. + * WARNING: does not delete the ECollide object, this must be done elsewhere. + */ +HullObject::~HullObject() { + + if ( guns != NULL ) { + for ( int q = 0; q < max_guns; q++ ) + if ( guns[q] != NULL ) + delete guns[q]; + delete[] guns; + } + // if ( Shadow_Bitmap ) destroy_Bitmap( Shadow_Bitmap ); + if ( Shadow_Bitmap ){ + delete Shadow_Bitmap; + } + if ( myBitmap ){ + delete myBitmap; + } +} --- rafkill-1.2.2.orig/build/loading_screen.cpp +++ rafkill-1.2.2/build/loading_screen.cpp @@ -0,0 +1,79 @@ +#ifdef WINDOWS +#include +#include +#endif + +#include "bitmap.h" +#include "defs.h" +#include + +static pthread_t loadingThread; +static pthread_mutex_t loadingMutex; +static bool loading = false; + +static const int MAX_COLORS = 32; +static int shades[ MAX_COLORS ]; + +#define LOCK pthread_mutex_lock( &loadingMutex ); +#define UNLOCK pthread_mutex_unlock( &loadingMutex ); + +static void * loadScreen( void * arg ); + +void startLoadingScreen(){ + + loading = true; + int c1 = Bitmap::makeColor( 128, 32, 94 ); + int c2 = Bitmap::makeColor( 200, 10, 160 ); + Util::blend_palette( shades, MAX_COLORS >> 1, c1, c2 ); + Util::blend_palette( shades + (MAX_COLORS >> 1), MAX_COLORS >> 1, c2, c1 ); + pthread_mutex_init( &loadingMutex, NULL ); + pthread_create( &loadingThread, NULL, loadScreen, NULL ); + +} + +static void * loadScreen( void * arg ){ + + int i = 0; + bool alive = true; + unsigned int ticks; + Font font = Util::getNormalFont(); + Util::getTicks( &ticks ); + while ( alive ){ + + LOCK;{ + alive = loading; + } + UNLOCK; + + bool draw = false; + + int count = Util::getTicks( &ticks ); + if ( count == 0 ){ + Util::YIELD(); + continue; + } + while ( count > 0 ){ + i = (i + 1) % MAX_COLORS; + count--; + draw = true; + } + + if ( draw ){ + int color = shades[ i ]; + // Util::raptor_font->rtext( *Bitmap::Screen, 300, 220, color, "Loading" ); + + // Bitmap::Screen->printfNormal( 300, 220, color, "Loading" ); + Bitmap::Screen->printf( 300, 220, color, &font, "Loading" ); + } + } + + return NULL; +} + +void endLoadingScreen(){ + LOCK;{ + loading = false; + } + UNLOCK; + pthread_join( loadingThread, NULL ); +} --- rafkill-1.2.2.orig/build/animation.cpp +++ rafkill-1.2.2/build/animation.cpp @@ -0,0 +1,82 @@ +#include "animation.h" +#include + +Animation::Animation( int x, int y ): +posx( x ), +posy( y ) { + current = pics.begin(); +} + + +void Animation::add( const Bitmap & who ){ + pics.push_back( who ); + current = pics.begin(); +} + + +const Bitmap Animation::show() const{ + return (*current); +} + + +void Animation::clear() { + + pics.clear(); + current = pics.begin(); + + /* + if ( sent ) destroy_bitmap( sent ); + sent = NULL; + return; + + if ( pics.empty() ) return; + + for ( current = pics.begin(); current != pics.end(); ) { + + BITMAP * temp = *current; + current = pics.erase( current ); + destroy_bitmap( temp ); + + } + current = pics.begin(); + */ + +} + + +void Animation::Next( const Bitmap & work ){ + + if ( ! pics.empty() ){ + + const Bitmap & frame = *current; + frame.draw( posx, posy, work ); + + current++; + if ( current == pics.end() ) current = pics.begin(); + } + +} + + +void Animation::changePos( const int x, const int y ) { + posx = x; + posy = y; +} + + +Animation::~Animation() { + + /* + if ( sent ) + destroy_bitmap( sent ); + return; + for ( current = pics.begin(); current != pics.end(); ) { + + BITMAP * temp = *current; + current = pics.erase( current ); + destroy_bitmap( temp ); + + } + */ + +} --- rafkill-1.2.2.orig/build/move_find.h +++ rafkill-1.2.2/build/move_find.h @@ -0,0 +1,27 @@ +#ifndef _move_find_h +#define _move_find_h + +#include "move.h" +#include + +using namespace std; + +struct XYPoint{ + XYPoint( int _x, int _y ): x( _x ), y( _y ){} + int x, y; +}; + +class MoveFind: public Move{ +public: + + MoveFind( double _dx, double _dy ); + virtual void action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ); + virtual ~MoveFind(); + +protected: + + deque< XYPoint * > points; + +}; + +#endif --- rafkill-1.2.2.orig/build/move_find.cpp +++ rafkill-1.2.2/build/move_find.cpp @@ -0,0 +1,61 @@ +#include "move.h" +#include "move_find.h" +#include "trigtable.h" +#include +#include +#include + +using namespace std; + +MoveFind::MoveFind( double _dx, double _dy ): +Move( _dx, _dy ){ + + /* + dx = 0; + dy = 0; + */ + //points.push_back( new XYPoint( screen_x/2, screen_y/2 ) ); + //points.push_back( new XYPoint( 100, 100/*screen_y/3*/ ) ); + //points.push_back( new XYPoint( screen_x-100, screen_y-100 ) ); + //points.push_back( new XYPoint( rnd( screen_x ), rnd( screen_y ) ) ); + for ( int q = 0; q < 5; q++ ) + points.push_back( new XYPoint( Util::rnd( Util::screen_x ), Util::rnd( Util::screen_y / 2 ) ) ); + +} + +void MoveFind::action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy){ + + XYPoint * f = points.front(); + + if ( dist( x, y, f->x, f->y ) < 15 ){ + + points.pop_front(); + points.push_back( f ); + + } + f = points.front(); + int ang = gang( x, y, f->x, f->y ); + double s_dx = o_dx * Tcos(ang); + double s_dy = o_dy * Tsine(ang); + + #define move_fox 0.2 + + if ( s_dx + move_fox < sdx ) sdx -= move_fox; + else if ( s_dx - move_fox > sdx ) sdx += move_fox; + else sdx = s_dx; + + if ( s_dy + move_fox < sdy ) sdy -= move_fox; + else if ( s_dy - move_fox > sdy ) sdy += move_fox; + else sdy = s_dy; + + // return MoveReal(); + +} + +MoveFind::~MoveFind(){ + while ( !points.empty() ){ + XYPoint * f = points.front(); + delete f; + points.pop_front(); + } +} --- rafkill-1.2.2.orig/build/defs.cpp +++ rafkill-1.2.2/build/defs.cpp @@ -0,0 +1,378 @@ +#include + +#include "defs.h" +#include +#include +#include "explode.h" +#include "rfont.h" +#include "fonts.h" +#include "font.h" +#include "explode.h" +#include "bitmap.h" +#include "sound.h" + +#include "strings.h" +#include + +#include + +#ifndef INSTALL_DIR +#define INSTALL_DIR "." +#endif + +using namespace std; + +DATAFILE * Util::global_data; +DATAFILE * Util::global_snd; +DATAFILE * Util::global_fonts; + +// RFont * Util::raptor_font; + +int Util::screen_x = 640*3/2; +int Util::screen_y = 480; + +int * Util::e_color; +float Util::sound_vol; +// float music_vol; + +volatile unsigned int Util::speed_counter = 0; + +Font Util::getNormalFont(){ + return Font( (FONT *)Util::global_fonts[ LCD_PCX ].dat ); +} + +Font Util::getMenuFont(){ + return Font( (FONT *)Util::global_fonts[ SQUARE_PCX ].dat ); +} + +Font Util::getDefaultFont(){ + return Font( ::font ); +} + +unsigned int Util::getTicks( unsigned int * tick ){ + unsigned int diff = Util::speed_counter - *tick; + *tick = speed_counter; + return diff; +} + +unsigned char Util::getByte( unsigned char q, int byte ) { + return ( q & ( 1 << byte ) ) >> byte; +} + +void Util::YIELD() { + rest( 1 ); + + /* + #ifdef UNIX + struct timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 1; + select( 0, NULL, NULL, NULL, &tv ); + #else + //sleep(1); + yield_timeslice(); + #endif + */ +} + + +unsigned char Util::setByte( unsigned char n, int byte, unsigned char p ) { + unsigned char final = 0; + for ( int q = 15; q >= 0; q-- ) { + unsigned char z = getByte( n, q ); + if ( q == byte ) + z = p; + final = final << 1 | z; + } + return final; +} + + +void Util::bitscramble( char & q ) { + + q = setByte( q, 5, getByte(q,5)^1 ); + q = setByte( q, 9, getByte(q,9)^1 ); + +} + +Bitmap Util::getDataSprite( int num ){ + return Bitmap( (BITMAP *) Util::global_data[ num ].dat ); +} + +void Util::alert( const char * message ){ + allegro_message( message ); +} + +void Util::scramble( char * scram, const int m ) { + + for ( int q = 0; q < m && q+2 < m; q += 3 ) { + char t = scram[q]; + scram[q] = scram[q+2]; + scram[q+2] = t; + } + for ( int q = 0; q < m; q++ ) + bitscramble( scram[q] ); + +} + + +int Util::rnd( int q ) { + + /* + #ifdef UNIX + + return random() % q; + + #else + + return (int)( q * ( (double)rand() / ( (double)RAND_MAX + 1.0 ) ) ); + #endif + */ + return (int)( q * ( (double)rand() / ( (double)RAND_MAX + 1.0 ) ) ); + +} + +bool Util::exists( const char * filename ){ + return ::exists( filename ); +} + +const char * Util::getOS() { + switch( ::os_type ) { + case OSTYPE_UNKNOWN : return "unknown, or regular MSDOS"; + case OSTYPE_WIN3 : return "Windows 3.1 or earlier"; + case OSTYPE_WIN95 : return "Windows 95"; + case OSTYPE_WIN98 : return "Windows 98"; + case OSTYPE_WINME : return "Windows ME"; + case OSTYPE_WINNT : return "Windows NT"; + case OSTYPE_WIN2000 : return "Windows 2000"; + case OSTYPE_WINXP : return "Windows XP"; + case OSTYPE_OS2 : return "OS/2"; + case OSTYPE_WARP : return "OS/2 Warp 3"; + case OSTYPE_DOSEMU : return "Linux DOSEMU"; + case OSTYPE_OPENDOS : return "Caldera OpenDOS"; + case OSTYPE_LINUX : return "Linux"; + case OSTYPE_FREEBSD : return "FreeBSD"; + case OSTYPE_UNIX : return "Unknown Unix variant"; + case OSTYPE_BEOS : return "BeOS"; + case OSTYPE_QNX : return "QNX"; + case OSTYPE_MACOS : return "MacOS"; + } + return "Unknown OS"; +} + +string Util::getInstallDirectory(){ + return string( INSTALL_DIR ) + "/rafkill/"; +} + +vector< string > Util::getFiles( string dataPath, string find ){ + struct al_ffblk info; + vector< string > files; + + dataPath = getInstallDirectory() + dataPath; + + if ( al_findfirst( (dataPath + find).c_str(), &info, FA_ARCH ) != 0 ){ + return files; + } + files.push_back( string( info.name ) ); + while ( al_findnext( &info ) == 0 ){ + files.push_back( dataPath + string( info.name ) ); + } + al_findclose( &info ); + + return files; +} + +void Util::loadGlobals(){ + + char path[ 4096 ]; + Util::getDataPath( path, "raptor.dat" ); + Util::global_data = load_datafile( path ); + + Util::getDataPath( path, "sound.dat" ); + Util::global_snd = load_datafile( path ); + + Util::getDataPath( path, "beast.fnt" ); + // Util::raptor_font = new RFont( path ); + + Util::getDataPath( path, "fonts.dat" ); + Util::global_fonts = load_datafile( path ); + + cout << "Loaded data" << endl; + + if ( !Util::global_data || !Util::global_snd || !Util::global_fonts ) { + cerr << "Could not load data. Install directory is " << INSTALL_DIR << endl; + // Util::alert( "Error with data!" ); + Bitmap::setGfxModeText(); + exit( 1 ); + } +} + +void Util::unloadGlobals(){ + unload_datafile( Util::global_data ); + unload_datafile( Util::global_snd ); + unload_datafile( Util::global_fonts ); + // delete Util::raptor_font; + delete Bitmap::Screen; +} + +int Util::addcol( int c1, int c2 ) { + + int r1, g1, b1; + int r2, g2, b2; + r1 = getr( c1 ); + g1 = getg( c1 ); + b1 = getb( c1 ); + + r2 = getr( c2 ); + g2 = getg( c2 ); + b2 = getb( c2 ); + + r1 += r2; + g1 += g2; + b1 += b2; + if ( r1 > 255 ) r1 = 255; + if ( g1 > 255 ) g1 = 255; + if ( b1 > 255 ) b1 = 255; + + /* printf("C1 = %d. C2 = %d. New color = %d\n", c1, c2, makecol(r1,g1,b1) ); */ + + return makecol(r1,g1,b1); + +} + + +void Util::blend_palette( int * pal, int mp, int sc, int ec ) { + + int sc_r = getr( sc ); + int sc_g = getg( sc ); + int sc_b = getb( sc ); + + int ec_r = getr( ec ); + int ec_g = getg( ec ); + int ec_b = getb( ec ); + + for ( int q = 0; q < mp; q++ ) { + float j = (float)( q ) / (float)( mp ); + int f_r = (int)( 0.5 + (float)( sc_r ) + (float)( ec_r-sc_r ) * j ); + int f_g = (int)( 0.5 + (float)( sc_g ) + (float)( ec_g-sc_g ) * j ); + int f_b = (int)( 0.5 + (float)( sc_b ) + (float)( ec_b-sc_b ) * j ); + pal[q] = makecol( f_r, f_g, f_b ); + } + +} // end blend_palette + +time_t Util::fileTime( const char * filename ){ + return ::file_time( filename ); +} + +int Util::pcount( char ** p, const int m ) { + + int total = 0; + for ( int q = 0; q < m; q++ ) + if ( p[q] != NULL ) + total++; + return total; +} + + +int Util::readnum( FILE * fv, int num ) { + + int final = 0; + //char temp; + char * buf = new char[ num ]; + + fread( buf, sizeof( char ), num, fv ); + for ( int q = num-1; q >= 0; q-- ) + final = final | buf[q]; + delete[] buf; + return final; + +} + + +void Util::explColor() { + + e_color = new int[ MAX_E_COLOR ]; + blend_palette( e_color, 60, makecol(0,0,0), makecol(240,100,0) ); + blend_palette( e_color+60, 20, makecol(240,100,0), makecol(240,220,0) ); + blend_palette( e_color+60+20, 20, makecol(240,220,0), makecol(254,254,254) ); + +} + +void Util::getDataPath( char * buffer, const char * file ){ + sprintf( buffer, (getInstallDirectory() + "data").c_str() ); + put_backslash( buffer ); + strcat( buffer, file ); +} + +/* +char * Util::data_file( const char * file_name ) { + + //char * file_place = new char[ 6 ]; + char file_place[ 30 ]; + //file_place = strdup( "data" ); + sprintf( file_place, "data" ); + put_backslash( file_place ); + char * final = append( file_place, file_name ); + //delete[] file_place; + return final; + +} +*/ + + +void Util::MakeExplosion( ExplosionClass ** expl, int M_EX, int x, int y ) { + /* + int q = 0; + while ( q < M_EX && expl[q] != NULL ) + q++; + if ( q >= M_EX ) + return; + */ + double a = (double)( rnd( 45 ) + 15 ) / -10.0; + ExplosionClass * w_expl = new ExplosionClass(x,y,0,a,rnd(6)+3); + addExplode( expl, M_EX, w_expl ); + //expl[q] = new ExplosionClass( x, y, 0, a, rnd( 6 ) + 3 ); +} + + +/* +void MakeSlimExplosion( ExplosionClass ** expl, int M_EX, int x, int y ){ + + int q = 0; + while ( q < M_EX && expl[q] != NULL ) + q++; + if ( q >= M_EX ) + return; + //double a = (double)( rnd( 45 ) + 15 ) / -10.0; + expl[q] = new ExplosionSlim( x, y ); + +} +*/ + +/* +void draw_mask( BITMAP * dest, BITMAP * source, int _x, int _y ){ + int mask = makecol(255,0,255); + for ( int x = 0; x < source->w; x++ ) + for ( int y = 0; y < source->h; y++ ) + if ( _getpixel16( source,x,y ) == mask ) + _putpixel16( dest, x+_x, y+_y, mask ); +} +*/ + +void Util::play_sound( DATAFILE * snd, int m, int vol ) { + play_sample( (SAMPLE *)snd[m].dat, (int)(vol*sound_vol), 128, 1000, false ); +} + +void Util::playSound( int m, int vol ){ + int max = SND_SUSTAIN + 1; + if ( m >= 0 && m < max ){ + play_sample( (SAMPLE *)Util::global_snd[m].dat, (int)(vol*sound_vol), 128, 1000, false ); + } else { + cerr << "Sample out of range: " << m << endl; + } +} + +void Util::play_sound( SAMPLE * snd, int vol ) { + play_sample( snd, (int)(vol*sound_vol), 128, 1000, false ); +} --- rafkill-1.2.2.orig/build/trigtable.h +++ rafkill-1.2.2/build/trigtable.h @@ -0,0 +1,57 @@ +#ifndef _TRIGTABLE_H_ +#define _TRIGTABLE_H_ + +#include +#include "defs.h" + +double tsqr( const double r ); +double tsqrt( const double q ); +long int tcube( const long int c ); +double fsqr( double r ); +double fcube( double r ); +double dist( int x1, int y1, int x2, int y2 ); +double zdist( int x, int y, int x1, int y1 ); +long int area( int x1, int y1, int x2, int y2, int x3, int y3 ); +bool prect( int px1, int py1, int x1, int y1, int x2, int y2 ); +bool ptriangle( int tx1, int ty1, int tx2, int ty2, int tx3, int ty3, int x1, int y1 ); +// int sarctan( const double tr ); +// int barctan( const double tr ); +int lineIntersect( int ax, int ay, int bx, int by, int cx, int cy, int dx, int dy, int *ix, int *iy ); +int gang( int x1, int y1, int x2, int y2 ); +int getAngle( int x1, int y1, int x2, int y2 ); +int arcsine( double x ); +// void set_trig(); + +inline double Tcos( double x ){ + return cos( x * Util::PI / 180.0 ); +} + +inline double Tsine( double x ){ + return -sin( x * Util::PI / 180.0 ); +} + +inline double Rsine( double x ){ + return sin( x * Util::PI / 180.0 ); +} + +inline double Tcos( int x ){ + return Tcos( (double)x ); +} + +inline double Tsine( int x ){ + return Tsine( (double)x ); +} + +inline double Rsine( int x ){ + return Rsine( (double)x ); +} + +/* +extern double tcos[360]; +extern double tsine[360]; +extern double rsine[360]; +extern double ttan[360]; +*/ + +#endif + --- rafkill-1.2.2.orig/build/group.h +++ rafkill-1.2.2/build/group.h @@ -0,0 +1,31 @@ +#ifndef _group_h +#define _group_h + +using namespace std; + +#include + +class SpaceObject; + +class Group{ +public: + + Group( const int _y ); + + void add( SpaceObject * who ); + void drop( SpaceObject * who ); + int size() const; + inline const int pos() const{ + return y; + } + const vector< SpaceObject * > * members() const; + + ~Group(); + +protected: + vector< SpaceObject * > list; + int y; + +}; + +#endif --- rafkill-1.2.2.orig/build/group.cpp +++ rafkill-1.2.2/build/group.cpp @@ -0,0 +1,79 @@ +#include "group.h" +#include "spaceobj.h" +#include +#include + +using namespace std; + +/* Group: + * Creates a new group with a y coordinate to be used for knowing when to + * put the group into the game. + */ +Group::Group( const int _y ): +y( _y ) { + + // list = new vector< SpaceObject * >; + +} + +/* pos: + * Returns the y coordinate of the group + */ +/* +int Group::pos() const{ + return y; +} +*/ + +/* add: + * Adds another spaceobject to this group + */ +void Group::add( SpaceObject * who ) { + list.push_back( who ); +} + + +/* drop: + * Removes a spaceobject from this group if it exists + */ +void Group::drop( SpaceObject * who ) { + for ( vector< SpaceObject *>::iterator it = list.begin(); it != list.end(); ){ + if ( *it == who ) { + it = list.erase( it ); + return; + } else it++; + } +} + +/* size: + * Returns number of spaceobjects currently stored in this group + */ +int Group::size() const{ + return list.size(); +} + + +/* members: + * Returns a list of the objects that this group stores + */ +const vector< SpaceObject * > * Group::members() const{ + return &list; +} + +/* ~Group: + * Destructor. Deletes all objects stored in this group. + */ +Group::~Group() { + for ( vector< SpaceObject * >::iterator it = list.begin(); it != list.end(); it++ ){ + SpaceObject * del = *it; + /* remove the object from this group */ + del->Independent(); + // it = list.erase( it ); + /* then delete the object */ + delete del; + } + // delete list; + + list.clear(); +} + --- rafkill-1.2.2.orig/build/defs.h +++ rafkill-1.2.2/build/defs.h @@ -0,0 +1,154 @@ +#ifndef _def_h_ +#define _def_h_ + +#ifndef NULL +#define NULL 0 +#endif + +#include "font.h" + +const double missle_speed = -0.56; +// #define missle_speed -0.56 + +const int MAX_ENEMY = 50; +// #define MAX_ENEMY 50 + +// #define USE_AMMO 8 +// #define MAX_EXPL 200 + +const int expl_color = 254; +// #define expl_color 254 +const int PLAYER_TOTAL = 1; +// #define PLAYER_TOTAL 1 +const int MAX_PLANE = 20; +// #define MAX_PLANE 20 +const int NO_EXPLODE = 4000; +// #define NO_EXPLODE 4000 + +const int GRAPHICS_X = 640; +// #define GRAPHICS_X 640 +const int GRAPHICS_Y = 480; +// #define GRAPHICS_Y 480 + +const int TEAM_ENEMY = 1; +// #define TEAM_ENEMY 1 +const int TEAM_PLAYER = 2; +// #define TEAM_PLAYER 2 + +const int SHIP_DAMAGE = 4; +// #define SHIP_DAMAGE 4 + +/* +#define SMALL_BULLET 1.6 +#define LARGE_BULLET 1.6 +#define FIND_BULLET 1.2 +#define ENEMY_MISSLE 1.9 +*/ + +const int PLANE_AIR = 1; +// #define PLANE_AIR 1 +const int PLANE_GROUND = 2; +// #define PLANE_GROUND 2 + + + +// #define Y_BLIT_OFFSET 500 + +//#define MAX_GAMMO 350 +//#define MAX_BAMMO 100 + +const int MAX_E_COLOR = 100; +// #define MAX_E_COLOR 100 + +const int MAX_EX = 6; +// #define MAX_EX 6 + +/* +#ifdef UNIX +#define DATADIR ./data +#else +#define DATADIR .\data +#endif +*/ + +#include "explode.h" +#include "bitmap.h" +#include "rfont.h" +#include +#include + +using namespace std; + +struct DATAFILE; +struct SAMPLE; + +namespace Util{ + +/* + class ECollide; + class ExplosionClass; +*/ + + extern int screen_x; + extern int screen_y; + + // extern RFont * raptor_font; + + extern int * e_color; + extern float sound_vol; + // extern float music_vol; + + extern DATAFILE * global_fonts; + extern DATAFILE * global_data; + extern DATAFILE * global_snd; + + const double TPI = 3.141592654; + const double PI = TPI; + + extern volatile unsigned int speed_counter; + + Font getNormalFont(); + Font getMenuFont(); + Font getDefaultFont(); + + vector< string > getFiles( string datapath, string find ); + + void loadGlobals(); + void unloadGlobals(); + + const char * getOS(); + + Bitmap getDataSprite( int num ); + + int rnd( int q ); + int pcount( char ** p, const int m ); + int readnum( FILE * fv, int num ); + int addcol( int c1, int c2 ); + + bool exists( const char * filename ); + + time_t fileTime( const char * filename ); + + void alert( const char * message ); + + unsigned int getTicks( unsigned int * tick ); + + void playSound( int m, int vol ); + void play_sound( DATAFILE * snd, int m, int vol ); + void play_sound( SAMPLE * snd, int vol ); + void blend_palette( int * pal, int mp, int sc, int ec ); + void explColor(); + void MakeExplosion( ExplosionClass ** expl, int M_EX, int x, int y ); + unsigned char getByte( unsigned char q, int byte ); + unsigned char setByte( unsigned char n, int byte, unsigned char p ); + void bitscramble( char & q ); + void scramble( char * scram, const int m ); + void YIELD(); + // void draw_mask( BITMAP * dest, BITMAP * source, int _x, int _y ); + + // char * data_file( const char * file_name ); + void getDataPath( char * buffer, const char * file ); + string getInstallDirectory(); +} + +#endif --- rafkill-1.2.2.orig/build/trigger.cpp +++ rafkill-1.2.2/build/trigger.cpp @@ -0,0 +1,67 @@ +#include "trigger.h" + +/* Trigger: + * Constructor. Sets things and whatnot. Not very exciting. + */ +trigger::trigger( char * info, int size_data, int type, int xv, int yv ) { + data = info; + size_d = size_data; + id = type; + loc_x = xv; + loc_y = yv; +} + +/* kind: + * Returns a number that determines what kind of trigger this is. + * Those numbers are defined elsewhere. + */ +int trigger::kind() { + return id; +} + +/* kill: + * Forces trigger to die. + */ +void trigger::kill() { + id = -1; +} + + +/* size: + * Returns the size of the data the trigger is storing + */ +int trigger::size() { + return size_d; +} + + +/* CX: + * Returns the X coordinate of the trigger + */ +int trigger::CX() { + return loc_x; +} + + +/* CY: + * Returns the Y coordinate of the trigger + */ +int trigger::CY() { + return loc_y; +} + + +/* get: + * Returns the data stored by the trigger. + */ +void * trigger::get( void * helper ) { + return data; +} + +/* ~Trigger: + * Deletes data + */ +trigger::~trigger() { + if ( data ) + delete[] data; +} --- rafkill-1.2.2.orig/build/system.h +++ rafkill-1.2.2/build/system.h @@ -0,0 +1,13 @@ +#ifndef _happy_stupid_face_system_h_ +#define _happy_stupid_face_system_h_ + +#include + +namespace System{ + bool onUnix(); + bool onWindows(); + + std::string getHomeDirectory(); +} + +#endif --- rafkill-1.2.2.orig/build/fader.cpp +++ rafkill-1.2.2/build/fader.cpp @@ -0,0 +1,36 @@ +#include "fader.h" +#include "allegro.h" + +Fader::Fader( RLE_SPRITE * back ) { + x = 0; + y = 0; + own = create_bitmap( back->w, back->h ); + first = back; + draw_rle_sprite( own, back, 0, 0 ); +} + + +RLE_SPRITE * Fader::blend() { + + for ( int x = 0; x < 640; x++ ) + ((short *)own->line[y])[x] += makecol(9,9,9); + y++; + if ( y >= first->h ) { + destroy_rle_sprite( first ); + RLE_SPRITE * use = get_rle_sprite( own ); + destroy_bitmap( own ); + return use; + } + + return first; + +} + + +bool Fader::complete() { + return y >= first->h; +} + + +Fader::~Fader() { +} --- rafkill-1.2.2.orig/build/menu.h +++ rafkill-1.2.2/build/menu.h @@ -0,0 +1,95 @@ +#ifndef _menu_h +#define _menu_h + +#include + +#include "bitmap.h" + +using namespace std; + +class WeaponObject; +class SpaceObject; +class RMenu; +class RMenuAnimation; +class Font; +class HullObject; +class Animation; +class ECollide; +class Music; + +#define GUN_MACHINE 0 +#define GUN_BEAM 1 +#define GUN_MINIMISSLE 2 +#define GUN_FINDGUN 3 +#define GUN_PULSE 4 +#define GUN_LASER 5 +#define GUN_MISSLE 6 +#define GUN_FOLLOW 7 +#define GUN_ARC 8 +#define GUN_MACHINE_CIRCLE 9 +#define GUN_CHAIN 10 +#define GUN_CHAIN_FIRE 11 +#define GUN_SHATTER 12 +#define GUN_SWIRL 13 +#define GUN_SPREAD 14 +#define GUN_MASSIVE 15 +#define GUN_SABER 16 +#define GUN_ANGLE 17 +#define GUN_TRACTOR 18 +#define GUN_ROTATE 19 +#define GUN_STICKY 20 +#define GUN_YEHAT 21 + +struct gunPlace{ + int * gunz; + int mgun; +}; + +class menuClass{ +public: + + menuClass(); + ~menuClass(); + + bool activate( SpaceObject * player ); + +private: + + int sellGun( WeaponObject * gun ); + int upgradeCost( WeaponObject * gun ); + int upgradeHelper( int worth, int lev ); + int hull_price( int z ); + void vectorAdd( vector< SpaceObject * > * stable, vector< SpaceObject * > * state ); + + char * getFileInfo( int number ); + + //RMenuAnimation * GunMenu( int q, WeaponObject * current, BITMAP * intr, int score ); + void GunMenu( RMenu * weap, int q, WeaponObject * current, const Bitmap & intr, int score ); + void GetHullMenu( RMenu * hull_menu, SpaceObject * human, const Bitmap & intr ); + void GetAccessoryMenu( RMenu * weap, WeaponObject ** a_list, const Bitmap & intr, int score ); + + void getSaveMenu( RMenu * save_menu ); + void weaponMenu( RMenu * gun_menu, SpaceObject * player ); + SpaceObject * copySpace( SpaceObject * player ); + WeaponObject * GetWeapon( int q ); + Bitmap menuScreen(); + HullObject * playerHull( int q ); + void getAnimation( Animation * hold, SpaceObject * player, vector< SpaceObject * > * ammo, vector< SpaceObject * > * enemy ); + bool accept_sell(); + + gunPlace pgun[ 5 ]; //regular guns + gunPlace agun; //accessory guns + // DATAFILE * data; + // RFont * menu_font; + Animation * player_animate; + +public: + static ECollide ** gun_sticky_collide_list; + static int gun_sticky_max_collide; + +private: + Font * menuFont; + +}; + +#endif --- rafkill-1.2.2.orig/build/booster.cpp +++ rafkill-1.2.2/build/booster.cpp @@ -0,0 +1,81 @@ +#include "booster.h" +#include "bitmap.h" +#include "defs.h" + +#define MAX_BOOSTER_SHADE 13 + +PixelList::PixelList( int ax, int ay, int l, PixelList * nx ) { + x = ax; + y = ay; + next = nx; + life = l; +} + +int PixelList::Update(){ + life++; + return life; +} + +void PixelList::Draw( const Bitmap & work, int * shade, int offset ) const{ + // circlefill( work, x, y+offset, 1, shade[ life ] ); + work.circleFill( x, y+offset, 1, shade[ life ] ); +} + + +Booster::Booster() { + + shade = new int[ MAX_BOOSTER_SHADE ]; + Util::blend_palette( shade, MAX_BOOSTER_SHADE*2/3, Bitmap::makeColor(244,220,12), Bitmap::makeColor(237,53,42) ); + Util::blend_palette( shade+MAX_BOOSTER_SHADE*2/3, (MAX_BOOSTER_SHADE-MAX_BOOSTER_SHADE*2/3), Bitmap::makeColor(237,53,42), Bitmap::makeColor(83,6,0) ); + head = new PixelList(0,0,0,NULL); + +} + + +void Booster::add( int x, int y) { + + PixelList * temp = new PixelList( x, y, 0, head->next ); + head->next = temp; + +} + + +void Booster::Draw( const Bitmap & work, int offset ) const{ + + PixelList * cur = head; + while ( cur->next != NULL ) { + cur->next->Draw( work, shade, offset ); + cur = cur->next; + + /* + if ( cur->next->Draw(work,shade,offset) >= MAX_BOOSTER_SHADE ) { + PixelList * dump = cur->next; + cur->next = cur->next->next; + delete dump; + } else cur = cur->next; + */ + } + +} + +void Booster::Update(){ + PixelList * cur = head; + while ( cur->next != NULL ) { + if ( cur->next->Update() >= MAX_BOOSTER_SHADE ) { + PixelList * dump = cur->next; + cur->next = cur->next->next; + delete dump; + } else cur = cur->next; + } +} + +Booster::~Booster() { + delete shade; + PixelList * cur = head; + while ( cur != NULL ) { + PixelList * dump = cur; + cur = cur->next; + delete dump; + } + +} --- rafkill-1.2.2.orig/build/drawer.h +++ rafkill-1.2.2/build/drawer.h @@ -0,0 +1,72 @@ +#ifndef _drawer_h +#define _drawer_h + +#include +#include "bitmap.h" + +using namespace std; + +class SpaceObject; +class PlayerObject; +class ExplosionClass; + +const int MAX_WARNING_SHADE = 40; +const int MAX_ATTRIBUTE_COLOR = 100; + +/* Drawer: + * Draws all the objects and everything you see on the screen + */ +class Drawer{ +public: + + Drawer(); + + void Draw( const vector< SpaceObject * > * objects, const SpaceObject * player, ExplosionClass ** expl, int MAX_EXPL ); + void fadeToBlack( int num ); + + inline void setDrawTrans(){ + drawTrans = true; + } + + inline void setDrawSolid(){ + drawTrans = false; + } + + inline void setDrawLand(bool value){ + draw_land = value; + } + + ~Drawer(); + +protected: + + void drawHud( const PlayerObject * player ); + void showAttribute( int amount, int MAX, int start_x, int offset, int * shade ); + void drawLand( int view, int y1 ); + + Bitmap * loadLand(); + +protected: + int land_counter; + Bitmap * work; + Bitmap * radar; + Bitmap * land; + Bitmap * transBuffer; + + int warning_shade[ MAX_WARNING_SHADE ]; + int warning_shade_color; + + int view_port; + + int level_speech; + + int shade_energy[ MAX_ATTRIBUTE_COLOR ]; + int shade_shield[ MAX_ATTRIBUTE_COLOR ]; + + bool draw_land; + bool drawTrans; + + // Bitmap * Screen; +}; + +#endif --- rafkill-1.2.2.orig/build/menu.cpp +++ rafkill-1.2.2/build/menu.cpp @@ -0,0 +1,1069 @@ +#include +#include "defs.h" +#include "menu.h" +#include "loadsave.h" +#include "trigtable.h" +#include "strings.h" +#include +#include "animation.h" +#include "spaceobj.h" +#include "shipobj.h" +#include "sound.h" +#include "font.h" +#include "rmenu.h" +#include "rmenu_animation.h" +#include "raptor.h" +#include "hull.h" +#include "hulls/hull_player.h" +#include "ebox.h" +#include +#include +#include "music.h" +#include + +#include + +using namespace std; + +#include "guns/gun_arc.h" +#include "guns/gun_angle.h" +#include "guns/gun_beam.h" +#include "guns/gun_chain.h" +#include "guns/gun_destruct.h" +#include "guns/gun_edfstraight.h" +#include "guns/gun_ednstraight.h" +#include "guns/gun_eflarge.h" +#include "guns/gun_efmsingle.h" +#include "guns/gun_efsingle.h" +#include "guns/gun_elarge.h" +#include "guns/gun_emissle.h" +#include "guns/gun_emlight.h" +#include "guns/gun_eside.h" +#include "guns/gun_estraight.h" +#include "guns/gun_findgun.h" +#include "guns/gun_fire.h" +#include "guns/gun_follow.h" +#include "guns/gun_laser.h" +#include "guns/gun_machine.h" +#include "guns/gun_machine_circle.h" +#include "guns/gun_minimissle.h" +#include "guns/gun_missle.h" +#include "guns/gun_pulse.h" +#include "guns/gun_shatter.h" +#include "guns/gun_spread.h" +#include "guns/gun_stick.h" +#include "guns/gun_yehat.h" +#include "guns/gun_swirl.h" +#include "guns/gun_massive.h" +#include "guns/gun_saber.h" +#include "guns/gun_tractor_beam.h" +#include "guns/gun_rotate.h" + +#define MENU_BUY 7 +#define MENU_QUIT 843 +#define MENU_NEXT 844 +#define MENU_CONTINUE 4321 +#define MENU_WEAPON 9002 +#define MENU_HULL 9003 + +#define MENU_SELL_WEAPON 30 +#define MENU_UPGRADE 321 +#define MENU_BUY_WEAPON 56 +#define MENU_BUY_ACCESSORY 600 + +#define MENU_SAVE 14000 + +#define MENU_HULL_LIFE 12000 +#define MENU_HULL_SHIELD 12001 +#define MENU_BUY_HULL 12005 +#define MENU_HULL_MAX 12006 +#define MENU_SHIELD_MAX 12007 + +#define HULL_LIFE_WORTH 1000 +#define HULL_SHIELD_WORTH 3000 + +static const int INCREASE_SHIELD = 3; + +#define ANIMATION_X 180 + +#define MENU_TITLE_COLOR (Bitmap::makeColor(240,205,7)) + +#ifndef debug +#define debug printf("File: %s Line: %d\n", __FILE__, __LINE__ ); +#endif + +static const int NO_SOUND = -1; + +/* TODO: + * This whole class needs to be rewritten. It sucks! + */ + +menuClass::menuClass() { + + menuClass::gun_sticky_collide_list = NULL; + + pgun[0].mgun = 4; + pgun[0].gunz = new int[ pgun[0].mgun ]; + pgun[0].gunz[0] = GUN_MACHINE; + pgun[0].gunz[1] = GUN_MACHINE_CIRCLE; + pgun[0].gunz[2] = GUN_SPREAD; + pgun[0].gunz[3] = GUN_ANGLE; + + pgun[1].mgun = 4; + pgun[1].gunz = new int[ pgun[1].mgun ]; + pgun[1].gunz[0] = GUN_BEAM; + pgun[1].gunz[1] = GUN_MINIMISSLE; + pgun[1].gunz[2] = GUN_SHATTER; + pgun[1].gunz[3] = GUN_YEHAT; + + pgun[2].mgun = 3; + pgun[2].gunz = new int[ pgun[2].mgun ]; + pgun[2].gunz[0] = GUN_ARC; + pgun[2].gunz[1] = GUN_LASER; + pgun[2].gunz[2] = GUN_STICKY; + + pgun[3].mgun = 2; + pgun[3].gunz = new int[ pgun[3].mgun ]; + pgun[3].gunz[0] = GUN_MISSLE; + pgun[3].gunz[1] = GUN_PULSE; + + pgun[4].mgun = 3; + pgun[4].gunz = new int[ pgun[4].mgun ]; + pgun[4].gunz[0] = GUN_FINDGUN; + pgun[4].gunz[1] = GUN_FOLLOW; + pgun[4].gunz[2] = GUN_TRACTOR; + + agun.mgun = 4; + agun.gunz = new int[ agun.mgun ]; + agun.gunz[0] = GUN_SABER; + agun.gunz[1] = GUN_SWIRL; + agun.gunz[2] = GUN_CHAIN; + agun.gunz[3] = GUN_MASSIVE; + + /* + char * font_name = Util::data_file( "vulture.fnt" ); + // menuFont = new RFont( font_name ); + free( font_name ); + */ + + if ( menuClass::gun_sticky_collide_list == NULL ){ + menuClass::gun_sticky_max_collide = 20; + menuClass::gun_sticky_collide_list = new ECollide*[ menuClass::gun_sticky_max_collide ]; + for ( int q = 0; q < menuClass::gun_sticky_max_collide; q++ ) { + int size = 6; + Bitmap temp( (size + q * size)*2, (size + q * size)*2 ); + temp.fill( Bitmap::MaskColor ); + temp.circleFill( size + q * size, size + q * size, size + q * size, Bitmap::makeColor(255,0,0) ); + // menuClass::gun_sticky_collide_list[q] = new ECollide( temp, 3, mask, 35.0 ); + menuClass::gun_sticky_collide_list[q] = new ECollide( temp ); + } + } + +} + + +menuClass::~menuClass() { + for ( int q = 0; q < 5; q++ ) + delete[] pgun[q].gunz; + delete[] agun.gunz; + // delete menuFont; + + if ( menuClass::gun_sticky_collide_list != NULL ){ + for ( int q = 0; q < menuClass::gun_sticky_max_collide; q++ ) + delete menuClass::gun_sticky_collide_list[q]; + delete[] menuClass::gun_sticky_collide_list; + } +} + + +void menuClass::vectorAdd( vector< SpaceObject * > * stable, vector< SpaceObject * > * state ) { + + for ( vector< SpaceObject * >::iterator it = state->begin(); + it != state->end(); it++ ) + stable->push_back( *it ); + +} + + +void menuClass::getAnimation( Animation * hold, SpaceObject * player, vector< SpaceObject * > * ammo, vector< SpaceObject * > * enemy ) { + + player->SetCoordXY( ANIMATION_X/2, 350 ); + + player->setDX( 0 ); + player->setDY( 0 ); + /* + player->getDX() = 0; + player->getDY() = 0; + */ + //hold->clear(); + + // for ( int z = 0; z < 1; z++ ) { + + for ( vector< SpaceObject * >::iterator it = ammo->begin(); it != ammo->end(); ) { + (*it)->MoveMe( ammo, enemy, NULL ); + // if ( (*it)->MoveMe( ammo, enemy, NULL, NULL ) ) { + int x = (*it)->getX(); + int y = (*it)->getY(); + if ( x < 0 || x > 640 || y < 0 || y > 480 ){ + SpaceObject * del = *it; + it = ammo->erase( it ); + delete del; + } else it++; + } + + + for ( vector< SpaceObject * >::iterator it = ammo->begin(); it != ammo->end(); ) { + if ( (*it)->getLife() <= 0 ) { + SpaceObject * del = *it; + it = ammo->erase( it ); + delete del; + } else ++it; + } + // } + + + WeaponObject ** myGun = player->getHull()->Guns(); + for ( int q = 0; q < player->getHull()->maxGuns(); q++ ) + if ( myGun[q] != NULL ) { + if ( myGun[q]->getShotCounter() > 0 ) + myGun[q]->Wait( 1 ); + else { + myGun[q]->MakeShot(player->getX(),player->getY()-10,ammo,enemy); + } + } + + // vector< SpaceObject * > * draw = new vector< SpaceObject * >(); + vector< SpaceObject * > draw; + vectorAdd( &draw, ammo ); + draw.push_back( player ); + //BITMAP * add_b = create_bitmap( ANIMATION_X, 480 ); + const Bitmap & add_b = player_animate->show(); + add_b.clear(); + + int total = 0; + for ( vector< SpaceObject * >::iterator it = draw.begin(); it != draw.end(); it++, total++ ){ + (*it)->Draw( add_b, NULL, 0, (*it)->lookPlane(), 0 ); + } + + /* draw a white fading to grey border */ + for ( int z = 0; z < 7; z++ ) { + + int d = 11; + int col = Bitmap::makeColor(255-z*d,255-z*d,255-z*d); + add_b.rectangle( z, z, ANIMATION_X-z-1, 480-z-1, col ); + + } + + // delete draw; + +} + + +Bitmap menuClass::menuScreen() { + + // int * shade = new int[ 100 ]; + int shade[ 100 ]; + + Util::blend_palette( shade, 100, Bitmap::makeColor( Util::rnd(50)+20, Util::rnd(40)+50, Util::rnd(50)+170 ), Bitmap::makeColor( Util::rnd(40)+190, Util::rnd(128)+128, Util::rnd(30)+10 ) ); + Bitmap rec( GRAPHICS_X, GRAPHICS_Y ); + + int divx = 3; + double mmx = tsqrt( tsqr(GRAPHICS_X) + tsqr(GRAPHICS_Y) ); + for ( int x = 0; x < GRAPHICS_X / divx; x++ ){ + for ( int y = 0; y < GRAPHICS_Y / divx; y++ ) { + double ma = (double)tsqrt( tsqr(x*divx) + tsqr(y*divx) ) / mmx * 99.0; + rec.rectangleFill( x*divx, y*divx, x*divx+divx-1, y*divx+divx-1, shade[(int)ma] ); + } + } + + // delete[] shade; + + return rec; +} + + +int menuClass::upgradeHelper( int worth, int lev ) { + + return worth * (lev+1); + + //if ( lev == 0 ) return worth*3/2; + //return (int)( (double)upgradeHelper( worth, lev-1 ) * 7.0/4.0 ); + +} + + +int menuClass::upgradeCost( WeaponObject * gun ) { + //int g = (int)((double)gun->Worth() * (double)tcube(gun->strength+3)*30.0/650.0); + return upgradeHelper( gun->Worth(), gun->getPower() ); +} + + +int menuClass::sellGun( WeaponObject * gun ) { + + //int resell = ( tcube( (gun->strength+1)*6 ) + gun->Worth() ) * 4 / 12; + int resell = upgradeCost( gun ) / 2; + return resell; + +} + + +int menuClass::hull_price( int z ) { + switch( z ) { + case 1 : return 160000; + case 2 : return 485000; + case 3 : return 700000; + case 4 : return 1000000; + } + return 0; +} + + +void menuClass::GunMenu( RMenu * weap, int q, WeaponObject * current, const Bitmap & intr, int score ) { + WeaponObject ** legal = new WeaponObject*[pgun[q].mgun]; + for ( int z = 0; z < pgun[q].mgun; z++ ) + legal[z] = GetWeapon( pgun[q].gunz[z] ); + + string numnum; + + if ( current != NULL ) { + /* + char * numnum = int2str(current->strength+1); + char * sub = append( current->GetName()," at strength "); + weap->addTitle( append(sub,numnum), menuFont ); + free( numnum ); + free( sub ); + */ + weap->addTitle( current->GetName(), menuFont ); + // char * numnum = int2str( current->strength + 1 ); + int max = current->maxPower(); + + char power[ 64 ]; + if ( max != -1 ) snprintf( power, 64, "%d", max+1 ); + else snprintf( power, 64, "Infinite" ); + + char tmp[ 128 ]; + snprintf( tmp, 128, "Strength %d out of %s", current->getPower()+1, power ); + weap->addTitle( tmp, menuFont ); + + // char * maxnum; + + /* + if ( max != -1 ) maxnum = int2str( max+1 ); + else maxnum = strdup("Infinite"); + */ + + /* + char * sub = append( "Strength ", numnum ); + char * sub2 = append( " out of ", maxnum ); + weap->addTitle( append(sub,sub2), menuFont ); + free( numnum); + free( maxnum ); + free( sub ); + free( sub2 ); + */ + + } else weap->addTitle( "No Weapon", menuFont ); + numnum = int2normal( score ); + weap->addTitle( "Score " + numnum, menuFont ); + weap->addMenu( "Return", menuFont, true, 0, NULL, NO_SOUND ); + if ( current != NULL ) { + + if ( current->getPower() < current->maxPower() || current->maxPower() == -1 ) { + numnum = int2normal( upgradeCost(current) ); + weap->addMenu( "Upgrade " + numnum, menuFont, score>=upgradeCost(current), MENU_UPGRADE, weap, -1 ); + } + + numnum = int2normal( sellGun( current ) ); + weap->addMenu( "Sell for " + numnum, menuFont, true, MENU_SELL_WEAPON, weap, NO_SOUND ); + } + weap->addTitle( "Purchase", menuFont ); + for ( int z = 0; z < pgun[q].mgun; z++ ) + if ( !(current != NULL && strcasecmp(legal[z]->GetName(),current->GetName())==0) ) { + + /* + numnum = int2normal( legal[z]->Worth() ); + char * sub = append(legal[z]->GetName(),":"); + char * sub2 = append(sub,numnum); + */ + //weap->addMenu(strdup(sub2),menuFont,score>=legal[z]->Worth(),MENU_BUY_WEAPON+z, weap, NULL ); + char sub2[ 256 ]; + sprintf( sub2, "%s: %d", legal[z]->GetName(), legal[z]->Worth() ); + weap->addMenu(sub2,menuFont,true,MENU_BUY_WEAPON+z, weap, NO_SOUND ); + /* + free( numnum ); + free( sub2 ); + free( sub ); + */ + } + + for ( int z = 0; z < pgun[q].mgun; z++ ) + delete legal[z]; + delete[] legal; +} + + +void menuClass::GetAccessoryMenu( RMenu * weap, WeaponObject ** a_list, const Bitmap & intr, int score ) { + WeaponObject ** legal = new WeaponObject*[agun.mgun]; + for ( int z = 0; z < agun.mgun; z++ ) + legal[z] = GetWeapon( agun.gunz[z] ); + + weap->addTitle( "Accessory Bays", menuFont ); + string numnum; + numnum = int2normal( score ); + weap->addTitle( "Score " + numnum, menuFont ); + weap->addTitle( "Currently have", menuFont ); + for ( int q = 0; q < MAX_ACCESSORY; q++ ) + if ( a_list[q] != NULL ) + weap->addTitle( a_list[q]->GetName(), menuFont ); + + weap->addTitle( "Purchase", menuFont ); + for ( int q = 0; q < agun.mgun; q++ ) { + bool cy = true; + int total = 0; + for ( int z = 0; z < MAX_ACCESSORY; z++ ) + if ( a_list[z] != NULL ) { + if ( strcasecmp(a_list[z]->GetName(),legal[q]->GetName()) == 0 ) cy = false; + total++; + } + + if ( cy ) { + + /* + numnum = int2normal( legal[q]->Worth() ); + char * sub = append(legal[q]->GetName(),":"); + char * sub2 = append(sub,numnum); + */ + char sub2[ 256 ]; + snprintf( sub2, 256, "%s: %d", legal[q]->GetName(), legal[q]->Worth() ); + weap->addMenu( sub2, menuFont, score>=legal[q]->Worth() && total < MAX_ACCESSORY, MENU_BUY_ACCESSORY+q, weap, NO_SOUND ); + } + + } + + weap->addMenu( "Return", menuFont, true, 0, NULL, NO_SOUND ); + + for ( int z = 0; z < agun.mgun; z++ ) + delete legal[z]; + delete[] legal; + +} + +void menuClass::weaponMenu( RMenu * gun_menu, SpaceObject * player ) { + //RMenu * gun_menu = new RMenu( intr, 1, 40, makecol(80,0,0),makecol(255,136,0), MENU_TITLE_COLOR ); + gun_menu->addTitle( "Buy Weapons", menuFont ); + // string numnum = int2normal( player->getScore() ); + string score = "Score "; + score += int2normal( player->getScore() ); + cout << "String = '" << score << "'" << endl; + gun_menu->addTitle( score, menuFont ); + for ( int q = 0; q < player->getHull()->maxGuns()-1; q++ ) { + // numnum = int2str(q+1); + string bay = "Weapon Bay "; + bay += int2normal( q + 1 ); + gun_menu->addMenu( bay, menuFont,true,MENU_BUY+q,gun_menu, NO_SOUND ); + } + gun_menu->addMenu( "Accessories", menuFont, true, 1, gun_menu, NO_SOUND ); + gun_menu->addMenu( "Return", menuFont, true, 0, NULL, NO_SOUND ); +} + + +HullObject * menuClass::playerHull( int q ) { + + // BITMAP ** pics = new BITMAP*[ 9 ]; + vector< Bitmap * > pics; + int life = 0; + int shield = 0; + int guns = 0; + int hn = 0; + int startingSprite = HULL_1_1; + switch( q ) { + case 1 : { + startingSprite = HULL_1_1; + life = 100; + shield = 100; + guns = 3; + hn = 1; + break; + } + case 2 : { + startingSprite = HULL_2_1; + + /* + for ( int q = 0; q < 9; q++ ){ + pics.push_back( new Bitmap( Util::getDataSprite( HULL_2_1 + q ) ) ); + } + */ + life = 150; + shield = 150; + guns = 4; + hn = 2; + break; + } + case 3 : { + startingSprite = HULL_3_1; + /* + for ( int q = 0; q < 9; q++ ){ + pics.push_back( new Bitmap( Util::getDataSprite( HULL_3_1 + q ) ) ); + } + */ + life = 200; + shield = 250; + guns = 5; + hn = 3; + break; + } + } + + for ( int q = 0; q < 9; q++ ){ + pics.push_back( new Bitmap( Util::getDataSprite( startingSprite + q ) ) ); + } + + // return new PlayerHull( pics, 9, life, shield, guns, hn, new ECollide( pics[4], 6, makecol(255,0,255), 52 ) ); + return new PlayerHull( pics, life, shield, guns, hn, new ECollide( pics[4] ) ); +} + +void menuClass::GetHullMenu( RMenu * hull_menu, SpaceObject * human, const Bitmap & intr ){ + + PlayerHull * phull = (PlayerHull *)human->getHull(); + char tmp[ 128 ]; + snprintf( tmp, 128, "Score %d", human->getScore() ); + hull_menu->addTitle( tmp, menuFont ); + + snprintf( tmp, 128, "Hull life %d out of %d", (int)human->getHull()->life, phull->getMaxLife() ); + hull_menu->addTitle( tmp, menuFont ); + + snprintf( tmp, 128, "Hull Shield %d out of %d", (int)phull->getShield(), phull->getMaxShield() ); + hull_menu->addTitle( tmp, menuFont ); + + bool can_buy; + + can_buy = ( human->getScore() >= HULL_LIFE_WORTH ) && ( human->getHull()->life < phull->getMaxLife() ); + hull_menu->addMenu( "Buy Life 1000", menuFont, can_buy, MENU_HULL_LIFE, hull_menu, NO_SOUND ); + + can_buy = (human->getScore() >= HULL_SHIELD_WORTH) && (phull->getShield() < phull->getMaxShield() ); + hull_menu->addMenu( "Buy Shield 3000", menuFont, can_buy, MENU_HULL_SHIELD, hull_menu, NO_SOUND ); + + hull_menu->addMenu( "Maxout life", menuFont, true, MENU_HULL_MAX, hull_menu, NO_SOUND ); + hull_menu->addMenu( "Maxout shield", menuFont, true, MENU_SHIELD_MAX, hull_menu, NO_SOUND ); + + snprintf( tmp, 128, "Buy next hull for %d", hull_price( phull->rank() ) ); + if ( phull->rank() < 3 ){ + can_buy = human->getScore() >= hull_price( phull->rank() ); + + hull_menu->addMenu( tmp, menuFont, can_buy, MENU_BUY_HULL, hull_menu, NO_SOUND ); + } + + hull_menu->addMenu( "Return", menuFont, true, 0, NULL, NO_SOUND ); + +} + + +SpaceObject * menuClass::copySpace( SpaceObject * player ) { + + /* TODO: fix + SpaceObject * who = new SpaceObject( 0, 0, 0, 0, new HullObject( player->getHull()->Bitmap, 1, 1, player->getHull()->maxGuns(), 1, 10, false, NULL ), NULL, 10, 1 ); + for ( int q = 0; q < player->getHull()->maxGuns(); q++ ) + who->giveWeapon( player->getHull()->Guns()[q], q ); + return who; + */ + + return NULL; + +} + + +bool menuClass::accept_sell(){ + + // BITMAP * sell_screen = create_bitmap( GRAPHICS_X, GRAPHICS_Y ); + // Bitmap sell_screen( GRAPHICS_X, GRAPHICS_Y ); + Bitmap sell_screen( *Bitmap::Screen, true ); + sell_screen.BlitToScreen(); + Bitmap::transBlender( 0, 0, 0, 120 ); + Bitmap::drawingMode( Bitmap::MODE_TRANS ); + sell_screen.rectangleFill( 120, 80, 450, 235, Bitmap::makeColor(0,0,0) ); + sell_screen.rectangle( 120, 80, 450, 235, Bitmap::makeColor(255,255,255) ); + Bitmap::drawingMode( Bitmap::MODE_SOLID ); + RMenu sell( sell_screen, 130, 100, 1000, Bitmap::makeColor(80,0,0), Bitmap::makeColor(255,136,0), MENU_TITLE_COLOR ); + sell.addTitle( "Sell weapon", menuFont ); + sell.addMenu( "Yes", menuFont, true, 1, &sell, NO_SOUND ); + sell.addMenu( "No", menuFont, true, 0, &sell, NO_SOUND ); + sell.init(); + + int call = -1; + RMenu * current = &sell; + while( call == -1 ) { + call = current->procMenu( ¤t ); + if ( !sell.Selected() ) call = -1; + Util::YIELD(); + // al_poll_duh( dumb_player ); + // dumb_player->play(); + + } + + // delete sell; + // destroy_bitmap( sell_screen ); + + return call; + +} + +char * menuClass::getFileInfo( int number ){ + + char * temp = (char *)malloc( sizeof(char) * 1024 ); + char buf[ 64 ]; + sprintf( buf, "player%d.rap", number+1 ); + FILE * fv = fopen( buf, "rb" ); + if ( !fv ){ + sprintf( temp, "Slot %d Empty", number+1 ); + } else { + + time_t tl = Util::fileTime( buf ); + struct tm * real_time = localtime( &tl ); + + // strftime( date, 64, "%A %F %r", real_time ); + char xbuf[ 128 ]; + strftime( xbuf, 64, "%A %F", real_time ); + sprintf( temp, "Slot %d %s", number+1, xbuf ); + + fclose( fv ); + } + + return temp; + +} + +void menuClass::getSaveMenu( RMenu * save_menu ){ + + save_menu->clear(); + + for ( int q = 0; q < 6; q++ ){ + save_menu->addMenu( getFileInfo(q), menuFont, true, MENU_SAVE+q, NULL, NO_SOUND ); + } + save_menu->addMenu( "Return", menuFont, true, 345345, NULL, NO_SOUND ); + +} + + +bool menuClass::activate( SpaceObject * player ){ + + Font _menuFont = Util::getMenuFont(); + this->menuFont = &_menuFont; + + /* Give the player some default minimum amount of life */ + if ( player->getLife() <= 0 ){ + player->getHull()->life = ((PlayerHull *)player->getHull())->getMaxLife()/2; + } + + //cheat line + // player->IncScore( 1000000 ); + + //BITMAP * intr = menuScreen(); + char buyMenuFile[ 4096 ]; + // char * buy_menu_file = Util::data_file( "buy-scene.pcx" ); + Util::getDataPath( buyMenuFile, "buy-scene.pcx" ); + Bitmap intr( buyMenuFile ); + // free( buy_menu_file ); + if ( intr.getError() ) { + printf("Supreme error with menu screen\n"); + return true; + } + + // SAMPLE * menu_sound = (SAMPLE *)Util::global_snd[ INTRO_MENU_SELECT ].dat; + int menu_sound = INTRO_MENU_SELECT; + + SpaceObject * human = player; + + SpaceObject * alias; //used for animation in menu + alias = player->copy(); + + vector< SpaceObject * > * ammo = new vector< SpaceObject * >; + vector< SpaceObject * > * enemy = new vector< SpaceObject * >; + SpaceObject * enemy_guy = new SpaceObject( 320, -800, 0, 0, new HullObject(NULL,0,0,0,0,0,false,NULL), NULL, PLANE_AIR, TEAM_ENEMY ); + enemy->push_back( enemy_guy ); + + int num_guns = human->getHull()->maxGuns()-1; + + player_animate = new Animation( 640-ANIMATION_X, 0 ); + Bitmap pa( ANIMATION_X, 480 ); + player_animate->add( pa ); + + RMenu intro_menu( intr, 1, 40, 1000, Bitmap::makeColor(90,0,0), Bitmap::makeColor(255,136,0), MENU_TITLE_COLOR ); + RMenu gun_menu( intr, 1, 40, 1000, Bitmap::makeColor(90,0,0), Bitmap::makeColor(255,136,0), MENU_TITLE_COLOR ); + RMenu hull_menu( intr, 1, 40, 1000, Bitmap::makeColor(90,0,0), Bitmap::makeColor(255,136,0), MENU_TITLE_COLOR ); + RMenu save_menu( intr, 1, 40, 1000, Bitmap::makeColor(90,0,0), Bitmap::makeColor(255,136,0), MENU_TITLE_COLOR ); + RMenu * accessory_menu = new RMenuAnimation( intr, 1, 40, 1000, Bitmap::makeColor(90,0,0), Bitmap::makeColor(255,136,0), MENU_TITLE_COLOR, player_animate ); + weaponMenu( &gun_menu, human ); + gun_menu.nextMenu( gun_menu.askPos( "Accessories" ), accessory_menu ); + GetHullMenu( &hull_menu, human, intr ); + GetAccessoryMenu( accessory_menu, ((PlayerHull *)human->getHull())->Accessories(), intr, human->getScore() ); + + RMenu ** weapon_menu = new RMenu*[ num_guns ]; + for ( int q = 0; q < num_guns; q++ ) { + weapon_menu[q]=new RMenuAnimation(intr, 1, 40, 1000, Bitmap::makeColor(120,0,0), Bitmap::makeColor(255,0,0),MENU_TITLE_COLOR,player_animate); + GunMenu(weapon_menu[q], q, human->getHull()->Guns()[q], intr, human->getScore() ); + gun_menu.nextMenu( q+3, weapon_menu[q] ); + } + + intro_menu.addTitle( "Buy Menu", menuFont ); + string numnum = int2normal( human->getScore() ); + intro_menu.addTitle( "Score " + numnum, menuFont ); + intro_menu.addMenu( "Weapon Menu", menuFont, true, MENU_WEAPON, &gun_menu, menu_sound ); + intro_menu.addMenu( "Hull Menu", menuFont, true, MENU_HULL, &hull_menu, menu_sound ); + intro_menu.addMenu( "Save Game", menuFont, true, MENU_HULL, &save_menu, menu_sound ); + intro_menu.addMenu( "Next Level", menuFont, true, MENU_NEXT, NULL, menu_sound ); + intro_menu.addMenu( "Main Menu", menuFont, true, MENU_QUIT, NULL, menu_sound ); + + getSaveMenu( &save_menu ); + + /* + for ( int q = 0; q < 6; q++ ) + save_menu.addMenu( getFileInfo(q), Util::raptor_font, true, MENU_SAVE+q, NULL, NULL ); + save_menu.addMenu( "Return", Util::raptor_font, true, 345345, NULL, NULL ); + */ + + /** END INIT **/ + + RMenu * current = &intro_menu; + current->init(); + int call = -1; + int cur_weapon = 0; + Util::speed_counter = 0; + while ( call != MENU_QUIT && call != MENU_NEXT ) { + + Util::YIELD(); + // al_poll_duh( dumb_player ); + // dumb_player->play(); + + bool score_change = false; + if ( Util::speed_counter ){ + getAnimation( player_animate, alias, ammo, enemy ); + } + + RMenu * temp = current; + call = current->procMenu( ¤t ); + if ( !temp->Selected() ) { + + if ( temp->changed() ) { + + //delete alias; + //alias = player->copy(); + + if ( call == 0 ) { + delete alias; + alias = player->copy(); + } + + if ( call-MENU_BUY >= 0 && call-MENU_BUY < num_guns ) + cur_weapon = call-MENU_BUY; + + if ( call == MENU_SELL_WEAPON ) { + + delete alias; + alias = player->copy(); + alias->eraseWeapon( cur_weapon ); + } + + if ( call == MENU_UPGRADE ) { + delete alias; + alias = player->copy(); + WeaponObject * up = alias->getHull()->Guns()[ cur_weapon ]; + if ( up ) + up->IncreasePower( 1 ); + } + + if ( call-MENU_BUY_WEAPON >= 0 && call-MENU_BUY_WEAPON < pgun[cur_weapon].mgun ) { + delete alias; + alias = player->copy(); + int w_buy = call-MENU_BUY_WEAPON; + + WeaponObject * legal = GetWeapon( pgun[cur_weapon].gunz[w_buy] ); + alias->eraseWeapon( cur_weapon ); + alias->giveWeapon( GetWeapon( pgun[cur_weapon].gunz[w_buy] ), cur_weapon ); + + delete legal; + } + + if ( call-MENU_BUY_ACCESSORY >= 0 && call-MENU_BUY_ACCESSORY < agun.mgun ) { + delete alias; + alias = player->copy(); + int w_buy = call - MENU_BUY_ACCESSORY; + alias->eraseWeapon( alias->getHull()->maxGuns()-1 ); + alias->giveWeapon( GetWeapon( agun.gunz[w_buy] ), alias->getHull()->maxGuns()-1 ); + } + + } + + call = -1; + + } + + if ( call >= MENU_SAVE && call <= MENU_SAVE+6 ){ + int save_game = call - MENU_SAVE + 1; + savePlayer( player, save_game ); + getSaveMenu( &save_menu ); + } + + if ( call-MENU_BUY >= 0 && call-MENU_BUY < num_guns ) + cur_weapon = call-MENU_BUY; + + if ( call == MENU_SELL_WEAPON ) { + WeaponObject * sl = human->getHull()->Guns()[ cur_weapon ]; + if ( sl ) { + + if ( accept_sell() ) { + // human->score += sellGun( sl ); + human->IncScore( sellGun( sl ) ); + human->eraseWeapon( cur_weapon ); + human->giveWeapon( NULL, cur_weapon ); + score_change = true; + } + } + + delete alias; + alias = player->copy(); + } + + if ( call-MENU_BUY_WEAPON >= 0 && call-MENU_BUY_WEAPON < pgun[cur_weapon].mgun ) { + int w_buy = call-MENU_BUY_WEAPON; + + WeaponObject * legal = GetWeapon( pgun[cur_weapon].gunz[w_buy] ); + WeaponObject ** guns = human->getHull()->Guns(); + if ( human->getScore() >= legal->Worth() ) { + // human->score -= legal->Worth(); + human->IncScore( -(legal->Worth()) ); + if ( guns[cur_weapon] != NULL ) { + // human->score += sellGun( guns[cur_weapon] ); + human->IncScore( sellGun( guns[cur_weapon] ) ); + human->eraseWeapon( cur_weapon ); + human->giveWeapon( NULL, cur_weapon ); + } + WeaponObject * nw = GetWeapon( pgun[ cur_weapon].gunz[w_buy] ); + human->giveWeapon( nw, cur_weapon ); + score_change = true; + } + + delete legal; + + delete alias; + alias = player->copy(); + + } + + if ( call-MENU_BUY_ACCESSORY >= 0 && call-MENU_BUY_ACCESSORY < agun.mgun ) { + int w_buy = call - MENU_BUY_ACCESSORY; + WeaponObject * a_give = GetWeapon( agun.gunz[w_buy] ); + if ( human->getScore() >= a_give->Worth() ) { + // human->score -= a_give->Worth(); + human->IncScore( -(a_give->Worth()) ); + human->giveWeapon( GetWeapon(agun.gunz[w_buy]), human->getHull()->maxGuns()-1 ); + score_change = true; + } + delete a_give; + + delete alias; + alias = player->copy(); + } + + if ( call == MENU_HULL_LIFE ) { + // human->score -= HULL_LIFE_WORTH; + human->IncScore( -HULL_LIFE_WORTH ); + human->getHull()->life += 3; + if ( human->getHull()->life > ((PlayerHull *)human->getHull())->getMaxLife() ) + human->getHull()->life = ((PlayerHull *)human->getHull())->getMaxLife(); + score_change = true; + } + + if ( call == MENU_HULL_SHIELD ) { + // human->score -= HULL_SHIELD_WORTH; + human->IncScore( -HULL_SHIELD_WORTH ); + // ((PlayerHull *)human->getHull())->getShield() += 3; + ((PlayerHull *)human->getHull() )->incShield( INCREASE_SHIELD ); + + /* + if ( ((PlayerHull *)human->getHull())->getShield() > ((PlayerHull *)human->getHull())->getMaxShield() ) + ((PlayerHull *)human->getHull())->getShield() = ((PlayerHull *)human->getHull())->getMaxShield(); + */ + + score_change = true; + } + + if ( call == MENU_BUY_HULL && ((PlayerHull *)human->getHull())->rank() < 3 ) { + if ( human->getScore() >= hull_price( ((PlayerHull *)human->getHull())->rank() ) ) { + // human->score -= hull_price( ((PlayerHull *)human->hull)->rank() ); + human->IncScore( -hull_price( ((PlayerHull *)human->getHull())->rank() ) ); + HullObject * bh = playerHull( ((PlayerHull *)human->getHull())->rank()+1 ); + + WeaponObject ** save_weapons = new WeaponObject*[ human->getHull()->maxGuns()-1 ]; + for ( int q = 0; q < human->getHull()->maxGuns()-1; q++ ) { + save_weapons[q] = human->getHull()->Guns()[q]; + human->giveWeapon( NULL, q ); + } + int old_guns = human->getHull()->maxGuns()-1; + + human->giveHull( bh ); + for ( int q = 0; q < old_guns; q++ ) + human->giveWeapon( save_weapons[q], q ); + + score_change = true; + + delete[] save_weapons; + for ( int q = 0; q < num_guns; q++ ) + delete weapon_menu[q]; + delete[] weapon_menu; + + num_guns = human->getHull()->maxGuns()-1; + gun_menu.clear(); + weaponMenu( &gun_menu, human ); + weapon_menu = new RMenu*[ num_guns ]; + for ( int q = 0; q < num_guns; q++ ) { + + weapon_menu[ q ] = new RMenuAnimation( intr, 1, 40, 1000, Bitmap::makeColor( 120, 0, 0 ), Bitmap::makeColor( 255, 0, 0), MENU_TITLE_COLOR, player_animate ); + GunMenu(weapon_menu[q],q,human->getHull()->Guns()[q], intr, human->getScore() ); + gun_menu.nextMenu( q + 3, weapon_menu[ q ] ); + } + gun_menu.nextMenu( gun_menu.askPos( "Accessories" ), accessory_menu ); + + delete alias; + alias = player->copy(); + } + } + + if ( call == MENU_HULL_MAX ) { + + PlayerHull * ph = (PlayerHull *)human->getHull(); + while ( human->getScore() > HULL_LIFE_WORTH && ph->life < ph->getMaxLife() ) { + if ( ph->getMaxLife()-ph->life < 3 ){ + ph->life += ph->getMaxLife()-ph->life; + } else { + ph->life += 3; + } + // human->score -= HULL_LIFE_WORTH; + human->IncScore( -HULL_LIFE_WORTH ); + score_change = true; + } + + } + + if ( call == MENU_SHIELD_MAX ) { + + PlayerHull * ph = (PlayerHull *)human->getHull(); + + while ( human->getScore() > HULL_SHIELD_WORTH && ph->getShield() < ph->getMaxShield() ) { + ph->incShield( INCREASE_SHIELD ); + + /* + if ( ph->getMaxShield() - ph->getShield() < 3 ) + // ph->getShield() += ph->max(1) - ph->shield; + ph->incShield( ph->max(1) - ph->shield ); + + else / *ph->shield += 3;* /ph->incShield( 3 ); + */ + // human->score -= HULL_SHIELD_WORTH; + human->IncScore( -HULL_SHIELD_WORTH ); + score_change = true; + } + + } + + if ( call == MENU_UPGRADE ) { + WeaponObject * up = human->getHull()->Guns()[cur_weapon]; + if ( up ) { + if ( human->getScore() >= upgradeCost( up ) && (up->getPower() < human->getHull()->Guns()[cur_weapon]->maxPower() || human->getHull()->Guns()[cur_weapon]->maxPower() == -1) ) { + // human->score -= upgradeCost( up ); + human->IncScore( -upgradeCost( up ) ); + up->IncreasePower( 1 ); + score_change = true; + } + } + } + + if ( score_change ) { + + numnum = int2normal( human->getScore() ); + intro_menu.replaceTitle( 2, "Score " + numnum, menuFont ); + gun_menu.clear(); + weaponMenu( &gun_menu, human ); + + for ( int q = 0; q < num_guns; q++ ) { + weapon_menu[q]->clear(); + GunMenu(weapon_menu[q],q, human->getHull()->Guns()[q],intr,human->getScore() ); + gun_menu.nextMenu( q+3, weapon_menu[q] ); + } + hull_menu.clear(); + GetHullMenu( &hull_menu, human, intr ); + accessory_menu->clear(); + GetAccessoryMenu( accessory_menu, ((PlayerHull *)human->getHull())->Accessories(), intr, human->getScore() ); + gun_menu.nextMenu( gun_menu.askPos( "Accessories" ), accessory_menu ); + + } + + } + + /** END **/ + + // destroy_bitmap( intr ); + /* + delete intro_menu; + delete gun_menu; + delete hull_menu; + */ + delete accessory_menu; + for ( int q = 0; q < num_guns; q++ ){ + delete weapon_menu[q]; + } + delete[] weapon_menu; + delete player_animate; + delete ammo; + delete enemy; + delete enemy_guy; + delete alias; + + return ( call == MENU_QUIT ); + /* + if ( call == MENU_QUIT ) return true; + return false; + */ + +} + + +WeaponObject * menuClass::GetWeapon( int q ) { + + switch( q ) { + case GUN_MACHINE : return new WeaponMachineGun( 0, -1, -1, TEAM_PLAYER ); + case GUN_MACHINE_CIRCLE : return new WeaponMachineCircleGun( 0, -1, -1, TEAM_PLAYER ); + case GUN_BEAM : return new WeaponBeam( 0, -1, TEAM_PLAYER ); + case GUN_MINIMISSLE : return new WeaponMiniMissle( 0, -1, TEAM_PLAYER ); + case GUN_FINDGUN : return new WeaponFindGun( 0, -1, TEAM_PLAYER ); + case GUN_PULSE : return new WeaponPulse( 0, -1, TEAM_PLAYER ); + case GUN_LASER : return new WeaponLaser( 0, -1, TEAM_PLAYER ); + case GUN_MISSLE : return new WeaponMissle( 0, -1, TEAM_PLAYER ); + case GUN_FOLLOW : return new WeaponFollow( 0, -1, TEAM_PLAYER ); + case GUN_ARC : return new WeaponArc( 0, -1, -1, TEAM_PLAYER ); + // case GUN_CHAIN : return new WeaponChainGun( 0, -1, "Iron Chain", 65500, NULL, TEAM_PLAYER, new ECollide((BITMAP *)global_data[IRON_000].dat,6,makecol(255,0,255),52) ); + case GUN_CHAIN : return new WeaponChainGun( 0, -1, "Iron Chain", 65500, -1, TEAM_PLAYER, new ECollide( Util::getDataSprite( IRON_000 ) ) ); + // case GUN_CHAIN_FIRE : return new WeaponChainGun( 1, -1, "Fire Chain", 153000, NULL, TEAM_PLAYER, new ECollide((BITMAP *)Util::global_data[IRON_000].dat,6,makecol(255,0,255),52) ); + case GUN_CHAIN_FIRE : return new WeaponChainGun( 1, -1, "Fire Chain", 153000, -1, TEAM_PLAYER, new ECollide( Util::getDataSprite( IRON_000 ) ) ); + case GUN_SHATTER : return new WeaponShatter( 0, -1, -1, TEAM_PLAYER ); + case GUN_SWIRL : return new WeaponSwirlGun(0,-1,-1,TEAM_PLAYER); + case GUN_SPREAD : return new WeaponSpreadGun( 0, -1, -1, TEAM_PLAYER ); + case GUN_MASSIVE : return new WeaponMassiveGun( 0, -1, -1, TEAM_PLAYER ); + case GUN_SABER : return new WeaponSaber( 0, -1, -1, TEAM_PLAYER ); + case GUN_ANGLE : return new WeaponAngle( 0, -1, TEAM_PLAYER ); + case GUN_TRACTOR : return new WeaponTractorBeam( 0, -1, TEAM_PLAYER ); + case GUN_ROTATE : return new WeaponRotateGun( 0, -1, -1, TEAM_PLAYER ); + //case GUN_STICKY : return new WeaponStick( 0, -1, TEAM_PLAYER ); + case GUN_STICKY : { + //ECollide ** temp_list = new ECollide*[ gun_sticky_max_collide ]; + //for ( int q = 0; q < gun_sticky_max_collide; q++ ) + // temp_list[q] = gun_sticky_collide_list[q]->copy(); + //return new WeaponStick( 0, -1, TEAM_PLAYER, temp_list, gun_sticky_max_collide ); + return new WeaponStick( 0, -1, TEAM_PLAYER, menuClass::gun_sticky_collide_list, menuClass::gun_sticky_max_collide ); + } + case GUN_YEHAT : return new WeaponYehatGun( 0, -1, -1, TEAM_PLAYER ); + } + return NULL; +} + +ECollide ** menuClass::gun_sticky_collide_list; +int menuClass::gun_sticky_max_collide; --- rafkill-1.2.2.orig/build/main.h +++ rafkill-1.2.2/build/main.h @@ -0,0 +1,6 @@ +#ifndef _MAIN_H +#define _MAIN_H + +int rafkill( int argc, char ** argv ); + +#endif --- rafkill-1.2.2.orig/build/animation.h +++ rafkill-1.2.2/build/animation.h @@ -0,0 +1,33 @@ +#ifndef _animation_h_ +#define _animation_h_ + +#include +#include "bitmap.h" + +using namespace std; + +class Animation{ +public: + + Animation( int x, int y ); + + virtual void add( const Bitmap & add ); + virtual void Next( const Bitmap & work ); + virtual void changePos( const int x, const int y ); + virtual void clear(); + virtual const Bitmap show() const; + + virtual ~Animation(); + + +protected: + + vector< Bitmap > pics; + vector< Bitmap >::const_iterator current; + + // Bitmap sent; + + int posx, posy; +}; + +#endif --- rafkill-1.2.2.orig/build/rmenu_animation.cpp +++ rafkill-1.2.2/build/rmenu_animation.cpp @@ -0,0 +1,34 @@ +#include "rmenu.h" +#include "rmenu_animation.h" +#include "animation.h" +#include "rfield.h" +#include "bitmap.h" + +RMenuAnimation::RMenuAnimation( const Bitmap & intr, int x, int y, int height, int c1, int c2, int c3, Animation * ani ): +RMenu( intr, x, y, height, c1, c2, c3 ) { + show_case = ani; +} + + +void RMenuAnimation::Draw( const Bitmap & work, int x, int * yval, int * yshade, int min, int max ) { + + show_case->Next( work ); + + RMenu::Draw( work, x, yval, yshade, min, max ); + + /* + RField * junk = head->Next(); + for ( int q = min; q <= max; q++ ) { + while( junk->Place() != q ) junk=junk->Next(); + if ( junk->Title() ) + junk->Draw( work, x, yval[q-min], t_color ); + else + junk->Draw( work, x, yval[q-min], shade_opt_color[yshade[junk->Place()]] ); + } + */ + +} + + +RMenuAnimation::~RMenuAnimation() { +} --- rafkill-1.2.2.orig/build/explode.cpp +++ rafkill-1.2.2/build/explode.cpp @@ -0,0 +1,51 @@ +#include "defs.h" +#include "explode.h" +#include "bitmap.h" + +int last_explode = 0; + +ExplosionClass::ExplosionClass( int cx, int cy, double walkx, double walky, int rad ): +x( cx ), +y( cy ), +vx( cx ), +vy( cy ), +wx( walkx ), +wy( walky ), +radius( rad ), +max_rad( rad ){} + +bool ExplosionClass::update() { + vx += wx; + vy += wy; + x = (int)vx; + y = (int)vy; + + radius--; + if ( radius <= 0 ) return true; + return false; +} + + +void ExplosionClass::Draw( Bitmap * who, int offset ) { + + int color = Util::e_color[(int)((double)radius / (double)max_rad * (double)(MAX_E_COLOR-1))]; + who->circleFill( x, y+offset, radius, color ); +} + + +void addExplode( ExplosionClass ** explode_array, int MAX_EXPL_ARRAY, ExplosionClass * who ) { + if ( explode_array == NULL ) { + delete who; + return; + } + + if ( last_explode >= MAX_EXPL_ARRAY ){ + last_explode = 0; + } + + if ( explode_array[ last_explode ] != NULL ) + delete explode_array[ last_explode ]; + explode_array[ last_explode ] = who; + last_explode = (last_explode+1) % MAX_EXPL_ARRAY; + +} --- rafkill-1.2.2.orig/build/loadsave.cpp +++ rafkill-1.2.2/build/loadsave.cpp @@ -0,0 +1,385 @@ +/* TODO: Rewrite this entire file cuase it sucks badly + */ + +#include "loadsave.h" +#include +#include "spaceobj.h" +#include "strings.h" +#include +#include +#include "gunobj.h" +#include "hull.h" +#include "hulls/hull_player.h" +#include "playerobj.h" +#include "raptor.h" +#include "ebox.h" + +#include "guns/gun_arc.h" +#include "guns/gun_angle.h" +#include "guns/gun_beam.h" +#include "guns/gun_chain.h" +#include "guns/gun_destruct.h" +#include "guns/gun_findgun.h" +#include "guns/gun_fire.h" +#include "guns/gun_follow.h" +#include "guns/gun_laser.h" +#include "guns/gun_machine.h" +#include "guns/gun_machine_circle.h" +#include "guns/gun_minimissle.h" +#include "guns/gun_missle.h" +#include "guns/gun_pulse.h" +#include "guns/gun_shatter.h" +#include "guns/gun_spread.h" +#include "guns/gun_stick.h" +#include "guns/gun_yehat.h" +#include "guns/gun_swirl.h" +#include "guns/gun_massive.h" +#include "guns/gun_saber.h" +#include "guns/gun_tractor_beam.h" +#include "guns/gun_rotate.h" +#include + +// menu.h is needed to hack around the fact that +// only one gun_sticky_collide_list should exist, +// and that is in menu.cpp +#include "menu.h" + +using namespace std; +#ifndef debug +#define debug cout<<"File: "<<__FILE__<<" Line: "<<__LINE__<(player->getHull()); + PlayerHull * hull = (PlayerHull *)(player->getHull() ); + // HullObject * hull = player->getHull(); + + WeaponObject ** guns = hull->Guns(); + WeaponObject ** accessories = hull->Accessories(); + + int rank = hull->rank(); + int shields = hull->getShield(); + int life = hull->getLife(); + int score = player->getScore(); + int dif = ((PlayerObject *)player)->getDifficulty(); + int level = ((PlayerObject *)player)->getLevel(); + + std::string gun_str(""); + for ( int q = 0; q < hull->maxGuns()-1; q++ ){ + if ( guns[q] != NULL ){ + gun_str += guns[q]->GetName(); + gun_str += ":"; + char pow[ 10 ]; + snprintf( pow, 10, "%d|", guns[q]->getPower() ); + gun_str += pow; + } + } + + for ( int q = 0; q < MAX_ACCESSORY; q++ ){ + if ( accessories[q] != NULL ){ + WeaponObject * ac = accessories[q]; + gun_str += ac->GetName(); + gun_str += ":"; + char pow[ 10 ]; + snprintf( pow, 10, "%d|", ac->getPower() ); + gun_str += pow; + } + } + + char final[ 1024 ]; + snprintf( final, 1024, "Life:%d Shields:%d Score:%d Rank:%d Difficulty:%d Level:%d |%s", life, shields, score, rank, dif, level, gun_str.c_str() ); + + // printf("Save string = %s\n", final ); + FILE * fv = fopen( filename, "wb" ); + fwrite( final, sizeof(char), strlen(final), fv ); + fclose( fv ); + + return 0; + +} + +struct weapon_data{ + char name[ 128 ]; + int power; +}; + +HullObject * newPlayerHull( int q ) { + + // Bitmap ** pics = new BITMAP*[ 9 ]; + vector< Bitmap * > pics; + int life = 0; + int shield = 0; + int guns = 0; + int hn = 0; + int pic_number = 0; + switch( q ) { + case 1 : { + pic_number = HULL_1_1; + /* + for ( int q = 0; q < 9; q++ ) + pics[q] = (BITMAP *)global_data[HULL_1_1+q].dat; + */ + life = 100; + shield = 100; + guns = 3; + hn = 1; + break; + } + case 2 : { + pic_number = HULL_2_1; + /* + for ( int q = 0; q < 9; q++ ) + pics[q] = (BITMAP *)global_data[HULL_2_1+q].dat; + */ + life = 150; + shield = 150; + guns = 4; + hn = 2; + break; + } + case 3 : { + pic_number = HULL_3_1; + /* + for ( int q = 0; q < 9; q++ ) + pics[q] = (BITMAP *)global_data[HULL_3_1+q].dat; + */ + life = 200; + shield = 250; + guns = 5; + hn = 3; + break; + } + default : { + pic_number = HULL_1_1; + /* + for ( int q = 0; q < 9; q++ ) + pics[q] = (BITMAP *)global_data[HULL_1_1+q].dat; + */ + life = 100; + shield = 100; + guns = 3; + hn = 1; + break; + + } + } + // return new PlayerHull( pics, 9, life, shield, guns, hn, new ECollide( pics[4], 6, makecol(255,0,255), 52 ) ); + + for ( int q = 0; q < 9; q++ ) + pics.push_back( new Bitmap( Util::getDataSprite( pic_number + q ) ) ); + + return new PlayerHull( pics, life, shield, guns, hn, new ECollide( pics[4] ) ); +} + +int filesize( FILE * f ){ + fseek( f, 0, SEEK_END ); + int x = ftell( f ); + fseek( f, 0, SEEK_SET ); + return x; +} + +void getAllWeapons( vector< vector< WeaponObject * > > & all_weapons ){ + + + vector< WeaponObject * > bay_1; + bay_1.push_back( new WeaponMachineGun( 0, -1, -1, TEAM_PLAYER ) ); + bay_1.push_back( new WeaponMachineCircleGun( 0, -1, -1, TEAM_PLAYER ) ); + bay_1.push_back( new WeaponSpreadGun( 0, -1, -1, TEAM_PLAYER ) ); + bay_1.push_back( new WeaponAngle( 0, -1, TEAM_PLAYER ) ); + + all_weapons.push_back( bay_1 ); + + vector< WeaponObject * > bay_2; + + bay_2.push_back( new WeaponBeam( 0, -1, TEAM_PLAYER ) ); + bay_2.push_back( new WeaponMiniMissle( 0, -1, TEAM_PLAYER ) ); + bay_2.push_back( new WeaponShatter( 0, -1, -1, TEAM_PLAYER ) ); + bay_2.push_back( new WeaponYehatGun( 0, -1, -1, TEAM_PLAYER ) ); + + all_weapons.push_back( bay_2 ); + + vector< WeaponObject * > bay_3; + + bay_3.push_back( new WeaponArc( 0, -1, -1, TEAM_PLAYER ) ); + bay_3.push_back( new WeaponLaser( 0, -1, TEAM_PLAYER ) ); + bay_3.push_back( new WeaponStick( 0, -1, TEAM_PLAYER, menuClass::gun_sticky_collide_list, menuClass::gun_sticky_max_collide ) ); + + all_weapons.push_back( bay_3 ); + + vector< WeaponObject * > bay_4; + + bay_4.push_back( new WeaponMissle( 0, -1, TEAM_PLAYER ) ); + bay_4.push_back( new WeaponPulse( 0, -1, TEAM_PLAYER ) ); + + all_weapons.push_back( bay_4 ); + + vector< WeaponObject * > bay_5; + + bay_5.push_back( new WeaponFindGun( 0, -1, TEAM_PLAYER ) ); + bay_5.push_back( new WeaponFollow( 0, -1, TEAM_PLAYER ) ); + bay_5.push_back( new WeaponTractorBeam( 0, -1, TEAM_PLAYER ) ); + + all_weapons.push_back( bay_5 ); + + vector< WeaponObject * > accessory; + + accessory.push_back( new WeaponSaber( 0, -1, -1, TEAM_PLAYER ) ); + accessory.push_back( new WeaponSwirlGun( 0, -1, -1, TEAM_PLAYER ) ); + // accessory.push_back( new WeaponChainGun( 0, -1, "Iron Chain", 65500, NULL, TEAM_PLAYER, new ECollide((BITMAP *)global_data[IRON_000].dat,6,makecol(255,0,255),52) ) ); + accessory.push_back( new WeaponChainGun( 0, -1, "Iron Chain", 65500, -1, TEAM_PLAYER, new ECollide( Util::getDataSprite( IRON_000 ) ) ) ); + accessory.push_back( new WeaponMassiveGun( 0, -1, -1, TEAM_PLAYER ) ); + + all_weapons.push_back( accessory ); + +} + +SpaceObject * loadPlayer( int game_slot ){ + + FILE * fv; + + char filename[ 64 ]; + snprintf( filename, 64, "player%d.rap", game_slot ); + fv = fopen( filename, "rb" ); + if ( fv == NULL ){ + printf("Could not open %s\n", filename ); + return NULL; + } + + int size = filesize( fv ); + + // printf("Size = %d\n", size ); + SpaceObject * player; + char final[ size+1 ]; + fread( final, sizeof(char), size, fv ); + final[ size ] = '\0'; + fclose( fv ); + + int life; + int shields; + int rank; + int score; + int dif; + int level; + + sscanf( final, "Life:%d Shields:%d Score:%d Rank:%d Difficulty:%d Level:%d", &life, &shields, &score, &rank, &dif, &level ); + debug + + /* + printf("Life = %d\n", life ); + printf("Shields = %d\n", shields ); + printf("Score = %d\n", score ); + printf("Rank = %d\n", rank ); + printf("Difficulty = %d\n", dif ); + */ + + HullObject * hwho; + player = NULL; + + PlayerObject * pp; + PlayerHull * ph; + + debug + + vector< vector< WeaponObject * > > all_weapons; + getAllWeapons( all_weapons ); + + char * weapon_begin = strchr( final, '|' ); + vector< weapon_data * > weapons; + + if ( weapon_begin == NULL ) goto evil_end; + weapon_begin++; + // printf("Final: %s\n", final ); + while ( weapon_begin != NULL && (*weapon_begin) != 0 ){ + char * weapon_end = strchr( weapon_begin, '|' ); + if ( weapon_end == NULL ){ + printf("Error parsing %s. You tried to hack it, didnt you?\n", filename ); + goto evil_end; + } + *weapon_end = '\0'; + weapon_data * wd = new weapon_data; + + char wname[ 128 ]; + strcpy( wname, weapon_begin ); + char * power = strchr( wname, ':' ); + if ( power == NULL ){ + printf("Error parsing %s. You tried to hack it, didnt you?\n", filename ); + goto evil_end; + } + *power = '\0'; + power++; + strcpy( wd->name, wname ); + wd->power = str2int( power ); + + weapons.push_back( wd ); + + weapon_begin = weapon_end+1; + } + + hwho = newPlayerHull( rank ); + debug + player = new PlayerObject(320,450, dif, hwho ); + + // a little c++ never hurt anyone + pp = (PlayerObject *)(player); + ph = (PlayerHull *)(hwho); + pp->setLevel( level ); + ph->setShields( shields ); + ph->setLife( life ); + pp->setScore( score ); + pp->setLevel( level ); + pp->setDifficulty( dif ); + + debug + for ( vector< weapon_data * >::iterator cur_data = weapons.begin(); cur_data != weapons.end(); cur_data++ ){ + weapon_data * mine = *cur_data; + + // 6 is the max number of slots a gun could be in + // 0-4 for regular guns and 5 for accessories + for ( int q = 0; q < 6; q++ ){ + vector< WeaponObject * > & wv = all_weapons[ q ]; + for ( vector< WeaponObject * >::iterator it = wv.begin(); it != wv.end(); ){ + WeaponObject * sofar = *it; + + if ( strcasecmp( sofar->GetName(), mine->name ) == 0 ){ + sofar->IncreasePower( mine->power ); + pp->giveWeapon( sofar, q ); + it = wv.erase( it ); + } else it++; + } + } + } + + debug + cout<<"All weapons: "< >::iterator it = all_weapons.begin(); it != all_weapons.end(); it++ ){ + // vector< WeaponObject * > & wv = *it; + debug + for ( vector< WeaponObject * >::iterator k = it->begin(); k != it->end(); k++ ){ + cout<<"Weapon: "<<(*k)->getName()<::iterator it = weapons.begin(); it != weapons.end(); it++ ){ + delete *it; + } + + debug + return player; +} +// im tired and angry --- rafkill-1.2.2.orig/build/font.h +++ rafkill-1.2.2/build/font.h @@ -0,0 +1,23 @@ +#ifndef _paintown_font_h +#define _paintown_font_h + +struct FONT; + +class Font{ +public: + Font( FONT * f ); + Font( const Font & f ); + + inline FONT * getInternalFont() const{ + return my_font; + } + + const int textLength( const char * text ); + + const int getHeight() const; + +protected: + FONT * my_font; +}; + +#endif --- rafkill-1.2.2.orig/build/move.cpp +++ rafkill-1.2.2/build/move.cpp @@ -0,0 +1,289 @@ +#include "move.h" +#include "spaceobj.h" +#include "trigtable.h" +#include + +using namespace std; + +//{ +Move::Move( double _dx, double _dy ): +o_dx( _dx ), +o_dy( _dy ){ + + /* + dx = _dx; + dy = _dy; + */ + + /* + actualx = NULL; + actualy = NULL; + virtualx = NULL; + virtualy = NULL; + */ + + accel_x = 0; + accel_y = 0; +} + +/* +int Move::AX(){ + / * + if ( actualx != NULL ) + return *actualx; + * / + return 0; +} + +int Move::AY(){ + / * + if ( actualy != NULL ) + return *actualy; + * / + return 0; +} +*/ + + /* +void Move::setP( int & ax, int & ay, double & vx, double & vy ) { + actualx = &ax; + actualy = &ay; + virtualx = &vx; + virtualy = &vy; +} + */ + + +/* +double Move::Accel_X(){ + return accel_x; +} + +double Move::Accel_Y(){ + return accel_y; +} + +void Move::setD( double _dx, double _dy ) { + dx = _dx; + dy = _dy; +} +*/ + +void Move::action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ) { + sdx = o_dx; + sdy = o_dy; + // return MoveReal(); +} + +/* +double Move::DX() { + return dx; +} + + +double Move::DY() { + return dy; +} +*/ + + /* +bool Move::MoveReal() { + + *virtualx += dx; + *virtualy += dy; + *actualx = (int)*virtualx; + *actualy = (int)*virtualy; + + if ( *actualy >= screen_y+100 || *actualx < -100 || *actualx > screen_x+100 || *actualy < -500 ) return true; + return false; +} + */ + + +//} +//{ +MoveHorizontal::MoveHorizontal( double _dx, double _dy ): +Move( _dx, _dy ) { + dir = 1; + //dx = 2.3; +} + + +void MoveHorizontal::action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ) { + + /* + if ( *actualx > screen_x-20 ) dir = -1; + if ( *actualx < 20 ) dir = 1; + + dx = dir * o_dx; + dy = o_dy; + */ + if ( x > Util::screen_x - 20 ) dir = -1; + if ( x < 20 ) dir = 1; + sdx = dir * o_dx; + sdy = o_dy; + // return MoveReal(); +} + + +//} +//{ +MoveMine::MoveMine( double _dx, double _dy ): +Move( _dx, _dy ), +fx( -1 ), +fy( -1 ), +sx( _dx ), +sy( _dy ){} + +void MoveMine::action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ) { + + // if ( fight->empty() ) return MoveReal(); + if ( fight->empty() ) return; + + if ( fx == -1 || fy == -1 || (Util::rnd(30) == Util::rnd(30)) ) { + SpaceObject * attack = fight->front(); + if ( attack != NULL ) { + fx = attack->getX() + Util::rnd(20) - 10; + fy = attack->getY() + Util::rnd(20) - 10; + int sang = gang( x, y, fx, fy ); + double gm = fabs( o_dx ) > fabs( o_dy ) ? fabs(o_dx) : fabs( o_dy ); + + accel_x = Tcos(sang); + accel_y = Tsine(sang); + + sdx = accel_x * gm; + sdy = accel_y * gm; + } + } + + // return MoveReal(); + +} + + +//} +//{ +MoveAngular::MoveAngular( double _dx, double _dy ): +Move( _dx, _dy ), +ang( 0 ), +dir( Util::rnd(10) + 2 ) { + // if ( dx == 0 ) dx = dy; +} + + +void MoveAngular::action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ) { + + ang += dir; + while ( ang >= 360 ) ang -= 360; + while ( ang < 0 ) ang += 360; + + accel_x = Tcos(ang); + accel_y = Tsine(ang); + + sdx = accel_x * fabs(o_dx); + sdy = accel_y * fabs(o_dy) + 2; + // return MoveReal(); + +} + + +//} +//{ +MoveSwingRight::MoveSwingRight( double _dx, double _dy ): +Move( _dx, _dy ){ + accel_x = 0.15; + accel_y = 0; +} + +void MoveSwingRight::action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ) { + // if ( *actualy > 0 ) dx += accel_x; + sdx += accel_x; + sdy = o_dy; + // return MoveReal(); +} + + +//} +//{ +MoveSwingLeft::MoveSwingLeft( double _dx, double _dy ): +Move( _dx, _dy ){ + accel_x = -0.15; + accel_y = 0; +} + +void MoveSwingLeft::action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ) { + + // if ( *actualy > 0 ) dx += accel_x; + sdx += accel_x; + sdy = o_dy; + // return MoveReal(); +} + + +//} +//{ +MoveSwingDown::MoveSwingDown( double _dx, double _dy ): +Move( _dx, _dy ){ + accel_x = 0; + accel_y = 0.13; +} + +void MoveSwingDown::action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ) { + + //if ( *actualy > 0 ) dy += 0.35; + sdy += accel_y; + sdx = o_dx; + // return MoveReal(); +} + + +//} +//{ +MoveSine::MoveSine( double _dx, double _dy ): +Move( _dx, _dy ), +ang( 0 ){} + +void MoveSine::action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ) { + accel_x = Tcos(ang); + sdx = accel_x * fabs( o_dx ); + sdy = o_dy; + ang = (ang+6) % 360; + // return MoveReal(); +} + + +//} +//{ +MoveCircle_Player::MoveCircle_Player( double _dx, double _dy ): +Move( _dx, _dy ), +ang( 90 ) { + + find_circle = Util::rnd( 4 ) + 3; + +} + + +void MoveCircle_Player::action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ) { + + // if ( fight->empty() ) return MoveReal(); + if ( fight->empty() ) return; + SpaceObject * s = fight->front(); + + int sang = gang( s->getX(), s->getY(), x, y ); + ang = (sang + find_circle) % 360; + int fx = (int)( s->getX() + Tcos( ang ) * 150 ); + int fy = (int)( s->getY() + Tsine(ang ) * 150 ); + sang = gang( x, y, fx, fy ); + double fmax = fabs( o_dx ) > fabs( o_dy ) ? fabs( o_dx ) : fabs( o_dy ); + + accel_x = Tcos(sang); + accel_y = Tsine(sang); + + sdx = accel_x * fmax; + sdy = accel_y * fmax; + + // return MoveReal(); +} + + +//} --- rafkill-1.2.2.orig/build/logic.cpp +++ rafkill-1.2.2/build/logic.cpp @@ -0,0 +1,268 @@ +#include "logic.h" +#include "spaceobj.h" +#include "level.h" +#include "explode.h" +#include "section.h" +#include "sound.h" +#include "defs.h" +#include "group.h" + +#include + +/* +#include "hull.h" +#include "ebox.h" +*/ + +#ifndef debug +#define debug std::cout<<"File: "<<__FILE__<<" Line: "<<__LINE__<create( &objects, 1, x ); + } + + handleSpace( &objects, §ion ); + if ( player != NULL ){ + enforceUniverse( player ); + } + clearCollide( &objects ); + checkCollision( §ion, player, SND_SUSTAIN, 12 ); + DeleteSpace( &objects, §ion, player, level ); + + for ( vector< SpaceObject * >::iterator it = objects.begin(); it != objects.end(); ){ + if ( *it == player ){ + it = objects.erase( it ); + } else { + ++it; + } + } + + return 0; +} + +Logic::~Logic(){ + for ( int q = 0; q < MAX_EXPL; q++ ){ + if ( expl[q] ){ + delete expl[q]; + expl[q] = NULL; + } + } + + for ( vector< SpaceObject * >::iterator it = objects.begin(); it != objects.end(); ++it ){ + delete *it; + } + + objects.clear(); +} + +vector< SpaceObject * > * Logic::getObjects(){ + return &objects; +} + +ExplosionClass ** Logic::getExplode(){ + return expl; +} + +int Logic::maxExplode(){ + return MAX_EXPL; +} + +void Logic::HandleExplosion() { + for ( int q = 0; q < MAX_EXPL; q++ ){ + if( expl[q] != NULL ){ + if ( expl[q]->update() ) { + delete expl[q]; + expl[q] = NULL; + } + } + } +} + +void Logic::enforceUniverse( SpaceObject * player ){ + + if ( player->getX() + player->getMaxX()/2 > Util::screen_x ) + player->setX( Util::screen_x - player->getMaxX()/2 ); + if ( player->getX() - player->getMaxX()/2 < 0 ) + player->setX( player->getMaxX()/2 ); + if ( player->getY() + player->getMaxY()/2 > Util::screen_y ) + player->setY( Util::screen_y - player->getMaxY()/2 ); + if ( player->getY() - player->getMaxY()/2 < 0 ) + player->setY( player->getMaxY()/2 ); + +} + +bool Logic::outOfBounds( SpaceObject * who ){ + + int x = who->getX(); + int y = who->getY(); + + if ( x < -200 || x > Util::screen_x + 200 || y < -500 || y > Util::screen_y+200 ) + return true; + return false; + +} + +void Logic::handleSpace( vector< SpaceObject * > * mv, Section * onscreen ) { + + vector< SpaceObject * > Ammo; + for ( vector< SpaceObject * >::iterator it = mv->begin(); it != mv->end(); ) { + if ( *it == NULL ){ + cerr << "Object = NULL. Skipping" << endl; + it = mv->erase( it ); + continue; + } + + (*it)->MoveMe( &Ammo, mv, onscreen ); + + // if ( (*it)->MoveMe( &Ammo, mv, onscreen, global_snd ) ) { + if ( outOfBounds( *it ) && (*it)->Destroyable() ){ + SpaceObject * del = *it; + it = mv->erase( it ); + delete del; + } else ++it; + } + vectorAdd( mv, &Ammo ); + + for ( vector< SpaceObject * >::iterator it = mv->begin(); it != mv->end(); ++it ){ + (*it)->addSection( onscreen ); + } +} + +void Logic::vectorAdd( vector< SpaceObject * > * stable, vector< SpaceObject * > * state ) { + + for ( vector< SpaceObject * >::iterator it = state->begin(); it != state->end(); it++ ){ + stable->push_back( *it ); + } + +} + +void Logic::clearCollide( vector< SpaceObject * > * contain ) { + + for ( vector< SpaceObject * >::iterator it = contain->begin(); it != contain->end(); ++it ) { + (*it)->clearCollide(); + } + +} + +void Logic::DeleteSpace( vector< SpaceObject *> * objs, Section * sec, const SpaceObject * _player, LevelCreator * level ) { + + // extra vector to store special objects + vector< SpaceObject * > objs_special; + + for ( vector< SpaceObject * >::iterator it = objs->begin(); it != objs->end(); ) { + + if ( (*it)->getLife() <= 0 && (*it)->Destroyable() ){ + + /* If object can become a powerup, it may in fact do so + * Can only become a powerup if it was the last in its group + * which is known when group->size() is 1. + */ + if ( (*it)->powerUp() ) { + if ( (*it)->getGroup() != NULL ) { + if ( (*it)->getGroup()->size() == 1 ){ + if ( Util::rnd(3) ) { + int x = (*it)->getX(); + int y = (*it)->getY(); + + // The following line used to cuase a bug + // objs->push_back( level->special(x,y,_player) ); + + objs_special.push_back( level->special(x,y,_player) ); + } + } + } + } + + SpaceObject * del = *it; + it = objs->erase( it ); + delete del; + + } else ++it; + + } + + vectorAdd( objs, &objs_special ); +} + +void Logic::checkCollision( Section * fight, SpaceObject * take, int sound, int vol ) { + + /* Reset section lists. Look at section.cpp to see why this is important */ + fight->reset(); + + vector< SpaceObject * > * fight_space = fight->getNext(); + + int total = 0; + while ( fight_space != NULL ) { + + // Loop through bad objects next + for ( vector< SpaceObject * >::iterator fight_it = fight_space->begin(); fight_it != fight_space->end(); fight_it++ ) { + + for ( vector< SpaceObject * >::iterator good_it = fight_it+1; good_it != fight_space->end(); good_it++){ + + SpaceObject * g_use = *good_it; + SpaceObject * f_use = *fight_it; + + // First test to see if badobject life is less than 0 + // and if good object has already collided with bad object + ++total; + + /* + cout << "F: " << f_use << " G: " << g_use << endl; + cout << "F-hit: " << f_use->CanbeHit( g_use ) << " G-hit: " << g_use->CanbeHit( f_use ) << endl; + */ + if ( (f_use->CanbeHit(g_use) || g_use->CanbeHit(f_use)) && f_use->getLife() > 0 && !g_use->haveCollide( f_use ) ){ + if ( g_use->Collide( f_use ) || f_use->Collide( g_use ) ) { + // Util::play_sound( Util::global_snd, sound, vol ); + Util::playSound( sound, vol ); + + float fhurt = f_use->Hurt(); + float ghurt = g_use->Hurt(); + + if ( g_use->Damage( fhurt ) ) + g_use->Died( take, expl, MAX_EXPL ); + if ( f_use->Damage( ghurt ) ) + f_use->Died( take, expl, MAX_EXPL ); + + // Let both objects know they collided with something + g_use->Collided( f_use, expl, MAX_EXPL ); + f_use->Collided( g_use, expl, MAX_EXPL ); + + g_use->addCollide( f_use ); + f_use->addCollide( g_use ); + + //g_use->addCollide( f_use ); + //f_use->addCollide( g_use ); + } + }//if + + } //for fight + + } //for good + + fight_space = fight->getNext(); + + } //while +} --- rafkill-1.2.2.orig/build/raptor.cpp +++ rafkill-1.2.2/build/raptor.cpp @@ -0,0 +1,1014 @@ +#include "menu.h" +#include "spaceobj.h" +// #include "game.h" +#include "drawer.h" +#include "logic.h" +#include "level.h" +#include "trigtable.h" +#include "bitmap.h" +#include "keyboard.h" +#include "strings.h" +#include +#include +#include +#include "loadsave.h" +#include "defs.h" +#include "ebox.h" +#include "raptor.h" +#include "sound.h" +#include "rmenu.h" +#include "rfield.h" +#include "hull.h" +#include "wormhole.h" +#include "explode.h" +#include "music.h" +#include "loading_screen.h" + +#include "hulls/hull_player.h" +#include "playerobj.h" +#include "guns/gun_machine.h" + +#include "config.h" + +#ifndef debug +#define debug cout << "File: " << __FILE__ << " Line: " << __LINE__ << endl; +#endif + +/* easier as a #define because Allegro isnt initialized till later */ +#define RAPTOR_TITLE_COLOR (Bitmap::makeColor(244,228,7)) + +static const int NO_SOUND = -1; +static const int INIT_CONTINUE = 0; +static const int INIT_PLAY = 1; +static const int INIT_OPT = 2; +static const int INIT_QUIT = 3; +static const int INIT_CREDITS = 4; +static const int INIT_BACK = 6; +static const int INIT_SAVE = 7; +static const int INIT_CHANGE_KEYS = 8; +static const int INIT_LOAD = 5000; +static const int INC_RATE = 10; +static const int DEC_RATE = 11; +static const int INIT_HELP = 12; +static const int INIT_SCREEN = 13; +static const int SOUND_INC = 15; +static const int SOUND_DEC = 16; +static const int MUSIC_INC = 17; +static const int MUSIC_DEC = 18; +static const int DIFFICULT_MENU = 1000; + +static const int CHANGE_KEY_FORWARD = 20; +static const int CHANGE_KEY_BACKWARD = 21; +static const int CHANGE_KEY_LEFT = 22; +static const int CHANGE_KEY_RIGHT = 23; +static const int CHANGE_KEY_SHOOT = 24; + +static Font * normalFont = NULL; + +extern void init( int GFX, int GAME_SPEED ); + +void credits() { + cout << "Exiting normally.. " << endl; + cout << "-------" << endl; + cout << "Credits" << endl; + cout << "Programming: Jon Rafkind" << endl; + cout << "Graphics: Jon Rafkind and Elton Fry" << endl; + cout << "Sound: Jon Rafkind" << endl; + cout << "Gameplay: Jon Rafkind" << endl; + cout << "Concept and design: Jon Rafkind" << endl; + cout << "Almost all ideas stolen from other games, including idea to steal in the first place" << endl; + cout << "Made with the Allegro graphics library by Shawn Hargreaves" << endl; + cout << "Email Jon at: workmin@ccs.neu.edu" << endl; +} + + +void do_credits(){ + + Bitmap work( GRAPHICS_X, GRAPHICS_Y ); + work.clear(); + + int y_begin = GRAPHICS_Y-20; + char ** creds = new char*[6]; + creds[0] = "Rafkill"; + creds[1] = "Programming Jon Rafkind"; + creds[2] = "Design Jon Rafkind"; + creds[3] = "Art Jon Rafkind"; + creds[4] = "Art Elton Fry"; + creds[5] = "Sound Jon Rafkind"; + + // int * shade = new int[60]; + int shade[ 60 ]; + #define RCOLOR (127+Util::rnd(127)) + shade[0] = Bitmap::makeColor( RCOLOR, RCOLOR, RCOLOR ); + for ( int q = 0; q < 4; q++ ){ + Util::blend_palette( shade+q*12+1, 12, shade[q*12], Bitmap::makeColor(RCOLOR,RCOLOR,RCOLOR) ); + } + Util::blend_palette( shade+48, 12, shade[48], shade[0] ); + int color = 0; + int shade_color = 0; + + WormHole wole; + for ( int q = 0; q < 40; q++ ) + wole.Update(); + + unsigned int ticks; + Util::getTicks( &ticks ); + while ( ! Keyboard::getAnyKey( Keyboard::SPACE ) && ! Keyboard::getAnyKey( Keyboard::ESC ) ){ + + bool draw = false; + int counter = Util::getTicks( &ticks ); + if ( counter == 0 ){ + Util::YIELD(); + continue; + } + while ( counter ){ + draw = true; + if ( y_begin > 100 ) y_begin-=2; + if ( y_begin > 100 ) { + y_begin-=2; + color = Bitmap::makeColor(255,255,255); + } + else { + color = shade[ shade_color ]; + shade_color++; + if ( shade_color > 59 ) shade_color = 0; + } + + wole.Update(); + + counter--; + } + + if ( draw ) { + wole.Draw( work ); + + for ( int q = 0; q < 6; q++ ){ + work.printf( 100, y_begin + q * 30, color, normalFont, creds[q] ); + } + work.BlitToScreen(); + work.clear(); + /* + blit( work, screen, 0, 0, 0, 0, GRAPHICS_X, GRAPHICS_Y ); + clear( work ); + */ + } + } + while ( Keyboard::getAnyKey( Keyboard::SPACE ) ){ + Util::YIELD(); + } + // destroy_bitmap( work ); + delete[] creds; + // delete[] shade; + +} + +Bitmap get_help_screen() { + + Bitmap work( 640, 480 ); + work.fill( Bitmap::makeColor( 0, 12, 19 ) ); + + //int cy = 10; + /* + textprintf(work,font,10,cy,makecol(255,255,255),"How to play Raptor" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"Main Menu Options" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"Continue: Continue playing an already started game" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"Play New: Play a new game" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"Options: More Options" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"Help: This screen" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"Credits: The credits! What else?" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"Quit: Quit the game" );cy+=10; + cy += 10; + textprintf(work,font,10,cy,makecol(255,255,255),"Options Menu" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"Frame Rate: Frame Rate Menu" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"Fullscreen: Fullscreen Mode" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"Background on/off: Turn the background on or off" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"" );cy+=10; + textprintf(work,font,10,cy,makecol(255,255,255),"" );cy+=10; + */ + + return work; + +} + +SpaceObject * getNewPlayer( int difficulty ){ + + SpaceObject * player = NULL; + + vector< Bitmap * > pics; + for ( int q = 0; q < 9; q++ ){ + pics.push_back( new Bitmap( Util::getDataSprite( HULL_1_1 + q ) ) ); + } + + HullObject * hwho = new PlayerHull( pics, 100, 100, 3, 1, new ECollide( pics[4] ) ); + player = new PlayerObject(320,450, difficulty, hwho ); + WeaponObject * wwho = new WeaponMachineGun( 0, -1, -1, TEAM_PLAYER ); + player->giveWeapon( wwho, 0 ); + ( ((PlayerObject *) player ) )->setLevel( 1 ); + + return player; +} + +void getLoadMenu( RMenu * menu, int load_num, int select_smp ){ + + menu->clear(); + for ( int q = 0; q < 6; q++ ){ + char filename[ 64 ]; + snprintf( filename, 64, "player%d.rap", q+1 ); + if ( Util::exists( filename ) ){ + time_t tl = Util::fileTime( filename ); + struct tm * real_time = localtime( &tl ); + + char xbuf[ 128 ]; + strftime( xbuf, 64, "%A %F", real_time ); + char * temp = (char *)malloc( sizeof(char) * 1024 ); + sprintf( temp, "Slot %d %s", q+1, xbuf ); + menu->addMenu( temp, normalFont, true, load_num+q+1, NULL, NO_SOUND ); + } + } + + menu->addMenu( "Return", normalFont, true, 800, NULL, select_smp ); +} + +void popUp( const char * title ){ + + int length = 550; + int begin = 30; + + Bitmap sell_screen( GRAPHICS_X, GRAPHICS_Y ); + Bitmap::Screen->Blit( sell_screen ); + Bitmap::transBlender( 0, 0, 0, 120 ); + Bitmap::drawingMode( Bitmap::MODE_TRANS ); + sell_screen.rectangleFill( begin, 80, begin+length, 235, Bitmap::makeColor(0,0,0) ); + sell_screen.rectangle( begin, 80, begin+length, 235, Bitmap::makeColor(255,255,255) ); + Bitmap::drawingMode( Bitmap::MODE_SOLID ); + RMenu sell( sell_screen, begin+10, 100, 1000, Bitmap::makeColor(80,0,0), Bitmap::makeColor(255,136,0), RAPTOR_TITLE_COLOR ); + sell.addTitle( title, normalFont ); + sell.addMenu( "OK", normalFont, true, 1, &sell, NO_SOUND ); + sell.init(); + + int call = -1; + RMenu * current = &sell; + while( call == -1 ) { + call = current->procMenu( ¤t ); + if ( !sell.Selected() ) call = -1; + Util::YIELD(); + // al_poll_duh( dumb_player ); + // dumb_player->play(); + + } + + // delete sell; + // destroy_bitmap( sell_screen ); +} + +static int userSelectKey(){ + + Bitmap work( normalFont->textLength( "Press a key" ) + 20, 50 ); + work.fill( Bitmap::makeColor( 32, 32, 32 ) ); + + work.printf( 10, 10, Bitmap::makeColor( 200, 64, 23 ), normalFont, "Press a key" ); + work.drawBorder( 2, Bitmap::makeColor( 200, 200, 200 ) ); + + work.drawTrans( GRAPHICS_X / 2 - work.getWidth() / 2, GRAPHICS_Y / 2 - work.getHeight() / 2 - 100, *Bitmap::Screen ); + + while ( Keyboard::readKey() != -1 ){ + Util::YIELD(); + } + + int key = Keyboard::readKey(); + while ( key == -1 ){ + Util::YIELD(); + key = Keyboard::readKey(); + } + + while ( Keyboard::keyPressed() ){ + Util::YIELD(); + } + + return key; +} + +int intro_screen( int & frames, SpaceObject ** player, DATAFILE * sound ){ + + char backgroundFile[ 4096 ]; + Util::getDataPath( backgroundFile, "logosmoot.pcx" ); + Bitmap intr( backgroundFile ); + + if ( intr.getError() ) { + string message = "Could not load: "; + message += backgroundFile; + Util::alert( message.c_str() ); + return 3; + } + + int select_smp = INTRO_MENU_SELECT; + + RMenu intro_menu( intr, 170, 200, 1000, Bitmap::makeColor(120,0,0), Bitmap::makeColor(255,0,0), RAPTOR_TITLE_COLOR); + RMenu option_menu( intr, 1, 120, 1000, Bitmap::makeColor(120,0,0), Bitmap::makeColor(255,0,0), RAPTOR_TITLE_COLOR ); + RMenu frame_menu( intr, 1, 230, 1000, Bitmap::makeColor(120,0,0), Bitmap::makeColor(255,0,0), RAPTOR_TITLE_COLOR ); + RMenu difficulty_menu( intr, 1, 180, 1000, Bitmap::makeColor(120,0,0), Bitmap::makeColor(255,0,0), RAPTOR_TITLE_COLOR ); + RMenu changeKeyMenu( intr, 1, 180, 1000, Bitmap::makeColor(120,0,0), Bitmap::makeColor(255,0,0), RAPTOR_TITLE_COLOR ); + RMenu sound_menu( intr, 1, 145, 1000, Bitmap::makeColor(120,0,0), Bitmap::makeColor(255,0,0), RAPTOR_TITLE_COLOR ); + RMenu load_menu( intr, 1, 200, 1000, Bitmap::makeColor(128,64,0), Bitmap::makeColor(255,128,0), RAPTOR_TITLE_COLOR ); + + // load_menu.addMenu( "Return", Util::raptor_font, true, 800, NULL, select_smp ); + getLoadMenu( &load_menu, INIT_LOAD, select_smp ); + + if ( *player != NULL ){ + intro_menu.addMenu( "Continue", normalFont, true, INIT_CONTINUE,NULL,select_smp); + } + + intro_menu.addMenu( "Play new", normalFont, true,INIT_PLAY,NULL,select_smp); + intro_menu.addMenu( "Load Game", normalFont, true,INIT_LOAD,&load_menu,select_smp); + intro_menu.addMenu( "Options", normalFont, true,INIT_OPT,&option_menu,select_smp); + intro_menu.addMenu( "Credits", normalFont, true,INIT_CREDITS,&intro_menu,select_smp); + intro_menu.addMenu( "Quit", normalFont, true,INIT_QUIT,NULL,select_smp); + + option_menu.addTitle( "Options", normalFont ); + string numnum = int2str( frames ); + + RField * forwardKey = changeKeyMenu.addMenu( string("Forward: ") + Configuration::getForwardKeyName(), normalFont, true, CHANGE_KEY_FORWARD, &changeKeyMenu, select_smp ); + RField * backwardKey = changeKeyMenu.addMenu( string("Backwards: ") + Configuration::getBackwardKeyName(), normalFont, true, CHANGE_KEY_BACKWARD, &changeKeyMenu, select_smp ); + RField * leftKey = changeKeyMenu.addMenu( string("Left: ") + Configuration::getLeftKeyName(), normalFont, true, CHANGE_KEY_LEFT, &changeKeyMenu, select_smp ); + RField * rightKey = changeKeyMenu.addMenu( string("Right: ") + Configuration::getRightKeyName(), normalFont, true, CHANGE_KEY_RIGHT, &changeKeyMenu, select_smp ); + RField * shootKey = changeKeyMenu.addMenu( string("Shoot: ") + Configuration::getShootKeyName(), normalFont, true, CHANGE_KEY_SHOOT, &changeKeyMenu, select_smp ); + + changeKeyMenu.addMenu( "Return", normalFont, true, INIT_OPT, NULL, select_smp ); + + option_menu.addMenu( "Change Keys", normalFont, true, INIT_CHANGE_KEYS, &changeKeyMenu, select_smp ); + + RField * fullscreenField; + if ( Configuration::getWindowMode() ){ + fullscreenField = option_menu.addMenu( "Fullscreen on", normalFont, true,INIT_SCREEN,&option_menu,select_smp); + } else { + fullscreenField = option_menu.addMenu( "Fullscreen off", normalFont, true,INIT_SCREEN,&option_menu,select_smp); + } + + RField * backgroundField; + if ( Configuration::getBackground() ){ + backgroundField = option_menu.addMenu( "Background off", normalFont, true, INIT_BACK, &option_menu, select_smp ); + } else { + backgroundField = option_menu.addMenu( "Background on", normalFont, true, INIT_BACK, &option_menu, select_smp); + } + option_menu.addMenu( "Sound", normalFont, true, 800, &sound_menu, select_smp ); + option_menu.addMenu( "Return to Menu", normalFont, true,800,NULL,select_smp); + + /* + frame_menu.addTitle( append("Frame Rate ",numnum), normalFont ); + //frame_menu->addTitle( "Frame Rate is Unstable",Util::raptor_font ); + frame_menu.addMenu( "Increase Rate", normalFont, true,INC_RATE,&frame_menu,select_smp); + frame_menu.addMenu( "Decrease Rate", normalFont, true,DEC_RATE,&frame_menu,select_smp); + frame_menu.addMenu( "Return to options", normalFont, true,800,NULL,select_smp); + */ + + // char * sound_num = int2str( (int)(sound_vol * 100 ) ); + // char * music_num = int2str( (int)(music_vol * 100 ) ); + char soundNum[ 64 ]; + char musicNum[ 64 ]; + + // int music_volume = 100; + + Font menuFont = Util::getMenuFont(); + + sprintf( soundNum, "Sound volume %d", (int)(Util::sound_vol * 100 )); + + /* make music_volume be the Music::volume */ + sprintf( musicNum, "Music volume %d", (int)(Music::getVolume() * 100) ); + + RField * soundTitle = sound_menu.addTitle( soundNum, &menuFont ); + sound_menu.addMenu( "Increase sound volume", &menuFont, true, SOUND_INC, &sound_menu, select_smp ); + sound_menu.addMenu( "Decrease sound volume", &menuFont, true, SOUND_DEC, &sound_menu, select_smp ); + RField * musicTitle = sound_menu.addTitle( musicNum, &menuFont ); + sound_menu.addMenu( "Increase music volume", &menuFont, true, MUSIC_INC, &sound_menu, select_smp ); + sound_menu.addMenu( "Decrease music volume", &menuFont, true, MUSIC_DEC, &sound_menu, select_smp ); + sound_menu.addMenu( "Return to options", &menuFont, true,800,NULL,select_smp); + + difficulty_menu.addTitle( "Difficulty", &menuFont ); + difficulty_menu.addMenu( "Very Easy", &menuFont, true, DIFFICULT_MENU+1, NULL, select_smp ); + difficulty_menu.addMenu( "Easy", &menuFont, true, DIFFICULT_MENU+2, NULL, select_smp ); + difficulty_menu.addMenu( "Medium", &menuFont, true, DIFFICULT_MENU+3, NULL, select_smp ); + difficulty_menu.addMenu( "Hard", &menuFont, true, DIFFICULT_MENU+4, NULL, select_smp ); + difficulty_menu.addMenu( "Impossible", &menuFont, true, DIFFICULT_MENU+5, NULL, select_smp ); + + RMenu * current = &intro_menu; + RMenu * temp = current; + current->init(); + + int option = -1; + while ( option != INIT_QUIT && + option != INIT_CONTINUE && + option != INIT_PLAY ) { + + Util::YIELD(); + // al_poll_duh( dumb_player ); + /* + dumb_player->play(); + */ + + temp = current; + option = current->procMenu( ¤t ); + if ( !temp->Selected() ) option = -1; + + bool changed_frames = false; + bool changed_sound = false; + bool changed_music = false; + + if ( option > INIT_LOAD && option <= INIT_LOAD+6 ){ + int load = option - INIT_LOAD; + + // printf("Loading %d\n", load ); + *player = loadPlayer( load ); + + if ( *player == NULL ){ + + char tmp[ 64 ]; + snprintf( tmp, 64, "Error loading slot %d", load ); + popUp( tmp ); + + } else option = INIT_CONTINUE; + } + + switch ( option ) { + case INC_RATE : { + frames++; + changed_frames = true; + break; + } + case DEC_RATE : { + if( frames > 1 ) { + frames--; + changed_frames = true; + } + break; + } + case SOUND_INC : { + Util::sound_vol += 0.02; + if ( Util::sound_vol > 1.0 ) Util::sound_vol = 1.0; + changed_sound = true; + break; + } + case SOUND_DEC : { + Util::sound_vol -= 0.02; + if ( Util::sound_vol < 0 ) Util::sound_vol = 0; + changed_sound = true; + break; + } + case MUSIC_INC : { + Music::louden(); + changed_music = true; + break; + } + case MUSIC_DEC : { + Music::soften(); + changed_music = true; + break; + } + case INIT_CREDITS : { + do_credits(); + break; + } + + case CHANGE_KEY_FORWARD : { + int key = userSelectKey(); + Configuration::setForwardKey( key ); + stringstream stream; + stream << "Forward: " << Configuration::getForwardKeyName(); + string str( stream.str() ); + forwardKey->set( &str ); + break; + } + + case CHANGE_KEY_LEFT : { + int key = userSelectKey(); + Configuration::setLeftKey( key ); + stringstream stream; + stream << "Left: " << Configuration::getLeftKeyName(); + string str( stream.str() ); + leftKey->set( &str ); + break; + } + + case CHANGE_KEY_RIGHT : { + int key = userSelectKey(); + Configuration::setRightKey( key ); + stringstream stream; + stream << "Right: " << Configuration::getRightKeyName(); + string str( stream.str() ); + rightKey->set( &str ); + + break; + } + + case CHANGE_KEY_BACKWARD : { + int key = userSelectKey(); + Configuration::setBackwardKey( key ); + stringstream stream; + stream << "Backwards: " << Configuration::getBackwardKeyName(); + string str( stream.str() ); + backwardKey->set( &str ); + break; + } + + case CHANGE_KEY_SHOOT : { + int key = userSelectKey(); + Configuration::setShootKey( key ); + stringstream stream; + stream << "Shoot: " << Configuration::getShootKeyName(); + string str( stream.str() ); + shootKey->set( &str ); + break; + } + case INIT_SCREEN : { + Configuration::setWindowMode( ! Configuration::getWindowMode() ); + if ( Configuration::getWindowMode() ) { + Bitmap::setGfxModeWindowed( GRAPHICS_X, GRAPHICS_Y ); + string str( "Fullscreen off" ); + fullscreenField->set( &str ); + } else { + Bitmap::setGfxModeFullscreen( GRAPHICS_X, GRAPHICS_Y ); + string str( "Fullscreen on" ); + fullscreenField->set( &str ); + } + break; + } + case INIT_BACK : { + Configuration::setBackground( ! Configuration::getBackground() ); + if ( Configuration::getBackground() ){ + // option_menu.replace( 5, "Background ON", &menuFont, true, INIT_BACK, &option_menu, select_smp ); + string str( "Background Off" ); + backgroundField->set( &str ); + } else { + // option_menu.replace( 5, "Background off", &menuFont, true, INIT_BACK, &option_menu, select_smp ); + string str( "Background On" ); + backgroundField->set( &str ); + } + break; + } + + } + + /* wait for enter/space to be released + * so the user doesnt get into a loop of selecting + * enter or space for the key and then modifying + * that key again + */ + if ( option == CHANGE_KEY_SHOOT || + option == CHANGE_KEY_FORWARD || + option == CHANGE_KEY_BACKWARD || + option == CHANGE_KEY_LEFT || + option == CHANGE_KEY_RIGHT ){ + while ( Keyboard::getAnyKey( Keyboard::SPACE, Keyboard::ENTER ) ){ + Util::YIELD(); + } + } + + /* + if ( changed_frames ) { + free( numnum ); + numnum = int2str( frames ); + option_menu.replaceTitle( 2, append("Frame Rate ",numnum), &menuFont ); + frame_menu.replaceTitle( 1, append("Frame Rate ",numnum), &menuFont ); + install_int_ex( inc_speed_counter, MSEC_TO_TIMER( frames ) ); + } + */ + + if ( changed_sound ) { + stringstream stream; + stream << "Sound volume " << (int)(Util::sound_vol * 100); + string str( stream.str() ); + soundTitle->set( &str ); + } + + if ( changed_music ) { + stringstream stream; + stream << "Music volume " << (int)(Music::getVolume() * 100); + string str( stream.str() ); + musicTitle->set( &str ); + } + + } + + if ( option == INIT_PLAY ) { + + if ( *player != NULL ) + delete *player; + current = &difficulty_menu; + current->init(); + int v = 0; + while ( !current->Selected() ) { + v = current->procMenu( ¤t ); + // al_poll_duh( dumb_player ); + // dumb_player->play(); + Util::YIELD(); + } + int difficulty = v - DIFFICULT_MENU; + + *player = getNewPlayer( difficulty ); + + /* + BITMAP ** pics = new BITMAP*[ 9 ]; + for ( int q = 0; q < 9; q++ ) + pics[q] = (BITMAP *)Util::global_data[HULL_1_1+q].dat; + HullObject * hwho = new PlayerHull( pics, 9, 100, 100, 3, 1, new ECollide( pics[4], 6, makecol(255,0,255), 52 ) ); + *player = new PlayerObject(320,450, difficulty, hwho ); + WeaponObject * wwho = new WeaponMachineGun( 0, -1, NULL, TEAM_PLAYER ); + (*player)->giveWeapon( wwho, 0 ); + ( ((PlayerObject *) (*player) ) )->level = 1; + */ + + + } + + if ( *player != NULL ){ + PlayerObject * px = (PlayerObject *)(*player); + if ( px->getDifficulty() == 1 ) + Util::screen_x = 640; + else Util::screen_x = 640*3/2; + } + + //al_stop_duh( dumb_player ); + //unload_duh( dumb_file ); + + /* + delete intro_menu; + delete option_menu; + delete frame_menu; + delete difficulty_menu; + delete sound_menu; + */ + // free( sound_num ); + // free( music_num ); + + // destroy_bitmap( intr ); + + Configuration::saveConfiguration(); + + return option; +} + +void usage(){ + + printf("OPTIONS\n"); + printf("------\n"); + printf("-w\t\t\tWindowed Mode\n"); + printf("-l\t\t\tNo background\n"); + printf("-g#\t\t\tRun game at # msec per tick\n"); + printf("-h -help --help\t\tThis Help Screen\n"); +} + +void deathScreen(){ + + Font font = Util::getDefaultFont(); + + int tx = font.textLength( "YOU DIED" ); + int ty = 10; + // BITMAP * text = create_bitmap( tx, ty ); + Bitmap text( tx, ty ); + // clear( text ); + text.clear(); + // textprintf_ex( text, font, 0, 0, makecol(255,255,255), -1, "YOU DIED"); + text.printf( 0, 0, Bitmap::makeColor(255,255,255), &font, "YOU DIED" ); + // BITMAP * work = create_bitmap( GRAPHICS_X, GRAPHICS_Y ); + Bitmap work( GRAPHICS_X, GRAPHICS_Y ); + + int _max_ex = 500; + last_explode = 0; + ExplosionClass ** expl = new ExplosionClass*[ _max_ex ]; + for ( int q = 0; q < _max_ex; q++ ) + expl[q] = NULL; + + while ( Keyboard::getAnyKey( Keyboard::SPACE, Keyboard::ENTER ) ){ + Util::YIELD(); + } + + unsigned int ticks; + Util::getTicks( &ticks ); + while ( ! Keyboard::getAnyKey( Keyboard::SPACE ) && ! Keyboard::getAnyKey( Keyboard::ENTER ) ){ + + bool dirty = false; + unsigned int counter = Util::getTicks( &ticks ); + if ( counter == 0 ){ + Util::YIELD(); + continue; + } + while ( counter > 0 ){ + + dirty = true; + + for ( int q = 0; q < 300; q++ ) { + int x = Util::rnd( tx ); + int y = Util::rnd( ty ); + double ymove = ((double)y - (double)(ty-1) / 2.0) * 1.54; + if ( text.getPixel( x, y ) == Bitmap::makeColor(255,255,255) ) + addExplode( expl, _max_ex, new ExplosionClass( x*9 + 50, y*9 + 200, 0, ymove, Util::rnd( 3 ) + 7 ) ); + } + + for ( int q = 0; q < _max_ex; q++ ){ + if( expl[q] != NULL ){ + if ( expl[q]->update() ) { + delete expl[q]; + expl[q] = NULL; + } + } + } + counter--; + } + + if ( dirty ) { + for ( int q = 0; q < _max_ex; q++ ) + if ( expl[q] != NULL ) + expl[q]->Draw( &work, 0 ); + + work.BlitToScreen(); + work.clear(); + } + } + + for ( int q = 0; q < _max_ex; q++ ){ + if ( expl[q] ){ + delete expl[q]; + } + } + delete[] expl; + + /* + destroy_bitmap( text ); + destroy_bitmap( work ); + */ + + while ( Keyboard::getAnyKey( Keyboard::SPACE, Keyboard::ENTER ) ){ + Util::YIELD(); + } + +} + +void pauseGame(){ + + Bitmap work( Util::screen_x, Util::screen_y ); + work.fill( Bitmap::makeColor( 32, 32, 32 ) ); + + int width = 100; + int height = 50; + + work.rectangleFill( 320 - width / 2, 240 - height / 2, 320 + width / 2, 240 + height / 2, Bitmap::makeColor( 0, 0, 0 ) ); + work.rectangle( 320 - width / 2, 240 - height / 2, 320 + width / 2, 240 + height / 2, Bitmap::makeColor( 200, 0, 0 ) ); + Font font = Util::getNormalFont(); + work.printf( 320 - font.textLength( "Paused" ) / 2, 240 - 10, Bitmap::makeColor(255,128,0), &font, "Paused" ); + + work.drawTrans( 0, 0, *Bitmap::Screen ); + while ( Keyboard::getAnyKey( Keyboard::P ) ){ + Util::YIELD(); + } + while ( ! Keyboard::getAnyKey( Keyboard::P ) ){ + Util::YIELD(); + } + while ( Keyboard::getAnyKey( Keyboard::P ) ){ + Util::YIELD(); + } +} + +void playLevel( PlayerObject * const player ){ + char file_level[ 64 ]; + sprintf( file_level, "level%d.lev", player->getLevel() ); + + player->SetCoordXY( Util::screen_x/2, Util::screen_y - 40 ); + + int game_error = 0; + int score = player->getScore(); + + // dumb_player.pause(); + Drawer draw; + Logic logic; + LevelCreator level( file_level, player ); + draw.setDrawLand( Configuration::getBackground() ); + + /* stop loading screen */ + endLoadingScreen(); + + const int QUIT = 6; + + int doneCounter = 0; + int deathCounter = 0; + unsigned int ticks; + Util::getTicks( &ticks ); + + PlayerObject * gamePlayer = player; + + while ( game_error == 0 ){ + + bool doDraw = false; + int counter = Util::getTicks( &ticks ); + if ( counter == 0 ){ + Util::YIELD(); + continue; + } + + while ( counter > 0 ){ + logic.runCycle( gamePlayer, &level ); + counter--; + doDraw = true; + } + + if ( doDraw ){ + draw.Draw( logic.getObjects(), gamePlayer, logic.getExplode(), logic.maxExplode() ); + } + + if ( Keyboard::getAnyKey( Keyboard::P ) ){ + pauseGame(); + Util::getTicks( &ticks ); + } + + while ( Keyboard::getAnyKey( Keyboard::L ) && counter < 7 ){ + counter += Util::getTicks( &ticks ); + Util::YIELD(); + } + + if ( deathCounter == 0 ){ + if ( player->getLife() <= 0 ){ + gamePlayer = NULL; + deathCounter = 1; + } + } else { + if ( ++deathCounter > 80 ){ + game_error = 1; + } + } + + if ( doneCounter == 0 ){ + if ( level.done() ){ + doneCounter = 1; + } + } else { + if ( ++doneCounter > 400 ){ + game_error = 5; + } + + int min = 350; + if ( doneCounter > min ){ + draw.fadeToBlack( 255 - (doneCounter - min) * 4 ); + } + } + + if ( Keyboard::getAnyKey( Keyboard::V ) ){ + game_error = 5; + } + + if ( Keyboard::getAnyKey( Keyboard::ESC ) ){ + game_error = QUIT; + } + } + + /* + if ( player->getLevel() == 1 ){ + real_level++; + } + */ + + // cout << "Game error = " << game_error << endl; + + switch( game_error ) { + case 5 : { + player->setLevel( player->getLevel()+1 ); + break; + + } + case 1 : { + deathScreen(); + player->setScore( score ); + break; + } + case 2 : { + player->setLevel( 1 ); + break; + } + case 3 : { + // quit = true; + break; + } + case 4 : { + break; + } + case QUIT : { + player->setScore( score ); + break; + } + default : { + } + } +} + +static vector< string > getSongs(){ + return Util::getFiles( "music/", "*" ); +} + +int rafkill( int argc, char ** argv ) { + + int gameSpeed = 40; + + printf("rafkill -h for help screen\n"); + for ( int q = 1; q < argc; q++ ) { + if ( strcmp( argv[q], "-h" ) == 0 || strcmp( argv[q], "-help" ) == 0 || strcmp( argv[q], "--help" ) == 0 ) { + usage(); + return 0; + } + if ( strcmp( argv[q], "-w" ) == 0 ){ + Configuration::setWindowMode( true ); + } else if ( strcmp( argv[q], "-l" ) == 0 ){ + Configuration::setBackground( false ); + } else if ( strlen( argv[q] ) > 2 ){ + if ( argv[q][1] == 'g' ){ + gameSpeed = atoi( &argv[q][2] ); + } + } + } + + if ( gameSpeed <= 0 ){ + gameSpeed = 40; + } + + cout << "Running game at " << gameSpeed << endl; + cout << "Using window mode " << Configuration::getWindowMode() << endl; + init( Configuration::getWindowMode(), gameSpeed ); + cout << "OS " << Util::getOS() << endl; + + Util::loadGlobals(); + + Font useFont = Util::getMenuFont(); + normalFont = &useFont; + + char musicPath[ 1024 ]; + Util::getDataPath( musicPath, "intro.mod" ); + + /* musicBox will be destructed at the end of main() and thus free up all music resources */ + Music musicBox; + + Music::loadSong( musicPath ); + + SpaceObject * player; + menuClass menu; + + player = NULL; + + /* + { + player = getNewPlayer( 3 ); + playLevel( (PlayerObject * )player ); + delete player; + return 0; + } + */ + + Bitmap::transBlender( 0, 0, 0, 192 ); + + cout << "** Running game" << endl; + bool quit; + // int real_level = 1; + int geti; + while ( (geti = intro_screen( gameSpeed, &player, Util::global_snd ) ) != INIT_QUIT ) { + quit = geti == INIT_QUIT; + while ( ! quit ) { + + if ( ! quit && geti != INIT_CONTINUE ) { + /* show some loading text in a seperate thread */ + startLoadingScreen(); + + /* load new song */ + Music::loadSong( getSongs() ); + + /* play level */ + playLevel( (PlayerObject *) player ); + Bitmap::transBlender( 0, 0, 0, 192 ); + + /* load intro music and go to menu */ + Music::loadSong( musicPath ); + } + + /* TODO: dont leave this */ + // player->setScore( player->getScore() + 1000000 ); + + geti = INIT_PLAY; + quit = menu.activate( player ); + } + /* go back to main menu */ + } + + /* deal with globally allocated memory */ + if ( player ){ + delete player; + } + + // Configuration::saveConfiguration(); + + cout << "Unloading data" << endl; + + Util::unloadGlobals(); + + credits(); + + return 0; +} --- rafkill-1.2.2.orig/build/rgbhandle.h +++ rafkill-1.2.2/build/rgbhandle.h @@ -0,0 +1,26 @@ +#ifndef _rgbhandle_h +#define _rgbhandle_h + +#define RGB_GO_BLACK 12 +#define RGB_SWITCH 15 + +struct RGB{ + unsigned char r, g, b; +}; + +class RGBHandle{ +public: + + RGBHandle(); + void update( int max, int min ); + int Get(); + +protected: + + bool changecol( unsigned char & c, unsigned char & dir ); + + RGB mine; + unsigned char rwant, gwant, bwant; +}; + +#endif --- rafkill-1.2.2.orig/build/loading_screen.h +++ rafkill-1.2.2/build/loading_screen.h @@ -0,0 +1,7 @@ +#ifndef _LOADING_SCREEN_H +#define _LOADING_SCREEN_H + +void startLoadingScreen(); +void endLoadingScreen(); + +#endif --- rafkill-1.2.2.orig/build/music.h +++ rafkill-1.2.2/build/music.h @@ -0,0 +1,92 @@ +#ifndef _music_class_h +#define _music_class_h + +#include +#include + +/* +#ifdef WINDOWS +#include +#include +#endif + +#include +*/ + +using namespace std; + +struct AL_DUH_PLAYER; +struct DUH; + +/* The music class. Dont be late or youll get an F! + */ +class Music{ +public: + Music(); + + /* + Music( const char * song ); + Music( const string & song ); + */ + + ~Music(); + + static bool loadSong( const char * song ); + static bool loadSong( const string & song ); + + /* load one of the songs in 'songs' */ + static void loadSong( const vector< string > & songs ); + + void doPlay(); + + /* + void _loadSong( const char * song ); + void _loadSong( const string & song ); + */ + + void _play(); + void _pause(); + void _soften(); + void _louden(); + + static void pause(); + static void play(); + static void soften(); + static void louden(); + + /* + void _pause(); + void _resume(); + */ + + /* + void _play(); + int _soften(); + int _louden(); + void _maxVolume(); + */ + + static void setVolume( double v ); + static double getVolume(); + + /* + return (int)( volume * 100 ); + } + */ + + static void mute(); + static void unmute(); + +protected: + + void _setVolume( double vol ); + + bool playing; + + bool internal_loadSong( const char * path ); + + AL_DUH_PLAYER * player; + DUH * music_file; +}; + +#endif --- rafkill-1.2.2.orig/build/shipobj.h +++ rafkill-1.2.2/build/shipobj.h @@ -0,0 +1,95 @@ +#ifndef _shipobj_h_ +#define _shipobj_h_ + +#include "spaceobj.h" +#include "defs.h" +#include "bitmap.h" +#include + +using namespace std; + +class Booster; +class Move; +class WeaponObject; +class HullObject; +class WeaponNode; +class ExplosionClass; +class Section; +class Group; + +class ShipObject:public SpaceObject{ +public: + + ShipObject( int qx, int qy, int spc, HullObject * hnew, Group * _group, Move * movey, int al ); + + virtual void MoveMe(vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ); + + virtual void Died( SpaceObject * check, ExplosionClass ** explr, int ME ); + + virtual void Explode( ExplosionClass ** explr, int ME ); + + /* + virtual double getDX(); + virtual double getDY(); + virtual double getAccelX(); + virtual double getAccelY(); + */ + + virtual double Hurt(); + + virtual bool powerUp(); + + //destructor + virtual ~ShipObject(); + +protected: + + Move * style; + int special; + +}; + +class MeteorObject:public ShipObject{ +public: + MeteorObject( int qx, int qy, int spc, HullObject * hnew, Move * hmove ); + virtual void Explode( ExplosionClass ** explr, int ME ); +}; + +//there must be a better way to implement this +class EnemyGeneric:public ShipObject{ +public: + EnemyGeneric( int qx, int qy, HullObject * hnew, WeaponObject * myW, Move * movey, Group * _group ); + virtual void Radar( const Bitmap & rad )const; +}; + +class PowerUp:public ShipObject{ +public: + PowerUp( int qx, int qy, HullObject * hnew, Move * movey ); + virtual bool Damage( double much ); + virtual void Died( SpaceObject * check, ExplosionClass ** explr, int ME ); + virtual bool powerUp(); + virtual bool isSpecial() const; + virtual void Radar( const Bitmap & rad )const; +}; + +class Money:public PowerUp{ +public: + Money( int qx, int qy, int m, HullObject * hnew, Move * movey ); + virtual bool Damage( double much ); + virtual void Died( SpaceObject * check, ExplosionClass ** explr, int ME ); +}; + +class Health:public PowerUp{ +public: + Health( int qx, int qy, HullObject * hnew, Move * movey ); + virtual void Died( SpaceObject * check, ExplosionClass ** explr, int ME ); +}; + +class Cloak:public PowerUp{ +public: + + Cloak( int qx, int qy, HullObject * hnew, Move * movey ); + virtual void Died( SpaceObject * check, ExplosionClass ** explr, int ME ); +}; + +#endif --- rafkill-1.2.2.orig/build/playerobj.cpp +++ rafkill-1.2.2/build/playerobj.cpp @@ -0,0 +1,309 @@ +#include "playerobj.h" +#include "shipobj.h" +#include "spaceobj.h" +#include "booster.h" +#include "keyboard.h" +#include "bitmap.h" +#include "gunobj.h" +#include "hull.h" +#include "hulls/hull_player.h" + +PlayerObject::PlayerObject(int qx, int qy, int _difficulty, HullObject * hnew): +ShipObject(qx,qy,0,hnew,NULL,NULL,TEAM_PLAYER), +difficulty( _difficulty ), +change_frame( 0 ), +holding_accessory( true ), +user_control( true ), +level( 1 ){ + score = 10000; +} + + +PlayerObject::~PlayerObject() { +} + + +bool PlayerObject::acceptSpecial() const { + return true; +} + + +void PlayerObject::Radar( const Bitmap & rad ) const{ + + int x = (int)( (float)getX() / ( (float) Util::screen_x / (float)rad.getWidth() ) ); + int y = (int)( (float)getY() / ( (float) Util::screen_y / (float)rad.getHeight() ) ); + rad.circleFill( x, y, 1, Bitmap::makeColor(100,200,50) ); +} + +void PlayerObject::setControl( bool a ){ + user_control = a; +} + +void PlayerObject::Draw( const Bitmap & less, ExplosionClass ** _explr, int MAX_EXPLR, int g, int offset ) const{ + + if ( g != hull->drawLevel ) return; + + WeaponObject ** myGun = hull->Guns(); + for ( int q = 0; q < hull->maxGuns(); q++ ) + if ( myGun[q] != NULL ) + myGun[q]->Draw( less, getX(), getY()+offset ); + + PlayerHull * ph = (PlayerHull *)hull; + if ( ph->life < 30 ) { + + int mx = getX(); + int my = getY(); + for ( int q = 0; q < 3; q++ ) { + // #define garb 35 + const int garb = 35; + if ( Util::rnd( (int)ph->life ) == Util::rnd( (int)ph->life ) ) { + if ( _explr != NULL ) + addExplode( _explr, MAX_EXPLR, new ExplosionClass( mx + Util::rnd( garb ) - garb / 2, my + Util::rnd( garb ) - garb / 2, 0,4.8, Util::rnd( 3 ) + 5 ) ); + } + // #undef garb + } + + } + + engine.Draw( less, offset ); + ph->Draw( less, getX(), getY()+offset ); + +} + + +bool PlayerObject::powerUp() { + return false; +} + + +void PlayerObject::MoveD( double & d, double f_max ) { + + #define move_change 3.9 + + if ( f_max > 0 ) { + d += move_change; + if ( d > f_max ) d = f_max; + } + else { + d -= move_change; + if ( d < f_max ) d = f_max; + } + +} + +bool PlayerObject::Destroyable() const{ + return false; +} + +void PlayerObject::MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ){ + + if ( user_control ) + userInput( fight, Ammo ); + + MoveReal(); + + engine.Update(); + + if ( hull ) hull->Moved( this->getDX(), this->getDY(), this->getAccelX(), this->getAccelY() ); + + // return false; + +} + +void PlayerObject::joyInput(){ + /* TODO: Add joystick code */ +} + +void PlayerObject::keyboardInput(){ + + key_UP = Keyboard::getAnyKey( Keyboard::UP, + Keyboard::W, + Keyboard::PAD_8 ); + + key_DOWN = Keyboard::getAnyKey( Keyboard::DOWN, + Keyboard::X, + Keyboard::S, + Keyboard::PAD_2 ); + + key_RIGHT = Keyboard::getAnyKey( Keyboard::RIGHT, + Keyboard::D, + Keyboard::PAD_6 ); + + key_LEFT = Keyboard::getAnyKey( Keyboard::LEFT, + Keyboard::A, + Keyboard::PAD_4 ); + + + key_SHOOT = Keyboard::getAnyKey( Keyboard::SPACE, + Keyboard::ENTER, + Keyboard::ENTER_PAD ); + + if ( !holding_accessory ){ + if ( Keyboard::getAnyKey( Keyboard::ALT, Keyboard::ALTGR ) ){ + key_ACCESSORY = true; + // ((PlayerHull *)hull)->NextAccessory(); + holding_accessory = true; + } + } + + if ( ! Keyboard::getAnyKey( Keyboard::ALT, Keyboard::ALTGR ) ){ + holding_accessory = false; + } + + /* + if ( key[KEY_UP] || key[KEY_W] || key[KEY_8_PAD] ) { + setAccelY( -move_quick ); + if ( change_frame % 2 == 0 ) { + int mx = getX() + getMaxX() / 2; + int my = getY() + getMaxY() / 2; + mx = getX(); + my = getY(); + engine.add( mx-7, my ); + engine.add( mx+7, my ); + } + } + if ( key[KEY_DOWN] || key[KEY_X] || key[KEY_S] || key[KEY_2_PAD] ) { + setAccelY( move_quick ); + } + + if ( key[KEY_RIGHT] || key[KEY_D] || key[KEY_6_PAD] ) { + setAccelX( move_quick ); + } + if ( key[KEY_LEFT] || key[KEY_A] || key[KEY_4_PAD] ) { + setAccelX( -move_quick ); + } + + if ( !holding_accessory ) + if ( key[KEY_ALT] || key[KEY_ALTGR] ) { + ((PlayerHull *)hull)->NextAccessory(); + holding_accessory = true; + } + + if ( !key[KEY_ALT] && !key[KEY_ALTGR] ) holding_accessory = false; + */ + + +} + +void PlayerObject::userInput( const vector< SpaceObject * > * fight, vector< SpaceObject * > * Ammo ){ + + setAccelX( 0 ); + setAccelY( 0 ); + + if ( ++change_frame >= 10 ) change_frame = 0; + + key_UP = key_DOWN = key_RIGHT = key_LEFT = key_SHOOT = key_ACCESSORY = false; + + keyboardInput(); + + #define move_quick 11.23 + if ( key_UP ){ + setAccelY( -move_quick ); + if ( change_frame % 2 == 0 ) { + int mx = getX() + getMaxX() / 2; + int my = getY() + getMaxY() / 2; + mx = getX(); + my = getY(); + engine.add( mx-7, my ); + engine.add( mx+7, my ); + } + } + if ( key_DOWN ){ + setAccelY( move_quick ); + } + + if ( key_RIGHT ){ + setAccelX( move_quick ); + } + + if ( key_LEFT ){ + setAccelX( -move_quick ); + } + #undef move_quick + + double mdx = getDX(); + double mdy = getDY(); + + MoveD( mdx, getAccelX() ); + MoveD( mdy, getAccelY() ); + + if ( getAccelX() != 0 ) + Inertia( mdx ); + + if ( getAccelY() != 0 ) + Inertia( mdy ); + + setDX( mdx ); + setDY( mdy ); + + if ( key_ACCESSORY ) + ((PlayerHull *)hull)->NextAccessory(); + + if ( key_SHOOT ) + shootGuns( Ammo, fight ); + else idleGuns( Ammo, fight ); + + +} + +void PlayerObject::idleGuns( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ){ + + int mx = getX(); + int my = getY(); + + WeaponObject ** myGun = hull->Guns(); + for ( int q = 0; q < hull->maxGuns(); q++ ){ + if ( myGun[q] != NULL ) { + if ( myGun[q]->getShotCounter() > 0 ) + myGun[q]->Wait( 1 ); + else { + myGun[q]->Idle( mx, my, Ammo, fight ); + } + } + } + +} + +void PlayerObject::shootGuns( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ){ + + int mx = getX(); + int my = getY(); + + WeaponObject ** myGun = hull->Guns(); + for ( int q = 0; q < hull->maxGuns(); q++ ){ + if ( myGun[q] != NULL ) { + if ( myGun[q]->getShotCounter() > 0 ) + myGun[q]->Wait( 1 ); + else { + myGun[q]->MakeShot( mx, my, Ammo, fight ); + } + } + } + +} + +int PlayerObject::getDifficulty(){ + return difficulty; +} + +void PlayerObject::setDifficulty( int d ){ + difficulty = d; + if ( difficulty < 0 ) difficulty = 0; + if ( difficulty > 7 ) difficulty = 7; +} + +int PlayerObject::getLevel() const{ + return level; +} + +void PlayerObject::setLevel( int s ){ + level = s; + if ( level < 0 ) level = 0; +} + +void PlayerObject::Inertia( double & d ) { + #define slowdown 1.69 + if ( d > slowdown ) d -= slowdown; + else if ( d < -slowdown ) d += slowdown; + else d = 0; +} --- rafkill-1.2.2.orig/build/font.cpp +++ rafkill-1.2.2/build/font.cpp @@ -0,0 +1,18 @@ +#include +#include "font.h" + +Font::Font( FONT * f ): +my_font( f ){ +} + +Font::Font( const Font & f ): +my_font( f.getInternalFont() ){ +} + +const int Font::textLength( const char * text ){ + return text_length( getInternalFont(), text ); +} + +const int Font::getHeight() const{ + return text_height( getInternalFont() ); +} --- rafkill-1.2.2.orig/build/keyboard.cpp +++ rafkill-1.2.2/build/keyboard.cpp @@ -0,0 +1,303 @@ +#include +#include "keyboard.h" +#include + +using namespace std; + +static const bool getKey( int k ){ + return ::key[ k ]; +} + +const bool Keyboard::getAnyKey( int k1, int k2, int k3, int k4 ){ + return getKey( k1 ) || getKey( k2 ) || getKey( k3 ) || getKey( k4 ); +} + +const bool Keyboard::getAnyKey( int k1, int k2, int k3 ){ + return getKey( k1 ) || getKey( k2 ) || getKey( k3 ); +} + +const bool Keyboard::getAnyKey( int k1, int k2 ){ + return getKey( k1 ) || getKey( k2 ); +} + +const bool Keyboard::getAnyKey( int k1 ){ + return getKey( k1 ); +} + +const bool Keyboard::keyPressed(){ + return ::keypressed(); +} + +void Keyboard::clear(){ + ::clear_keybuf(); +} + +const int Keyboard::readKey(){ + if ( ! ::keypressed() ){ + return -1; + } + return ::readkey() >> 8; +} + +string Keyboard::keyToString( int key ){ + if ( key == A ) return "A"; + if ( key == B ) return "B"; + if ( key == C ) return "C"; + if ( key == D ) return "D"; + if ( key == E ) return "E"; + if ( key == F ) return "F"; + if ( key == G ) return "G"; + if ( key == H ) return "H"; + if ( key == I ) return "I"; + if ( key == J ) return "J"; + if ( key == K ) return "K"; + if ( key == L ) return "L"; + if ( key == M ) return "M"; + if ( key == N ) return "N"; + if ( key == O ) return "O"; + if ( key == P ) return "P"; + if ( key == Q ) return "Q"; + if ( key == R ) return "R"; + if ( key == S ) return "S"; + if ( key == T ) return "T"; + if ( key == U ) return "U"; + if ( key == V ) return "V"; + if ( key == W ) return "W"; + if ( key == X ) return "X"; + if ( key == Y ) return "Y"; + if ( key == Z ) return "Z"; + if ( key == N0 ) return "N0"; + if ( key == N1 ) return "N1"; + if ( key == N2 ) return "N2"; + if ( key == N3 ) return "N3"; + if ( key == N4 ) return "N4"; + if ( key == N5 ) return "N5"; + if ( key == N6 ) return "N6"; + if ( key == N7 ) return "N7"; + if ( key == N8 ) return "N8"; + if ( key == N9 ) return "N9"; + if ( key == PAD_0 ) return "PAD_0"; + if ( key == PAD_1 ) return "PAD_1"; + if ( key == PAD_2 ) return "PAD_2"; + if ( key == PAD_3 ) return "PAD_3"; + if ( key == PAD_4 ) return "PAD_4"; + if ( key == PAD_5 ) return "PAD_5"; + if ( key == PAD_6 ) return "PAD_6"; + if ( key == PAD_7 ) return "PAD_7"; + if ( key == PAD_8 ) return "PAD_8"; + if ( key == PAD_9 ) return "PAD_9"; + if ( key == F1 ) return "F1"; + if ( key == F2 ) return "F2"; + if ( key == F3 ) return "F3"; + if ( key == F4 ) return "F4"; + if ( key == F5 ) return "F5"; + if ( key == F6 ) return "F6"; + if ( key == F7 ) return "F7"; + if ( key == F8 ) return "F8"; + if ( key == F9 ) return "F9"; + if ( key == F10 ) return "F10"; + if ( key == F11 ) return "F11"; + if ( key == F12 ) return "F12"; + if ( key == ESC ) return "ESC"; + if ( key == TILDE ) return "TILDE"; + if ( key == MINUS ) return "MINUS"; + if ( key == EQUALS ) return "EQUALS"; + if ( key == BACKSPACE ) return "BACKSPACE"; + if ( key == TAB ) return "TAB"; + if ( key == OPENBRACE ) return "OPENBRACE"; + if ( key == CLOSEBRACE ) return "CLOSEBRACE"; + if ( key == ENTER ) return "ENTER"; + if ( key == COLON ) return "COLON"; + if ( key == QUOTE ) return "QUOTE"; + if ( key == BACKSLASH ) return "BACKSLASH"; + if ( key == BACKSLASH2 ) return "BACKSLASH2"; + if ( key == COMMA ) return "COMMA"; + if ( key == STOP ) return "STOP"; + if ( key == SLASH ) return "SLASH"; + if ( key == SPACE ) return "SPACE"; + if ( key == INSERT ) return "INSERT"; + if ( key == DEL ) return "DEL"; + if ( key == HOME ) return "HOME"; + if ( key == END ) return "END"; + if ( key == PGUP ) return "PGUP"; + if ( key == PGDN ) return "PGDN"; + if ( key == LEFT ) return "LEFT"; + if ( key == RIGHT ) return "RIGHT"; + if ( key == UP ) return "UP"; + if ( key == DOWN ) return "DOWN"; + if ( key == SLASH_PAD ) return "SLASH_PAD"; + if ( key == ASTERISK ) return "ASTERISK"; + if ( key == MINUS_PAD ) return "MINUS_PAD"; + if ( key == PLUS_PAD ) return "PLUS_PAD"; + if ( key == DEL_PAD ) return "DEL_PAD"; + if ( key == ENTER_PAD ) return "ENTER_PAD"; + if ( key == PRTSCR ) return "PRTSCR"; + if ( key == PAUSE ) return "PAUSE"; + if ( key == C1 ) return "C1"; + if ( key == YEN ) return "YEN"; + if ( key == KANA ) return "KANA"; + if ( key == CONVERT ) return "CONVERT"; + if ( key == NOCONVERT ) return "NOCONVERT"; + if ( key == AT ) return "AT"; + if ( key == CIRCUMFLEX ) return "CIRCUMFLEX"; + if ( key == COLON2 ) return "COLON2"; + if ( key == KANJI ) return "KANJI"; + if ( key == EQUALS_PAD ) return "EQUALS_PAD"; + if ( key == BACKQUOTE ) return "BACKQUOTE"; + if ( key == SEMICOLON ) return "SEMICOLON"; + if ( key == COMMAND ) return "COMMAND"; + if ( key == UNKNOWN1 ) return "UNKNOWN1"; + if ( key == UNKNOWN2 ) return "UNKNOWN2"; + if ( key == UNKNOWN3 ) return "UNKNOWN3"; + if ( key == UNKNOWN4 ) return "UNKNOWN4"; + if ( key == UNKNOWN5 ) return "UNKNOWN5"; + if ( key == UNKNOWN6 ) return "UNKNOWN6"; + if ( key == UNKNOWN7 ) return "UNKNOWN7"; + if ( key == UNKNOWN8 ) return "UNKNOWN8"; + if ( key == MODIFIERS ) return "MODIFIERS"; + if ( key == LSHIFT ) return "LSHIFT"; + if ( key == RSHIFT ) return "RSHIFT"; + if ( key == LCONTROL ) return "LCONTROL"; + if ( key == RCONTROL ) return "RCONTROL"; + if ( key == ALT ) return "ALT"; + if ( key == ALTGR ) return "ALTGR"; + if ( key == LWIN ) return "LWIN"; + if ( key == RWIN ) return "RWIN"; + if ( key == MENU ) return "MENU"; + if ( key == SCRLOCK ) return "SCRLOCK"; + if ( key == NUMLOCK ) return "NUMLOCK"; + if ( key == CAPSLOCK ) return "CAPSLOCK"; + if ( key == MAX ) return "MAX"; + + return "Unknown"; +} + +const int Keyboard::A = KEY_A; +const int Keyboard::B = KEY_B; +const int Keyboard::C = KEY_C; +const int Keyboard::D = KEY_D; +const int Keyboard::E = KEY_E; +const int Keyboard::F = KEY_F; +const int Keyboard::G = KEY_G; +const int Keyboard::H = KEY_H; +const int Keyboard::I = KEY_I; +const int Keyboard::J = KEY_J; +const int Keyboard::K = KEY_K; +const int Keyboard::L = KEY_L; +const int Keyboard::M = KEY_M; +const int Keyboard::N = KEY_N; +const int Keyboard::O = KEY_O; +const int Keyboard::P = KEY_P; +const int Keyboard::Q = KEY_Q; +const int Keyboard::R = KEY_R; +const int Keyboard::S = KEY_S; +const int Keyboard::T = KEY_T; +const int Keyboard::U = KEY_U; +const int Keyboard::V = KEY_V; +const int Keyboard::W = KEY_W; +const int Keyboard::X = KEY_X; +const int Keyboard::Y = KEY_Y; +const int Keyboard::Z = KEY_Z; +const int Keyboard::N0 = KEY_0; +const int Keyboard::N1 = KEY_1; +const int Keyboard::N2 = KEY_2; +const int Keyboard::N3 = KEY_3; +const int Keyboard::N4 = KEY_4; +const int Keyboard::N5 = KEY_5; +const int Keyboard::N6 = KEY_6; +const int Keyboard::N7 = KEY_7; +const int Keyboard::N8 = KEY_8; +const int Keyboard::N9 = KEY_9; +const int Keyboard::PAD_0 = KEY_0_PAD; +const int Keyboard::PAD_1 = KEY_1_PAD; +const int Keyboard::PAD_2 = KEY_2_PAD; +const int Keyboard::PAD_3 = KEY_3_PAD; +const int Keyboard::PAD_4 = KEY_4_PAD; +const int Keyboard::PAD_5 = KEY_5_PAD; +const int Keyboard::PAD_6 = KEY_6_PAD; +const int Keyboard::PAD_7 = KEY_7_PAD; +const int Keyboard::PAD_8 = KEY_8_PAD; +const int Keyboard::PAD_9 = KEY_9_PAD; +const int Keyboard::F1 = KEY_F1; +const int Keyboard::F2 = KEY_F2; +const int Keyboard::F3 = KEY_F3; +const int Keyboard::F4 = KEY_F4; +const int Keyboard::F5 = KEY_F5; +const int Keyboard::F6 = KEY_F6; +const int Keyboard::F7 = KEY_F7; +const int Keyboard::F8 = KEY_F8; +const int Keyboard::F9 = KEY_F9; +const int Keyboard::F10 = KEY_F10; +const int Keyboard::F11 = KEY_F11; +const int Keyboard::F12 = KEY_F12; +const int Keyboard::ESC = KEY_ESC; +const int Keyboard::TILDE = KEY_TILDE; +const int Keyboard::MINUS = KEY_MINUS; +const int Keyboard::EQUALS = KEY_EQUALS; +const int Keyboard::BACKSPACE = KEY_BACKSPACE; +const int Keyboard::TAB = KEY_TAB; +const int Keyboard::OPENBRACE = KEY_OPENBRACE; +const int Keyboard::CLOSEBRACE = KEY_CLOSEBRACE; +const int Keyboard::ENTER = KEY_ENTER; +const int Keyboard::COLON = KEY_COLON; +const int Keyboard::QUOTE = KEY_QUOTE; +const int Keyboard::BACKSLASH = KEY_BACKSLASH; +const int Keyboard::BACKSLASH2 = KEY_BACKSLASH2; +const int Keyboard::COMMA = KEY_COMMA; +const int Keyboard::STOP = KEY_STOP; +const int Keyboard::SLASH = KEY_SLASH; +const int Keyboard::SPACE = KEY_SPACE; +const int Keyboard::INSERT = KEY_INSERT; +const int Keyboard::DEL = KEY_DEL; +const int Keyboard::HOME = KEY_HOME; +const int Keyboard::END = KEY_END; +const int Keyboard::PGUP = KEY_PGUP; +const int Keyboard::PGDN = KEY_PGDN; +const int Keyboard::LEFT = KEY_LEFT; +const int Keyboard::RIGHT = KEY_RIGHT; +const int Keyboard::UP = KEY_UP; +const int Keyboard::DOWN = KEY_DOWN; +const int Keyboard::SLASH_PAD = KEY_SLASH_PAD; +const int Keyboard::ASTERISK = KEY_ASTERISK; +const int Keyboard::MINUS_PAD = KEY_MINUS_PAD; +const int Keyboard::PLUS_PAD = KEY_PLUS_PAD; +const int Keyboard::DEL_PAD = KEY_DEL_PAD; +const int Keyboard::ENTER_PAD = KEY_ENTER_PAD; +const int Keyboard::PRTSCR = KEY_PRTSCR; +const int Keyboard::PAUSE = KEY_PAUSE; +const int Keyboard::C1 = KEY_ABNT_C1; +const int Keyboard::YEN = KEY_YEN; +const int Keyboard::KANA = KEY_KANA; +const int Keyboard::CONVERT = KEY_CONVERT; +const int Keyboard::NOCONVERT = KEY_NOCONVERT; +const int Keyboard::AT = KEY_AT; +const int Keyboard::CIRCUMFLEX = KEY_CIRCUMFLEX; +const int Keyboard::COLON2 = KEY_COLON2; +const int Keyboard::KANJI = KEY_KANJI; +const int Keyboard::EQUALS_PAD = KEY_EQUALS_PAD; +const int Keyboard::BACKQUOTE = KEY_BACKQUOTE; +const int Keyboard::SEMICOLON = KEY_SEMICOLON; +const int Keyboard::COMMAND = KEY_COMMAND; +const int Keyboard::UNKNOWN1 = KEY_UNKNOWN1; +const int Keyboard::UNKNOWN2 = KEY_UNKNOWN2; +const int Keyboard::UNKNOWN3 = KEY_UNKNOWN3; +const int Keyboard::UNKNOWN4 = KEY_UNKNOWN4; +const int Keyboard::UNKNOWN5 = KEY_UNKNOWN5; +const int Keyboard::UNKNOWN6 = KEY_UNKNOWN6; +const int Keyboard::UNKNOWN7 = KEY_UNKNOWN7; +const int Keyboard::UNKNOWN8 = KEY_UNKNOWN8; +const int Keyboard::MODIFIERS = KEY_MODIFIERS; +const int Keyboard::LSHIFT = KEY_LSHIFT; +const int Keyboard::RSHIFT = KEY_RSHIFT; +const int Keyboard::LCONTROL = KEY_LCONTROL; +const int Keyboard::RCONTROL = KEY_RCONTROL; +const int Keyboard::ALT = KEY_ALT; +const int Keyboard::ALTGR = KEY_ALTGR; +const int Keyboard::LWIN = KEY_LWIN; +const int Keyboard::RWIN = KEY_RWIN; +const int Keyboard::MENU = KEY_MENU; +const int Keyboard::SCRLOCK = KEY_SCRLOCK; +const int Keyboard::NUMLOCK = KEY_NUMLOCK; +const int Keyboard::CAPSLOCK = KEY_CAPSLOCK; +const int Keyboard::MAX = KEY_MAX; + --- rafkill-1.2.2.orig/build/weaponobj.cpp +++ rafkill-1.2.2/build/weaponobj.cpp @@ -0,0 +1,40 @@ +#include "weaponobj.h" +#include "spaceobj.h" +#include "hull.h" +#include "trigtable.h" +#include "sound.h" +#include "defs.h" +#include "raptor.h" +#include "explode.h" + +WeaponNode::WeaponNode(int qx, int qy, double kx, double ky, HullObject * hnew, int alignment): +SpaceObject(qx,qy,kx,ky, hnew, NULL, PLANE_AIR | PLANE_GROUND, alignment ){} + +bool WeaponNode::Damage( double much ) { + hull->takeDamage( getLife() ); + hull->takeDamage( NO_EXPLODE ); + return true; +} + +bool WeaponNode::hullCollide( ECollide * col, int x, int y ){ + return false; +} + +bool WeaponNode::CanbeHit( const SpaceObject * ht ) const{ + return false; +} + +void WeaponNode::Died( SpaceObject * check, ExplosionClass ** explr, int ME ){ + Util::playSound( SND_SUSTAIN, 50 ); + Explode( explr, ME ); +} + +void WeaponNode::Explode( ExplosionClass ** explr, int ME ) { + //double a = (double)( Util::rnd( 45 ) + 15 ) / -10.0; + //addExplode( explr, ME, new ExplosionClass(actualx,actualy,0,a,Util::rnd(6) + 3 ) ); + addExplode( explr, ME, new ExplosionClass(getX(),getY(),this->getDX()/2,this->getDY()/2,Util::rnd(6) + 3 ) ); + +} + +WeaponNode::~WeaponNode() { +} --- rafkill-1.2.2.orig/build/rfont.cpp +++ rafkill-1.2.2/build/rfont.cpp @@ -0,0 +1,160 @@ +#include + +#include "rfont.h" +#include "strings.h" +#include "bitmap.h" +#include "defs.h" + +RGlyph::RGlyph( int w, int h, unsigned char * dat, char mc ): +_width( w ), +_height( h ) { + + letter = upcase( mc ); + + data = new unsigned char[ w * h ]; + int count = 0; + for ( int y = 0; y < h; y++ ) + for ( int x = 0; x < w; x++ ) { + data[count] = (unsigned char)((double)dat[count]*100.0/255.0); + count++; + } + +} + + +bool RGlyph::rightLetter( char x ) { + return x==letter; +} + + +int RGlyph::height() { + return _height; +} + + +int RGlyph::width() { + return _width; +} + + +RGlyph::~RGlyph() { + delete[] data; +} + + +void RGlyph::Draw( const Bitmap & work, int x, int y, int c ) { + + int o_r = Bitmap::getRed( c ); + int o_g = Bitmap::getGreen( c ); + int o_b = Bitmap::getBlue( c ); + + int count = 0; + for ( int cy = 0; cy < _height; cy++ ) + for ( int cx = 0; cx < _width; cx++ ) { + + int bash = count; + int lx = cx; + while ( data[bash] == data[count] && lx < _width ) { + bash++; + lx++; + } + + if ( data[count] > 0 ) { + double rd = (double)data[count] / 100.0; + int a_r = (int)( (double)o_r*rd ); + int a_g = (int)( (double)o_g*rd ); + int a_b = (int)( (double)o_b*rd ); + + int fc = Bitmap::makeColor( a_r, a_g, a_b ); + + work.horizontalLine( x+cx, y+cy, x+lx-1, fc ); + + } + count = bash; + cx = lx-1; + + } + +} + + +RFont::RFont( char * fname ) { + + FILE * fv = fopen( fname, "rb" ); + + glyphs = NULL; + if ( fv == NULL ) { + printf("Error reading font file %s\n", fname ); + return; + } + + printf("Loading font %s\n", fname ); + + max_glyphs = Util::readnum( fv, sizeof( int ) ); + + glyphs = new RGlyph*[max_glyphs]; + for ( int q = 0; q < max_glyphs; q++ ) + glyphs[q] = NULL; + for ( int q = 0; q < max_glyphs; q++ ) { + int w; + int h; + char letter; + w = Util::readnum( fv, sizeof( int ) ); + h = Util::readnum( fv, sizeof( int ) ); + letter = Util::readnum( fv, sizeof( char ) ); + unsigned char * d = new unsigned char[ w*h ]; + fread( d, sizeof( unsigned char ), w*h, fv ); + glyphs[q] = new RGlyph( w, h, d, letter ); + delete[] d; + } + + fclose( fv ); + +} + + +int RFont::height() { + + if ( glyphs == NULL ) return 0; + int average = 0; + int count = 0; + for ( char q = 'A'; q < 'Z'; q++ ) + for ( int z = 0; z < max_glyphs; z++ ) + if ( glyphs[z]->rightLetter(upcase(q)) ) { + average += glyphs[z]->height(); + count++; + } + return average /= count; + +} + + +void RFont::rtext( const Bitmap & work, int x, int y, int c, const char * wr ) { + + if ( glyphs == NULL ) return; + + int sx = x; + int sy = y; + + for ( int q = 0; wr[q] != '\0'; q++ ) { + int z = 0; + for ( z = 0; z < max_glyphs && !glyphs[z]->rightLetter(upcase(wr[q])); z++ ); + if ( z == max_glyphs )sx += 20; + else { + glyphs[z]->Draw( work, sx, sy, c ); + sx += glyphs[z]->width(); + } + } +} + + +RFont::~RFont() { + + if ( glyphs ) { + for ( int q = 0; q < max_glyphs; q++ ) + if ( glyphs[q] ) + delete glyphs[q]; + delete[] glyphs; + } + +} --- rafkill-1.2.2.orig/build/gunobj.h +++ rafkill-1.2.2/build/gunobj.h @@ -0,0 +1,84 @@ +#ifndef _weaponobject_h_ +#define _weaponobject_h_ + +#include +#include +#include "bitmap.h" + +class SpaceObject; + +using namespace std; + +class WeaponObject{ +public: + + //basic constructor + WeaponObject( int direction, const char * name, int _worth, int _alignment, int _strength, int _max_strength ); + + //Draw + //process: draws onto bitmap (unused) + virtual void Draw( const Bitmap & less, int x, int y); + + //MakeShot + //process: shoots a bullet, able to use enemy as target + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + + //if we dont shoot, we idle. yay! + virtual void Idle( int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + + // increase strength by q, cannot excede max_power + virtual void IncreasePower( int q ); + + virtual inline int getPower(){ + return strength; + } + + //return the name of this gun + virtual inline const char * GetName() const{ + return gun_name.c_str(); + } + virtual inline const char * getName() const { + return gun_name.c_str(); + } + + inline int getTeam(){ + return alignment; + } + + //how much the gun costs + virtual int Worth(); + + // returns shot_counter + virtual const int getShotCounter() const; + + virtual void Wait( const int n ); + + //returns the maximum strength of the gun + virtual int maxPower(); + + //returns a copy of this object + virtual WeaponObject * copy(); + + //destructor + virtual ~WeaponObject(); + +protected: + + const SpaceObject * getCollidableObject( const vector< SpaceObject * > * fight, const SpaceObject * obj ); + + void setShotCounter( const int x ); + + int shot_counter; //how much time till next shot + int strength; //how strong this gun is + int max_strength; //how strong this gun can possibly be + int dir; //direction to shoot in, -1 or 1 + int gun_type; //useless gun type number + int worth; //how much the gun is worth + // const char * gun_name; //name of gun + string gun_name; + int alignment; //which grouping gun makes bullets for + int smp; //played during Makeshot or Idle + +}; + +#endif --- rafkill-1.2.2.orig/build/bitmap.cpp +++ rafkill-1.2.2/build/bitmap.cpp @@ -0,0 +1,746 @@ +#include +#include "bitmap.h" +#include "font.h" +#include +#include +#include +#include +// #include + +#ifdef WINDOWS +#include +#endif + +using namespace std; + +#ifndef debug +#define debug cout<<"File: "<<__FILE__<<" Line: "<<__LINE__<w, his->h ) ); + ::blit( his, getBitmap(), 0, 0, 0, 0, his->w, his->h ); + own = new int; + *own = 1; + } else { + setBitmap( who ); + own = NULL; + } +} + +Bitmap::Bitmap( const char * load_file ): +error( false ){ + internalLoadFile( load_file ); + /* + my_bitmap = load_bitmap( load_file, NULL ); + if ( !my_bitmap ){ + my_bitmap = create_bitmap( 100, 100 ); + clear( my_bitmap ); + cout<<"Could not load "<w, temp->h, 0, 0, getBitmap()->w, getBitmap()->h ); + destroy_bitmap( temp ); + } + // own = true; + own = new int; + *own = 1; +} + +Bitmap::Bitmap( const char * load_file, int sx, int sy, double accuracy ): +error( false ){ + path = load_file; + BITMAP * temp = load_bitmap( load_file, NULL ); + own = new int; + *own = 1; + if ( !temp ){ + cout<<"Could not load "<w > sx || temp->h > sy ){ + double bx = temp->w / sx; + double by = temp->h / sy; + double use; + use = bx > by ? bx : by; + int fx = (int)(sx / use); + int fy = (int)(sy / use); + setBitmap( create_bitmap( fx, fy ) ); + + stretch_blit( temp, getBitmap(), 0, 0, temp->w, temp->h, 0, 0, getBitmap()->w, getBitmap()->h ); + + destroy_bitmap( temp ); + } else setBitmap( temp ); + } + // own = true; +} + +Bitmap::Bitmap( const Bitmap & copy, int sx, int sy ): +error( false ){ + path = copy.getPath(); + BITMAP * temp = copy.getBitmap(); + setBitmap( create_bitmap( sx, sy ) ); + // clear( my_bitmap ); + clear(); + stretch_blit( temp, getBitmap(), 0, 0, temp->w, temp->h, 0, 0, getBitmap()->w, getBitmap()->h ); + // own = true; + // own = copy.own; + own = new int; + *own = 1; +} + +Bitmap::Bitmap( const Bitmap & copy, int sx, int sy, double accuracy ): +error( false ){ + path = copy.getPath(); + BITMAP * temp = copy.getBitmap(); + own = new int; + *own = 1; + if ( temp->w > sx || temp->h > sy ){ + double bx = (double)temp->w / (double)sx; + double by = (double)temp->h / (double)sy; + double use; + use = bx > by ? bx : by; + int fx = (int)(temp->w / use); + int fy = (int)(temp->h / use); + setBitmap( create_bitmap( fx, fy ) ); + if ( ! getBitmap() ){ + allegro_message("Could not create bitmap\n"); + // own = false; + // own = copy.own; + // *own++; + error = true; + return; + } + + stretch_blit( temp, getBitmap(), 0, 0, temp->w, temp->h, 0, 0, getBitmap()->w, getBitmap()->h ); + // destroy_bitmap( temp ); + } else { + setBitmap( create_bitmap( temp->w, temp->h ) ); + blit( temp, getBitmap(), 0, 0, 0, 0, temp->w, temp->h ); + // own = new int + // own = true; + } +} + +Bitmap::Bitmap( const Bitmap & copy, bool deep_copy ): +error( false ){ + + path = copy.getPath(); + if ( deep_copy ){ + BITMAP * his = copy.getBitmap(); + setBitmap( create_bitmap( his->w, his->h ) ); + ::blit( his, getBitmap(), 0, 0, 0, 0, his->w, his->h ); + own = new int; + *own = 1; + } else { + setBitmap( copy.getBitmap() ); + // own = false; + own = copy.own; + if ( own ){ + *own = *own + 1; + } + } + /* + BITMAP * his = copy.getBitmap(); + my_bitmap = create_bitmap( his->w, his->h ); + ::blit( his, my_bitmap, 0, 0, 0, 0, his->w, his->h ); + own = true; + */ +} + +Bitmap::Bitmap( const Bitmap & copy, int x, int y, int width, int height ): +error( false ){ + path = copy.getPath(); + BITMAP * his = copy.getBitmap(); + if ( x < 0 ) + x = 0; + if ( y < 0 ) + y = 0; + if ( width > his->w ) + width = his->w; + if ( height > his->h ) + height = his->h; + setBitmap( create_sub_bitmap( his, x, y, width, height ) ); + + if ( ! getBitmap() ){ + cout<<"Could not create sub-bitmap"<w; +} + +const int Bitmap::getHeight() const{ + return getBitmap()->h; +} + +int Bitmap::getRed( int x ){ + return ::getr( x ); +} + +int Bitmap::getBlue( int x ){ + return ::getg( x ); +} + +int Bitmap::getGreen( int x ){ + return ::getb( x ); +} + +/* resize the internal bitmap. not guaranteed to destroy the internal bitmap */ +void Bitmap::resize( const int width, const int height ){ + + /* if internal bitmap is already the proper size, do nothing */ + if ( getWidth() == width && getHeight() == height ){ + return; + } + + releaseInternalBitmap(); + + own = new int; + setBitmap( create_bitmap( width, height ) ); + *own = 1; +} + +/* +const string & Bitmap::getPath() const{ + return path; +} +*/ + +void Bitmap::debugSelf() const{ + cout<<"Bitmap: "<w; +} + +int Bitmap::getHeight(){ + return my_bitmap->h; +} +*/ + +void Bitmap::acquire(){ + acquire_bitmap( getBitmap() ); +} + +void Bitmap::drawBorder( const int border, const int color ) const { + for ( int i = 0; i < border; i++ ){ + rectangle( i, i, getWidth() - i - 1, getHeight() - i - 1, color ); + } +} + +void Bitmap::release(){ + release_bitmap( getBitmap() ); +} + +void Bitmap::circleFill( int x, int y, int radius, int color ) const{ + ::circlefill( getBitmap(), x, y, radius, color ); +} + +void Bitmap::circle( int x, int y, int radius, int color ) const{ + ::circle( getBitmap(), x, y, radius, color ); +} + +void Bitmap::line( const int x1, const int y1, const int x2, const int y2, const int color ) const{ + + ::line( getBitmap(), x1, y1, x2, y2, color ); + +} + +void Bitmap::transBlender( int r, int g, int b, int a ){ + set_trans_blender( r, g, b, a ); +} + +void Bitmap::multiplyBlender( int r, int g, int b, int a ){ + set_multiply_blender( r, g, b, a ); +} + +void Bitmap::drawingMode( int mode ){ + // drawing_mode( DRAW_MODE_TRANS, NULL, 0, 0 ); + switch( mode ){ + case MODE_TRANS : { + drawing_mode( DRAW_MODE_TRANS, NULL, 0, 0 ); + break; + } + case MODE_SOLID : { + drawing_mode( DRAW_MODE_SOLID, NULL, 0, 0 ); + break; + } + } +} + +/* +const int Bitmap::getWidth() const{ + return getBitmap()->w; +} + +const int Bitmap::getHeight() const{ + return getBitmap()->h; +} +*/ + +const int Bitmap::getPixel( const int x, const int y ) const{ + if ( x >= 0 && x < getBitmap()->w && y >= 0 && y < getBitmap()->h ) + return _getpixel16( getBitmap(), x, y ); + return -1; +} + +void Bitmap::readLine( vector< int > & vec, int y ){ + if ( y >= 0 && y < getBitmap()->h ){ + for ( int q = 0; q < getBitmap()->w; q++ ){ + // int col = my_bitmap->line[ y ][ q ]; + int col = _getpixel16( getBitmap(), q, y ); + vec.push_back( col ); + } + } +} + +static int setGfxMode( int mode, int x, int y ){ + int ret = ::set_gfx_mode( mode, x, y, 0, 0 ); + if ( Bitmap::Screen != NULL ){ + delete Bitmap::Screen; + } + Bitmap::Screen = new Bitmap( ::screen ); + return ret; +} + +int Bitmap::setGfxModeText(){ + return setGfxMode( GFX_TEXT, 0, 0 ); +} + +int Bitmap::setGfxModeFullscreen( int x, int y ){ + return setGfxMode( GFX_AUTODETECT_FULLSCREEN, x, y ); +} + +int Bitmap::setGfxModeWindowed( int x, int y ){ + return setGfxMode( GFX_AUTODETECT_WINDOWED, x, y ); +} + +/* +int Bitmap::setGfxModeAny( int x, int y ){ + return setGfxMode( GFX_AUTODETECT, x, y ); +} +*/ + +int Bitmap::makeColor( int r, int g, int b ){ + return ::makecol16( r, g, b ); +} + +void Bitmap::hsvToRGB( float h, float s, float v, int * r, int * g, int * b ){ + ::hsv_to_rgb( h, s, v, r, g, b ); +} + +int Bitmap::addColor( int color1, int color2 ){ + return makeColor( getr( color1 ) + getr( color2 ), + getg( color1 ) + getg( color2 ), + getb( color1 ) + getb( color2 ) ); +} + +void Bitmap::putPixel( int x, int y, int col ) const{ + if ( x >= 0 && x < getBitmap()->w && y >= 0 && y < getBitmap()->h ) + _putpixel16( getBitmap(), x, y, col ); +} + +void Bitmap::printf( int x, int y, int color, FONT * f, const char * str, ... ) const{ + + char buf[512]; + va_list ap; + + va_start(ap, str); + uvszprintf(buf, sizeof(buf), str, ap); + va_end(ap); + + textout_ex( getBitmap(), f, buf, x, y, color, -1); +} + +void Bitmap::printf( int x, int y, int color, Font * f, const char * str, ... ) const{ + + char buf[512]; + va_list ap; + + va_start(ap, str); + uvszprintf(buf, sizeof(buf), str, ap); + va_end(ap); + + textout_ex( getBitmap(), f->getInternalFont(), buf, x, y, color, -1); +} + +void Bitmap::printf( int x, int y, int color, Font * f, const string & str ) const{ + printf( x, y, color, f, str.c_str() ); +} + +void Bitmap::printfNormal( int x, int y, int color, const char * str, ... ) const{ + + char buf[512]; + va_list ap; + + va_start(ap, str); + uvszprintf(buf, sizeof(buf), str, ap); + va_end(ap); + + textout_ex( getBitmap(), font, buf, x, y, color, -1); + +} + +void Bitmap::printfNormal( int x, int y, int color, const string & str ) const{ + printfNormal( x, y, color, "%s", str.c_str() ); +} + +void Bitmap::triangle( int x1, int y1, int x2, int y2, int x3, int y3, int color ) const{ + ::triangle( getBitmap(), x1, y1, x2, y2, x3, y3, color ); +} + +void Bitmap::ellipse( int x, int y, int rx, int ry, int color ) const { + ::ellipse( getBitmap(), x, y, rx, ry, color ); +} + +void Bitmap::ellipseFill( int x, int y, int rx, int ry, int color ) const { + ::ellipsefill( getBitmap(), x, y, rx, ry, color ); +} + +void Bitmap::rectangle( int x1, int y1, int x2, int y2, int color ) const{ + ::rect( getBitmap(), x1, y1, x2, y2, color ); +} + +void Bitmap::rectangleFill( int x1, int y1, int x2, int y2, int color ) const{ + ::rectfill( getBitmap(), x1, y1, x2, y2, color ); +} + +/* +int Bitmap::getPixel( int x, int y ){ + if ( x >= 0 && x < my_bitmap->w && y >= 0 && y <= my_bitmap->h ) + return _getpixel16( my_bitmap, x, y ); + return -1; +} +*/ + +/* +int Bitmap::makeColor( int r, int g, int b ){ + return makecol16( r, g, b ); +} +*/ + +void Bitmap::hLine( const int x1, const int y, const int x2, const int color ) const{ + ::hline( getBitmap(), x1, y, x2, color ); +} + +void Bitmap::horizontalLine( const int x1, const int y, const int x2, const int color ) const{ + this->hLine( x1, y, x2, color ); +} + +void Bitmap::vLine( const int y1, const int x, const int y2, const int color ) const{ + ::vline( getBitmap(), x, y1, y2, color ); +} + +void Bitmap::polygon( const int * verts, const int nverts, const int color ) const{ + ::polygon( getBitmap(), nverts, verts, color ); +} + +/* +void Bitmap::clear(){ + this->fill( 0 ); +} +*/ + +void Bitmap::fill( int color ) const{ + ::clear_to_color( getBitmap(), color ); +} + +void Bitmap::draw( const int x, const int y, const Bitmap & where ) const{ + ::draw_sprite( where.getBitmap(), getBitmap(), x, y ); +} + +void Bitmap::drawHFlip( const int x, const int y, const Bitmap & where ){ + ::draw_sprite_h_flip( where.getBitmap(), getBitmap(), x, y ); +} + +void Bitmap::drawLit( const int x, const int y, const int level, const Bitmap & where ) const{ + ::draw_lit_sprite( where.getBitmap(), getBitmap(), x, y, level ); +} + +void Bitmap::drawTrans( const int x, const int y, const Bitmap & where ) const{ + ::draw_trans_sprite( where.getBitmap(), getBitmap(), x, y ); +} + +void Bitmap::drawRotate( const int x, const int y, const int angle, const Bitmap & where ){ + ::fixed fang = itofix( (360 - angle) % 360 * 256 / 360 ); + ::rotate_sprite( where.getBitmap(), getBitmap(), x, y, fang ); +} + +void Bitmap::drawStretched( const int x, const int y, const int new_width, const int new_height, const Bitmap & who ){ + BITMAP * bmp = who.getBitmap(); + ::masked_stretch_blit( getBitmap(), bmp, 0, 0, getBitmap()->w, getBitmap()->h, x,y, new_height, new_width ); +} + +void Bitmap::drawMask( const int _x, const int _y, const Bitmap & where ){ + int mask = Bitmap::MaskColor; + for ( int x = 0; x < getWidth(); x++ ){ + for ( int y = 0; y < getHeight(); y++ ){ + if ( getPixel( x,y ) == mask ){ + where.putPixel( x+_x, y+_y, mask ); + } + } + } +} + +void Bitmap::StretchBy2( const Bitmap & where ){ + BITMAP * bmp = where.getBitmap(); + + if ( where.getWidth() == getWidth() && where.getHeight() == getHeight() ){ + ::blit( getBitmap(), bmp, 0, 0, 0, 0, getBitmap()->w, getBitmap()->h ); + return; + } + + if ( where.getWidth() != getWidth()*2 || + where.getHeight() != getHeight()*2 ){ + cout<<"Wrong dimensions"<w, getBitmap()->h, 0, 0, bmp->w, bmp->h ); + // fblend_2x_stretch( my_bitmap, bmp, 0, 0, 0, 0, my_bitmap->w, my_bitmap->h); + // scale2x_allegro( my_bitmap, bmp, 2 ); + // debug + +} + +void Bitmap::StretchBy4( const Bitmap & where ){ + + BITMAP * bmp = where.getBitmap(); + if ( where.getWidth() != getWidth()*4 || + where.getHeight() != getHeight()*4 ){ + cout<<"Wrong dimensions"<w, my_bitmap->h); + // scale4x_allegro( my_bitmap, bmp, 2 ); + ::stretch_blit( getBitmap(), bmp, 0, 0, getBitmap()->w, getBitmap()->h, 0, 0, bmp->w, bmp->h ); + +} + +void Bitmap::Stretch( const Bitmap & where ){ + BITMAP * bmp = where.getBitmap(); + ::stretch_blit( getBitmap(), bmp, 0, 0, getBitmap()->w, getBitmap()->h, 0, 0, bmp->w, bmp->h ); +} + +void Bitmap::Blit( const string & xpath ){ + Bitmap duh( xpath ); + duh.Blit( *this ); +} + +void Bitmap::Blit( const int x, const int y, const Bitmap & where ){ + BITMAP * bmp = where.getBitmap(); + /* + acquire_bitmap( bmp ); + acquire_bitmap( my_bitmap ); + */ + ::blit( getBitmap(), bmp, 0, 0, x, y, getBitmap()->w, getBitmap()->h ); + /* + release_bitmap( my_bitmap ); + release_bitmap( bmp ); + */ +} + +void Bitmap::Blit( const int mx, const int my, const int wx, const int wy, const Bitmap & where ){ + BITMAP * bmp = where.getBitmap(); + ::blit( getBitmap(), bmp, mx, my, wx, wy, getBitmap()->w, getBitmap()->h ); +} + +void Bitmap::Blit( const int mx, const int my, const int width, const int height, const int wx, const int wy, Bitmap & where ){ + BITMAP * bmp = where.getBitmap(); + ::blit( getBitmap(), bmp, mx, my, wx, wy, width, height ); +} + +void Bitmap::Blit( const Bitmap & where ){ + this->Blit( 0, 0, where ); +} + +void Bitmap::BlitToScreen(){ + this->Blit( *Bitmap::Screen ); +} --- rafkill-1.2.2.orig/build/move.h +++ rafkill-1.2.2/build/move.h @@ -0,0 +1,121 @@ +#ifndef _move_h +#define _move_h + +#include "spaceobj.h" +#include + +using namespace std; + +//Most basic, just move whatever dx and dy are +class Move{ +public: + Move( double _dx, double _dy ); + + /* + virtual void setP( int & ax, int & ay, double & vx, double & vy ); + virtual void setD( double _dx, double _dy ); + */ + virtual void action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ); + /* + virtual double DX(); + virtual double DY(); + virtual double Accel_X(); + virtual double Accel_Y(); + */ + +protected: + + // virtual bool MoveReal(); + /* + virtual int AX(); + virtual int AY(); + */ + +protected: + /* + int * actualx; + int * actualy; + double * virtualx; + double * virtualy; + */ + const double o_dx; + const double o_dy; + /* + double dx, dy; + */ + double accel_x, accel_y; + +}; + +//Move from side to side +class MoveHorizontal: public Move{ +public: + MoveHorizontal( double _dx, double _dy ); + virtual void action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ); +protected: + int dir; +}; + +//Heads for the player +class MoveMine: public Move{ +public: + + MoveMine( double _dx, double _dy ); + virtual void action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ); +protected: + int fx, fy; + double sx, sy; +}; + +//Moves in circles +class MoveAngular: public Move{ +public: + MoveAngular( double _dx, double _dy ); + virtual void action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ); +protected: + int ang; + int dir; +}; + +//Moves down and slowly increases its positive dx speed +class MoveSwingRight: public Move{ +public: + MoveSwingRight( double _dx, double _dy ); + virtual void action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ); +}; + +//Move down and slowly increases its negative dx speed +class MoveSwingLeft: public Move{ +public: + MoveSwingLeft( double _dx, double _dy ); + virtual void action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ); +}; + +//Slowly increases its dy speed +class MoveSwingDown: public Move{ +public: + MoveSwingDown( double _dx, double _dy ); + virtual void action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ); +}; + +//Moves from side to side in a sine wave motion. +class MoveSine: public Move{ +public: + MoveSine( double _dx, double _dy ); + virtual void action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ); + +protected: + int ang; +}; + +class MoveCircle_Player: public Move{ +public: + MoveCircle_Player( double _dx, double _dy ); + virtual void action( const vector< SpaceObject * > * fight, int x, int y, double & sdx, double & sdy ); + +protected: + int ang; + int find_circle; +}; + +#endif --- rafkill-1.2.2.orig/build/section.h +++ rafkill-1.2.2/build/section.h @@ -0,0 +1,50 @@ +#ifndef _section_h +#define _section_h + +class SpaceObject; + +using namespace std; + +#include +#include + +#define MAX_SECTION_LIST_Y 20 +#define MAX_SECTION_OBJ_Y 30 +#define MIN_SECTION_Y 100 + +#define MAX_SECTION_LIST_X 40 +#define MAX_SECTION_OBJ_X 40 +#define MIN_SECTION_X 100 + +class Section{ +public: + + Section(); + + void add( SpaceObject * who, int x, int y ); + void reset(); + int spacerY(); + int spacerX(); + void clear(); + + vector< SpaceObject * > * getNext(); + + void dispose( SpaceObject * who ); + + //debug + void print(); + + ~Section(); + +protected: + //vector< SpaceObject * > container_list[ MAX_SECTION_LIST ]; + // vector< SpaceObject * > * container_list[ MAX_SECTION_LIST ]; + vector< SpaceObject * > container_list[ MAX_SECTION_LIST_Y ][ MAX_SECTION_LIST_X ]; + map< int, vector< SpaceObject * > * > lists; + map< int, vector< SpaceObject * > * >::iterator current_list; + int section_y, section_x; + // int internal_list; + +}; + +#endif --- rafkill-1.2.2.orig/build/rmenu.h +++ rafkill-1.2.2/build/rmenu.h @@ -0,0 +1,101 @@ +#ifndef _raptor_menu_h_ +#define _raptor_menu_h_ + +#include +#include "bitmap.h" + +using namespace std; + +class Font; +class RField; + +class RMenu{ +public: + + RMenu( const Bitmap & intr, int x, int y, int height, int c1, int c2, int title_color ); + + //addMenu: Adds a RField class to the list + virtual RField * addTitle( string title, Font * rf ); + virtual RField * addMenu( string menu, Font * rf, bool s, int r, RMenu * who, int sound ); + virtual RField * addMenu( const Bitmap & look, bool s, int r, RMenu * who, int sound ); + + //replace: Replaces a given RField with a new RField at position q in the list + virtual void replace( int q, string title, Font * rf, bool s, int r, RMenu * who, int sound ); + virtual void replaceTitle( int q, string title, Font * rf ); + virtual void replace( int q, const Bitmap & look, bool s, int r, RMenu * who, int sound ); + + //returns the place where field str lives, or -1 if cant find + virtual int askPos( string title ); + + //procMenu: Runs the current menu, returning the value of the menu + //and changing the current menu to the selected one + virtual int procMenu( RMenu ** current ); + + virtual void init(); + + virtual bool changed(); + + virtual void nextMenu( int q, RMenu * nx ); + + virtual void prevMenu( RMenu * rm ); + + virtual RMenu * Previous(); + + virtual void clear(); + + virtual bool Selected(); + + virtual ~RMenu(); + +protected: + + int countNodes(); + void spiffy_triangle( const Bitmap & work, int x1, int y1, int color, int * shade, int MAX_SHADE, int dir ); + virtual void Draw( const Bitmap & work, int x, int * yval, int * yshade, int min, int max ); + virtual void endMenu(); + + Bitmap background; + + int last_opt; + int first_x, first_y; + + int col1, col2; + int t_color; + RField * head, * location; + RMenu * prev; + + int * shade; + int * shade_border; + int * shade_opt_color; + + bool select; + +protected: + + Bitmap work; + + double x1; + int ang; + + int height; + + int col_up; + int col_down; + int opt_max; + int max_seen; //maximum number of fields on the screen at any one time + int * opts; + RField * field_seen; + int keep_y; + int * opts_shade; + RField * temp; + int ac_y; + bool k_hold; + int min_x; + int shade_counter; + + bool initialized; + bool change; + +}; + +#endif --- rafkill-1.2.2.orig/build/fonts.h +++ rafkill-1.2.2/build/fonts.h @@ -0,0 +1,80 @@ +/* Allegro datafile object indexes, produced by grabber v4.1.13 (WIP), Unix */ +/* Datafile: /home/kazzmir/archives/scratch/c++/jezzball/PCX_fonts/fonts.dat */ +/* Date: Wed Mar 31 14:12:06 2004 */ +/* Do not hand edit! */ + +#define ANDALEMONO_PCX 0 /* FONT */ +#define BROADWAY_PCX 1 /* FONT */ +#define CALIGRAPH_PCX 2 /* FONT */ +#define CATANEO_PCX 3 /* FONT */ +#define CENTURYGOTHIC_PCX 4 /* FONT */ +#define CORSIVA_PCX 5 /* FONT */ +#define FIXEDSYS_PCX 6 /* FONT */ +#define HIGHLIGHT_PCX 7 /* FONT */ +#define IRONMAIDEN_PCX 8 /* FONT */ +#define JOHNHANDY_PCX 9 /* FONT */ +#define JOKERMAN_PCX 10 /* FONT */ +#define KUNSTLER_PCX 11 /* FONT */ +#define LABAMBA_PCX 12 /* FONT */ +#define LCD_PCX 13 /* FONT */ +#define MEKANIK_PCX 14 /* FONT */ +#define METALLORD_PCX 15 /* FONT */ +#define MISTER_PCX 16 /* FONT */ +#define ODESSA_PCX 17 /* FONT */ +#define OLDDREAD_PCX 18 /* FONT */ +#define ONESTROKE_PCX 19 /* FONT */ +#define ORANGE_PCX 20 /* FONT */ +#define PARKAVENUE_PCX 21 /* FONT */ +#define PUMP_PCX 22 /* FONT */ +#define QUIXLEY_PCX 23 /* FONT */ +#define RAGE_PCX 24 /* FONT */ +#define RAUCH_PCX 25 /* FONT */ +#define SCRUFF_PCX 26 /* FONT */ +#define SMUDGER_PCX 27 /* FONT */ +#define SQUARE_PCX 28 /* FONT */ +#define STACCATO_PCX 29 /* FONT */ +#define TIRANTI_PCX 30 /* FONT */ +#define VICTORAIN_PCX 31 /* FONT */ +#define WOFACHABCER_PCX 32 /* FONT */ +#define WOFALDE_PCX 33 /* FONT */ +#define WOFAMBROS_PCX 34 /* FONT */ +#define WOFAMERUNI_PCX 35 /* FONT */ +#define WOFANDRO_PCX 36 /* FONT */ +#define WOFARGENT_PCX 37 /* FONT */ +#define WOFARIZONA_PCX 38 /* FONT */ +#define WOFARROW_PCX 39 /* FONT */ +#define WOFARTE_PCX 40 /* FONT */ +#define WOFBAIDER_PCX 41 /* FONT */ +#define WOFBARIUM_PCX 42 /* FONT */ +#define WOFBASTIA_PCX 43 /* FONT */ +#define WOFBATS_PCX 44 /* FONT */ +#define WOFBILIA_PCX 45 /* FONT */ +#define WOFBLADE_PCX 46 /* FONT */ +#define WOFBLIXA_PCX 47 /* FONT */ +#define WOFBONIX_PCX 48 /* FONT */ +#define WOFBORDER_PCX 49 /* FONT */ +#define WOFBOROLD_PCX 50 /* FONT */ +#define WOFBORSCH_PCX 51 /* FONT */ +#define WOFBURO_PCX 52 /* FONT */ +#define WOFCANDI_PCX 53 /* FONT */ +#define WOFCHIRO_PCX 54 /* FONT */ +#define WOFCLIPS_PCX 55 /* FONT */ +#define WOFCLOCK_PCX 56 /* FONT */ +#define WOFCLOCKER_PCX 57 /* FONT */ +#define WOFCOOL_PCX 58 /* FONT */ +#define WOFDELLI_PCX 59 /* FONT */ +#define WOFDRAKER_PCX 60 /* FONT */ +#define WOFEDUK_PCX 61 /* FONT */ +#define WOFELECTRO_PCX 62 /* FONT */ +#define WOFFIRNIS_PCX 63 /* FONT */ +#define WOFFITIO_PCX 64 /* FONT */ +#define WOFFLOW_PCX 65 /* FONT */ +#define WOFFUTUR_PCX 66 /* FONT */ +#define WOFGINEWRA_PCX 67 /* FONT */ +#define WOFHANDS_PCX 68 /* FONT */ +#define WOFHARDSH_PCX 69 /* FONT */ +#define WOFINTONA_PCX 70 /* FONT */ +#define WOFJOKER_PCX 71 /* FONT */ +#define WOFNEWART_PCX 72 /* FONT */ +#define ZLAST 73 /* BMP */ + --- rafkill-1.2.2.orig/build/spaceobj.h +++ rafkill-1.2.2/build/spaceobj.h @@ -0,0 +1,256 @@ +#ifndef _SpaceObject_h_ +#define _SpaceObject_h_ + +#include +#include "bitmap.h" + +using namespace std; + +class WeaponObject; +class ExplosionClass; +class Section; +class ECollide; +class Engine; +class Group; +class Vector; +class HullObject; + +class SpaceObject{ +public: + + SpaceObject( int startX, int startY, double velocityX, double velocityY, HullObject * mhull, Group * _group, int plane, int alignment ); + + // copy constructor, but should never be run. + SpaceObject( const SpaceObject & s ); + + //Hitme: calls hull->Inside( x, y, ax, ay ) + virtual bool HitMe( int ax, int ay ); + + //Collide: determines if have collided with another object + virtual bool Collide( SpaceObject * check); + + //Damage: decreases life returns true if 0 or less + virtual bool Damage( double much ); + + //Hurt: returns amount of damage object does when colliding with + //another object + virtual double Hurt(); + + //Draw: if plane == g then draw self + virtual void Draw( const Bitmap & less, ExplosionClass ** _expl, int MAX_EXPLR, int g, int offset )const; + + //Shadow: draw a shadow the same way as the Draw() method + virtual void Shadow( const Bitmap & less, int g, int offset ) const; + + // returns true if this object can be destroyed in the universe + // basically only playerobj cannot be destroyed + virtual bool Destroyable() const; + + //PowerUp: determines whether or not ship should turn into a powerup or money + virtual bool powerUp(); + + //GiveHull: replace old hull with hnew + virtual void giveHull( HullObject * hnew ); + + // push the coordinates onto mini-stack + virtual void savePosition(); + + // pop the coordinates from the mini-stack + virtual void restorePosition(); + + // true for powerups + virtual bool isSpecial() const; + + // true for ships that can get powerups + virtual bool acceptSpecial() const; + + virtual Group * getGroup(); + + // ammo - array of pointers to bullets + // fight - array of pointers to ships + virtual void MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ); + + //process: changes check according to death of object + virtual void Died(SpaceObject * check,ExplosionClass ** explr, int ME ); + + //process: increments objects score + virtual void IncScore( int j ); + + //returns hull->drawlevel + virtual int lookPlane() const; + + //process: returns whether or not object can be hit + virtual bool CanbeHit( const SpaceObject * ht ) const; + + //forces object to have no group + virtual void Independent(); + + //gives the hull a weapon at slot num + virtual void giveWeapon( WeaponObject * weap, int num ); + + virtual void eraseWeapon( int num ); + + virtual bool hullCollide( ECollide * col, int x, int y ); + virtual void Collided( SpaceObject * who, ExplosionClass ** explr, int M_EX ); + + //adds an object to the collide list + virtual void addCollide( SpaceObject * who ); + + //check to see if the object is in the collide list + virtual bool haveCollide( const SpaceObject * who ); + + //clears the collide list + virtual void clearCollide(); + + //destructor + virtual ~SpaceObject(); + + //returns an exact copy of this object + virtual SpaceObject * copy(); + + //draws self on the radar + virtual void Radar( const Bitmap & rad ) const; + + virtual inline void setX( int x ){ + actualx = x; + virtualx = x; + } + + virtual inline void setY( int y ){ + actualy = y; + virtualy = y; + } + + virtual inline void setX( double x ){ + actualx = (int)x; + virtualx = x; + } + + virtual inline void setY( double y ){ + actualy = (int)y; + virtualy = y; + } + + inline void setOffsetX( int x ){ + offset_x = x; + } + + inline void setOffsetY( int y ){ + offset_y = y; + } + + inline int getOffsetX(){ + return offset_x; + } + + inline int getOffsetY(){ + return offset_y; + } + + + virtual void setDX( double x ); + virtual void setDY( double y ); + virtual void setAccelX( double x ); + virtual void setAccelY( double y ); + virtual void setScore( int s ); + virtual void setStrength( int s ); + virtual void setPlane( int p ); + virtual void setAlignment( int a ); + + virtual HullObject * getHull() const; + + //return dx and dy respectively + virtual double getDX(); + virtual double getDY(); + + //return accelx and accely respectively + virtual double getAccelX(); + virtual double getAccelY(); + + //returns alignment + virtual inline const int getTeam() const{ + return alignment; + } + + //process: returns hull->life + + virtual int getMaxX(); + virtual int getMaxY(); + + inline int getX() const{ + return actualx + offset_x; + } + + inline int getY() const{ + return actualy + offset_y; + } + + inline double getVX() const{ + return virtualx; + } + + inline double getVY() const{ + return virtualy; + } + + virtual inline int getScore() const{ + return score; + } + + virtual inline int getStrength(){ + return str; + } + + virtual inline int getPlane(){ + return plane; + } + + virtual inline int getAlignment(){ + return alignment; + } + +public: + + // non-overridable methods + void addSection( Section * onscreen ); + + // applies dx, dy to coordinates + void MoveReal(); + + // returns life + double getLife() const; + + // set virtualx, virtualy, actualx, actualy + void SetCoordXY( int ax, int ay ); + +private: + + int actualx, actualy; // position in integer format + int old_x, old_y; + double virtualx, virtualy; // position in double format + double dx, dy; // velocity + double accel_x, accel_y; //acceleration + + int save_ax, save_ay; + double save_vx, save_vy; + +protected: + int score; + int str; + + // offset_x and offset_y alter getX() and getY() + // a hack? maybe + int offset_x, offset_y; + + int plane; + int alignment; + + HullObject * hull; + Group * my_group; + +protected: + vector< SpaceObject * > collide_list; + +}; + +#endif --- rafkill-1.2.2.orig/build/rfont.h +++ rafkill-1.2.2/build/rfont.h @@ -0,0 +1,40 @@ +#ifndef _raptor_font_h +#define _raptor_font_h + +#include "bitmap.h" + +class RGlyph{ +public: + RGlyph( int w, int h, unsigned char * dat, char mc ); + + void Draw( const Bitmap & work, int x, int y, int c ); + bool rightLetter( char x ); + int height(); + int width(); + + ~RGlyph(); + +protected: + unsigned char * data; + int _width; + int _height; + char letter; + +}; + +class RFont{ +public: + RFont( char * fname ); + + void rtext( const Bitmap & work, int x, int y, int c, const char * wr ); + int height(); + + ~RFont(); + +private: + RGlyph ** glyphs; + int max_glyphs; + +}; + +#endif --- rafkill-1.2.2.orig/build/ebox.cpp +++ rafkill-1.2.2/build/ebox.cpp @@ -0,0 +1,579 @@ +/* ebox version 2: + * by Jon Rafkind + */ + +#include "ebox.h" +#include +#include "bitmap.h" +#include +#include "timedifference.h" + +// using namespace Ebox2; + +#ifndef debug +// #define debug printf("File: %s Line: %d\n", __FILE__, __LINE__ ); +#define debug std::cout<<"File: "<<__FILE__<<" Line: "<<__LINE__<width ), +height( head->height ), +full( head->full ), +min_x( head->min_x ), +min_y( head->min_y ), +parent( NULL ), +num_quads( head->num_quads ){ + + for ( int q = 0; q < 4; q++ ) + quads[q] = NULL; + + for ( int i = 0; i < head->numQuads(); i++ ){ + // EQuad * tmp = head->getQuad( i ); + quads[i] = new EQuad( head->getQuad( i ) ); + quads[i]->parent = this; + } + +} + +EQuad::EQuad( int w, int h, EQuad * _parent ): +width( w ), +height( h ), +min_x( 0 ), +min_y( 0 ), +parent( _parent ), +num_quads( 0 ){ + full = true; + for ( int i = 0; i < 4; i++ ) + quads[i] = NULL; +} + +EQuad::EQuad( const Bitmap * who, int min_size, int mask_pixel, int _min_x, int _min_y, EQuad * _parent ): +width( who->getWidth() ), +height( who->getHeight() ), +full( false ), +min_x( _min_x ), +min_y( _min_y ), +parent( _parent ){ + + Bitmap * b1, * b2, * b3, * b4; + EQuad * quad1, * quad2, * quad3, * quad4; + quad1 = quad2 = quad3 = quad4 = NULL; + + if ( width > min_size && height > min_size ){ + + + int w = who->getWidth() >> 1; + int h = who->getHeight() >> 1; + + // b1 = create_sub_Bitmap( who, 0, 0, w, h ); + b1 = new Bitmap( *who, 0, 0, w, h ); + quad1 = new EQuad( b1, min_size, mask_pixel, 0, 0, this ); + // destroy_Bitmap( b1 ); + delete b1; + + // b2 = create_sub_Bitmap( who, w, 0, w, h ); + b2 = new Bitmap( *who, w, 0, w, h ); + quad2 = new EQuad( b2, min_size, mask_pixel, w, 0, this ); + delete b2; + // destroy_Bitmap( b2 ); + + + // b3 = create_sub_Bitmap( who, 0, h, w, h ); + b3 = new Bitmap( *who, 0, h, w, h ); + quad3 = new EQuad( b3, min_size, mask_pixel, 0, h, this ); + delete b3; + // destroy_Bitmap( b3 ); + + // b4 = create_sub_Bitmap( who, w, h, w, h ); + b4 = new Bitmap( *who, w, h, w, h ); + quad4 = new EQuad( b4, min_size, mask_pixel, w, h, this ); + delete b4; + // destroy_Bitmap( b4 ); + + if ( quad1->empty() ){ + delete quad1; + quad1 = NULL; + } + if ( quad2->empty() ){ + delete quad2; + quad2 = NULL; + } + if ( quad3->empty() ){ + delete quad3; + quad3 = NULL; + } + if ( quad4->empty() ){ + delete quad4; + quad4 = NULL; + } + + if ( quad1 && quad2 && quad3 && quad4 ) + if ( quad1->full && quad2->full && quad3->full && quad4->full ){ + delete quad1; + delete quad2; + delete quad3; + delete quad4; + quad1 = NULL; + quad2 = NULL; + quad3 = NULL; + quad4 = NULL; + full = true; + } + + checkQuad( quad1 ); + checkQuad( quad2 ); + checkQuad( quad3 ); + checkQuad( quad4 ); + + } else { + // printf("Size X:%d Y:%d\n", width, height ); + int total = 0; + for ( int x = 0; x < who->getWidth(); x++ ) + for ( int y = 0; y < who->getHeight(); y++ ){ + // int pixel = _getpixel16( who, x, y ); + int pixel = who->getPixel( x, y ); + if ( pixel != mask_pixel ) + ++total; + } + + if ( total*100/(who->getWidth()*who->getHeight()) > 50 ){ + full = true; + } + + } + + for ( int i = 0; i < 4; i++ ) + quads[i] = NULL; + + int i = 0; + if ( quad1 ) quads[i++] = quad1; + if ( quad2 ) quads[i++] = quad2; + if ( quad3 ) quads[i++] = quad3; + if ( quad4 ) quads[i++] = quad4; + + num_quads = numQuads(); + +} + +bool EQuad::addQuad( EQuad * who ){ + int n = numQuads(); + if ( n < 4 ){ + quads[n] = who; + full = false; + return true; + } else return false; +} + +void EQuad::checkQuad( EQuad *& q ){ + if ( q != NULL ){ + while ( q->numQuads() == 1 ){ + EQuad * const newquad = q->getQuad(); + q->detach( newquad ); + int x = q->getMinX(); + int y = q->getMinY(); + delete q; + q = newquad; + newquad->setMinX( newquad->getMinX() + x ); + newquad->setMinY( newquad->getMinY() + y ); + q->parent = this; + } + } +} + +int EQuad::totalQuads(){ + if ( full ) return 1; + int total = 0; + for ( int i = 0; i < numQuads(); i++ ) + if ( quads[i] ) + total += quads[i]->totalQuads(); + /* + if ( quad1 ) total += quad1->totalQuads(); + if ( quad2 ) total += quad2->totalQuads(); + if ( quad3 ) total += quad3->totalQuads(); + if ( quad4 ) total += quad4->totalQuads(); + */ + + return total; +} + +void EQuad::setMinX( int x ){ + min_x = x; +} + +void EQuad::setMinY( int y ){ + min_y = y; +} + +/* +int EQuad::numQuads() const{ + int total = 0; + / * + if ( quad1 ) ++total; + if ( quad2 ) ++total; + if ( quad3 ) ++total; + if ( quad4 ) ++total; + * / + for ( total = 0; total < 4 && quads[total] != NULL; total++ ); + + return total; +} +*/ + +EQuad * const EQuad::getQuad() const{ + return quads[0]; + /* + if ( quad1 ) return quad1; + if ( quad2 ) return quad2; + if ( quad3 ) return quad3; + if ( quad4 ) return quad4; + return NULL; + */ +} + +EQuad * const EQuad::getQuad( int x ) const{ + return quads[x]; +} + +void EQuad::detach( EQuad * const who ){ + + // printf("Detach %p\n", who ); + /* + if ( who == quad1 ) quad1 = NULL; + if ( who == quad2 ) quad2 = NULL; + if ( who == quad3 ) quad3 = NULL; + if ( who == quad4 ) quad4 = NULL; + */ + for ( int i = 0; i < numQuads(); i++ ) + if ( who == quads[i] ) + quads[i] = NULL; + + EQuad * tmp[ 4 ]; + int begin = 0; + for ( int i = 0; i < 4; i++ ) + if ( quads[i] ){ + tmp[begin++] = quads[i]; + quads[i] = NULL; + } + + for ( int q = 0; q < begin; q++ ) + quads[q] = tmp[q]; + +} + +int EQuad::calcSize(){ + int total = sizeof(*this); + for ( int q = 0; q < numQuads(); q++ ){ + total += quads[q]->calcSize(); + } + return total; +} + +bool EQuad::empty(){ + + if ( numQuads() == 0 ) return !full; + // if ( !quad1 && !quad2 && !quad3 && !quad4 ) return !full; + return false; + +} + +void EQuad::draw( const Bitmap & work, int x, int y, int color, bool flipped ){ + + int mx = x + getMinX(); + int my = y + getMinY(); + // std::cout<<"getMinX: "<getWidth() - (getMinX()+getWidth()); + // mx = getMinX() - parent->getWidth()/2 + x; + // my = y + parent->getHeight()/2 - getMinY(); + // my = y + getMinY(); + + // mx2 = mx - getWidth(); + // mx2 = mx + getWidth(); + + /* + int i; + i = mx; + mx = mx2; + mx2 = i; + */ + } + } + + int mx2 = mx + getWidth(); + int my2 = my + getHeight(); + + for ( int i = 0; i < numQuads(); i++ ) + quads[i]->draw( work, mx, my, color, flipped ); + + if ( full ) + work.rectangle( mx, my, mx2, my2, color ); + /* + if ( full ) + work->rectangle( x+getMinX(), y+getMinY(), x+getMinX()+getWidth(), y+getMinY()+getHeight(), Bitmap::makeColor(255,64,32) ); + else + work->rectangle( x+getMinX(), y+getMinY(), x+getMinX()+getWidth(), y+getMinY()+getHeight(), color ); + */ +} + +void EQuad::draw( const Bitmap & work, int x, int y, int color, EQuad * who ){ + + bool cy = false; + for ( int i = 0; i < numQuads(); i++ ) + if ( who == quads[i] ) + cy = true; + + int mx = x + getMinX(); + int my = y + getMinY(); + if ( cy ) + who->draw( work, mx, my, color ); + else { + for ( int i = 0; i < numQuads(); i++ ) + quads[i]->draw( work, mx, my, color, who ); + } + +} + +bool boxCollide( int zx1, int zy1, int zx2, int zy2, int zx3, int zy3, int zx4, int zy4 ){ + + if ( zx1 < zx3 && zx1 < zx4 && + zx2 < zx3 && zx2 < zx4 ) return false; + if ( zx1 > zx3 && zx1 > zx4 && + zx2 > zx3 && zx2 > zx4 ) return false; + if ( zy1 < zy3 && zy1 < zy4 && + zy2 < zy3 && zy2 < zy4 ) return false; + if ( zy1 > zy3 && zy1 > zy4 && + zy2 > zy3 && zy2 > zy4 ) return false; + + return true; + +} + +bool EQuad::collide( int mx, int my, int x1, int y1, int x2, int y2, EQuad ** last, bool xflipped, bool yflipped ){ + + int rx = mx + getMinX(); + int ry = my + getMinY(); + + if ( parent ){ + if ( xflipped ){ + rx = mx + parent->getWidth() - (getMinX()+getWidth()); + } + if ( yflipped ){ + ry = my + parent->getHeight() - (getMinY()+getHeight()); + } + } + int rx2 = rx + getWidth(); + int ry2 = ry + getHeight(); + + // rect( screen, rx, ry, rx2, ry2, makecol(255,255,0) ); + + bool cy = boxCollide( rx, ry, rx2, ry2, x1, y1, x2, y2 ); + if ( !cy ) return false; + + for ( int i = 0; i < numQuads(); i++ ) + if ( quads[i]->collide( rx, ry, x1, y1, x2, y2, last ) ) + return true; + + if ( !full ) return false; + if ( cy ) *last = this; + return cy; + + return false; + +} + +EQuad::~EQuad(){ + /* + if ( quad1 ) delete quad1; + if ( quad2 ) delete quad2; + if ( quad3 ) delete quad3; + if ( quad4 ) delete quad4; + */ + + for ( int q = 0; q < 4; q++ ) + if ( quads[q] != NULL ) + delete quads[q]; +} + +long long ECollide::totalTime = 0; +void ECollide::initECollide( const Bitmap * who, int mask_pixel ){ + /* + TimeDifference dif; + dif.startTime(); + */ + head_quad = new EQuad( who, MIN_SIZE, mask_pixel, 0, 0, NULL ); + last_collide = NULL; + + /* + dif.endTime(); + totalTime += dif.getTime(); + cout<<"Total time taken: "<< totalTime / 1000 <<" ms" <head_quad ); + /* + last_collide = NULL; + head_quad = new EQuad( e->head_quad ); + */ +} + +ECollide::ECollide( const ECollide & e ){ + initQuad( e.head_quad ); + /* + last_collide = NULL; + head_quad = new EQuad( e.head_quad ); + */ +} + +ECollide::ECollide( EQuad * const head ){ + initQuad( head ); + /* + last_collide = NULL; + head_quad = new EQuad( head ); + */ +} + +void ECollide::initQuad( EQuad * const head ){ + last_collide = NULL; + head_quad = new EQuad( head ); +} + +ECollide * ECollide::copy(){ + return new ECollide( head_quad ); +} + +int ECollide::getMinHeight(){ + return head_quad->getMinY(); +} + +int ECollide::getMaxHeight(){ + return head_quad->getMinY() + head_quad->getHeight(); +} + +int ECollide::getMinWidth(){ + return head_quad->getMinX(); +} + +int ECollide::getMaxWidth(){ + return head_quad->getMinX() + head_quad->getWidth(); +} + +int ECollide::calcSize(){ + int total = sizeof(*this); + if ( head_quad ) + total += head_quad->calcSize(); + return total; +} + +bool ECollide::collide( int mx, int my, int x1, int y1, int x2, int y2, bool xflipped, bool yflipped ){ + + last_collide = NULL; + + return head_quad->collide(mx,my,x1,y1,x2,y2,&last_collide, xflipped, yflipped ); + +} + +bool ECollide::Collision( int mx, int my, int ax, int ay, bool xflipped, bool ylfipped ){ + + return collide( mx, my, ax, ay, ax, ay ); + +} + +bool ECollide::Collision( int mx, int my, int x1, int y1, int x2, int y2, bool xflipped, bool yflipped ){ + + return collide( mx, my, x1, y1, x2, y2 ); + +} + +bool ECollide::Collision( ECollide * col, int mx, int my, int ax, int ay, bool my_xflipped, bool my_yflipped, bool him_xflipped, bool him_yflipped ){ + if ( !col ) return false; + + int x1 = mx > ax ? mx : ax; + int y1 = my > ay ? my : ay; + int x2 = (mx+getWidth()) < (ax+col->getWidth()) ? (mx+getWidth()) : (ax+col->getWidth()); + int y2 = (my+getHeight()) < (ay+col->getHeight()) ? (my+getHeight()) : (ay+col->getHeight()); + + if ( x1 > x2 ) return false; + if ( y1 > y2 ) return false; + + return ( collide(mx,my,x1,y1,x2,y2,my_xflipped,my_yflipped) && col->collide(ax,ay,x1,y1,x2,y2,him_xflipped,him_yflipped) ); + +} + +/* +int ECollide::getWidth() const{ + return head_quad->getWidth(); +} + +int ECollide::getHeight() const{ + return head_quad->getHeight(); +} +*/ + +void ECollide::draw( const Bitmap & work, int x, int y, bool flipped ){ + + head_quad->draw( work, x, y, Bitmap::makeColor(255,255,255), flipped ); + +} + +int ECollide::numQuads() const{ + return head_quad->totalQuads(); +} + +void ECollide::draw( const Bitmap & work, int x, int y, int color, EQuad * who ){ + if ( head_quad == who ) + head_quad->draw( work, x, y, color ); + else head_quad->draw( work, x, y, color, who ); +} + +EQuad * ECollide::getLast(){ + return last_collide; +} + +ECollide::~ECollide(){ + delete head_quad; +} --- rafkill-1.2.2.orig/build/trigtable.cpp +++ rafkill-1.2.2/build/trigtable.cpp @@ -0,0 +1,289 @@ +#include "trigtable.h" +#include "defs.h" +#include + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +/* +double tcos[360]; +double tsine[360]; +double rsine[360]; +double ttan[360]; +*/ + +double tsqr( const double r ) { + return r*r; +} + + +long int tcube( const long int c ) { + return c*c*c; +} + + +double fsqr( double r ) { + return r*r; +} + + +double fcube( double r ) { + return r*r*r; +} + + +double tsqrt( const double q ) { + + return sqrt( q ); + + if ( q <= 0 ) + return 0; + + long int min = 0; + + while ( tsqr( min ) < q ) + min += 30; + + while ( tsqr( min ) > q ) + min -= 10; + + while ( tsqr( min ) < q ) + min++; + + if ( tsqr( min ) > q ) + min--; + return min; + +} + + +double dist( const int x1, const int y1, const int x2, const int y2 ) { + + double a = tsqr( y1 - y2 ); + double b = tsqr( x1 - x2 ); + + return tsqrt( a + b ); + +} + +double zdist( int x, int y, int x1, int y1 ) { + + double a = tsqr(x-x1); + double b = tsqr(y-y1); + return sqrt( a+b ); +} + + +long int area( int x1, int y1, int x2, int y2, int x3, int y3 ) { + double d1 = zdist(x1,y1,x2,y2); + double d2 = zdist(x1,y1,x3,y3); + double d3 = zdist(x2,y2,x3,y3); + double s = ( d1 + d2 + d3 ) / 2.0; + // area = sqrt( s * (s-d1) * (s-d2) * (s-d3) ) + long int atotal = (long int)(sqrt(s*(s-d1)) * sqrt((s-d2)*(s-d3))); + return atotal; +} + + +bool ptriangle( int tx1, int ty1, int tx2, int ty2, int tx3, int ty3, int x1, int y1 ) { + long int atotal = area( tx1, ty1, tx2, ty2, tx3, ty3 )+2; + long int a1 = area( tx1, ty1, tx2, ty2, x1, y1 ); + if ( a1 > atotal ) return false; + long int a2 = area( tx1, ty1, tx3, ty3, x1, y1 ); + if ( a2 > atotal ) return false; + long int a3 = area( tx2, ty2, tx3, ty3, x1, y1 ); + if ( a3 > atotal ) return false; + if ( a1+a2+a3 > atotal ) + return false; + return true; +} + + +bool prect( int px1, int py1, int x1, int y1, int x2, int y2 ) { + + if ( px1 >= x1 && px1 <= x2 && py1 >= y1 && py1 <= y2 ) + return true; + return false; +} + +/* +int sarctan( const double tr ) { + + if ( tr == 0.0 ) + return 0; + int my_ang = 0; + double precision = fabs(ttan[0] - tr ); + for ( int r = 1; r < 180; r++ ) { + + double dif = fabs( ttan[r] - tr ); + if ( dif == 0 ) + return r; + + if ( dif < precision ) { + precision = dif; + my_ang = r; + + } + + } + return my_ang; + +} +*/ + +/* +int barctan( const double tr ) { + + int my_ang = 180; + double precision = fabs(ttan[180] - tr ); + for ( int r = 181; r < 360; r++ ) { + + double dif = fabs( ttan[r] - tr ); + if ( dif <= precision ) { + precision = dif; + my_ang = r; + + } + + } + return my_ang; + +} +*/ + + +int lineIntersect( int ax, int ay, int bx, int by, int cx, int cy, int dx, int dy, int *ix, int *iy ) { + float r, s; + float denom = (bx-ax)*(dy-cy)-(by-ay)*(dx-cx); + + r = (float)((ay-cy)*(dx-cx)-(ax-cx)*(dy-cy))/denom; + s = (float)((ay-cy)*(bx-ax)-(ax-cx)*(by-ay))/denom; + + if ( r < 0.0 || s < 0.0 || r > 1.0 || s > 1.0 ) + return 0; + + *ix=ax+(int)(r*(float)(bx-ax)+0.5); + *iy=ay+(int)(r*(float)(by-ay)+0.5); + + return 1; + +} // end lineIntersect + +/* nicer name for gang */ +int getAngle( int x1, int y1, int x2, int y2 ){ + return gang( x1, y1, x2, y2 ); +} + +int gang( int x1, int y1, int x2, int y2 ) { + + int tang = 0; + if ( x1 == x2 ) { + if ( y1 < y2 ) + tang = 90; + else + tang = 270; + } + if ( y1 == y2 ) { + + if ( x1 < x2 ) + tang = 0; + else + tang = 180; + + } else + tang = (int)(0.5+atan2( (double) -(y2-y1), (double) (x2 - x1) ) * 180.0 / M_PI ); + + while ( tang < 0 ) + tang += 360; + return tang % 360; + +} + + +int arcsine( double x ) { + + int tang = (int)(0.5 + asin( x * 180.0 / M_PI) ); + while ( tang < 0 ) + tang += 360; + return tang % 360; + +} + + +/* +int find_sin_pos( double q, bool side ) +{ + + double low = 9999; + int keep; + for ( int x = side*90; x <= side*90+90; x++ ) + { + + if ( fabs(tsine[x]-q) < low ) + { +low = fabs(tsine[x]-q); +keep = x; +} + +} +return keep; + +} + +int find_sin_neg( double q, bool side ) +{ + +double low = 9999; +int keep; +for ( int x = side*90+180; x < side*90+270; x++ ) +{ + +if ( fabs(tsine[x]-q) < low ) +{ +low = fabs(tsine[x]-q); +keep = x; +} + +} +return keep; + +} + +int mang( int x1, int y1, int x2, int y2 ) +{ + +if ( x1 == x2 )return 0; +if ( y1 == y2 )return 0; + +int t1 = dist( x1, y1, x2, y2 ); +if ( y2 > y1 ) +{ +double cr = (double)t1 / (double)( y2 - y1 ); +return find_sin_pos( cr, x1>x2 ); +} +else +{ +double cr = (double)t1 / (double)( y1 - y2 ); +return find_sin_neg( cr, x1>x2 ); +} + +} +*/ + +/* +void set_trig() { + for ( int r = 0; r<360; r++ ) { + + tcos[ r ] = cos( (double)(r) * AL_PI / 180.0 ); + tsine[ r ] = -sin( (double)(r) * AL_PI / 180.0 ); + rsine[ r ] = sin( (double)(r) * AL_PI / 180.0 ); + + if ( tcos[r] == 0.0 ) + ttan[r] = 99999.0; + else + ttan[ r ] = tsine[r] / tcos[r]; + + } +} +*/ --- rafkill-1.2.2.orig/build/init.cpp +++ rafkill-1.2.2/build/init.cpp @@ -0,0 +1,50 @@ +#include +#include "defs.h" +#include +#include + +void inc_speed_counter() { + Util::speed_counter++; +} + +END_OF_FUNCTION( inc_speed_counter ); + +void init( int windowMode, int GAME_SPEED ) { + + allegro_init(); + srand( time( NULL ) ); + install_timer(); + install_keyboard(); + + /* + if ( get_desktop_resolution(&Util::screen_x,&Util::screen_y) == -1 ){ + Util::screen_x = 640; + Util::screen_y = 480; + } + */ + + set_color_depth( 16 ); + if ( windowMode ){ + Bitmap::setGfxModeWindowed( GRAPHICS_X, GRAPHICS_Y ); + } else { + Bitmap::setGfxModeFullscreen( GRAPHICS_X, GRAPHICS_Y ); + } + + reserve_voices (8, -1); + set_volume_per_voice( 0 ); + install_sound( DIGI_AUTODETECT, MIDI_NONE, "" ); + atexit( &dumb_exit ); + dumb_register_packfiles(); + + LOCK_VARIABLE( speed_counter ); + LOCK_FUNCTION( (void *)inc_speed_counter ); + install_int_ex( inc_speed_counter, MSEC_TO_TIMER( GAME_SPEED ) ); + Util::explColor(); + set_trans_blender( 0, 0, 0, 128 ); + //set_config_int( "sound", "quality", 2 ); + get_config_int( "sound", "quality", 2 ); + Util::sound_vol = 1.0; //max volume to begin with + // music_vol = 0.50; + dumb_resampling_quality = get_config_int( "sound", "dumb_resampling_quality", 1 ); +} + --- rafkill-1.2.2.orig/build/sound.h +++ rafkill-1.2.2/build/sound.h @@ -0,0 +1,18 @@ +/* Allegro datafile object indexes, produced by grabber v4.1.13 (WIP), Unix */ +/* Datafile: /home/kazzmir/archives/scratch/c++/raptor/rap/data/sound.dat */ +/* Date: Sat May 8 12:27:08 2004 */ +/* Do not hand edit! */ + +#define INTRO_MENU_SELECT 0 /* SAMP */ +#define MENU_BUTTON 1 /* SAMP */ +#define SND_CODE_RED 2 /* SAMP */ +#define SND_EXPLODE_1 3 /* SAMP */ +#define SND_EXPLODE_2 4 /* SAMP */ +#define SND_FIGHT 5 /* SAMP */ +#define SND_GUN_1 6 /* SAMP */ +#define SND_HEALTH 7 /* SAMP */ +#define SND_HULL_COLLIDE 8 /* SAMP */ +#define SND_METAL 9 /* SAMP */ +#define SND_POWER 10 /* SAMP */ +#define SND_SUSTAIN 11 /* SAMP */ + --- rafkill-1.2.2.orig/build/drawer.cpp +++ rafkill-1.2.2/build/drawer.cpp @@ -0,0 +1,313 @@ +#include "drawer.h" +#include "playerobj.h" +#include "bitmap.h" +#include "explode.h" +#include "timedifference.h" +#include "hulls/hull_player.h" +#include "spaceobj.h" +#include +#include +#include "defs.h" +#include "trigtable.h" +#include "pck.h" +#include + +/* TODO: + * Add weapon icons to HUD + */ + +using namespace std; + +#ifndef debug +#define debug cout<<"File: "<<__FILE__<< " Line:"<<__LINE__<fill( Bitmap::makeColor(10,40,10) ); + + Util::blend_palette( warning_shade, MAX_WARNING_SHADE/2, Bitmap::makeColor(85,0,0), Bitmap::makeColor(255,0,0) ); + Util::blend_palette( warning_shade+MAX_WARNING_SHADE/2, MAX_WARNING_SHADE/2, Bitmap::makeColor(255,0,0), Bitmap::makeColor(85,0,0) ); + + Util::blend_palette( shade_energy, MAX_ATTRIBUTE_COLOR, Bitmap::makeColor(255,0,0), Bitmap::makeColor(255,255,255) ); + Util::blend_palette( shade_shield, MAX_ATTRIBUTE_COLOR, Bitmap::makeColor(0,100,140), Bitmap::makeColor(255,255,255) ); + + land = loadLand(); +} + +Bitmap * Drawer::loadLand(){ + + pckLoader p; + const char * ff = "1.pck"; + switch ( Util::rnd( 3 ) ) { + case 0 : ff = "1.pck";break; + case 1 : ff = "2.pck";break; + case 2 : ff = "3.pck";break; + } + + /* TODO: fix */ + Bitmap * ld = p.load( ff ); + if ( !ld ) { + printf("Supreme error with land Bitmap\n"); + return NULL; + } + + land_counter = 0; + // blit( ld, screen, 0, 0, 0, 0, GRAPHICS_X, GRAPHICS_Y ); + + /* + Bitmap * who = get_rle_sprite( ld ); + destroy_Bitmap( ld ); + */ + // Bitmap * who = new Bitmap(10,10); + + return ld; + +} + +void Drawer::fadeToBlack( int num ){ + // cout << "Fade to black " << num << endl; + if ( num < 255 ){ + setDrawTrans(); + } + Bitmap::transBlender( 0, 0, 0, num ); +} + +void Drawer::drawHud( const PlayerObject * player ){ + + if ( player->getLife() < 30 ) { + // rectfill( work, view_port, 0+Y_BLIT_OFFSET, view_port+GRAPHICS_X-1, 10+Y_BLIT_OFFSET, warning_shade[warning_shade_color] ); + work->rectangleFill( view_port, Y_BLIT_OFFSET, view_port+GRAPHICS_X-1,10+Y_BLIT_OFFSET,warning_shade[warning_shade_color] ); + // rectfill( work, view_port, GRAPHICS_Y-10+Y_BLIT_OFFSET, view_port+GRAPHICS_X-1, GRAPHICS_Y-1+Y_BLIT_OFFSET, warning_shade[warning_shade_color] ); + work->rectangleFill( view_port, GRAPHICS_Y-10+Y_BLIT_OFFSET, view_port+GRAPHICS_X-1, GRAPHICS_Y-1+Y_BLIT_OFFSET, warning_shade[warning_shade_color] ); + if ( ++warning_shade_color > MAX_WARNING_SHADE ) warning_shade_color = 0; + } + + // Show the player's score at the bottom left of the screen + int score = player->getScore(); + char temp[ 64 ]; + sprintf( temp, "Score %d", score ); + /* TODO: fix */ + Font font = Util::getNormalFont(); + work->printf( view_port + 11, GRAPHICS_Y - font.getHeight() - 2 + Y_BLIT_OFFSET, Bitmap::makeColor(255,128,0), &font, temp ); + + int level_use = ( (PlayerObject *)player )->getLevel(); + if ( level_speech < 120 ) { + + int speech[ 30 ]; + Util::blend_palette( speech, 10, Bitmap::makeColor( 255, 0, 120 ), Bitmap::makeColor(150,220,20) ); + Util::blend_palette( speech+10, 10, Bitmap::makeColor(150, 220, 20), Bitmap::makeColor(20,160,255) ); + Util::blend_palette( speech+10+10, 10, Bitmap::makeColor(20,160,255), Bitmap::makeColor(255,0,120) ); + + level_speech++; + char temp[ 64 ]; + snprintf( temp, 64, "level %d", level_use ); + int vx = 300; + int vy = 200; + for ( unsigned int q = 0; q < strlen( temp ); q++ ) { + int sy = (int)(vy + Tsine( (int) (((level_speech+q*2)*12)%360) )*8); + int sx = vx + q * 10; + int col = 32 + ((level_speech+q*2)%20); + col = speech[ (level_speech+q) % 30 ]; + // textprintf_ex( work, font, sx+view_port, sy+Y_BLIT_OFFSET, col, -1, "%c", temp[q] ); + work->printf( sx+view_port, sy+Y_BLIT_OFFSET, col, &font, "%c", temp[q] ); + } + } + + // Show the player's health and shield on the sides of the screen + PlayerHull * ph = (PlayerHull *)(player->getHull()); + + showAttribute( (int)ph->getLife(), (int)ph->getMaxLife(), view_port+GRAPHICS_X-10, Y_BLIT_OFFSET, shade_energy ); + showAttribute( (int)ph->getShield(), (int)ph->getMaxShield(), view_port+1, Y_BLIT_OFFSET, shade_shield ); + +} + +void Drawer::showAttribute( int amount, int MAX, int start_x, int offset, int * shade ) { + const int start_attr = 470; + for ( int z = 0; z < amount; z++ ) { + + int x1 = start_x; + int x2 = start_x + 9; + int start = start_attr * z / MAX; + int y1 = start_attr - start + offset; + int y2 = y1 + 1; + + int num = z * MAX_ATTRIBUTE_COLOR / MAX; + if ( num >= MAX_ATTRIBUTE_COLOR ){ + num = MAX_ATTRIBUTE_COLOR - 1; + } + int color = shade[num]; + // rectfill( work, x1, y1, x2, y2, color ); + work->rectangleFill( x1, y1, x2, y2, color ); + + } +} + +void Drawer::drawLand( int view, int y1 ) { + + // clear( work ); + /* TODO: fix */ + /* + draw_rle_sprite( work, land, view, y1-GRAPHICS_Y+Y_BLIT_OFFSET ); + draw_rle_sprite( work, land, view, y1+Y_BLIT_OFFSET ); + */ + + land->Blit( view, y1+Y_BLIT_OFFSET, *work ); + land->Blit( view, y1-GRAPHICS_Y+Y_BLIT_OFFSET, *work ); +} + +void Drawer::Draw( const vector< SpaceObject * > * objects, const SpaceObject * player, ExplosionClass ** expl, int MAX_EXPL ){ + + TimeDifference time; + + time.startTime(); + + if ( player != NULL ){ + if ( player->getX() < view_port + SCROLL_VIEW ) + view_port = player->getX() - SCROLL_VIEW; + if ( player->getX() > view_port + GRAPHICS_X - SCROLL_VIEW ) + view_port += player->getX() - ( view_port + GRAPHICS_X - SCROLL_VIEW ); + } + + if ( view_port < 0 ) view_port = 0; + if ( view_port > Util::screen_x - GRAPHICS_X ) view_port = Util::screen_x - GRAPHICS_X; + + /* + * Some crazy people from allegro said you should do this + * cuase windows directX blows and might mess up if you dont. + */ + // acquire_Bitmap( work ); + // work->acquire(); + + /* + time.endTime(); + time.printTime( "Drawer 1: " ); + time.startTime(); + */ + + /* Either draw the background or clear it */ + if ( draw_land ){ + drawLand( view_port, land_counter ); + } else { + work->rectangleFill( view_port, Y_BLIT_OFFSET, view_port+GRAPHICS_X, GRAPHICS_Y+Y_BLIT_OFFSET, Bitmap::makeColor(0,0,0) ); + } + + /* + time.endTime(); + time.printTime( "Drawer 2: " ); + time.startTime(); + */ + + land_counter = (land_counter+1) % 480; + + map< int, vector< const SpaceObject * > > map_draw; + for ( vector< SpaceObject *>::const_iterator it = objects->begin(); it != objects->end(); ++it ){ + SpaceObject * m = *it; + if ( m == 0 ) continue; + vector< const SpaceObject * > & vec = map_draw[ (*it)->lookPlane() ]; + vec.push_back( *it ); + } + + /* add player to the vector of the plane he is in */ + if ( player != NULL ){ + vector< const SpaceObject * > & player_vec = map_draw[ player->lookPlane() ]; + player_vec.push_back( player ); + } + + for ( map< int, vector< const SpaceObject * > >::iterator it = map_draw.begin(); it != map_draw.end(); ++it ){ + vector< const SpaceObject * > & vec = (*it).second; + int plane = (*it).first; + + for ( vector< const SpaceObject * >::const_iterator ship = vec.begin(); ship != vec.end(); ++ship ){ + const SpaceObject * s = *ship; + + s->Shadow( *work, plane, Y_BLIT_OFFSET ); + s->Draw( *work, expl, MAX_EXPL, plane, Y_BLIT_OFFSET ); + s->Radar( *radar ); + } + } + + /* + time.endTime(); + time.printTime( "Drawer 3: " ); + time.startTime(); + */ + + /* Draw all the explosions. */ + for ( int q = 0; q < MAX_EXPL; q++ ) { + if ( expl[q] != NULL ) + expl[q]->Draw( work, Y_BLIT_OFFSET ); + } + + /* + if ( time(NULL) != timex ) { + fsec_keep = fsec; + fsec = 0; + timex = time(NULL); + } + */ + + if ( player != NULL ){ + drawHud( (const PlayerObject *)player ); + } + + /* + if ( finished ) { + + } + */ + + /* Draw all the important things */ + + radar->drawTrans( view_port, Y_BLIT_OFFSET, *work ); + radar->fill( Bitmap::makeColor(10,60,30) ); + radar->rectangle( 0, 0, RADAR_X-1, RADAR_Y-1, Bitmap::makeColor(200,200,200) ); + + if ( drawTrans ){ + /* Get the current viewport */ + Bitmap trans( *work, view_port, Y_BLIT_OFFSET, Util::screen_x, Util::screen_y ); + // trans.drawTrans( 0, 0, *Bitmap::Screen ); + /* Draw it translucently onto a buffer */ + trans.drawTrans( 0, 0, *transBuffer ); + + /* Blit the buffer to the screen */ + transBuffer->Blit( 0, 0, 0, 0, *Bitmap::Screen ); + } else { + work->Blit( view_port, Y_BLIT_OFFSET, 0, 0, *Bitmap::Screen ); + } + + /* + time.endTime(); + time.printTime( "Drawer 4: " ); + cout << endl; + */ +} + +Drawer::~Drawer(){ + + delete work; + delete radar; + delete transBuffer; + // destroy_Bitmap( work ); + +} --- rafkill-1.2.2.orig/build/level.cpp +++ rafkill-1.2.2/build/level.cpp @@ -0,0 +1,1164 @@ +#include "level.h" +#include "shipobj.h" +#include "spaceobj.h" +#include +#include +#include +#include "defs.h" +#include "strings.h" +#include "raptor.h" +#include "ebox.h" +#include "trigger.h" +#include "trigtable.h" +#include "group.h" +#include "bitmap.h" +#include "playerobj.h" +#include + +#include "move.h" +#include "move_find.h" + +#include "guns/gun_destruct.h" +#include "guns/gun_edfstraight.h" +#include "guns/gun_ednstraight.h" +#include "guns/gun_eflarge.h" +#include "guns/gun_efmsingle.h" +#include "guns/gun_efsingle.h" +#include "guns/gun_elarge.h" +#include "guns/gun_emissle.h" +#include "guns/gun_ecork.h" +#include "guns/gun_emlight.h" +#include "guns/gun_eside.h" +#include "guns/gun_etwirl.h" +#include "guns/gun_etwirl_find.h" +#include "guns/gun_etwirl_machine.h" +#include "guns/gun_estraight.h" +#include "guns/gun_fire.h" +#include "hulls/hull_ship_shield.h" +#include "hulls/hull_meteor.h" +#include "hulls/hull_animation.h" + +using namespace std; + +#define SHIP_TRIGGER 0 +#define POWER_TRIGGER 1 +#define METEOR_ON_TRIGGER 2 +#define METEOR_OFF_TRIGGER 3 +#define HEALTH_TRIGGER 4 + +#define MAX_ENEMY_GUNS 15 +#define MAX_ENEMY_MOVE 9 +#define MAX_ENEMY_HULL (SHIP_LAST-SHIP0_FIRST-1) +#define space_cracker ( sizeof(int)*6 + sizeof(double)*2 + sizeof(char)*7 ) +//6 integers = x, y, gun, hull, move, life +//2 doubles = dx, dy +//7 spaces between numbers + +static int gl_map( int who ); + +/* this is ok as long as only one LevelCreator is alive at any one time */ +static vector< Bitmap > hull_money_shadows; +static ECollide ** gl_collide; +const int MAX_GL_COLLIDE = (SHIP_LAST-SHIP0_FIRST-1) + 6; + +void LevelCreator::makeInfo( char * tmp, int & current ) { + + /* + //scramble( buffer, space_cracker ); + scramble( tmp, space_cracker ); + + int x1, y1; + double dx, dy; + int gun, move, hull_num; + + x1 = *( (int *)tmp ); + tmp += sizeof( int ) + 1; + + y1 = *( (int *)tmp ); + tmp += sizeof( int ) + 1; + + dx = *( (double *)tmp ); + tmp += sizeof( double ) + 1; + + dy = *( (double *)tmp ); + tmp += sizeof( double ) + 1; + + gun = *( (int *)tmp ); + tmp += sizeof( int ) + 1; + + move = *( (int *)tmp ); + tmp += sizeof( int ) + 1; + + hull_num = *( (int *)tmp ); + info[current] = new info_holder; + info[current]->x = x1; + info[current]->y = y1; + info[current]->dx = dx; + info[current]->dy = dy; + info[current]->gun = gun; + info[current]->hull = hull_num; + info[current]->move = move; + + current++; + */ + +} + + +void LevelCreator::put_ship( int x, int y, double dx, double dy, int hull, int gun, int move, int life ) { + + char * buf = new char[ space_cracker ]; + char * tmp = buf; + *(int *)tmp = x; + tmp += sizeof( int ); + *tmp = ' '; + tmp++; + + *(int *)tmp = y; + tmp += sizeof( int ); + *tmp = ' '; + tmp++; + + *(double *)tmp = dx; + tmp += sizeof( double ); + *tmp = ' '; + tmp++; + + *(double *)tmp = dy; + tmp += sizeof( double ); + *tmp = ' '; + tmp++; + + *(int *)tmp = gun; + tmp += sizeof( int ); + *tmp = ' '; + tmp++; + + *(int *)tmp = move; + tmp += sizeof( int ); + *tmp = ' '; + tmp++; + + *(int *)tmp = hull; + tmp += sizeof( int ); + *tmp = '\n'; + tmp++; + *(int *)tmp = life; + + //trigger * add_t = new triggerEnemy( buf, space_cracker, SHIP_TRIGGER, x, y ); + //trigger_list.push_back( add_t ); + +} + + +Group * LevelCreator::randomGroup( int x, int y ) { + + Group * who_group = new Group( y ); + + int gun = Util::rnd( MAX_ENEMY_GUNS ); + int move = Util::rnd( MAX_ENEMY_MOVE ); + int hull = Util::rnd( MAX_ENEMY_HULL ); + while ( !accept_guns[ gun ] ) + gun = Util::rnd( MAX_ENEMY_GUNS ); + while ( !accept_hull[ hull ] ) + hull = Util::rnd( MAX_ENEMY_HULL ); + while ( !accept_move[ move ] ) + move = Util::rnd( MAX_ENEMY_MOVE ); + + double dx = (double)Util::rnd(2000) / 200.0 - 5.0; + double dy = (double)Util::rnd(1300) / 300.0 + 3.0; + int pattern = Util::rnd( 9 ); + + switch( pattern ) { + + case 0 : { + new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy),who_group); + new EnemyGeneric( x + 60, y, getHull(hull,1,accept_hull[hull]), getWeapon(gun), getMove(move,dx,dy), who_group); + break; + + } + case 1 : { + + new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x+60,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x+120,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + + break; + + } + case 2 : { + + new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x+140,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x+70,y+30,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x,y+60,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x+140,y+60,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + + break; + } + case 3 : { + + new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x+40,y+20,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x+80,y+40,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x+120,y+20,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x+160,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + + break; + + } + + case 4 : { + int spacer = Util::rnd( 2 ) * 15 + 20; + + new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x,y-spacer,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x,y-spacer*2,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + + break; + + } + + case 5 : { + int spacer = Util::rnd( 5 ) * 10 + 25; + new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x,y-spacer*1,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x,y-spacer*2,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x,y-spacer*3,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x,y-spacer*4,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + + break; + + } + case 6 : { + + int ang = 270-20*2; + for ( int q = 0; q < 5; q++ ) { + new EnemyGeneric((int)(x+Tcos(ang)*85),(int)(y+Tsine(ang)*90),getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + ang += 20; + } + + break; + } + case 7 : { + new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x+100,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x+50,y+40,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + + break; + + } + + case 8 : { + + new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x+100,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x,y+40,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + new EnemyGeneric(x+100,y+40,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ); + + break; + + } + + } //switch + + return who_group; + +} + + +void LevelCreator::randomShip( int x, int y, Group * who_group, vector< SpaceObject * > * sh ) { + + int gun = Util::rnd( MAX_ENEMY_GUNS ); + int move = Util::rnd( MAX_ENEMY_MOVE ); + int hull = Util::rnd( MAX_ENEMY_HULL ); + while ( !accept_guns[ gun ] ) + gun = Util::rnd( MAX_ENEMY_GUNS ); + while ( !accept_hull[ hull ] ) + hull = Util::rnd( MAX_ENEMY_HULL ); + while ( !accept_move[ move ] ) + move = Util::rnd( MAX_ENEMY_MOVE ); + + double dx = (double)Util::rnd(2000) / 200.0 - 5.0; + double dy = (double)Util::rnd(1300) / 300.0 + 3.0; + int pattern = Util::rnd( 9 ); + + switch( pattern ) { + + case 0 : { + sh->push_back( new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x+60,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + break; + + } + case 1 : { + + sh->push_back( new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x+60,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x+120,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + + break; + + } + case 2 : { + + sh->push_back( new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x+140,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x+70,y+30,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x,y+60,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x+140,y+60,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + + break; + } + case 3 : { + + sh->push_back( new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x+40,y+20,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x+80,y+40,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x+120,y+20,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x+160,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + + break; + + } + + case 4 : { + int spacer = Util::rnd( 2 ) * 15 + 20; + + sh->push_back( new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x,y-spacer,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x,y-spacer*2,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + + break; + + } + + case 5 : { + int spacer = Util::rnd( 5 ) * 10 + 25; + sh->push_back( new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x,y-spacer*1,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x,y-spacer*2,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x,y-spacer*3,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x,y-spacer*4,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + + break; + + } + case 6 : { + + int ang = 270-20*2; + for ( int q = 0; q < 5; q++ ) { + sh->push_back( new EnemyGeneric((int)(x+Tcos(ang)*85),(int)(y+Tsine(ang)*90),getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + ang += 20; + } + + break; + } + case 7 : { + sh->push_back( new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x+100,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x+50,y+40,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + + break; + + } + + case 8 : { + + sh->push_back( new EnemyGeneric(x,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x+100,y,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x,y+40,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + sh->push_back( new EnemyGeneric(x+100,y+40,getHull(hull,1,accept_hull[hull]),getWeapon(gun),getMove(move,dx,dy), who_group ) ); + + break; + + } + + } //switch + +} + + +/* +int LevelCreator::file_length( FILE * fv ){ + + fseek( fv, 0, SEEK_END ); + int l = ftell( fv ); + fseek( fv, 0, SEEK_SET ); + return l; + +} +*/ + +char * LevelCreator::get_token( char * list, char find ) { + + while ( *list != 0 && *list != find ) list++; + if ( *list == 0 ) return NULL; + return list; + +} + +/* processFile: + * Reads a file to determine how the level will be set up. + * File determines the following things: + * - What kind of enemies can be made + * - What kind of guns can they have + * - What kind of movement patterns can they have + */ +int LevelCreator::processFile( const char * file_name ) { + + // This function is so obvuios, it needs no comments + + bool use_hull[ MAX_ENEMY_HULL ]; + bool use_guns[ MAX_ENEMY_GUNS ]; + bool use_move[ MAX_ENEMY_MOVE ]; + + for ( int q = 0; q < MAX_ENEMY_HULL; q++ ) + use_hull[q] = false; + for ( int q = 0; q < MAX_ENEMY_MOVE; q++ ) + use_move[q] = false; + for ( int q = 0; q < MAX_ENEMY_GUNS; q++ ) + use_guns[q] = false; + + FILE * fv = fopen( file_name, "rb" ); + if ( !fv ) { + printf("Playing %s without rules\n", file_name ); + return 0; + } + + while ( !feof( fv ) ) { + + char * words = new char[ 1024 ]; + fgets( words, 1024, fv ); + + if ( *words != '#' ) { + + char * line = words; + if ( *line == '[' ) { + + line++; + char * syntax = line; + line = get_token( line, ']' ); + if ( line == NULL ) { + delete[] words; + return 1; + } + *line = '\0'; + line++; + upstring( syntax ); + line = get_token( line, '=' ); + if ( line == NULL ) { + delete[] words; + return 1; + } + line++; + while( *line != 0 ) { + + while ( *line == ' ' && *line != '\n' && *line != 0 ) line++; + char * num = line; + while ( *line != ' ' && *line != '\n' && *line != 0 ) line++; + if ( *line != 0 ) { + *line = '\0'; + line++; + } else *line = '\0'; + + int use = str2int( num ); + + if ( strcasecmp(syntax,"HULL") == 0 ) + if ( use >= 0 && use < MAX_ENEMY_HULL ) + use_hull[ use ] = true; + if ( strcasecmp(syntax,"GUNS") == 0 ) + if ( use >= 0 && use < MAX_ENEMY_GUNS ) + use_guns[ use ] = true; + if ( strcasecmp(syntax,"MOVE") == 0 ) + if ( use >= 0 && use < MAX_ENEMY_MOVE ) + use_move[ use ] = true; + + } + + } + + } + + delete[] words; + + } + + bool cy = false; + for ( int q = 0; q < MAX_ENEMY_GUNS; q++ ) + if ( use_guns[q] ) cy = true; + + if ( cy ) + for ( int q = 0; q < MAX_ENEMY_GUNS; q++ ) + if ( !use_guns[q] ) accept_guns[q] = 0; + + cy = false; + for ( int q = 0; q < MAX_ENEMY_MOVE; q++ ) + if ( use_move[q] ) cy = true; + + if ( cy ) + for ( int q = 0; q < MAX_ENEMY_MOVE; q++ ) + if ( !use_move[q] ) accept_move[q] = 0; + + cy = false; + for ( int q = 0; q < MAX_ENEMY_HULL; q++ ) + if ( use_hull[q] ) cy = true; + + if ( cy ) + for ( int q = 0; q < MAX_ENEMY_HULL; q++ ) + if ( !use_hull[q] ) accept_hull[q] = 0; + + return 0; + +} + + +double LevelCreator::life_level( double level, int min ) { + // Some stupid equation to determine how much life an enemy should get + return level * fsqr(level+min) / 4.0; + + // A recursive way of doing it. Not to good!! + if ( level == 0 ) return min; + double d = life_level( level-1, min ); + return sqrt( fsqr( d ) * level * 2.0 ) / sqrt( level + 1 ) + d/3.0 + level*2; + +} + +Group * LevelCreator::Boss( int y, int _life ){ + + Group * who_group = new Group( y ); + /* TODO: fix + + new EnemyGeneric( Util::screen_x/2 ,y, new HullObject( (BITMAP *)global_data[BOSS_01].dat, _life, SHIP_DAMAGE,1,1,10,false,gl_collide[gl_map(BOSS_01)] ), getWeapon(13),getMove(9,5,5), who_group ); + */ + + return who_group; + +} + +Group * LevelCreator::makeCloud( int x, int y ){ + + Group * who_group = new Group( y ); + // double dy = (double)Util::rnd(120) / 50.0 - 1.0; + /* TODO: fix + new ShipObject( x, y, 0, new HullObject((BITMAP *)global_data[CLOUD1].dat, 1,0,0,0,Util::rnd( 7 ) + 6, true, NULL ), who_group, new Move( 0, 3.0+dy ), TEAM_ENEMY ); + */ + return who_group; + + +} + +void LevelCreator::load_file( const char * file_name, SpaceObject * player ) { + + accept_guns = new int[ MAX_ENEMY_GUNS ]; + accept_hull = new int[ MAX_ENEMY_HULL ]; + accept_move = new int[ MAX_ENEMY_MOVE ]; + + int dif = ( (PlayerObject *)player )->getDifficulty(); + double lev = ( (PlayerObject *)player )->getLevel(); + int min = 1; + int max = 2; + + double life_enhance = 1; + switch ( dif ) { + case 1 : life_enhance = 0.80; min = 2; max = 5;break; + case 2 : life_enhance = 0.90; min = 3; max = 6;break; + case 3 : life_enhance = 1.0; min = 4; max = 8;break; + case 4 : life_enhance = 1.20; min = 5; max = 10;break; + case 5 : life_enhance = 1.35; min = 6; max = 12;break; + } + + for ( int q = 0; q < MAX_ENEMY_GUNS; q++ ) + accept_guns[q] = 1; + for ( int q = 0; q < MAX_ENEMY_MOVE; q++ ) + accept_move[q] = 1; + + int min_life = (int)life_level( lev, min ); + int max_life = min_life / 2 + min_life; + + meteor_life = min_life; + + for ( int q = 0; q < MAX_ENEMY_HULL; q++ ) { + int ml; + ml = Util::rnd( max_life - min_life ) + min_life; + accept_hull[q] = ml; + } + + if ( processFile( file_name ) != 0 ) + printf("Error processing %s. Skipping..\n", file_name ); + + /* length of level */ + int peak = 7000 + dif * 250; + + // peak = 500; + + /* + for ( int ay = 70; ay < peak; ay += 160 ){ + + int m = Util::rnd( dif ) + 1; + for ( int ac = 0; ac < m; ac++ ){ + + int x = Util::rnd( Util::screen_x - 100 ) + 100; + int y = -(ay + Util::rnd( 20 ) - 10 ); + + char * fake_data = new char[ 2 ]; + trigger * add_t = new trigger( fake_data, 2, SHIP_TRIGGER, x, y ); + trigger_list.push_back( add_t ); + } + + } + */ + + // Make a bunch of groups randomly + for ( int ay = 100; ay < peak; ay += 160 ) { + int m = Util::rnd( dif ) + 1; + for ( int ac = 0; ac < m; ac++ ) { + int x = Util::rnd( Util::screen_x - 100 ) + 100; + int y = -(ay + Util::rnd( 20 ) - 10 ); + group_list.push_back( randomGroup( x, y ) ); + + //if ( Util::rnd( 3 ) == Util::rnd( 3 ) ) + // group_list.push_back( makeCloud( x, y + Util::rnd( 30 ) ) ); + } + + if ( Util::rnd( 3 ) ) + group_list.push_back( makeCloud( Util::rnd( Util::screen_x - 100 ) + 100, -(ay + Util::rnd(30)-10) ) ); + } + + // Sup boss.. + //group_list.push_back( Boss( -(peak+200), max_life * 130 ) ); + + // Make some triggers of varied type + char * fake_data = new char[ 2 ]; + trigger * add_t = new trigger( fake_data, 2, POWER_TRIGGER, Util::rnd( Util::screen_x - 100 ) + 100, -7000 + Util::rnd( 100 ) ); + trigger_list.push_back( add_t ); + for ( int q = 0; q < Util::rnd( 5 ); q++ ) { + + fake_data = new char[ 2 ]; + *fake_data = Util::rnd( 50 ) + 5; + add_t = new trigger( fake_data, 2, METEOR_ON_TRIGGER, Util::rnd( Util::screen_x - 100 ) + 100, -( Util::rnd( 6000 ) + 1000 ) ); + trigger_list.push_back( add_t ); + + } + for ( int q = 0; q < Util::rnd( 5 ); q++ ) { + fake_data = new char[ 2 ]; + add_t = new trigger( fake_data, 2, METEOR_OFF_TRIGGER, Util::rnd( Util::screen_x - 100 ) + 100, -( Util::rnd( 6000 ) + 1000 ) ); + trigger_list.push_back( add_t ); + } + for ( int q = 0; q < Util::rnd( 3 ); q++ ) { + fake_data = new char[ 2 ]; + add_t = new trigger( fake_data, 2, HEALTH_TRIGGER, Util::rnd( Util::screen_x - 100 ) + 100, -( Util::rnd( 4000 ) + 3000 ) ); + trigger_list.push_back( add_t ); + } +} + +/* LevelCreator: + * Constructor. Creates all ECollides that enemies will use. Loads the level from a file. + */ +LevelCreator::LevelCreator( const char * file_name, SpaceObject * player ) { + //info = new info_holder*[ MAX_SHIPS ]; + counter = 0; + lerror = false; + max_use = 0; + + num_cloud = 0; + meteor_chance = 0; + + trigger_list.clear(); + + + //total collide objects = total ships + meteor + money + powerup + weaponup + health + boss + gl_collide = new ECollide*[ MAX_GL_COLLIDE ]; + for ( int q = 0; q < MAX_GL_COLLIDE; q++ ) + gl_collide[q] = NULL; + for ( int q = SHIP0_FIRST+1; q < SHIP_LAST; q++ ){ + // gl_collide[ gl_map( q ) ] = new ECollide((BITMAP *)global_data[q].dat,6,makecol(255,0,255),42); + Bitmap l = Util::getDataSprite( q ); + gl_collide[ gl_map( q ) ] = new ECollide( &l ); + } + + // gl_collide[ gl_map(METEOR_1) ] = new ECollide((BITMAP *)global_data[METEOR_1].dat); + gl_collide[ gl_map(METEOR_1) ] = new ECollide( Util::getDataSprite( METEOR_1 ) ); + gl_collide[ gl_map(COIN_1) ] = new ECollide( Util::getDataSprite( COIN_1 ) ); + gl_collide[ gl_map(POWERUP_1)] = new ECollide( Util::getDataSprite( POWERUP_1 ) ); + gl_collide[ gl_map(WEAPONUP_001) ] = new ECollide( Util::getDataSprite( WEAPONUP_001 ) ); + gl_collide[ gl_map(HEALTH_001) ] = new ECollide( Util::getDataSprite( HEALTH_001 ) ); + gl_collide[ gl_map(BOSS_01) ] = new ECollide( Util::getDataSprite( BOSS_01 ) ); + /* + gl_collide[ gl_map(METEOR_1) ] = new ECollide((BITMAP *)Util::global_data[METEOR_1].dat,6,makecol(255,0,255),45); + gl_collide[ gl_map(COIN_1) ] = new ECollide((BITMAP *)Util::global_data[COIN_1].dat,6,makecol(255,0,255),52); + gl_collide[ gl_map(POWERUP_1)] = new ECollide((BITMAP *)Util::global_data[POWERUP_1].dat,6,makecol(255,0,255),52); + gl_collide[ gl_map(WEAPONUP_001) ] = new ECollide((BITMAP *)Util::global_data[WEAPONUP_001].dat,6,makecol(255,0,255),52); + gl_collide[ gl_map(HEALTH_001) ] = new ECollide( (BITMAP *)Util::global_data[HEALTH_001].dat,6,makecol(255,0,255),52); + gl_collide[ gl_map(BOSS_01) ] = new ECollide( (BITMAP *)Util::global_data[BOSS_01].dat,6,makecol(255,0,255),52); + */ + + char final_file[ 4096 ]; + Util::getDataPath( final_file, file_name ); + // char * final_file = Util::data_file( file_name ); + + group_list.clear(); + load_file( final_file, player ); + // free( final_file ); + + current_counter = 0; + + int mpics = COIN_A_20 - COIN_1 + 1; + for ( int q = 0; q < mpics; q++ ){ + + Bitmap bitmap = Bitmap( Util::getDataSprite( COIN_1 + q ), true ); + Bitmap use = Util::getDataSprite( COIN_1 + q ); + + hull_money_shadows.push_back( bitmap ); + int m = 22; + bitmap.fill( Bitmap::makeColor( m, m, m ) ); + use.drawMask( 0, 0, bitmap ); + } +} + +/* noExist: + * Return an error cuase we screwed up somewhere + */ +bool LevelCreator::noExist() { + return lerror; +} + +/* Draw: + * What was I thinking? Maybe ill put some code here eventually + */ +void LevelCreator::Draw( BITMAP * work, int xfac, int yfac ) { +} + +/* gl_map: + * Recursive call to find the appropriate value for a defined constant + */ +static int gl_map( int who ) { + + if ( who >= SHIP0_FIRST && who <= SHIP_LAST ) + return who-(SHIP0_FIRST+1); + if ( who == METEOR_1 ) + return gl_map(SHIP_LAST-1)+1; + if ( who == COIN_1 ) + return gl_map(METEOR_1)+1; + if ( who == POWERUP_1 ) + return gl_map(COIN_1)+1; + if ( who == WEAPONUP_001 ) + return gl_map(POWERUP_1)+1; + if ( who == HEALTH_001 ) + return gl_map(WEAPONUP_001)+1; + if ( who == BOSS_01 ) + return gl_map(HEALTH_001)+1; + return 0; + +} + +/* done: + * Returns true if level is done making things. + * Whoa, look at all those return statements. They are there for beauty and ambieance( sp? ). + */ +bool LevelCreator::done() { + + return group_list.empty(); + + return trigger_list.empty(); + + if ( counter == 0 ) { + int total = 0; + //for ( int q = 0; q <= max_use; q++ ) + // if ( info[q] != NULL ) total++; + if ( total == 0 ) + counter = 500; + } else if( counter > 1 )counter--; + return counter == 1; +} + + +/* +void LevelCreator::emergency( vector< SpaceObject * > * sh ){ + + if ( Util::rnd( 260 ) == Util::rnd( 260 ) ){ + + int x = Util::rnd( Util::screen_x - 50 ) + 50; + int y = -100; + + int mpics = HEALTH_021 - HEALTH_001 + 1; + BITMAP ** pics = new BITMAP*[ mpics ]; + for ( int q = 0; q < mpics; q++ ) +pics[ q ] = (BITMAP *)Util::global_data[ HEALTH_001 + q ].dat; + +sh->push_back(new Health(x,y,new HullAnimation( pics, mpics,1,0,0,0,10,false,gl_collide[gl_map(HEALTH_001)]),new Move(0,4.5))); +} +} +*/ + +static SpaceObject * createCloak( const int x, const int y ){ + vector< Bitmap > pics; + int mpics = 0; + + mpics = WEAPONUP_020 - WEAPONUP_001 + 1; + for ( int q = 0; q < mpics; q++ ){ + pics.push_back( Util::getDataSprite( WEAPONUP_001 + q ) ); + } + return new Cloak( x, y, new HullAnimation(pics, vector< Bitmap >(), 1, 0, 0, 0, 10, false, gl_collide[gl_map(WEAPONUP_001)]), new Move(0,2.5) ); + +} + +static SpaceObject * createPowerUp( const int x, const int y ){ + vector< Bitmap > pics; + + int mpics = POWERUP_A_14 - POWERUP_1 + 1; + for ( int q = 0; q < mpics; q++ ){ + pics.push_back( Util::getDataSprite( POWERUP_1 + q ) ); + } + return new PowerUp( x, y, new HullAnimation( pics, vector< Bitmap >(), 1, 0, 0, 0, 10, false, gl_collide[gl_map(POWERUP_1)]), new Move(0,2.5) ); + +} + +static SpaceObject * createHealth( const int x, const int y ){ + + vector< Bitmap > pics; + int mpics = HEALTH_021 - HEALTH_001 + 1; + for ( int q = 0; q < mpics; q++ ){ + pics.push_back( Util::getDataSprite( HEALTH_001 + q ) ); + } + return new Health( x, y, new HullAnimation(pics,vector< Bitmap >(), 1, 0, 0, 0, 10, false, gl_collide[gl_map(HEALTH_001)]), new Move( 0, 2.5 ) ); + +} + +static SpaceObject * createMoney( const int x, const int y, const SpaceObject * player ){ + + vector< Bitmap > pics; + int mpics = COIN_A_20 - COIN_1 + 1; + for ( int q = 0; q < mpics; q++ ){ + pics.push_back( Util::getDataSprite( COIN_1 + q ) ); + } + + int lev = -1; + int min = 10; + int max = 4000; + if ( player != NULL ) { + lev = ( (PlayerObject *)player )->getLevel(); + min = 10*lev; + max = 2000*lev; + } + + int q = Util::rnd( max - min ) + min; + + return new Money( x, y, q, new HullAnimation( pics, hull_money_shadows, 1, 0, 0, 0, 10, false, gl_collide[gl_map(COIN_1)] ), new Move( 0, 2 ) ); + +} + +/* special: + * Makes a special item. Can be one of the following: + * - Powerup + * - Cloak + * - Health + * - Money + */ +SpaceObject * LevelCreator::special( int x, int y, const SpaceObject * player ) { + + + if ( Util::rnd( 50 ) == Util::rnd( 50 ) ) { + return createCloak( x, y ); + } + + if ( Util::rnd( 60 ) == Util::rnd( 60 ) ) { + return createPowerUp( x, y ); + } + + /* if the player has low life increase the chances a health will appear */ + int h_rnd = 21; + if ( player != NULL ){ + if ( player->getLife() < 30 ) h_rnd = 4; + } + + if ( Util::rnd( h_rnd ) == Util::rnd( h_rnd ) ) { + return createHealth( x, y ); + } + + return createMoney( x, y, player ); + // return NULL; + +} + +/* getHull: + * Some of the enemies have special hulls associated with them, so they need their own class + */ +HullObject * LevelCreator::getHull( int a, int l, int _life ) { + a++; + + /* TODO: fix + switch( a ) { + //case 0 : return new OrbHull( l ); + //case 1 : return new ShardHull( l ); + //case 2 : return new TangoHull( Util::rnd(32) + 32, l ); + //case 3 : return new HeliHull( (BITMAP *)Util::global_data[SHIP_003].dat, _life, l, gl_collide[gl_map(SHIP_003)] ); + case 5 : return new ShieldHull( (BITMAP *)Util::global_data[SHIP_005].dat, _life, l, gl_collide[gl_map(SHIP_005)] ); + //case 5 : return new StrongHull( Util::rnd(32) + 32, l ); + //case 6 : return new SplitHull( Util::rnd(32) + 32, l ); + //case 7 : return new HullObject( BLOCK, 100, 0, 0, 0, 8, NULL ); + //case 8 : return new Ship6(l); + //case 9 : return new Ship7(l); + case 8 : { + HullObject * h = new HullObject( (BITMAP *)Util::global_data[SHIP_008].dat,_life,SHIP_DAMAGE,2,l,10,false,gl_collide[gl_map(SHIP0_FIRST+a)] ); + h->giveWeapon( new GunDestruct(1,TEAM_ENEMY), 1 ); + return h; + } + case 9 : { + + int mpics = HELICOPTER_6 - HELICOPTER_1 + 1; + BITMAP ** pics = new BITMAP*[ mpics ]; + for ( int q = 0; q < mpics; q++ ) + pics[q] = (BITMAP *)Util::global_data[ HELICOPTER_1 + q ].dat; + + return new HullAnimation( pics, mpics, NULL,_life, SHIP_DAMAGE, 1, l, 10, false, gl_collide[gl_map(SHIP0_FIRST+a)] ); + + } + } + */ + return new HullObject( new Bitmap( Util::getDataSprite( SHIP0_FIRST + a ) ), _life, SHIP_DAMAGE,1,l,10,false,gl_collide[gl_map(SHIP0_FIRST+a)] ); +} + + +int LevelCreator::hullNum( int a, int l ) { + a++; + return SHIP0_FIRST+a; + switch( a ) { + case 1 : return SHIP_001; + case 2 : return SHIP_002; + case 4 : return SHIP_004; + case 6 : return SHIP_006; + case 7 : return SHIP_007; + } + return -1; +} + +/* getWeapon: + * Return a weapon depending on its number + */ +WeaponObject * LevelCreator::getWeapon( int a ) { + switch( a ) { + case 0 : return new EnemyStraightShooter( 1, TEAM_ENEMY ); + case 1 : return new EnemyLargeStraightShooter( 1, TEAM_ENEMY ); + case 2 : return new EnemyDoubleNearStraightShooter( 1, TEAM_ENEMY ); + case 3 : return new EnemyDoubleFarStraightShooter( 1, TEAM_ENEMY ); + case 4 : return new EnemyFindSingle( 1, TEAM_ENEMY ); + case 5 : return new WeaponFire( 1, 1, TEAM_ENEMY ); + case 6 : return new EnemyFindSingleMachine( 1, TEAM_ENEMY ); + case 7 : return new EnemyFindLarge( 1, TEAM_ENEMY ); + case 8 : return new EnemyMachineLight( 1, TEAM_ENEMY ); + case 9 : return new EnemyMissle( 1, TEAM_ENEMY ); + case 10 : return new EnemySide( 1, TEAM_ENEMY ); + case 11 : return new EnemyTwirlStraight( 1, TEAM_ENEMY ); + case 12 : return new EnemyTwirlFind( 1, TEAM_ENEMY ); + case 13 : return new EnemyTwirlMachine( 1, TEAM_ENEMY ); + case 14 : return new EnemyCork( 1, TEAM_ENEMY ); + } + return NULL; +} + +/* getMove: + * Return a movement style depending on its number + */ +Move * LevelCreator::getMove( int a, double _dx, double _dy ) { + if ( _dy <= 0 ) + _dy = 1; + switch( a ) { + case 0 : return new Move( _dx, _dy ); + case 1 : return new MoveHorizontal( _dx, _dy ); + case 2 : return new MoveMine( _dx, _dy ); + case 3 : return new MoveAngular( _dx, _dy ); + case 4 : return new MoveSwingRight( _dx, _dy ); + case 5 : return new MoveSwingLeft( _dx, _dy ); + case 6 : return new MoveSine( _dx, _dy ); + case 7 : return new MoveSwingDown( _dx, _dy ); + case 8 : return new MoveCircle_Player( _dx, _dy ); + case 9 : return new MoveFind( _dx, _dy ); + } + return new Move( 0, 2 ); +} + +/* GetEnemy: + * Returns NULL. Whoa + */ +SpaceObject * LevelCreator::GetEnemy( int cx, int cy, int hu,int we,int m,double _dx,double _dy ) { + + //HullObject * can; + /* + if ( hullNum( hu, 1 ) == -1 ) can = GetHull(hu,1); + else can = new HullObject( hullNum(hu,1), 20+Util::rnd(15), SHIP_DAMAGE, 1, 1, 10,gl_collide[gl_map(hullNum(hu,1))]); + */ + //can = GetHull( hu, 1 ); + + //return new EnemyGeneric(cx,cy,can,GetWeapon(we),GetMove(m,_dx,_dy) ); + return NULL; +} + +/* create: + * Puts new enemies into the enemy list. + */ +void LevelCreator::create( vector< SpaceObject * > * sh, int leva, const double & speed ) { + + current_counter -= 2; + + /* Search through all the groups. If group is close enough to the player, put + * all the ships the group contains into the object list passed to create via `sh'. + */ + for ( vector< class Group * >::iterator it = group_list.begin(); it != group_list.end(); ) { + + Group * group = *it; + + if ( group->pos() + 100 >= current_counter ) { + for ( vector< class SpaceObject * >::const_iterator vv = group->members()->begin(); vv != group->members()->end(); vv++ ) { + SpaceObject * object = *vv; + object->SetCoordXY( object->getX(), object->getY() - group->pos() - 100 ); + sh->push_back( object ); + } + it = group_list.erase( it ); + } else ++it; + + } + + /* Search through all triggers and activate them if they are close enough to the player */ + for ( vector< class trigger * >::iterator it = trigger_list.begin(); it != trigger_list.end(); it++ ) { + + if ( (*it)->CY()+100 >= current_counter ) { + switch( (*it)->kind() ) { + + //case SHIP_TRIGGER : sh->push_back((SpaceObject *)(*it)->get(this));break; + /*case SHIP_TRIGGER : { + + Group * mg = new Group(); + randomShip( (*it)->CX(), -100, mg, sh ); + break; + + } + */ + // Power_Trigger: Creates a powerup + case POWER_TRIGGER : { + /* TODO: fix + int mpics = POWERUP_A_14 - POWERUP_1 + 1; + BITMAP ** pics = new BITMAP * [ mpics ]; + for ( int q = 0; q < mpics; q++ ) + pics[q] = (BITMAP *)global_data[ POWERUP_1 + q ].dat; + sh->push_back( new PowerUp( (*it)->CX(), -100, new HullAnimation(pics,mpics,NULL,1,0,0,0,10,false,gl_collide[gl_map(POWERUP_1)]), new Move(0,5) ) ); + */ + break; + + } + // Meteor_on_trigger: Sets the meteor random number to be greater + // than 0 so that meteors are created during gameplay. + case METEOR_ON_TRIGGER : { + char * num = (char *)(*it)->get( NULL ); + meteor_chance = *num; + break; + } + // Meteor_off_trigger: Sets meteor random number to 0 so that + // no meteors are created during gameplay. + case METEOR_OFF_TRIGGER : meteor_chance = 0; break; + + // Health_trigger: Creates a health. + case HEALTH_TRIGGER : { + + /* TODO: fix + int mpics = HEALTH_021 - HEALTH_001 + 1; + BITMAP ** pics = new BITMAP * [ mpics ]; + for ( int q = 0; q < mpics; q++ ) + pics[q] = (BITMAP *)global_data[ HEALTH_001 + q ].dat; + sh->push_back( new Health( (*it)->CX(), -100, new HullAnimation(pics,mpics,NULL,1,0,0,0,10,false,gl_collide[gl_map(HEALTH_001)]), new Move(0,4.5) ) ); + */ + + break; + } + + } + + // We have used the trigger, so we must kill it + (*it)->kill(); + } + + } + + /* Delete all triggers that have been killed */ + for ( vector< class trigger * >::iterator it = trigger_list.begin(); it != trigger_list.end(); ){ + if ( (*it)->kind() == -1 ) { + trigger * temp = *it; + it = trigger_list.erase( it ); + delete temp; + } else ++it; + } + + /* Game isnt over, so make some whacky things for your amusement! */ + if ( !done() ) { + + if ( num_cloud ) num_cloud--; + + // Make a meteor with some velocity + if ( Util::rnd( meteor_chance ) == Util::rnd( meteor_chance ) && meteor_chance > 0 ) { + + /* TODO: fix + double dx = (double)( Util::rnd(90) ) / (double)( 25 ) * (Util::rnd(2)*2-1); + double dy = (double)( Util::rnd(200) ) / (double)( 25 ) + 2.3; + //int lv = (int)( 25.0 + real_level * 2 ); + //SpaceObject * use = new ShipObject( Util::rnd( 640 ), Util::rnd( 30 ) - 50, 40, new MeteorHull(leva,lv,gl_collide[ gl_map(METEOR_1) ] ), NULL, new Move(dx,dy), TEAM_ENEMY ); + int mpics = METEOR_9_20 - METEOR_1 + 1; + BITMAP ** pics = new BITMAP*[ mpics ]; + for ( int q = 0; q < mpics; q++ ) + pics[ q ] = (BITMAP *)global_data[ METEOR_1 + q ].dat; + + SpaceObject * use = new MeteorObject(Util::rnd(640),Util::rnd(30)-50,-meteor_life*3, new HullAnimation( pics, mpics,NULL,meteor_life,0,0,0,10,false,gl_collide[gl_map(METEOR_1)]), new Move(dx,dy) ); + + sh->push_back( use ); + */ + } + + /* + else if ( Util::rnd( 80 ) == Util::rnd( 80 ) && !num_cloud ) { + + // Make a fancy cloud! + num_cloud = 60; + + double dy = (double)Util::rnd(120) / 50.0 - 1.0; + SpaceObject * use = new ShipObject( Util::rnd(640), -200, 0, new HullObject((BITMAP *)global_data[CLOUD1].dat, 1,0,0,0,Util::rnd( 7 ) + 6, true, NULL ), NULL, new Move( 0, 3.0+dy ), TEAM_ENEMY ); + sh->push_back( use ); + } + */ + } + +} + +/* destructor + */ +LevelCreator::~LevelCreator() { + + // Delete all triggers + for ( vector< class trigger * >::iterator it = trigger_list.begin(); it != trigger_list.end(); ) { + trigger * temp = *it; + it = trigger_list.erase( it ); + delete temp; + } + + // Delete all groups and their associated ships + for ( vector< class Group * >::iterator it = group_list.begin(); it != group_list.end(); ){ + Group * del = *it; + it = group_list.erase( it ); + delete del; + } + + // Delete all ECollides that were stored for optimization + for ( int q = 0; q < MAX_GL_COLLIDE; q++ ) + if ( gl_collide[q] != NULL ) + delete gl_collide[q]; + delete[] gl_collide; + delete[] accept_hull; + delete[] accept_guns; + delete[] accept_move; + + hull_money_shadows.clear(); + + /* + for ( int q = 0; q < max_money_shadow; q++ ) + destroy_bitmap( hull_money_shadows[q] ); + delete[] hull_money_shadows; + */ +} --- rafkill-1.2.2.orig/build/loadsave.h +++ rafkill-1.2.2/build/loadsave.h @@ -0,0 +1,8 @@ +#ifndef _loadsave_h +#define _loadsave_h + +class SpaceObject; +int savePlayer( SpaceObject * player, int game_slot ); +SpaceObject * loadPlayer( int game_slot ); + +#endif --- rafkill-1.2.2.orig/build/timedifference.cpp +++ rafkill-1.2.2/build/timedifference.cpp @@ -0,0 +1,35 @@ +#include "timedifference.h" +#include +#include +using namespace std; + +TimeDifference::TimeDifference(){ + start.tv_usec = 0; + start.tv_sec = 0; + end.tv_usec = 0; + end.tv_sec = 0; +} + +void TimeDifference::printTime(){ + + this->printTime("Function"); + +} + +unsigned long long int TimeDifference::getTime(){ + unsigned long long int g = (end.tv_sec*1000000+end.tv_usec) - (start.tv_sec*1000000 + start.tv_usec ); + return g; +} + +void TimeDifference::printTime( const string & s ){ + + unsigned long long int micro = (end.tv_sec*1000000+end.tv_usec) - (start.tv_sec*1000000 + start.tv_usec ); + unsigned long long int milli = micro / 1000; + unsigned long long int sec = milli / 1000; + + cout< + +namespace Keyboard{ + + const bool getAnyKey( int k1, int k2, int k3, int k4 ); + const bool getAnyKey( int k1, int k2, int k3 ); + const bool getAnyKey( int k1, int k2 ); + const bool getAnyKey( int k1 ); + + const int readKey(); + const bool keyPressed(); + + void clear(); + + std::string keyToString( int key ); + + extern const int A; + extern const int B; + extern const int C; + extern const int D; + extern const int E; + extern const int F; + extern const int G; + extern const int H; + extern const int I; + extern const int J; + extern const int K; + extern const int L; + extern const int M; + extern const int N; + extern const int O; + extern const int P; + extern const int Q; + extern const int R; + extern const int S; + extern const int T; + extern const int U; + extern const int V; + extern const int W; + extern const int X; + extern const int Y; + extern const int Z; + extern const int N0; + extern const int N1; + extern const int N2; + extern const int N3; + extern const int N4; + extern const int N5; + extern const int N6; + extern const int N7; + extern const int N8; + extern const int N9; + extern const int PAD_0; + extern const int PAD_1; + extern const int PAD_2; + extern const int PAD_3; + extern const int PAD_4; + extern const int PAD_5; + extern const int PAD_6; + extern const int PAD_7; + extern const int PAD_8; + extern const int PAD_9; + extern const int F1; + extern const int F2; + extern const int F3; + extern const int F4; + extern const int F5; + extern const int F6; + extern const int F7; + extern const int F8; + extern const int F9; + extern const int F10; + extern const int F11; + extern const int F12; + extern const int ESC; + extern const int TILDE; + extern const int MINUS; + extern const int EQUALS; + extern const int BACKSPACE; + extern const int TAB; + extern const int OPENBRACE; + extern const int CLOSEBRACE; + extern const int ENTER; + extern const int COLON; + extern const int QUOTE; + extern const int BACKSLASH; + extern const int BACKSLASH2; + extern const int COMMA; + extern const int STOP; + extern const int SLASH; + extern const int SPACE; + extern const int INSERT; + extern const int DEL; + extern const int HOME; + extern const int END; + extern const int PGUP; + extern const int PGDN; + extern const int LEFT; + extern const int RIGHT; + extern const int UP; + extern const int DOWN; + extern const int SLASH_PAD; + extern const int ASTERISK; + extern const int MINUS_PAD; + extern const int PLUS_PAD; + extern const int DEL_PAD; + extern const int ENTER_PAD; + extern const int PRTSCR; + extern const int PAUSE; + extern const int C1; + extern const int YEN; + extern const int KANA; + extern const int CONVERT; + extern const int NOCONVERT; + extern const int AT; + extern const int CIRCUMFLEX; + extern const int COLON2; + extern const int KANJI; + extern const int EQUALS_PAD; + extern const int BACKQUOTE; + extern const int SEMICOLON; + extern const int COMMAND; + extern const int UNKNOWN1; + extern const int UNKNOWN2; + extern const int UNKNOWN3; + extern const int UNKNOWN4; + extern const int UNKNOWN5; + extern const int UNKNOWN6; + extern const int UNKNOWN7; + extern const int UNKNOWN8; + extern const int MODIFIERS; + extern const int LSHIFT; + extern const int RSHIFT; + extern const int LCONTROL; + extern const int RCONTROL; + extern const int ALT; + extern const int ALTGR; + extern const int LWIN; + extern const int RWIN; + extern const int MENU; + extern const int SCRLOCK; + extern const int NUMLOCK; + extern const int CAPSLOCK; + extern const int MAX; +} + +#endif --- rafkill-1.2.2.orig/build/trigger.h +++ rafkill-1.2.2/build/trigger.h @@ -0,0 +1,25 @@ +#ifndef _trigger_base_class_h +#define _trigger_base_class_h + +class trigger{ +public: + trigger( char * info, int size_data, int type, int xv, int yv ); + + virtual void * get( void * helper ); + virtual int size(); + virtual int kind(); + virtual int CX(); + virtual int CY(); + virtual void kill(); + + virtual ~trigger(); + +protected: + char * data; + int size_d; + int id; + int loc_x, loc_y; + +}; + +#endif --- rafkill-1.2.2.orig/build/hull.h +++ rafkill-1.2.2/build/hull.h @@ -0,0 +1,133 @@ +#ifndef _hull_h_ +#define _hull_h_ + +#include "bitmap.h" +#include "ebox.h" + +class WeaponObject; +class SpaceObject; +class Section; + +class HullObject{ +public: + + //c = color + //l = life + //s = strength + //num_guns = number of guns + //dl = drawing plane + HullObject( Bitmap * _drawBitmap, double _life, double _strength, int num_guns, int level, int _drawing_plane, bool _trans, ECollide * ec ); + + //process: determines if point is within hull + virtual bool Inside( int mx, int my, int ax, int ay ); + + //tells the hull it has been moved + virtual void Moved( double _dx, double _dy, double _ax, double _ay ); + + //process: draws hull onto Bitmap + virtual void Draw( const Bitmap & who, int x, int y ); + + virtual Bitmap * getShadow(); + + //Shadow: draws a shadow + virtual void Shadow( const Bitmap & who, int x, int y ); + + virtual bool hullCollide( ECollide * col, int mx, int my, int ax, int ay ); + //process: determines if hull is within check->hull + virtual bool Collide( int mx, int my, SpaceObject * check ); + + //process: returns amount of hull structural integrity + double GetLife(); + + //does something when collided with something else + virtual void Collided(); + + //process: returns whether or not hull can be hit by bullets + bool Translucent(); + + virtual inline int getHeight(){ + if ( myBitmap ) return myBitmap->getHeight(); + if ( collide ) return collide->getHeight(); + return 0; + } + + virtual inline int getWidth(){ + if ( myBitmap ) return myBitmap->getWidth(); + if ( collide ) return collide->getWidth(); + return 0; + } + + inline ECollide * getCollide() const{ + return collide; + } + + //returns how much damage hull should do + virtual double Hurt(); + + //allows hull to change how much damage it is going to take + virtual double Damage( double much ); + + //forces the hull to take so much damage + virtual void takeDamage( double r ); + + //adds current object to the section + virtual void addSection( SpaceObject * who, Section * onscreen, int x, int y ); + + //returns the guns the hull contains + virtual WeaponObject ** Guns(); + + //gives us a new weapon + virtual void giveWeapon( WeaponObject * weap, int num ); + + virtual void eraseWeapon( int num ); + + //returns the maximum number of guns the hull can contain + //usually a constant as guns is set to a specific number + //in the constructor + virtual int maxGuns(); + + //returns crash. sets crash to false + bool haveBeenHit(); + + //sets the current life according to the level + void setLife( double zx ); + + inline int getLife(){ + return (int)life; + } + + //debug stuff + // void debug( Bitmap * work, int x, int y ); + + //returns a copy of this hull + virtual HullObject * copy(); + + //virtual destructor + virtual ~HullObject(); + + bool crash; + int color; + double life; + double original_life; + bool trans; + + double strength; + + int drawNum; + int drawLevel; + +protected: + Bitmap * myBitmap; + Bitmap * Shadow_Bitmap; + WeaponObject ** guns; + ECollide * collide; + +public: + + int max_guns; + + double dx, dy; + +}; + +#endif --- rafkill-1.2.2.orig/build/music.cpp +++ rafkill-1.2.2/build/music.cpp @@ -0,0 +1,355 @@ +#include "music.h" +#include +#include +#include +#include "defs.h" + +#ifdef WINDOWS +#include +#endif + +#include + +using namespace std; + +static Music * instance = NULL; + +static double volume = 1.0; +// static bool muted = false; +static pthread_t musicThread; +static pthread_mutex_t musicMutex; +static bool alive = true; + +static void * playMusic( void * ); + +#define synchronized for( int __l( ! pthread_mutex_lock( &musicMutex ) ); __l; __l = 0, pthread_mutex_unlock( &musicMutex ) ) + +#define LOCK pthread_mutex_lock( &musicMutex ); +#define UNLOCK pthread_mutex_unlock( &musicMutex ); + +/* +#undef LOCK +#undef UNLOCK +#define LOCK +#define UNLOCK +*/ + +Music::Music(): +playing( false ), +player( NULL ), +music_file( NULL ){ + + if ( instance != NULL ){ + cerr << "Trying to instantiate music object twice!" << endl; + return; + } + + instance = this; + + pthread_mutex_init( &musicMutex, NULL ); + pthread_create( &musicThread, NULL, playMusic, (void *)instance ); +} + +/* +static bool isAlive(){ + bool f = false; + synchronized{ + f = alive; + } + return f; +} +*/ + +static void * playMusic( void * _music ){ + Music * music = (Music *) _music; + + cout << "Playing music" << endl; + + unsigned int tick = 0; + unsigned int counter; + + bool playing = true; + while ( playing ){ + + LOCK;{ + playing = alive; + music->doPlay(); + } + UNLOCK; + rest( 50 ); + + // Util::YIELD(); + // pthread_yield(); + } + + // cout << "Done with music thread" << endl; + + return NULL; +} + +double Music::getVolume(){ + return volume; +} + +void Music::doPlay(){ + if ( this->playing ){ + if ( al_poll_duh( this->player ) != 0 ){ + } + } +} + +/* +Music::Music( const char * song ): +volume( 1.0 ), +muted( false ), +player( NULL ), +music_file( NULL ){ + + loadSong( song ); + +} + +Music::Music( const string & song ): +volume( 1.0 ), +muted( false ), +player( NULL ), +music_file( NULL ){ + loadSong( song ); +} +*/ + +bool Music::loadSong( const char * song ){ + bool loaded = false; + LOCK;{ + loaded = instance->internal_loadSong( song ); + } + UNLOCK; + return loaded; + // muted = false; +} + +/* remove an element from a vector at index 'pos' and return it */ +template< class Tx_ > +static Tx_ removeVectorElement( vector< Tx_ > & toRemove, int pos ){ + int count = 0; + typename vector< Tx_ >::iterator it; + for ( it = toRemove.begin(); it != toRemove.end() && count < pos; count++, it++ ); + + if ( it == toRemove.end() ){ + /* this isnt right, but whatever */ + return toRemove.front(); + } + + const Tx_ & removed = toRemove[ pos ]; + toRemove.erase( it ); + return removed; + +} + +void Music::loadSong( const vector< string > & Songs ){ + + /* + cout << "Songs = " << &Songs << endl; + if ( ! loadSong( "music/song5.xm" ) ){ + cerr << "Could not load music/song5.xm" << endl; + } + return; + */ + + vector< string > _songs = Songs; + vector< string > songs; + while ( ! _songs.empty() ){ + int i = Util::rnd( _songs.size() ); + songs.push_back( removeVectorElement< string >( _songs, i ) ); + } + + /* + songs.clear(); + songs.push_back( "music/song3.xm" ); + */ + + for ( vector< string >::iterator it = songs.begin(); it != songs.end(); it++ ){ + cout << "Trying to load song " << *it << endl; + if ( loadSong( *it ) ){ + break; + } + } +} + +bool Music::loadSong( const string & song ){ + return loadSong( song.c_str() ); +} + +void Music::_play(){ + if ( playing == false && this->player != NULL ){ + al_resume_duh( this->player ); + } + playing = true; +} + +void Music::play(){ + LOCK;{ + instance->_play(); + } + UNLOCK; +} + +void Music::_pause(){ + playing = false; + if ( this->player != NULL ){ + al_pause_duh( this->player ); + } +} + +void Music::pause(){ + LOCK;{ + instance->_pause(); + } + UNLOCK; +} + +void Music::soften(){ + instance->_soften(); +} + +void Music::_soften(){ + if ( volume > 0.1 ) volume -= 0.1; + else volume = 0.0; + + setVolume( volume ); +} + +void Music::louden(){ + instance->_louden(); +} + +void Music::_louden(){ + if ( volume < 0.9 ) volume += 0.1; + else volume = 1.0; + + setVolume( volume ); +} + +void Music::mute(){ + setVolume( 0 ); +} + +void Music::setVolume( double vol ){ + volume = vol; + LOCK;{ + instance->_setVolume( volume ); + } + UNLOCK; +} + +void Music::_setVolume( double vol ){ + + if ( player ){ + al_duh_set_volume( player, vol ); + } + +} + +Music::~Music(){ + + LOCK;{ + if ( player ){ + al_stop_duh( player ); + unload_duh( music_file ); + } + + alive = false; + } + UNLOCK; + + cout << "Waiting for music thread to die" << endl; + pthread_join( musicThread, NULL ); + +} + +/* +void Music::pause(){ + al_pause_duh( player ); +} +*/ + +/* +void Music::resume(){ + al_resume_duh( player ); +} +*/ + +bool Music::internal_loadSong( const char * path ){ + + // cout << "Trying to load '" << path << "'" << endl; + + if ( player != NULL ){ + al_stop_duh( player ); + unload_duh( music_file ); + player = NULL; + music_file = NULL; + } + + // music_file = dumb_load_mod( path ); + /* + music_file = dumb_load_mod( path ); + if ( !music_file ){ + music_file = dumb_load_xm( path ); + } + if ( !music_file ){ + music_file = dumb_load_s3m( path ); + } + if ( !music_file ){ + music_file = dumb_load_it( path ); + } + */ + + for ( int i = 0; i < 4; i++ ){ + switch ( i ){ + case 0 : { + music_file = dumb_load_xm( path ); + break; + } + case 1 : { + music_file = dumb_load_s3m( path ); + break; + } + case 2 : { + music_file = dumb_load_it( path ); + break; + } + case 3 : { + music_file = dumb_load_mod( path ); + break; + } + } + if ( music_file != NULL ){ + cout << "Loaded " << path << " type " << i << endl; + break; + } + } + + if ( music_file ){ + int buf = 1 << 14; + player = al_start_duh( music_file, 2, 0, volume, buf, 22050 ); + // cout << "Loaded music player " << player << endl; + + /* + while ( 1 ){ + al_poll_duh( player ); + rest( 1 ); + } + */ + + playing = true; + } else { + cout<<"Could not load "< +#include +#include + +using namespace std; + +class TimeDifference{ +public: + + TimeDifference(); + + inline void startTime(){ + #ifndef WINDOWS + gettimeofday( &start, NULL ); + #endif + } + + inline void endTime(){ + #ifndef WINDOWS + gettimeofday( &end, NULL ); + #endif + } + + unsigned long long int getTime(); + + void printTime(); + void printTime( const string & s ); + + ~TimeDifference(); + +protected: + struct timeval start, end; + +}; + +#endif --- rafkill-1.2.2.orig/build/gunobj.cpp +++ rafkill-1.2.2/build/gunobj.cpp @@ -0,0 +1,122 @@ +#include "gunobj.h" +#include +#include "bitmap.h" +#include "spaceobj.h" + +using namespace std; + +/* Constructor: + * paramters: + * direction - direction the bullets should move in. Should either be 1 or -1 for up for down. + * name - the name of the gun + * _worth - the cost of the gun used for the buy menu for the guns the player can buy. + * _alignment - the TEAM of the gun. this will also be the TEAM of the bullets produced. + */ +WeaponObject::WeaponObject( int direction, const char * name, int _worth, int _alignment, int _strength, int _max_strength ): +shot_counter( 0 ), +strength( _strength ), +max_strength( _max_strength ), +dir( direction ), +worth( _worth ), +alignment( _alignment ) { + gun_name = name; +} + + +/* +int WeaponObject::getPower(){ + return strength; +} +*/ + +/* Draw: + * Allows the object to draw itself onto the specified bitmap. + * Defualt behavior is to do nothing. + */ +void WeaponObject::Draw( const Bitmap & less,int x,int y){} + +/* MakeShot: + * Makes a bullet, or bullets, given a list of ammo and a list of the object enemies. + * Default behavior is to do nothing. + */ +void WeaponObject::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ){} + +/* Idle: + * If the object containing the gun object shoots, the MakeShot method is called, + * otherwise the Idle method is called. + * Default behavior is to do nothing. + */ +void WeaponObject::Idle(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ){} + +/* GetName: + * Returns the name of the gun. + */ + /* +const char * WeaponObject::GetName() const { + return gun_name.c_str(); +} +*/ + +const int WeaponObject::getShotCounter() const{ + return shot_counter; +} + +void WeaponObject::setShotCounter( const int x ){ + shot_counter = x; +} + +void WeaponObject::Wait( const int n ) { + shot_counter -= n; +} + +const SpaceObject * WeaponObject::getCollidableObject( const vector< SpaceObject * > * fight, const SpaceObject * enemy ){ + for ( vector< SpaceObject * >::const_iterator it = fight->begin(); it != fight->end(); it++ ){ + const SpaceObject * object = *it; + if ( object->CanbeHit( enemy ) ){ + return object; + } + } + return NULL; +} + +/* Worth: + * Returns the cost of the gun. + */ +int WeaponObject::Worth() { + return worth; +} + + +WeaponObject * WeaponObject::copy() { + + WeaponObject * who = new WeaponObject( dir, gun_name.c_str(), worth, alignment, strength, max_strength ); + return who; + +} + + +/* maxPower: + * Returns the maximum strength of the gun + */ +int WeaponObject::maxPower() { + return max_strength; +} + + +/* IncreasePower: + * Increases the strength of the gun initiliazed to 0. Currently, the maximum power of any gun + * is 4. + */ +void WeaponObject::IncreasePower( int q ) { + + strength += q; + if ( max_strength != -1 ) + if ( strength > max_strength ) strength = max_strength; + +} + + +/* Destructor: + * Does nothing + */ +WeaponObject::~WeaponObject(){} --- rafkill-1.2.2.orig/build/pck.cpp +++ rafkill-1.2.2/build/pck.cpp @@ -0,0 +1,195 @@ +#include "pck.h" +#include "strings.h" +#include "defs.h" +#include "bitmap.h" + +#include +#include + +/* PCK: + * File format invented by me to store the background in a conveinent way. + * Initially, the background file contains numbers ranging from 0-127. Each number + * represents an index into an array of colors which are made by blend_palette. + * These numbers can be packed together becuase many numbers occur repeatedly next + * to each other. If this is the case then the number of repeated numbers is stored + * followed by the raw index. If a sample row of numbers is: + * 9 9 120 85 85 85 17 1 + * Then the final packed form would be: + * 2 9 248 3 85 145 129 + * If a number is larger than 128, subtract 128 to get its index value. Otherwise + * the first number is the count, and the second is the index. Simple enough and packs + * the file about 1/3. + */ + +/* pckLoader: + * Constructor. Does nothing + */ +pckLoader::pckLoader(){} + +Bitmap * pckLoader::load( const char * sf ) { + + //clear( screen ); + int g1, g2; + get_colors( g1, g2 ); + // int * shade = new int[ 128 ]; + int shade[ 128 ]; + Util::blend_palette( shade, 128, g1, g2 ); + + char fileName[ 4096 ]; + // char * file_name = Util::data_file( sf ); + Util::getDataPath( fileName, sf ); + + Bitmap * ret = load_pck( fileName, shade, 128 ); + + // free( file_name ); + // delete[] shade; + return ret; + +} + + +void pckLoader::set( Bitmap * fat, int & x, int & y, int col) { + if ( x >= 0 && x < 640 && y >= 0 && y < 480 ) + // _putpixel16( fat, x, y, col ); + fat->putPixel( x, y, col ); + x++; + if ( x >= 640 ) { + y++; + x = 0; + } +} + + +Bitmap * pckLoader::load_pck( char * sf, int * shade, int max ) { + + // Bitmap * choice = create_bitmap( 640, 480 ); + Bitmap * choice = new Bitmap( 640, 480 ); + if ( !choice ) { + printf("Supreme error with backgruond!\n"); + return NULL; + } + // clear( choice ); + choice->clear(); + + // textprintf_ex(screen,font,100,100,makecol(255,255,255), -1, "Loading background.."); + + int x = 0; + int y = 0; + FILE * fv = fopen( sf, "rb" ); + if ( !fv ) { + printf("File %s doesnt exist!\n", sf ); + return NULL; + } + + while ( y != 480 ) { + unsigned char rd; + + fread( &rd, sizeof( unsigned char ), 1, fv ); + if ( rd > 127 ) { + set( choice, x, y, shade[rd-128] ); + } + else { + unsigned char num; + fread( &num, sizeof( unsigned char ), 1, fv ); + for ( int q = 0; q < rd; q++ ) + set( choice, x, y, shade[num] ); + } + + } + + fclose( fv ); + return choice; +} + + +int pckLoader::getnum( char *& buf ) { + int r = str2int( buf ); + while ( *buf != '\0' ) buf++; + while ( *buf == '\0' ) buf++; + int g = str2int( buf ); + while ( *buf != '\0' ) buf++; + while ( *buf == '\0' ) buf++; + int b = str2int( buf ); + while ( *buf != '\0' ) buf++; + while ( *buf == '\0' ) buf++; + return Bitmap::makeColor( r, g, b ); +} + + +int pckLoader::filesize( FILE * fv ) { + /* + char dumb; + while ( !feof( fv ) ) fread( &dumb, sizeof( char ), 1, fv ); + */ + fseek( fv, 0, SEEK_END ); + int size = ftell( fv ); + rewind( fv ); + return size; +} + + +void pckLoader::get_colors( int & c1, int & c2 ) { + + // char * file_name_col = Util::data_file("table.col"); + char fileNameCol[ 4096 ]; + Util::getDataPath( fileNameCol, "table.col" ); + + FILE * fv = fopen( fileNameCol, "rb" ); + + if ( !fv ) { + + fv = fopen( fileNameCol, "wb" ); + char * buf; + buf = "4\n"; + fwrite( buf, sizeof( char ), length( buf ), fv ); + buf = "90 15 70\n"; + fwrite( buf, sizeof( char ), length( buf ), fv ); + buf = "3 78 3\n"; + fwrite( buf, sizeof( char ), length( buf ), fv ); + buf = "53 24 40\n"; + fwrite( buf, sizeof( char ), length( buf ), fv ); + buf = "25 4 98"; + fwrite( buf, sizeof( char ), length( buf ), fv ); + fclose( fv ); + fv = fopen( "table.col", "rb" ); + if ( !fv ){ + return; + } + + } + // free( file_name_col ); + int size = filesize( fv ); + + // char * buf = new char[ size+1 ]; + char storage[ size+1 ]; + char * buf = storage; + fread( buf, sizeof( char ), size, fv ); + buf[size] = '\0'; + + for ( int q = 0; q < size+1; q++ ) { + if ( buf[q] == ' ' ) buf[q] = '\0'; + if ( buf[q] == '\n' ) buf[q] = '\0'; + } + + int str = str2int( buf ); + while ( *buf != '\0' ) buf++; + while ( *buf == '\0' ) buf++; + + int colors[ str ]; + for ( int q = 0; q < str; q++ ) + colors[q] = getnum( buf ); + + int choose[ str ]; + for ( int q = 0; q < str; q++ ) choose[q] = 0; + + int g = Util::rnd( str ); + while ( choose[g] ) g = Util::rnd( str ); + c1 = colors[g]; + choose[g] = 1; + while ( choose[g] ) g = Util::rnd( str ); + c2 = colors[g]; + + //delete[] buf; + fclose( fv ); + +} --- rafkill-1.2.2.orig/build/rmenu_animation.h +++ rafkill-1.2.2/build/rmenu_animation.h @@ -0,0 +1,24 @@ +#ifndef _rmenu_animation_h_ +#define _rmenu_animation_h_ + +#include "rmenu.h" + +class Animation; +class Bitmap; + +class RMenuAnimation:public RMenu{ +public: + + RMenuAnimation( const Bitmap & intr, int x, int y, int height, int c1, int c2, int c3, Animation * ani ); + + virtual ~RMenuAnimation(); + +protected: + + virtual void Draw( const Bitmap & work, int x, int * yval, int * yshade, int min, int max ); + + Animation * show_case; + +}; + +#endif --- rafkill-1.2.2.orig/build/rfield.cpp +++ rafkill-1.2.2/build/rfield.cpp @@ -0,0 +1,137 @@ +#include "rfield.h" +#include "rmenu.h" +#include "defs.h" +#include "font.h" +#include +#include "bitmap.h" + +RField::RField( bool selectable, bool perm, int return_val, RMenu * who, int number, int sound_ ): +select( selectable ), +ret( return_val ), +num( number ), +title( perm ), +next( NULL ), +prev( NULL ), +menu_next( who ), +sound( sound_ ){ +} + + +void RField::Add( RField * rf ) { + next = rf; + if ( rf != NULL ) + rf->prev = this; +} + + +void RField::setMenu( RMenu * nx ) { + menu_next = nx; +} + + +bool RField::Ok() { + return select; +} + +bool RField::Title() { + return title; +} + +void RField::Selected() { + + if ( sound != -1 ){ + Util::playSound( sound, 255 ); + } + +} + +int RField::Size() { + return 0; +} + + +void RField::Draw( const Bitmap & work, int x, int y, int col ) { +} + +bool RField::equiv( void * obj ) { + return false; +} + +int RField::Val() { + return ret; +} + +void RField::set( void * object ){ +} + +RField * RField::Next() { + return next; +} + + +RField * RField::Prev() { + return prev; +} + + +int RField::Place() { + return num; +} + + +RMenu * RField::NextMenu() { + return menu_next; +} + + +RField::~RField() { +} + +//**// +RField_Name::RField_Name( Font * f_font, string name, bool selectable, bool perm, int return_val, RMenu * who, int number, int sound ): +RField( selectable, perm, return_val, who, number, sound ) { + handle = name; + field_font = f_font; +} + +bool RField_Name::equiv( void * obj ) { + return handle == *(string *)obj; +} + +int RField_Name::Size() { + return field_font->getHeight(); +} + +void RField_Name::set( void * object ){ + string * str = (string *) object; + this->handle = *str; +} + +void RField_Name::Draw( const Bitmap & work, int x, int y, int col ) { + work.printf( x, y, col, this->field_font, this->handle ); +} + +RField_Name::~RField_Name() { + //delete[] handle; + // free( handle ); +} + +RField_Bitmap::RField_Bitmap( const Bitmap & look, bool selectable, bool perm, int return_val, RMenu * who, int number, int sound ): +RField( selectable, perm, return_val, who, number, sound ) { + scene = look; +} + +bool RField_Bitmap::equiv( void * obj ) { + return false; +} + +int RField_Bitmap::Size() { + return scene.getHeight(); +} + +void RField_Bitmap::Draw( const Bitmap & work, int x, int y, int col ) { + scene.draw( x, y, work ); +} + +RField_Bitmap::~RField_Bitmap() { +} --- rafkill-1.2.2.orig/build/playerobj.h +++ rafkill-1.2.2/build/playerobj.h @@ -0,0 +1,70 @@ +#ifndef _player_object_h +#define _player_object_h + +#include "shipobj.h" +#include "booster.h" +#include "bitmap.h" + +class SpaceObject; +class HullObject; +class Section; + +class PlayerObject:public ShipObject{ +public: + PlayerObject(int qx, int qy, int _difficulty, HullObject * hnew); + virtual void MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight,Section * onscreen ); + + virtual void Draw( const Bitmap & less, ExplosionClass ** _explr, int MAX_EXPLR, int g, int offset ) const; + + virtual bool powerUp(); + virtual int getDifficulty(); + virtual void setDifficulty( int d ); + virtual int getLevel() const; + virtual void setLevel( int s ); + + virtual bool Destroyable() const; + + virtual bool acceptSpecial() const; + virtual void Radar( const Bitmap & rad )const; + + void idleGuns( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + void shootGuns( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + + virtual ~PlayerObject(); + + void Inertia( double & d ); + + void setControl( bool a ); + + int hull_num; + +private: + //process: slows object down + + //process: forces x and y to be within screen limitations + // void CheckXY(); + + void userInput( const vector< SpaceObject * > * fight, vector< SpaceObject * > * Ammo ); + void keyboardInput(); + void joyInput(); + + //process: sets dx=fx, dy=fy + void MoveD( double & d, double f_max ); + + int difficulty; + + int last_dir; + int change_frame; + bool holding_accessory; + int * shade; + int shade_color; + Booster engine; + + bool user_control; + + int level; + + bool key_UP, key_DOWN, key_LEFT, key_RIGHT, key_SHOOT, key_ACCESSORY; +}; + +#endif --- rafkill-1.2.2.orig/build/weaponobj.h +++ rafkill-1.2.2/build/weaponobj.h @@ -0,0 +1,23 @@ +#ifndef _weaponnode_h_ +#define _weaponnode_h_ + +#include "spaceobj.h" + +class ExplosionClass; +class HullObject; + +class WeaponNode:public SpaceObject{ +public: + WeaponNode(int qx, int qy, double kx, double ky, HullObject * hnew, int alignment ); + + virtual bool hullCollide( ECollide * col, int x, int y ); + virtual bool Damage( double much ); + virtual void Died( SpaceObject * check, ExplosionClass ** explr, int ME ); + virtual void Explode( ExplosionClass ** explr, int ME ); + virtual bool CanbeHit( const SpaceObject * ht ) const; + + virtual ~WeaponNode(); + +}; + +#endif --- rafkill-1.2.2.orig/build/raptor.h +++ rafkill-1.2.2/build/raptor.h @@ -0,0 +1,232 @@ +/* Allegro datafile object indexes, produced by grabber v4.1.13 (WIP), Unix */ +/* Datafile: /home/kazzmir/archives/scratch/c++/raptor/rap/data/raptor.dat */ +/* Date: Wed Jun 2 11:59:09 2004 */ +/* Do not hand edit! */ + +#define BOSS_01 0 /* BMP */ +#define BULLET_TWIRL 1 /* BMP */ +#define CHAIN_LINK_CIRCLE 2 /* BMP */ +#define CHAIN_LINK_LINK 3 /* BMP */ +#define CLOUD1 4 /* BMP */ +#define CLOUD2 5 /* BMP */ +#define COIN_1 6 /* BMP */ +#define COIN_2 7 /* BMP */ +#define COIN_3 8 /* BMP */ +#define COIN_4 9 /* BMP */ +#define COIN_5 10 /* BMP */ +#define COIN_6 11 /* BMP */ +#define COIN_7 12 /* BMP */ +#define COIN_8 13 /* BMP */ +#define COIN_9 14 /* BMP */ +#define COIN_A_10 15 /* BMP */ +#define COIN_A_11 16 /* BMP */ +#define COIN_A_12 17 /* BMP */ +#define COIN_A_13 18 /* BMP */ +#define COIN_A_14 19 /* BMP */ +#define COIN_A_15 20 /* BMP */ +#define COIN_A_16 21 /* BMP */ +#define COIN_A_17 22 /* BMP */ +#define COIN_A_18 23 /* BMP */ +#define COIN_A_19 24 /* BMP */ +#define COIN_A_20 25 /* BMP */ +#define EXPLODE_1 26 /* BMP */ +#define EXPLODE_2 27 /* BMP */ +#define EXPLODE_3 28 /* BMP */ +#define EXPLODE_4 29 /* BMP */ +#define EXPLODE_5 30 /* BMP */ +#define EXPLODE_6 31 /* BMP */ +#define EXPLODE_7 32 /* BMP */ +#define EXPLODE_8 33 /* BMP */ +#define EXPLODE_9 34 /* BMP */ +#define EXPLODE_A_10 35 /* BMP */ +#define EXPLODE_A_11 36 /* BMP */ +#define EXPLODE_A_12 37 /* BMP */ +#define EXPLODE_A_13 38 /* BMP */ +#define EXPLODE_A_14 39 /* BMP */ +#define EXPLODE_A_15 40 /* BMP */ +#define EXPLODE_A_16 41 /* BMP */ +#define EXPLODE_A_17 42 /* BMP */ +#define EXPLODE_A_18 43 /* BMP */ +#define EXPLODE_A_19 44 /* BMP */ +#define EXPLODE_A_20 45 /* BMP */ +#define EXPLODE_A_21 46 /* BMP */ +#define EXPLODE_A_22 47 /* BMP */ +#define EXPLODE_A_23 48 /* BMP */ +#define EXPLODE_A_24 49 /* BMP */ +#define EXPLODE_A_25 50 /* BMP */ +#define EXPLODE_A_26 51 /* BMP */ +#define EXPLODE_A_27 52 /* BMP */ +#define EXPLODE_A_28 53 /* BMP */ +#define EXPLODE_A_29 54 /* BMP */ +#define EXPLODE_A_30 55 /* BMP */ +#define GR_EXPLODE_01 56 /* BMP */ +#define GR_EXPLODE_02 57 /* BMP */ +#define GR_EXPLODE_03 58 /* BMP */ +#define GR_EXPLODE_04 59 /* BMP */ +#define GR_EXPLODE_05 60 /* BMP */ +#define GR_EXPLODE_06 61 /* BMP */ +#define GR_EXPLODE_07 62 /* BMP */ +#define GR_EXPLODE_08 63 /* BMP */ +#define GR_EXPLODE_09 64 /* BMP */ +#define GR_EXPLODE_10 65 /* BMP */ +#define GR_EXPLODE_11 66 /* BMP */ +#define GR_EXPLODE_12 67 /* BMP */ +#define GR_EXPLODE_13 68 /* BMP */ +#define GR_EXPLODE_14 69 /* BMP */ +#define GR_EXPLODE_15 70 /* BMP */ +#define GR_EXPLODE_16 71 /* BMP */ +#define GR_EXPLODE_17 72 /* BMP */ +#define GR_EXPLODE_18 73 /* BMP */ +#define GR_EXPLODE_19 74 /* BMP */ +#define GR_EXPLODE_20 75 /* BMP */ +#define GR_EXPLODE_21 76 /* BMP */ +#define GR_EXPLODE_22 77 /* BMP */ +#define GR_EXPLODE_23 78 /* BMP */ +#define GR_EXPLODE_24 79 /* BMP */ +#define GR_EXPLODE_25 80 /* BMP */ +#define GR_EXPLODE_26 81 /* BMP */ +#define GR_EXPLODE_27 82 /* BMP */ +#define GR_EXPLODE_28 83 /* BMP */ +#define GR_EXPLODE_29 84 /* BMP */ +#define HEALTH_001 85 /* BMP */ +#define HEALTH_002 86 /* BMP */ +#define HEALTH_003 87 /* BMP */ +#define HEALTH_004 88 /* BMP */ +#define HEALTH_005 89 /* BMP */ +#define HEALTH_006 90 /* BMP */ +#define HEALTH_007 91 /* BMP */ +#define HEALTH_008 92 /* BMP */ +#define HEALTH_009 93 /* BMP */ +#define HEALTH_010 94 /* BMP */ +#define HEALTH_011 95 /* BMP */ +#define HEALTH_012 96 /* BMP */ +#define HEALTH_013 97 /* BMP */ +#define HEALTH_014 98 /* BMP */ +#define HEALTH_015 99 /* BMP */ +#define HEALTH_016 100 /* BMP */ +#define HEALTH_017 101 /* BMP */ +#define HEALTH_018 102 /* BMP */ +#define HEALTH_019 103 /* BMP */ +#define HEALTH_020 104 /* BMP */ +#define HEALTH_021 105 /* BMP */ +#define HELICOPTER_1 106 /* BMP */ +#define HELICOPTER_2 107 /* BMP */ +#define HELICOPTER_3 108 /* BMP */ +#define HELICOPTER_4 109 /* BMP */ +#define HELICOPTER_5 110 /* BMP */ +#define HELICOPTER_6 111 /* BMP */ +#define HULL_1_1 112 /* BMP */ +#define HULL_1_2 113 /* BMP */ +#define HULL_1_3 114 /* BMP */ +#define HULL_1_4 115 /* BMP */ +#define HULL_1_5 116 /* BMP */ +#define HULL_1_6 117 /* BMP */ +#define HULL_1_7 118 /* BMP */ +#define HULL_1_8 119 /* BMP */ +#define HULL_1_9 120 /* BMP */ +#define HULL_2_1 121 /* BMP */ +#define HULL_2_2 122 /* BMP */ +#define HULL_2_3 123 /* BMP */ +#define HULL_2_4 124 /* BMP */ +#define HULL_2_5 125 /* BMP */ +#define HULL_2_6 126 /* BMP */ +#define HULL_2_7 127 /* BMP */ +#define HULL_2_8 128 /* BMP */ +#define HULL_2_9 129 /* BMP */ +#define HULL_3_1 130 /* BMP */ +#define HULL_3_2 131 /* BMP */ +#define HULL_3_3 132 /* BMP */ +#define HULL_3_4 133 /* BMP */ +#define HULL_3_5 134 /* BMP */ +#define HULL_3_6 135 /* BMP */ +#define HULL_3_7 136 /* BMP */ +#define HULL_3_8 137 /* BMP */ +#define HULL_3_9 138 /* BMP */ +#define IRON_000 139 /* BMP */ +#define IRON_001 140 /* BMP */ +#define IRON_002 141 /* BMP */ +#define IRON_003 142 /* BMP */ +#define IRON_004 143 /* BMP */ +#define IRON_005 144 /* BMP */ +#define IRON_006 145 /* BMP */ +#define IRON_007 146 /* BMP */ +#define IRON_008 147 /* BMP */ +#define IRON_009 148 /* BMP */ +#define IRON_010 149 /* BMP */ +#define IRON_011 150 /* BMP */ +#define IRON_012 151 /* BMP */ +#define METEOR_1 152 /* BMP */ +#define METEOR_2 153 /* BMP */ +#define METEOR_3 154 /* BMP */ +#define METEOR_4 155 /* BMP */ +#define METEOR_5 156 /* BMP */ +#define METEOR_6 157 /* BMP */ +#define METEOR_7 158 /* BMP */ +#define METEOR_8 159 /* BMP */ +#define METEOR_9 160 /* BMP */ +#define METEOR_9_10 161 /* BMP */ +#define METEOR_9_11 162 /* BMP */ +#define METEOR_9_12 163 /* BMP */ +#define METEOR_9_13 164 /* BMP */ +#define METEOR_9_14 165 /* BMP */ +#define METEOR_9_15 166 /* BMP */ +#define METEOR_9_16 167 /* BMP */ +#define METEOR_9_17 168 /* BMP */ +#define METEOR_9_18 169 /* BMP */ +#define METEOR_9_19 170 /* BMP */ +#define METEOR_9_20 171 /* BMP */ +#define POWERUP_1 172 /* BMP */ +#define POWERUP_2 173 /* BMP */ +#define POWERUP_3 174 /* BMP */ +#define POWERUP_4 175 /* BMP */ +#define POWERUP_5 176 /* BMP */ +#define POWERUP_6 177 /* BMP */ +#define POWERUP_7 178 /* BMP */ +#define POWERUP_8 179 /* BMP */ +#define POWERUP_9 180 /* BMP */ +#define POWERUP_A_10 181 /* BMP */ +#define POWERUP_A_11 182 /* BMP */ +#define POWERUP_A_12 183 /* BMP */ +#define POWERUP_A_13 184 /* BMP */ +#define POWERUP_A_14 185 /* BMP */ +#define SHIP0_FIRST 186 /* BMP */ +#define SHIP_001 187 /* BMP */ +#define SHIP_002 188 /* BMP */ +#define SHIP_003 189 /* BMP */ +#define SHIP_004 190 /* BMP */ +#define SHIP_005 191 /* BMP */ +#define SHIP_006 192 /* BMP */ +#define SHIP_007 193 /* BMP */ +#define SHIP_008 194 /* BMP */ +#define SHIP_009 195 /* BMP */ +#define SHIP_010 196 /* BMP */ +#define SHIP_LAST 197 /* BMP */ +#define WEAPON_BOMB_1 198 /* BMP */ +#define WEAPON_BOMB_2 199 /* BMP */ +#define WEAPON_BOMB_3 200 /* BMP */ +#define WEAPON_BOMB_4 201 /* BMP */ +#define WEAPON_BOMB_5 202 /* BMP */ +#define WEAPON_BOMB_6 203 /* BMP */ +#define WEAPON_BOMB_7 204 /* BMP */ +#define WEAPONUP_001 205 /* BMP */ +#define WEAPONUP_002 206 /* BMP */ +#define WEAPONUP_003 207 /* BMP */ +#define WEAPONUP_004 208 /* BMP */ +#define WEAPONUP_005 209 /* BMP */ +#define WEAPONUP_006 210 /* BMP */ +#define WEAPONUP_007 211 /* BMP */ +#define WEAPONUP_008 212 /* BMP */ +#define WEAPONUP_009 213 /* BMP */ +#define WEAPONUP_010 214 /* BMP */ +#define WEAPONUP_011 215 /* BMP */ +#define WEAPONUP_012 216 /* BMP */ +#define WEAPONUP_013 217 /* BMP */ +#define WEAPONUP_014 218 /* BMP */ +#define WEAPONUP_015 219 /* BMP */ +#define WEAPONUP_016 220 /* BMP */ +#define WEAPONUP_017 221 /* BMP */ +#define WEAPONUP_018 222 /* BMP */ +#define WEAPONUP_019 223 /* BMP */ +#define WEAPONUP_020 224 /* BMP */ +#define Z_MAX_DRAW 225 /* BMP */ + --- rafkill-1.2.2.orig/build/fader.h +++ rafkill-1.2.2/build/fader.h @@ -0,0 +1,25 @@ +#ifndef _background_fader_h +#define _background_fader_h + +#include "allegro.h" + +class Fader{ +public: + + Fader( RLE_SPRITE * back ); + + bool complete(); + + RLE_SPRITE * blend(); + + ~Fader(); + +private: + + BITMAP * own; + RLE_SPRITE * first; + int x, y; + +}; + +#endif --- rafkill-1.2.2.orig/build/wormhole.h +++ rafkill-1.2.2/build/wormhole.h @@ -0,0 +1,353 @@ +/* + * Wormhole effect + * by Jon Rafkind + * email: workmin@ccs.neu.edu + * + * last modifed December 2, 2002 + * + * You are free to use this code for whatever purpose you like. + * No gaurantee that the program will not destroy your monitor, computer, + * dog, or marriage. + * + */ + +#ifndef _wormhole_h +#define _wormhole_h + +#include +#include +#include "defs.h" +#include "bitmap.h" +#include +#include "trigtable.h" +#include "rgbhandle.h" +#include + +using namespace std; + +#define WORM_MOVE 9.3 +#define _si_ 1000 +#define MAX_STAR 1500 +#define Z_SPEED 9 +#define MAX_Z 550 + +class StarClass{ +public: + StarClass( const int x, const int y, const int z, const int mx, const int my ): + actualx( x ), + actualy( y ), + cx( mx ), + cy( my ), + Z( z ){ + ReCalc(); + } + + int GetZ(){ + return Z; + } + + int GetX(){ + return virtualx; + } + + int GetY(){ + return virtualy; + } + + void CalcX(){ + if ( Z <= 0 ) + virtualx = _si_ * actualx / cx; + else + virtualx = _si_ * actualx / Z + cx; + } + + void CalcY(){ + if ( Z <= 0 ) + virtualy = _si_ * actualy / cy; + else + virtualy = ( _si_ * actualy ) / Z + cy; + } + + void ReCalc(){ + CalcX(); + CalcY(); + } + + bool Update(){ + + Z-=Z_SPEED; + return ( Z <= 0 || !inbox() ); + } + + bool inbox(){ + return ( virtualx > 0 && virtualx < GRAPHICS_X && + virtualy > 0 && virtualy < GRAPHICS_Y ); + } + +protected: + int actualx; + int actualy; + int virtualx; + int virtualy; + int cx; + int cy; + int Z; +}; + +class StarLine{ +public: + + StarLine( int scale, int mx, int my ){ + int qz = MAX_Z; + int ang = Util::rnd(360); + for ( int q = 0; q < 2; q++ ) + star[q] = new StarClass( + (int)(Tcos(ang)*scale), + (int)(Tsine(ang)*scale), + qz-q*(Util::rnd(6)+4), mx, my ); + } + + StarLine( int scale, int mx, int my, int ang, int qz ){ + for ( int q = 0; q < 2; q++ ) + star[q] = new StarClass( + (int)(Tcos(ang)*scale), + (int)(Tsine(ang)*scale), + qz-q*(Util::rnd(5)+3), mx, my ); + } + + bool Update( ){ + + bool cy = false; + for ( int q = 0; q < 2; q++ ) + cy = cy || star[q]->Update(); + return cy; + + } + + void Draw( const Bitmap & work , int * shade, int max_shade ){ + for ( int q = 0; q < 2; q++ ){ + star[q]->ReCalc(); + } + int ncolor = (int)( (double)star[0]->GetZ() * (double)(max_shade-1) / (double)MAX_Z); + work.line( star[0]->GetX(), star[0]->GetY(), star[1]->GetX(), star[1]->GetY(), shade[ncolor]); + } + + ~StarLine(){ + for ( int q = 0; q < 2; q++ ) + delete star[q]; + } + +protected: + + StarClass * star[ 2 ]; + +}; + +class StarNode{ +public: + StarNode( StarLine * st ){ + next = NULL; + star = st; + } + + void add( StarNode * who ){ + next = who; + } + + StarNode * Next(){ + return next; + } + + StarLine * Get(){ + return star; + } + + ~StarNode(){ + delete star; + } + +protected: + StarNode * next; + StarLine * star; +}; + +class ColorChanger{ +public: + + ColorChanger( int m ){ + max = m; + shade = new int[ m ]; + + c1 = new RGBHandle(); + c2 = new RGBHandle(); + + Util::blend_palette( shade, max, c1->Get(), c2->Get() ); + + } + + void update(){ + + c1->update( 255, 180 ); + c2->update( 115, 30 ); + + Util::blend_palette( shade, max, c1->Get(), c2->Get() ); + } + + int * Colors(){ + return shade; + } + + int MAXCOLORS(){ + return max; + } + + ~ColorChanger(){ + delete[] shade; + delete c1; + delete c2; + } + +protected: + int * shade; + int max; + + RGBHandle * c1, * c2; + +}; + +class WormHole{ +public: + WormHole(){ + spiral = 0; + actualx = Util::rnd(640); + actualy = Util::rnd(480); + virtualx = actualx; + virtualy = actualy; + zsize = Util::rnd( 20 ) + 25; + msize = zsize; + ang = Util::rnd( 360 ); + //head = new StarNode( NULL ); + //very_last = head; + x_col = new ColorChanger( 30 ); + + } + + void Update(){ + if ( !spiral ){ + ang = ( ang + Util::rnd( 30 ) - 15 + 360 ) % 360; + if ( Util::rnd( 20 ) == Util::rnd( 20 ) ) + ang = Util::rnd( 360 ); + } else { + ang = ( ang + 15 ) % 360; + spiral--; + } + if( Util::rnd( 120 ) == Util::rnd( 120 ) ) + spiral = Util::rnd( 30 ) + 35; + + if ( actualx < 20 || actualy < 20 || actualx > GRAPHICS_X-20 || + actualy > Util::screen_y - 20 ) + ang = gang( actualx, actualy, GRAPHICS_X/2, GRAPHICS_Y/2 ); + virtualx += Tcos( ang ) * WORM_MOVE; + virtualy += Tsine(ang ) * WORM_MOVE; + actualx = (int)virtualx; + actualy = (int)virtualy; + + if ( Util::rnd( 20 ) == Util::rnd( 20 ) ) + msize = Util::rnd( 40 ) + 5; + if ( zsize < msize ) + zsize++; + if ( zsize > msize ) + zsize--; + + for ( int q = 0; q < 60; q++ ){ + StarLine * p = new StarLine(zsize,actualx,actualy); + //star_list.push_back( new StarLine(zsize,actualx,actualy) ); + star_list.push_back( p ); + } + + /* + StarNode * junk = head->Next(); + StarNode * hold = head; + while ( junk != NULL ){ + if ( junk->Get()->Update() ){ + hold->add( junk->Next() ); + if ( junk == very_last ) very_last = hold; + delete junk; + junk = NULL; + } + hold = hold->Next(); + if ( hold != NULL ) junk = hold->Next(); + } + */ + for ( vector< StarLine * >::iterator it = star_list.begin(); it != star_list.end(); ) + if ( (*it)->Update() ){ + StarLine * who = *it; + it = star_list.erase( it ); + delete who; + } else ++it; + + x_col->update(); + + } + + void add( StarNode * temp ){ + StarNode * junk = very_last; + //while ( junk->Next() != NULL ) junk = junk->Next(); + junk->add( temp ); + very_last = junk->Next(); + } + + void Draw( const Bitmap & work ){ + + for ( vector< StarLine * >::iterator it = star_list.begin(); it != star_list.end(); it++ ){ + (*it)->Draw( work, x_col->Colors(), x_col->MAXCOLORS() ); + } + + /* + StarNode * junk = head->Next(); + while ( junk != NULL ){ + junk->Get()->Draw( work, x_col->Colors(), x_col->MAXCOLORS() ); + junk = junk->Next(); + } + */ + + } + + ~WormHole(){ + + delete x_col; + for ( vector< StarLine * >::iterator it = star_list.begin(); it != star_list.end(); ){ + StarLine * who = *it; + it = star_list.erase( it ); + delete who; + } + + /* + StarNode * junk = head; + while( junk != NULL ){ + StarNode * last = junk; + junk = junk->Next(); + delete last; + } + */ + } + + +protected: + int zsize; + int msize; + int actualx, actualy; + int ang; + int spiral; + double virtualx, virtualy; + StarNode * head; + StarNode * very_last; + ColorChanger * x_col; + vector< StarLine * > star_list; + + bool printing; + int print_x; + int sang; + int scount; +}; +#endif --- rafkill-1.2.2.orig/build/explode_animate.cpp +++ rafkill-1.2.2/build/explode_animate.cpp @@ -0,0 +1,34 @@ +#include "defs.h" +#include "explode.h" +#include "explode_animate.h" +#include "raptor.h" +#include "bitmap.h" + +ExplosionAnimate::ExplosionAnimate( int cx, int cy, double dx, double dy, int _first_pic, int _last_pic ): +ExplosionClass( cx, cy, dx, dy, 99 ) { + first_pic = _first_pic; + radius = first_pic; + last_pic = _last_pic; +} + + +bool ExplosionAnimate::update() { + vx += wx; + vy += wy; + x = (int)vx; + y = (int)vy; + + if ( ++radius > last_pic ) return true; + return false; +} + + +void ExplosionAnimate::Draw( Bitmap * who, int offset ) { + Bitmap frame = Util::getDataSprite( radius ); + int mx = frame.getWidth() / 2; + int my = frame.getHeight() / 2; + // draw_sprite( who, (BITMAP *)global_data[ radius ].dat, x-mx, y-my+offset ); + // Bitmap c( (BITMAP *)Util::global_data[ radius ].dat ); + // who->draw( + frame.draw( x-mx, y-my+offset, *who ); +} --- rafkill-1.2.2.orig/build/explode.h +++ rafkill-1.2.2/build/explode.h @@ -0,0 +1,28 @@ +#ifndef _explode_h_ +#define _explode_h_ + +class Bitmap; + +extern int last_explode; + +class ExplosionClass{ +public: + ExplosionClass( int cx, int cy, double walkx, double walky, int rad ); + + //process: moves according to dx, dy and changes radius + virtual bool update(); + + //process: draws onto Bitmap + virtual void Draw( Bitmap * who, int offset ); + + int x, y; + double vx, vy; + double wx, wy; + int radius; + int max_rad; + +}; + +void addExplode( ExplosionClass ** explode_array, int MAX_EXPL_ARRAY, ExplosionClass * who ); + +#endif --- rafkill-1.2.2.orig/build/bitmap.h +++ rafkill-1.2.2/build/bitmap.h @@ -0,0 +1,200 @@ +#ifndef _bitmap_h_ +#define _bitmap_h_ + +#include +#include + +#include + +/* +#ifdef WINDOWS +#include +#endif +*/ + +struct BITMAP; +struct FONT; +class Font; + +using namespace std; + +class Bitmap{ +public: + + static Bitmap * Screen; + + /* default constructor makes 10x10 bitmap */ + Bitmap(); + Bitmap( int x, int y ); + Bitmap( const char * load_file ); + Bitmap( const string & load_file ); + Bitmap( const char * load_file, int sx, int sy ); + Bitmap( const char * load_file, int sx, int sy, double accuracy ); + Bitmap( BITMAP * who, bool deep_copy = false ); + Bitmap( const Bitmap & copy, bool deep_copy = false ); + Bitmap( const Bitmap & copy, int sx, int sy ); + Bitmap( const Bitmap & copy, int sx, int sy, double accuracy ); + Bitmap( const Bitmap & copy, int x, int y, int width, int height ); + virtual ~Bitmap(); + + virtual void save( const string & str ); + + Bitmap & operator=( const Bitmap & ); + + const int getWidth() const; + const int getHeight() const; + + /* + inline const int getWidth() const{ + return getBitmap()->w; + } + + inline const int getHeight() const{ + return getBitmap()->h; + } + */ + + /* + inline const int getWidth() const{ + return my_bitmap->w; + } + + inline const int getHeight() const{ + return my_bitmap->h; + } + */ + + void detach(); + + static void transBlender( int r, int g, int b, int a ); + static void multiplyBlender( int r, int g, int b, int a ); + + static void drawingMode( int type ); + + void acquire(); + void release(); + + void resize( const int width, const int height ); + + void debugSelf() const; + + void printf( int x, int y, int color, FONT * f, const char * str, ... ) const; + void printf( int x, int y, int color, Font * f, const char * str, ... ) const; + void printf( int x, int y, int color, Font * f, const string & str ) const; + void printfNormal( int x, int y, int color, const char * str, ... ) const; + void printfNormal( int x, int y, int color, const string & str ) const; + void triangle( int x1, int y1, int x2, int y2, int x3, int y3, int color ) const; + void ellipse( int x, int y, int rx, int ry, int color ) const; + void ellipseFill( int x, int y, int rx, int ry, int color ) const; + + void rectangle( int x1, int y1, int x2, int y2, int color ) const; + void rectangleFill( int x1, int y1, int x2, int y2, int color ) const; + void circleFill( int x, int y, int radius, int color ) const; + void circle( int x, int y, int radius, int color ) const; + void line( const int x1, const int y1, const int x2, const int y2, const int color ) const; + + void horizontalLine( const int x1, const int y, const int x2, const int color ) const; + void hLine( const int x1, const int y, const int x2, const int color ) const; + void vLine( const int y1, const int x, const int y2, const int color ) const; + void polygon( const int * verts, const int nverts, const int color ) const; + + void drawBorder( const int border, const int color ) const; + void draw( const int x, const int y, const Bitmap & where ) const; + void drawLit( const int x, const int y, const int level, const Bitmap & where ) const; + void drawHFlip( const int x, const int y, const Bitmap & where ); + void drawTrans( const int x, const int y, const Bitmap & where ) const; + void drawMask( const int x, const int y, const Bitmap & where ); + void drawStretched( const int x, const int y, const int new_width, const int new_height, const Bitmap & who ); + void drawRotate( const int x, const int y, const int angle, const Bitmap & where ); + + void Stretch( const Bitmap & where ); + void StretchBy2( const Bitmap & where ); + void StretchBy4( const Bitmap & where ); + void Blit( const string & xpath ); + void Blit( const Bitmap & where ); + void Blit( const int x, const int y, const Bitmap & where ); + void Blit( const int mx, const int my, const int wx, const int wy, const Bitmap & where ); + void Blit( const int mx, const int my, const int width, const int height, const int wx, const int wy, Bitmap & where ); + void BlitToScreen(); + void fill( int color ) const; + + inline void clear() const{ + this->fill( 0 ); + } + + bool getError(); + + inline BITMAP * getBitmap() const{ + return _my_bitmap; + } + + void readLine( vector< int > & vec, int y ); + const int getPixel( const int x, const int y ) const; + + void putPixel( int x, int y, int col ) const; + + /* + inline int getPixel( int x, int y ) const{ + if ( x >= 0 && x < my_bitmap->w && y >= 0 && y <= my_bitmap->h ) + return _getpixel16( my_bitmap, x, y ); + return -1; + } + + inline void putPixel( int x, int y, int col ) const{ + if ( x >= 0 && x < my_bitmap->w && y >= 0 && y <= my_bitmap->h ) + _putpixel16( my_bitmap, x, y, col ); + } + */ + + inline const string & getPath() const{ + return path; + } + + static int setGfxModeText(); + static int setGfxModeFullscreen( int x, int y ); + static int setGfxModeWindowed( int x, int y ); + + static int makeColor( int r, int g, int b ); + static void hsvToRGB( float h, float s, float v, int * r, int * g, int * b ); + + static int getRed( int x ); + static int getBlue( int x ); + static int getGreen( int x ); + + /* Add two colors together + */ + static int addColor( int color1, int color2 ); + + /* + inline static int makeColor( int r, int g, int b ){ + return makecol16( r, g, b ); + } + */ + + // static const int MaskColor = MASK_COLOR_16; + static const int MaskColor; + static const int MODE_TRANS; + static const int MODE_SOLID; + +protected: + + void releaseInternalBitmap(); + + inline void setBitmap( BITMAP * bitmap ){ + if ( bitmap == NULL ){ + cout << "*FATAL* Setting null bitmap" << endl; + } + _my_bitmap = bitmap; + } + + void internalLoadFile( const char * load_file ); + + BITMAP * _my_bitmap; + int * own; + // bool own; + bool error; + string path; + +}; + +#endif --- rafkill-1.2.2.orig/build/config.cpp +++ rafkill-1.2.2/build/config.cpp @@ -0,0 +1,230 @@ +#include "config.h" +#include "keyboard.h" +#include "system.h" +#include +#include +#include + +using namespace std; + +static const char * filename = "rafkill.config"; + +string getConfigFile(){ + if ( System::onWindows() ){ + return System::getHomeDirectory() + "/" + filename; + } else if ( System::onUnix() ){ + return System::getHomeDirectory() + "/.rafkill"; + } + return filename; +} + +Configuration * Configuration::instance = NULL; + +Configuration * Configuration::getInstance(){ + if ( instance == NULL ){ + instance = new Configuration(); + } + return instance; +} + +Configuration::Configuration(){ + internalSetForwardKey( Keyboard::UP ); + internalSetBackwardKey( Keyboard::DOWN ); + internalSetLeftKey( Keyboard::LEFT ); + internalSetRightKey( Keyboard::RIGHT ); + internalSetShootKey( Keyboard::SPACE ); + internalSetWindowMode( false ); + internalSetBackground( true ); + + loadConfiguration(); +} + +void Configuration::loadConfiguration(){ + FILE * config = fopen( getConfigFile().c_str(), "rb" ); + if ( ! config ){ + return; + } + char buf[ 1024 ]; + while ( ! feof( config ) ){ + fgets( buf, sizeof( buf ), config ); + if ( feof( config ) ){ + continue; + } + if ( buf[ 0 ] != '#' ){ + char bname[ 1024 ]; + int key = 0; + sscanf( buf, "%s = %d", bname, &key ); + string name( bname ); + if ( name == "forward" ){ + internalSetForwardKey( key ); + } else if ( name == "backward" ){ + internalSetBackwardKey( key ); + } else if ( name == "left" ){ + internalSetLeftKey( key ); + } else if ( name == "right" ){ + internalSetRightKey( key ); + } else if ( name == "shoot" ){ + internalSetShootKey( key ); + } else if ( name == "window" ){ + internalSetWindowMode( key ); + } else if ( name == "background" ){ + internalSetBackground( key ); + } else { + cout << "Ignoring line " << buf << endl; + } + } + } + fclose( config ); +} + +std::string Configuration::getForwardKeyName(){ + return Keyboard::keyToString( getForwardKey() ); +} + +std::string Configuration::getBackwardKeyName(){ + return Keyboard::keyToString( getBackwardKey() ); +} + +std::string Configuration::getLeftKeyName(){ + return Keyboard::keyToString( getLeftKey() ); +} + +std::string Configuration::getRightKeyName(){ + return Keyboard::keyToString( getRightKey() ); +} + +std::string Configuration::getShootKeyName(){ + return Keyboard::keyToString( getShootKey() ); +} + +bool Configuration::getWindowMode(){ + return getInstance()->internalGetWindowMode(); +} + +bool Configuration::getBackground(){ + return getInstance()->internalGetBackground(); +} + +int Configuration::getForwardKey(){ + return getInstance()->internalGetForwardKey(); +} + +int Configuration::getBackwardKey(){ + return getInstance()->internalGetBackwardKey(); +} + +int Configuration::getLeftKey(){ + return getInstance()->internalGetLeftKey(); +} + +int Configuration::getRightKey(){ + return getInstance()->internalGetRightKey(); +} + +int Configuration::getShootKey(){ + return getInstance()->internalGetShootKey(); +} + +int Configuration::internalGetForwardKey() const { + return keyForward; +} + +int Configuration::internalGetBackwardKey() const { + return keyBackward; +} + +int Configuration::internalGetLeftKey() const { + return keyLeft; +} + +int Configuration::internalGetRightKey() const { + return keyRight; +} + +int Configuration::internalGetShootKey() const { + return keyShoot; +} + +bool Configuration::internalGetWindowMode() const { + return windowMode; +} + +bool Configuration::internalGetBackground() const { + return background; +} + +void Configuration::setForwardKey( int k ){ + getInstance()->internalSetForwardKey( k ); +} + +void Configuration::setBackwardKey( int k ){ + getInstance()->internalSetBackwardKey( k ); +} + +void Configuration::setLeftKey( int k ){ + getInstance()->internalSetLeftKey( k ); +} + +void Configuration::setRightKey( int k ){ + getInstance()->internalSetRightKey( k ); +} + +void Configuration::setShootKey( int k ){ + getInstance()->internalSetShootKey( k ); +} + +void Configuration::setWindowMode( bool b ){ + getInstance()->internalSetWindowMode( b ); +} + +void Configuration::setBackground( bool b ){ + getInstance()->internalSetBackground( b ); +} + +void Configuration::internalSetForwardKey( const int k ){ + keyForward = k; +} + +void Configuration::internalSetBackwardKey( const int k ){ + keyBackward = k; +} + +void Configuration::internalSetLeftKey( const int k ){ + keyLeft = k; +} + +void Configuration::internalSetRightKey( const int k ){ + keyRight = k; +} + +void Configuration::internalSetShootKey( const int k ){ + keyShoot = k; +} + +void Configuration::internalSetWindowMode( const bool b ){ + windowMode = b; +} + +void Configuration::internalSetBackground( const bool b ){ + background = b; +} + +void Configuration::saveConfiguration(){ + + ofstream config( getConfigFile().c_str() ); + + cout << "Config file: " << getConfigFile() << endl; + config << "## Rafkill config file" << endl; + config << "## Do not hand edit, the loader will get messed up" << endl; + config << "forward = " << getForwardKey() << endl; + config << "backward = " << getBackwardKey() << endl; + config << "left = " << getLeftKey() << endl; + config << "right = " << getRightKey() << endl; + config << "shoot = " << getShootKey() << endl; + config << "window = " << getWindowMode() << endl; + config << "background = " << getBackground() << endl; + config.close(); + + delete instance; + instance = NULL; +} --- rafkill-1.2.2.orig/build/rfield.h +++ rafkill-1.2.2/build/rfield.h @@ -0,0 +1,87 @@ +#ifndef _rfield_h +#define _rfield_h + +#include "bitmap.h" +#include + +using namespace std; + +class Font; +class RMenu; + +class RField{ +public: + RField( bool selectable, bool perm, int return_val, RMenu * who, int number, int sound ); + + //selectable + virtual bool Ok(); + + virtual bool Title(); + + //return value + virtual int Val(); + + //returns place in list + virtual int Place(); + + virtual void set( void * object ); + + //add RField to list + virtual void Add( RField * rf ); + + //sets the next menu when chosen + virtual void setMenu( RMenu * nx ); + + virtual int Size(); + + //called when field is selected from menu + virtual void Selected(); + + virtual void Draw( const Bitmap & work, int x, int y, int col ); + + //returns true if container = obj + virtual bool equiv( void * obj ); + + virtual RField * Next(); + virtual RField * Prev(); + virtual RMenu * NextMenu(); + + virtual ~RField(); + +protected: + bool select; + int ret; + int num; + + bool title; + + RField * next, * prev; + RMenu * menu_next; + int sound; +}; + +class RField_Name: public RField { +public: + RField_Name( Font * f_font, string name, bool selectable, bool perm, int return_val, RMenu * who, int number, int sound ); + virtual bool equiv( void * obj ); + virtual void Draw( const Bitmap & work, int x, int y, int col ); + virtual int Size(); + virtual void set( void * object ); + virtual ~RField_Name(); +protected: + string handle; + Font * field_font; +}; + +class RField_Bitmap: public RField { +public: + RField_Bitmap( const Bitmap & look, bool selectable, bool perm, int return_val, RMenu * who, int number, int sound ); + virtual bool equiv( void * obj ); + virtual void Draw( const Bitmap & work, int x, int y, int col ); + virtual int Size(); + virtual ~RField_Bitmap(); +protected: + Bitmap scene; +}; + +#endif --- rafkill-1.2.2.orig/build/level.h +++ rafkill-1.2.2/build/level.h @@ -0,0 +1,90 @@ +#ifndef _level_h +#define _level_h + +#include +#include "trigger.h" +#include "bitmap.h" +#include + +using namespace std; + +class SpaceObject; +class HullObject; +class WeaponObject; +class Move; +class ECollide; +class PCKLoader; +class Group; + +#define MAX_SHIPS 2000 + +struct info_holder{ + int x, y; + double dx, dy; + int gun, hull, move; +}; + +class LevelCreator{ +public: + + LevelCreator( const char * file_name, SpaceObject * player ); + bool done(); + bool noExist(); + void create( vector< SpaceObject * > * sh, int leva, const double & speed ); + //void emergency( vector< SpaceObject * > * sh ); + void Draw( BITMAP * work, int xfac, int yfac ); + SpaceObject * special( int x, int y, const SpaceObject * player ); + ~LevelCreator(); + + HullObject * getHull( int a, int l, int _life ); + WeaponObject * getWeapon( int a ); + SpaceObject * GetEnemy( int cx, int cy, int hu, int we, int m, double _dx, double _dy ); + Move * getMove( int a, double _dx, double _dy ); + +private: + int hullNum( int a, int l ); + + // int gl_map( int who ); + //int file_length( FILE * fv ); + + void load_file( const char * file_name, SpaceObject * player ); + void makeInfo( char * buffer, int & current ); + void randomShip( int x, int y, Group * who_group, vector< SpaceObject * > * sh ); + Group * randomGroup( int x, int y ); + void put_ship( int x, int y, double dx, double dy, int hull, int gun, int move, int life ); + char * get_token( char * list, char find ); + double life_level( double level, int min ); + int processFile( const char * fv ); + + Group * Boss( int y, int _life ); + Group * makeCloud( int x, int y ); + + //SpaceObject ** ships; + //info_holder ** info; + int counter; + int max_use; + bool lerror; + int real_level; + // ECollide ** gl_collide; + + int num_cloud; + + int current_counter; + int meteor_chance; + + vector< class trigger * > trigger_list; + vector< class Group * > group_list; + + int meteor_life; + int * accept_guns; + int * accept_hull; + int * accept_move; + +private: + BITMAP ** hull_meteor_shadows; + int max_meteor_shadow; + int max_money_shadow; + +}; + +#endif --- rafkill-1.2.2.orig/build/main.cpp +++ rafkill-1.2.2/build/main.cpp @@ -0,0 +1,9 @@ +#include "main.h" + +#include + +int main( int argc, char ** argv ){ + return rafkill( argc, argv ); +} + +END_OF_MAIN(); --- rafkill-1.2.2.orig/build/config.h +++ rafkill-1.2.2/build/config.h @@ -0,0 +1,65 @@ +#ifndef _rafkill_config_h +#define _rafkill_config_h + +#include + +class Configuration{ +public: + + static std::string getForwardKeyName(); + static std::string getBackwardKeyName(); + static std::string getLeftKeyName(); + static std::string getRightKeyName(); + static std::string getShootKeyName(); + + static int getForwardKey(); + static int getBackwardKey(); + static int getLeftKey(); + static int getRightKey(); + static int getShootKey(); + static bool getWindowMode(); + static bool getBackground(); + + static void setForwardKey( int k ); + static void setBackwardKey( int k ); + static void setLeftKey( int k ); + static void setRightKey( int k ); + static void setShootKey( int k ); + static void setWindowMode( bool b ); + static void setBackground( bool b ); + + static void saveConfiguration(); + + static Configuration * getInstance(); +private: + Configuration(); + static Configuration * instance; + + void loadConfiguration(); + + int internalGetForwardKey() const; + int internalGetBackwardKey() const; + int internalGetLeftKey() const; + int internalGetRightKey() const; + int internalGetShootKey() const; + bool internalGetWindowMode() const; + bool internalGetBackground() const; + + void internalSetForwardKey( const int k ); + void internalSetBackwardKey( const int k ); + void internalSetLeftKey( const int k ); + void internalSetRightKey( const int k ); + void internalSetShootKey( const int k ); + void internalSetWindowMode( const bool k ); + void internalSetBackground( const bool k ); + + int keyForward; + int keyBackward; + int keyLeft; + int keyRight; + int keyShoot; + bool windowMode; + bool background; +}; + +#endif --- rafkill-1.2.2.orig/build/pck.h +++ rafkill-1.2.2/build/pck.h @@ -0,0 +1,23 @@ +#ifndef _pck_loader_h +#define _pck_loader_h + +#include "defs.h" +#include + +class Bitmap; + +class pckLoader{ +public: + pckLoader(); + Bitmap * load( const char * sf ); + +private: + void set( Bitmap * fat, int & x, int & y, int col); + Bitmap * load_pck( char * sf, int * shade, int max ); + int getnum( char *& buf ); + int filesize( FILE * fv ); + void get_colors( int & c1, int & c2 ); + +}; + +#endif --- rafkill-1.2.2.orig/build/system.cpp +++ rafkill-1.2.2/build/system.cpp @@ -0,0 +1,39 @@ +#include "system.h" +#include +#include + +#ifdef WINDOWS +static const char * type(){ + return "WINBLOWS"; +} + +static std::string homeDir(){ + return std::string( "." ); +} + +#else +#include +#include + +static const char * type(){ + return "UNIX"; +} + +static std::string homeDir(){ + struct passwd * fields = getpwuid( getuid() ); + return std::string( fields->pw_dir ); +} + +#endif + +bool System::onWindows(){ + return strcasecmp( type(), "WINBLOWS" ) == 0; +} + +bool System::onUnix(){ + return strcasecmp( type(), "UNIX" ) == 0; +} + +std::string System::getHomeDirectory(){ + return homeDir(); +} --- rafkill-1.2.2.orig/build/explode_animate.h +++ rafkill-1.2.2/build/explode_animate.h @@ -0,0 +1,20 @@ +#ifndef _explode_animate_h_ +#define _explode_animate_h_ + +#include "explode.h" +class Bitmap; + +class ExplosionAnimate: public ExplosionClass{ +public: + ExplosionAnimate( int cx, int cy, double dx, double dy, int _first_pic, int _last_pic ); + + virtual bool update(); + virtual void Draw( Bitmap * who, int offset ); + +protected: + int first_pic; + int last_pic; + +}; + +#endif --- rafkill-1.2.2.orig/build/section.cpp +++ rafkill-1.2.2/build/section.cpp @@ -0,0 +1,159 @@ +#include "section.h" +#include "spaceobj.h" +// #include +#include +#include + +using namespace std; + +Section::Section(): +section_y( 0 ), +section_x( 0 ){ +// internal_list( 0 ) { + + /* + for ( int q = 0; q < MAX_SECTION_LIST; q++ ) + container_list[q] = new vector< SpaceObject * >(); + */ + + current_list = lists.begin(); + +} + + +void Section::add( SpaceObject * who, int x, int y ) { + + y += MIN_SECTION_Y; + y /= MAX_SECTION_OBJ_Y; + x += MIN_SECTION_X; + x /= MAX_SECTION_OBJ_X; + + if ( y >= 0 && y < MAX_SECTION_LIST_Y && x >= 0 && x < MAX_SECTION_LIST_X ) { + + //for ( int q = 0; q < container_list[y]->size(); q++ ) + // if ( (*container_list[y])[q] == who ) return; + + // container_list[y]->push_back( who ); + container_list[y][x].push_back( who ); + + lists[y*10+x] = &container_list[y][x]; + } + +} + + +void Section::dispose( SpaceObject * who ) { + + for ( int y = 0; y < MAX_SECTION_LIST_Y; y++ ) + for ( int x = 0; x < MAX_SECTION_LIST_X; x++ ){ + vector< SpaceObject * > & vec = container_list[y][x]; + for ( vector< SpaceObject * >::iterator it = vec.begin(); it != vec.end(); ){ + if ( *it == who ) + it = vec.erase( it ); + else ++it; + } + } + /* + for ( int q = 0; q < MAX_SECTION_LIST_Y; q++ ) { + + for ( vector< SpaceObject * >::iterator it = container_list[q]->begin(); + it != container_list[q]->end(); ) { + if ( *it == who ) + it = container_list[q]->erase( it ); + else ++it; + } + + } + */ + +} + + +void Section::print() { + + /* + printf("Info for %p\n", this ); + for ( int q = 0; q < MAX_SECTION_LIST; q++ ){ + + printf("Container %d\n", q ); + Iterator * i = container_list[q]->iterator(); + + while ( !i->isEmpty() ){ + printf("[%p]", i->getObj() ); + i->Next(); + } + + delete i; + printf("\n"); + + } + printf("End info for %p\n", this ); + */ + +} + + +void Section::reset() { + // internal_list = 0; + section_y = 0; + section_x = 0; + current_list = lists.begin(); +} + + +int Section::spacerY() { + return MAX_SECTION_OBJ_Y; +} + +int Section::spacerX() { + return MAX_SECTION_OBJ_X; +} + +void Section::clear() { + + /* + for ( int q = 0; q < MAX_SECTION_LIST; q++ ) + container_list[q]->clear(); + internal_list = 0; + */ + cout<<"CLEARARARA"< * Section::getNext() { + + /* + if ( section_x < MAX_SECTION_LIST_X && section_y < MAX_SECTION_LIST_Y ){ + vector< SpaceObject * > * ret = &container_list[section_y][section_x]; + section_x++; + if ( section_x >= MAX_SECTION_LIST_X ){ + section_x = 0; + section_y++; + } + + return ret; + } + */ + if ( current_list == lists.end() ) return NULL; + vector< SpaceObject * > * ret = (*current_list).second; + current_list++; + return ret; + return NULL; + /* + if ( internal_list < MAX_SECTION_LIST ) { + internal_list++; + return container_list[ internal_list-1 ]; + } + return NULL; + */ +} + + +Section::~Section() { + // clear(); + /* + for ( int q = 0; q < MAX_SECTION_LIST; q++ ) + delete container_list[q]; + */ +} --- rafkill-1.2.2.orig/build/strings.h +++ rafkill-1.2.2/build/strings.h @@ -0,0 +1,16 @@ +#ifndef _strings_h +#define _strings_h + +#include + +int numDig( int q ); +std::string int2str( int z ); +std::string int2normal( int z ); +// string d2normal( double whole, int precise ); +int str2int( char * convert ); +double str2d( char * convert ); +int length( char * q ); +char upcase( char u ); +void upstring( char * who ); + +#endif --- rafkill-1.2.2.orig/build/strings.cpp +++ rafkill-1.2.2/build/strings.cpp @@ -0,0 +1,195 @@ +#include "strings.h" +#include +#include +#include +#include +#include + +using namespace std; + +int numDig( int q ) { + + int t = 1; + q = abs( q ); + while( q >= 10 ) { + t++; + q /= 10; + } + return t; + +} + +string int2str( int z ) { + bool neg = z < 0; + int nd = numDig( z ); + char * str = (char *)malloc( sizeof(char) * (neg + nd + 1) ); + + z = abs( z ); + for ( int q = 0; q < nd; q++ ) { + int h = z % 10; + str[ neg + nd - q - 1 ] = '0' + h; + z /= 10; + } + if ( neg ) str[0] = '-'; + str[ neg + nd ] = '\0'; + string s = str; + free( str ); + return s; +} + +string int2normal( int z ) { + bool neg = z < 0; + int nd = numDig( z ); + int total_char = neg + nd + abs(nd-1)/3+1; + char * str = (char *)malloc( sizeof(char) * (total_char) ); + for ( int q = 0; q < total_char; q++ ) + str[q] = 'A'; + char * lem = str+(total_char-1); + *lem = '\0'; + lem--; + z = abs( z ); + for ( int q = 0; q < nd; q++ ) { + int h = z % 10; + *lem = '0'+h; + lem--; + if ( (q+1) % 3 == 0 && q != nd-1 ) { + *lem = ','; + lem--; + } + z /= 10; + } + if ( neg ) *str = '-'; + string s = str; + free( str ); + return s; +} + +/* +char * d2normal( double whole, int precise ) { + int z = (int)whole; + bool neg = z < 0; + int nd = numDig( z ); + int total_char = neg + nd + abs(nd-1)/3+1+1; + char * str = (char *)malloc( sizeof(char) * (total_char) ); + for ( int q = 0; q < total_char; q++ ) + str[q] = 'A'; + char * lem = str+(total_char-1); + *lem = '\0'; + lem--; + *lem = '.'; + lem--; + z = abs( z ); + for ( int q = 0; q < nd; q++ ) { + int h = z % 10; + *lem = '0'+h; + lem--; + if ( (q+1) % 3 == 0 && q != nd-1 ) { + *lem = ','; + lem--; + } + z /= 10; + } + + z = (int)whole; + whole -= z; + whole = fabs( whole ); + for ( int q = 0; q < precise; q++ ) { + + char * t = (char *)malloc( sizeof( char ) * 2 ); + whole *= 10; + z = (int)whole; + *t = '0' + z; + whole -= z; + *(t+1) = '\0'; + char * reveal = append( str, t ); + free( str ); + free( t ); + str = reveal; + + } + + if ( neg ) *str = '-'; + return str; +} +*/ + +char upcase( char u ) { + + if ( u >= 'a' && u <= 'z' ) + return u-'a'+'A'; + else return u; + +} + + +void upstring( char * who ) { + while ( *who != 0 ) + *who++ = upcase( *who ); +} + + +int str2int( char * convert ) { + + int total = 0; + bool neg = convert[0] == '-'; + for ( int q = neg; q < length( convert ); q++ ) { + if ( !(convert[q] >= '0' && convert[q] <= '9' ) ) + return 0; + total = total * 10 + convert[q]-'0'; + } + if ( neg ) total *= -1; + return total; + +} + + +double str2d( char * convert ) { + + double front = 0; + double back = 0; + int place; + bool neg = convert[0] == '-'; + for ( place = neg; place < length( convert ) && convert[place] != '.'; place++ ) { + if ( !( convert[place] >= '0' && convert[place] <= '9' ) ) + return 0; + front = (front * 10.0) + convert[place]-'0'; + } + if ( neg ) front *= -1; + if ( place >= length( convert ) ) + return front; + if ( convert[place] == '.' ) place++; + double total = 1.0; + for ( ; place < length( convert ); place++ ) { + if ( !(convert[place] >= '0' && convert[place] <= '9' ) ) + return 0; + total *= 10.0; + back = (back * 10.0) + convert[place]-'0'; + } + back /= total; + if ( neg ) back *= -1; + front += back; + return front; + +} + + +int length( char * q ) { + int z; + for ( z = 0; *q != '\0'; z++, q++ ); + return z; +} + +/* +char * append( const char * first, const char * second ) { + //printf("Appending [%s] with [%s]\n", first, second ); + int m1 = strlen( first ); + int m2 = strlen( second ); + if ( m1 + m2 == 0 ) + return strdup(""); + char * final = (char *)malloc( sizeof(char) * (m1 + m2 + 1) ); + if ( m1 ) memmove( (void *)final, (void *)first, m1 ); + if ( m2 ) memmove( (void *)(final + sizeof(char)*m1 ), (void *)second, m2 ); + final[ m1 + m2 ] = '\0'; + return final; +} +*/ --- rafkill-1.2.2.orig/build/ebox.h +++ rafkill-1.2.2/build/ebox.h @@ -0,0 +1,162 @@ +/* ebox version 2: + * by Jon Rafkind + */ + +#ifndef _ebox_2_h +#define _ebox_2_h + +#include "bitmap.h" + +class EQuad{ +public: + + EQuad( EQuad * const head ); + EQuad( int w, int h, EQuad * _parent ); + EQuad( const Bitmap * who, int min_size, int mask_pixel, int min_x, int min_y, EQuad * _parent ); + + void draw( const Bitmap & work, int x, int y, int color, bool flipped = false ); + void draw( const Bitmap & work, int x, int y, int color, EQuad * who ); + + inline int getWidth() const{ + return width; + } + + inline int getHeight() const{ + return height; + } + + inline void setFull( bool x ){ + full = x; + } + + EQuad * const getQuad( int x ) const; + + bool addQuad( EQuad * who ); + + inline int getPosX() const { + if ( parent ) + return min_x + parent->getPosX(); + return min_x; + } + + inline int getPosY() const { + if ( parent ) + return min_y + parent->getPosY(); + return min_y; + } + + // bool collide( int mx, int my, int x1, int y1, int x2, int y2, EQuad ** last ); + bool collide( int mx, int my, int x1, int y1, int x2, int y2, EQuad ** last, bool xflipped = false, bool yflipped = false ); + // int collide( int mx, int my, int x1, int y1, int x2, int y2, EQuad ** last, int depth ); + + int calcSize(); + + void setMinX( int x ); + void setMinY( int y ); + + inline int getMinX() const{ + return min_x; + } + + inline int getMinY() const{ + return min_y; + } + + int totalQuads(); + + ~EQuad(); + +protected: + + EQuad * const getQuad() const; + void detach( EQuad * const who ); + void checkQuad( EQuad *& q ); + + inline int numQuads() const{ + int total = 0; + if ( quads[0] != NULL ) total++; + if ( quads[1] != NULL ) total++; + if ( quads[2] != NULL ) total++; + if ( quads[3] != NULL ) total++; + // for ( int total = 0; total < 4 && quads[total] != NULL; total++ ); + return total; + } + + bool empty(); + // bool boxCollide( int zx1, int zy1, int zx2, int zy2, int zx3, int zy3, int zx4, int zy4 ); + +protected: + + int width, height; + // EQuad * quad1, * quad2, * quad3, * quad4; + + bool full; + + int min_x, min_y; + EQuad * quads[ 4 ]; + EQuad * parent; + int num_quads; + +}; + +class ECollide{ +public: + ECollide( EQuad * const head ); + ECollide( BITMAP * who, int mask_pixel = Bitmap::MaskColor ); + ECollide( const Bitmap * who, int mask_pixel = Bitmap::MaskColor ); + ECollide( const Bitmap & who, int mask_pixel = Bitmap::MaskColor ); + ECollide( const ECollide & e ); + ECollide( const ECollide * e ); + ECollide( int width, int height ); + + void draw( const Bitmap & work, int x, int y, bool flipped = false ); + void draw( const Bitmap & work, int x, int y, int color, EQuad * who ); + + bool Collision( ECollide * col, int mx, int my, int ax, int ay, bool my_xflipped = false, bool my_yflipped = false, bool him_xflipped = false, bool him_flipped = false ); + bool Collision( int mx, int my, int ax, int ay, bool xflipped = false, bool yflipped = false ); + bool Collision( int mx, int my, int x1, int y1, int x2, int y2, bool xflipped = false, bool yflipped = false ); + + int getMinHeight(); + int getMaxHeight(); + int getMinWidth(); + int getMaxWidth(); + + ECollide * copy(); + + EQuad * getLast(); + + EQuad * getHead() const{ + return head_quad; + } + + int calcSize(); + + inline int getWidth() const{ + return head_quad->getWidth(); + } + + inline int getHeight() const{ + return head_quad->getHeight(); + } + + int numQuads() const; + + ~ECollide(); + +private: + void initECollide( const Bitmap * who, int mask_pixel ); + void initQuad( EQuad * const head ); + + static long long totalTime; + +protected: + + bool collide( int mx, int my, int x1, int y1, int x2, int y2, bool xflipped = false, bool yflipped = false ); + // bool collide( int mx, int my, int x1, int y1 ); + + EQuad * head_quad; + EQuad * last_collide; + +}; + +#endif --- rafkill-1.2.2.orig/build/logic.h +++ rafkill-1.2.2/build/logic.h @@ -0,0 +1,44 @@ +#ifndef _game_logic_h_ +#define _game_logic_h_ + +#include + +using namespace std; + +class SpaceObject; +class LevelCreator; +class Section; +class ExplosionClass; + +#define MAX_EXPL 100 + +class Logic{ +public: + + Logic(); + ~Logic(); + + int runCycle( SpaceObject * player, LevelCreator * level ); + + vector< SpaceObject * > * getObjects(); + ExplosionClass ** getExplode(); + int maxExplode(); + +protected: + + void handleSpace( vector< SpaceObject * > * mv, Section * onscreen ); + void checkCollision( Section * fight, SpaceObject * take, int sound, int vol ); + void enforceUniverse( SpaceObject * player ); + void HandleExplosion(); + void DeleteSpace( vector< SpaceObject *> * objs, Section * sec, const SpaceObject * _player, LevelCreator * level ); + void clearCollide( vector< SpaceObject * > * contain ); + bool outOfBounds( SpaceObject * who ); + void vectorAdd( vector< SpaceObject * > * stable, vector< SpaceObject * > * state ); + +protected: + ExplosionClass * expl[ MAX_EXPL ]; + vector< SpaceObject * > objects; + +}; + +#endif --- rafkill-1.2.2.orig/build/rgbhandle.cpp +++ rafkill-1.2.2/build/rgbhandle.cpp @@ -0,0 +1,67 @@ +#include "rgbhandle.h" +#include "defs.h" + +RGBHandle::RGBHandle() { + rwant = Util::rnd( 255 ); + gwant = Util::rnd( 255 ); + bwant = Util::rnd( 255 ); + + mine.r = rwant; + mine.g = gwant; + mine.b = bwant; + +} + + +void RGBHandle::update( int max, int min ) { + + unsigned char * want[ 3 ]; + want[0] = &rwant; + want[1] = &gwant; + want[2] = &bwant; + + if ( changecol( mine.r, rwant ) ) { + if ( Util::rnd( RGB_GO_BLACK ) == Util::rnd( RGB_GO_BLACK ) ) + rwant = 0; + else rwant = Util::rnd(max-min)+min; + } + + if ( changecol( mine.g, gwant ) ) { + if ( Util::rnd( RGB_GO_BLACK ) == Util::rnd( RGB_GO_BLACK ) ) + gwant = 0; + else gwant = Util::rnd(max-min)+min; + } + + if ( changecol( mine.b, bwant ) ) { + if ( Util::rnd( RGB_GO_BLACK ) == Util::rnd( RGB_GO_BLACK ) ) + bwant = 0; + else bwant = Util::rnd(max-min)+min; + } + + bool cy = false; + for ( int q = 0; q < 3; q++ ) + cy = cy || (*(want[q]) >= min && *(want[q]) <= max); + if ( !cy ) *(want[Util::rnd(3)]) = Util::rnd(max-min)+min; + cy = true; + for ( int q = 0; q < 3; q++ ) + cy = cy && *(want[q]) == 0; + if ( cy ) *(want[Util::rnd(3)]) = Util::rnd(max-min)+min; + +} + + +int RGBHandle::Get( ) { + return Bitmap::makeColor( mine.r, mine.g, mine.b ); +} + + +bool RGBHandle::changecol( unsigned char & c, unsigned char & dir ) { + + for ( int q = 0; q < 2; q++ ) { + if ( c > dir ) c--; + if ( c < dir ) c++; + } + + return c == dir; + +} --- rafkill-1.2.2.orig/build/rmenu.cpp +++ rafkill-1.2.2/build/rmenu.cpp @@ -0,0 +1,428 @@ +#include +#include "rmenu.h" +#include "trigtable.h" +#include "strings.h" +#include "rfield.h" +#include "keyboard.h" +#include "font.h" +#include +#include "bitmap.h" + +static const int MAX_SHADE_OPT_COLOR = 14; +static const int NO_SOUND = -1; + +RMenu::RMenu( const Bitmap & intr, int x1, int y1, int _height, int c1, int c2, int title_color ): +last_opt( 0 ), +first_x( x1 ), +first_y( y1 ), +col1( c1 ), +col2( c2 ), +t_color( title_color ), +height( _height ){ + + prev = this; + background = intr; + head = new RField( false, false, -1, this, -1, NO_SOUND ); + location = head; + + + // #define MAX_SHADE_OPT_COLOR 14 + + shade = new int[ 20 ]; + shade_border = new int[ 20 ]; + shade_opt_color = new int[ MAX_SHADE_OPT_COLOR ]; + Util::blend_palette( shade_opt_color, MAX_SHADE_OPT_COLOR, col1, col2 ); + Util::blend_palette( shade_border, 20, Bitmap::makeColor( 130, 130, 0 ), Bitmap::makeColor( 255, 255, 0 ) ); + Util::blend_palette( shade, 20, Bitmap::makeColor( 240, 240, 0 ), Bitmap::makeColor( 130, 130, 0 ) ); + select = false; + initialized = false; + opts = NULL; + opts_shade = NULL; +} + + +RMenu::~RMenu() { + + while ( head != NULL ) { + RField * junk = head; + head = head->Next(); + delete junk; + } + + delete[] shade; + delete[] shade_border; + delete[] shade_opt_color; + + if ( initialized ){ + endMenu(); + } + +} + + +RField * RMenu::addTitle( string title, Font * rf ) { + int ta = countNodes(); + RField * junk = new RField_Name( rf, title, false, true, 0, NULL, ta, NO_SOUND ); + RField * current = head; + while ( current->Next() != NULL ) current = current->Next(); + current->Add( junk ); + return junk; +} + + +RField * RMenu::addMenu( string title, Font * rf, bool s, int r, RMenu * who, int sound ) { + int ta = countNodes(); + RField * junk = new RField_Name( rf, title, s, false, r, who, ta, sound ); + RField * current = head; + while ( current->Next() != NULL ) current = current->Next(); + current->Add( junk ); + return junk; +} + +RField * RMenu::addMenu( const Bitmap & look, bool s, int r, RMenu * who, int sound ) { + int ta = countNodes(); + RField * junk = new RField_Bitmap( look, s, false, r, who, ta, sound ); + RField * current = head; + while ( current->Next() != NULL ) current = current->Next(); + current->Add( junk ); + + return junk; +} + + +void RMenu::replace( int q, string title, Font * rf, bool s, int r, RMenu * who, int sound ) { + RField * current = head; + for ( int z = 0; z < q; z++ ){ + current = current->Next(); + } + RField * junk = new RField_Name( rf, title, s, false, r, who, current->Place(), sound ); + current->Prev()->Add( junk ); + junk->Add( current->Next() ); + if ( location == current ) location = junk; + delete current; + current = head; +} + + +void RMenu::replaceTitle( int q, string title, Font * rf ) { + RField * current = head; + for ( int z = 0; z < q; z++ ) + current = current->Next(); + RField * junk = new RField_Name( rf, title, false, true, 0, NULL, current->Place(), NO_SOUND ); + current->Prev()->Add( junk ); + junk->Add( current->Next() ); + if ( location == current ) location = junk; + delete current; + current = head; +} + + +void RMenu::replace( int q, const Bitmap & look, bool s, int r, RMenu * who, int sound ) { + RField * current = head; + for ( int z = 0; z < q; z++ ) + current = current->Next(); + RField * junk = new RField_Bitmap( look, s, false, r, who, current->Place(), sound ); + current->Prev()->Add( junk ); + junk->Add( current->Next() ); + if ( location == current ) location = junk; + delete current; + current = head; +} + + +void RMenu::nextMenu( int q, RMenu * nx ) { + RField * current = head; + for ( int z = 0; z < q; z++ ){ + current = current->Next(); + } + current->setMenu( nx ); +} + +void RMenu::prevMenu( RMenu * rm ) { + prev = rm; +} + +RMenu * RMenu::Previous() { + return prev; +} + +int RMenu::countNodes() { + RField * current = head->Next(); + int total = 0; + while ( current != NULL ) { + total++; + current = current->Next(); + } + return total; +} + +void RMenu::spiffy_triangle( const Bitmap & work, int x1, int y1, int color, int * shade, int MAX_SHADE, int dir ) { + + int x2 = x1 + 40; + int y2 = y1; + int x3 = ( x1 + x2) / 2; + + for ( int q = 10; q >= 0; q-- ) { + int y3 = y2 + dir * q; + int col = (color - q * 2 + MAX_SHADE) % MAX_SHADE; + work.triangle( x1, y1, x2, y2, x3, y3, shade[ col ] ); + } + +} + +int RMenu::askPos( string title ) { + + RField * junk = head->Next(); + while ( junk != NULL ) { + if ( junk->equiv( &title ) ){ + return junk->Place()+1; + } + junk = junk->Next(); + } + return -1; + +} + +void RMenu::clear() { + + while ( head != NULL ) { + RField * junk = head; + head = head->Next(); + delete junk; + } + head = new RField( false, false, -1, this, -1, NO_SOUND ); + location = head; + +} + + +bool RMenu::Selected() { + + bool cy = select; + select = false; + return cy; + +} + + +void RMenu::Draw( const Bitmap & work, int x, int * yval, int * yshade, int min, int max ) { + + RField * junk = head->Next(); + for ( int q = min; q <= max; q++ ) { + while( junk->Place() != q ) junk = junk->Next(); + if ( junk->Title() ) + junk->Draw( work, x, yval[q-min], t_color ); + else + junk->Draw( work, x, yval[q-min], shade_opt_color[yshade[junk->Place()]] ); + } +} + + +bool RMenu::changed() { + bool cy = change; + change = false; + return cy; +} + + +void RMenu::init() { + + initialized = true; + + while ( !location->Ok() ) { + location = location->Next(); + if ( location == NULL ) location = head; + } + + work.resize( GRAPHICS_X, GRAPHICS_Y ); + + /* + work = create_bitmap( GRAPHICS_X, GRAPHICS_Y ); + if ( !work ) + printf("Could not create proc work\n"); + */ + + background.Blit( work ); + + x1 = 0; + ang = 90; + + col_up = 5; + col_down = 15; + + opt_max = countNodes(); + + change = false; + + opts = new int[ opt_max ]; + opts_shade = new int[ opt_max ]; + + field_seen = head->Next(); + keep_y = first_y; + for ( int q = 0; q < opt_max; q++ ) { + opts[q] = keep_y; + if ( keep_y + field_seen->Size() < Util::screen_y ) max_seen = q; + // keep_y += field_seen->Size()*5/2; + keep_y += field_seen->Size() * 3 / 2; + field_seen = field_seen->Next(); + } + + RField * temp = head->Next(); + while ( temp != NULL ) { + if( temp->Ok() ) opts_shade[temp->Place()] = 0; + else opts_shade[temp->Place()]=MAX_SHADE_OPT_COLOR-1; + temp = temp->Next(); + } + + Util::speed_counter = 0; + k_hold = false; + + min_x = first_x; + + shade_counter = 0; + +} + + +void RMenu::endMenu() { + + initialized = false; + // destroy_bitmap( work ); + delete[] opts; + opts = NULL; + delete[] opts_shade; + opts_shade = NULL; + +} + + +int RMenu::procMenu( RMenu ** current ) { + + if ( !initialized ) init(); + + //while ( !key[KEY_SPACE] && !key[KEY_ENTER] ){ + + bool dirty = false; + while ( Util::speed_counter ) { + dirty = true; + Util::speed_counter--; + + ang += 6; + if ( ang < 0 ) ang += 180; + if ( ang >= 180 ) ang -= 180; + + if ( ! Keyboard::getAnyKey( Keyboard::DOWN ) && ! Keyboard::getAnyKey( Keyboard::UP ) ){ + k_hold = false; + } + + if ( Keyboard::getAnyKey( Keyboard::DOWN ) && ! k_hold ) { + do { + location = location->Next(); + if ( location == NULL ) location = head->Next(); + } while ( ! location->Ok() ); + + location->Selected(); + k_hold = true; + change = true; + } + if ( Keyboard::getAnyKey( Keyboard::UP ) && ! k_hold ) { + do { + if ( location != head ) + location = location->Prev(); + if ( location == head ) { + while ( location->Next() != NULL ) + location = location->Next(); + } + } while ( ! location->Ok() ); + location->Selected(); + k_hold = true; + change = true; + + } + + RField * junk = head->Next(); + while ( junk != NULL ) { + if ( junk->Place() == location->Place() || !junk->Ok() ) { + if ( opts_shade[junk->Place()] < MAX_SHADE_OPT_COLOR-1 )opts_shade[junk->Place()]++; + } else if ( opts_shade[junk->Place()] > 0 )opts_shade[junk->Place()]--; + junk = junk->Next(); + + } + + } + + if ( dirty ) { + + background.Blit( work ); + + col_up = ang / 9; + col_down = 19 - ang / 9; + x1 = Tsine(ang)*20; + + int real_seen = max_seen/2; + if ( location->Place() < max_seen/2 ){ + real_seen = location->Place(); + } + if ( location->Place() >= opt_max - (max_seen / 2 + 1) ){ + real_seen = max_seen - (opt_max - 1 - location->Place()); + } + + ac_y = opts[ real_seen ] + location->Size()/2; + work.triangle( min_x + 4, ac_y - (int) x1, min_x + 1, ac_y, min_x + 30, ac_y, shade[ col_down ] ); + work.triangle( min_x + 4, ac_y + (int) x1, min_x + 1, ac_y, min_x + 30, ac_y, shade[ col_up ] ); + + work.line( min_x+4, ac_y-(int)x1, min_x+30, ac_y, shade_border[ col_up ] ); + work.line( min_x+4, ac_y+(int)x1, min_x+30, ac_y, shade_border[ col_down ] ); + + int div2 = max_seen/2; + + int min = location->Place() - div2; + int max = location->Place() + (max_seen - div2); + + if ( min < 0 ) { + min = 0; + max = max_seen; + } + if ( max >= opt_max ) { + max = opt_max-1; + min = max-max_seen; + } + + Draw( work, min_x + 50, opts, opts_shade, min, max ); + + shade_counter = (shade_counter + 1) % 20; + + if ( max + 1 < opt_max ){ + spiffy_triangle( work, min_x, opts[ max_seen ], shade_counter, shade, 20, 1 ); + } + + if ( min > 0 ){ + spiffy_triangle( work, min_x, opts[ 0 ]+10, shade_counter, shade, 20, -1 ); + } + + work.BlitToScreen(); + } + + //} + + if ( Keyboard::getAnyKey( Keyboard::ENTER, Keyboard::SPACE ) ){ + select = true; + + while ( Keyboard::getAnyKey( Keyboard::SPACE, Keyboard::ENTER ) ){ + Util::YIELD(); + } + + // while ( key[KEY_ENTER] ); + + endMenu(); + + if ( location->NextMenu() != this ) { + if ( location->NextMenu() != NULL ) { + *current = location->NextMenu(); + (*current)->prevMenu( this ); + } else *current = prev; + } + } + return location->Val(); + +} --- rafkill-1.2.2.orig/build/guns/gun_destruct.h +++ rafkill-1.2.2/build/guns/gun_destruct.h @@ -0,0 +1,24 @@ +#ifndef _gun_enemy_destruct_h_ +#define _gun_enemy_destruct_h_ + +#include "gunobj.h" +#include +#include "spaceobj.h" + +using namespace std; + +class GunDestruct:public WeaponObject{ +public: + GunDestruct( int d, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + virtual ~GunDestruct(); + +protected: + vector< SpaceObject * > * ammo; + int max_ammo; + int lx, ly; + +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_destruct.cpp +++ rafkill-1.2.2/build/guns/gun_destruct.cpp @@ -0,0 +1,39 @@ +#include "gun_destruct.h" +#include "weaponobj.h" +#include "hulls/hull_weapon_s_s.h" +#include "spaceobj.h" +#include +#include "defs.h" + +using namespace std; + +GunDestruct::GunDestruct( int d, int al ): +WeaponObject( d, "Destruct", 0, al, 0, 0 ) { + ammo = NULL; +} + + +void GunDestruct::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + ammo = Ammo; + lx = x; + ly = y; +} + + +GunDestruct::~GunDestruct() { + + if ( ammo == NULL ) return; + + for ( int q = 0; q < Util::rnd( 10 ) + 10; q++ ) { + + double cx = ( (double)( Util::rnd( 11 ) + 11 ) / 19.0 ) * (Util::rnd(2)*2-1); + double cy = ( (double)( Util::rnd( 11 ) + 11 ) / 20.0 ) * (Util::rnd(2)*2-1); + + ammo->push_back( new WeaponNode(lx,ly,cx,cy,new SS_WHull(), alignment ) ); + } +} + + +WeaponObject * GunDestruct::copy() { + return new GunDestruct( dir, alignment ); +} --- rafkill-1.2.2.orig/build/guns/gun_massive.h +++ rafkill-1.2.2/build/guns/gun_massive.h @@ -0,0 +1,30 @@ +#ifndef _gun_massive_h +#define _gun_massive_h + +#include "gunobj.h" +#include + +using namespace std; + +class ECollide; +class SpaceObject; + +class WeaponMassiveGun: public WeaponObject{ +public: + + WeaponMassiveGun( int z, int d, int smp, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual void Idle(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + ~WeaponMassiveGun(); + +protected: + + int rising; + ECollide * diss_collide; + int ang; + +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_efmsingle.cpp +++ rafkill-1.2.2/build/guns/gun_efmsingle.cpp @@ -0,0 +1,56 @@ +#include "gunobj.h" +#include "weaponobj.h" +#include "gun_efmsingle.h" +#include "hulls/hull_weapon_s_s.h" +#include "trigtable.h" +#include "spaceobj.h" +#include + +using namespace std; + +EnemyFindSingleMachine::EnemyFindSingleMachine( int d, int al ): +WeaponObject( d, "Find Single Machine", 0, al, 0, 0 ), +tear( 5 ){} + +void EnemyFindSingleMachine::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * objects ) { + + setShotCounter( 40 ); + + if ( objects == NULL ) return; + if ( tear > 0 ) { + tear--; + setShotCounter( 10 ); + } else tear = 5; + if ( objects->empty() ) return; + + /* fixed: + * Find actual enemy, not just front + */ + SpaceObject obj(0,0,0,0,NULL, NULL, PLANE_AIR|PLANE_GROUND, getTeam() ); + + /* + vector< SpaceObject * > my_fight; + for ( vector< SpaceObject *>::const_iterator it = objects->begin(); it != objects->end(); it++ ){ + SpaceObject * potential = *it; + if ( potential->CanbeHit( &gay ) ){ + my_fight.push_back( potential ); + } + } + */ + + // if ( my_fight.empty() ) return; + // const SpaceObject * use = my_fight[ Util::rnd(my_fight.size()) ]; + const SpaceObject * use = getCollidableObject( objects, &obj ); + + if ( use != NULL ) { + const double FIND_BULLET = -1.2 * 8; + int sang = gang( x, y, use->getX(), use->getY()+7 ); + double sx = Tcos(sang)*FIND_BULLET; + double sy = Tsine(sang)*FIND_BULLET; + Ammo->push_back( new WeaponNode(x,y,sx,sy,new SS_WHull(), alignment ) ); + } + +} + +EnemyFindSingleMachine::~EnemyFindSingleMachine() { +} --- rafkill-1.2.2.orig/build/guns/gun_arc.h +++ rafkill-1.2.2/build/guns/gun_arc.h @@ -0,0 +1,28 @@ +#ifndef _gun_arc_h +#define _gun_arc_h + +#include "gunobj.h" +#include +// #include "ebox.h" + +using namespace std; + +class ECollide; + +class WeaponArc: public WeaponObject{ +public: + + WeaponArc( int z, int d, int smp, int al ); + + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + + virtual ~WeaponArc(); + +protected: + ECollide * arc_collide; + +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_machine.cpp +++ rafkill-1.2.2/build/guns/gun_machine.cpp @@ -0,0 +1,90 @@ +#include "gunobj.h" +#include "gun_machine.h" +#include "weaponobj.h" +#include "hulls/hull_weapon_machine.h" +#include "trigtable.h" + +// #define MACHINE_SPEED -21.0 +const int MACHINE_SPEED = -21; + +WeaponMachineGun::WeaponMachineGun( int z, int d, int _smp, int al ): +WeaponObject( d, "Machine Gun", 23500, al, z, -1 ), +dang( 0 ) { + smp = _smp; +} + + +WeaponObject * WeaponMachineGun::copy() { + return new WeaponMachineGun( strength, dir, smp, alignment ); +} + + +void WeaponMachineGun::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + if ( smp != -1 ){ + // Util::playSample( smp, 255, 128, 1000, false ); + Util::playSound( smp, 255 ); + } + + switch( strength ) { + case 0 : { + + shot_counter = 1; + + Ammo->push_back( new WeaponNode(x-8,y,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) ); + Ammo->push_back( new WeaponNode(x+8,y,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) ); + + break; + + } + case 1 : { + + shot_counter = 2; + + Ammo->push_back( new WeaponNode(x-9,y,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) ); + Ammo->push_back( new WeaponNode(x+9,y,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) ); + Ammo->push_back( new WeaponNode(x-4,y-1,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) ); + Ammo->push_back( new WeaponNode(x+4,y-1,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) ); + Ammo->push_back( new WeaponNode(x,y-2,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) ); + + break; + } + case 2 : { + shot_counter = 2; + Ammo->push_back( new WeaponNode(x-9,y-3,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) ); + Ammo->push_back( new WeaponNode(x+9,y-3,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) ); + Ammo->push_back( new WeaponNode(x-4,y-2,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) ); + Ammo->push_back( new WeaponNode(x+4,y-2,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) ); + break; + } + case 3 : { + shot_counter = 0; + + Ammo->push_back( new WeaponNode(x+7,y-3,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) ); + Ammo->push_back( new WeaponNode(x-7,y-3,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) ); + //Ammo->push_back( new WeaponNode(x,y-2,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) ); + break; + } + case 4 : { + dang = (dang+30)%360; + shot_counter = 2; + + #define magx(x) ( (int)( (x)+Tcos(dang)*6 ) ) + #define magy(y) ( (int)( (y)+Tsine(dang) ) ) + + Ammo->push_back( new WeaponNode(magx(x-8),y-2,0,MACHINE_SPEED, new Machine_WHull(3), alignment ) ); + Ammo->push_back( new WeaponNode(magx(x-5),y,0,MACHINE_SPEED, new Machine_WHull(3), alignment ) ); + Ammo->push_back( new WeaponNode(magx(x+5),y,0,MACHINE_SPEED, new Machine_WHull(3), alignment ) ); + Ammo->push_back( new WeaponNode(magx(x+8),y-2,0,MACHINE_SPEED, new Machine_WHull(3), alignment ) ); + break; + + } + default : { + + shot_counter = 0; + Ammo->push_back( new WeaponNode(x+7,y,0,MACHINE_SPEED, new Machine_WHull(strength), alignment ) ); + Ammo->push_back( new WeaponNode(x-7,y,0,MACHINE_SPEED, new Machine_WHull(strength), alignment ) ); + + } + } + +} --- rafkill-1.2.2.orig/build/guns/gun_ecork.cpp +++ rafkill-1.2.2/build/guns/gun_ecork.cpp @@ -0,0 +1,20 @@ +#include "gunobj.h" +#include "gun_ecork.h" +#include "weaponobj.h" +#include "hulls/hull_weapon_cork.h" +#include "trigtable.h" + +EnemyCork::EnemyCork( int d, int al ): +WeaponObject( d, "Cork", 0, al, 0, 0 ) { +} + + +void EnemyCork::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + shot_counter = 30; + + const double speed = 7; + + Ammo->push_back( new WeaponNode(x,y,0,speed, new Cork_WHull( 4 ), alignment ) ); + +} --- rafkill-1.2.2.orig/build/guns/gun_follow.h +++ rafkill-1.2.2/build/guns/gun_follow.h @@ -0,0 +1,18 @@ +#ifndef _gun_follow_h +#define _gun_follow_h + +#include "gunobj.h" +#include "spaceobj.h" +#include + +using namespace std; + +class WeaponFollow: public WeaponObject{ +public: + WeaponFollow( int z, int d, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_edfstraight.cpp +++ rafkill-1.2.2/build/guns/gun_edfstraight.cpp @@ -0,0 +1,18 @@ +#include "weaponobj.h" +#include "gun_edfstraight.h" +#include "gunobj.h" +#include "hulls/hull_weapon_s_s.h" +#include "spaceobj.h" +#include +#include "defs.h" + +using namespace std; + +EnemyDoubleFarStraightShooter::EnemyDoubleFarStraightShooter( int d, int al ): +WeaponObject( d, "Double Far Straight Shooter", 0, al, 0, 0 ){} + +void EnemyDoubleFarStraightShooter::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + setShotCounter( 45 ); + Ammo->push_back( new WeaponNode(x+15,y,0,10, new SS_WHull(), alignment ) ); + Ammo->push_back( new WeaponNode(x-15,y,0,10, new SS_WHull(), alignment ) ); +} --- rafkill-1.2.2.orig/build/guns/gun_machine_circle.h +++ rafkill-1.2.2/build/guns/gun_machine_circle.h @@ -0,0 +1,22 @@ +#ifndef _gun_machine_cirlce_h +#define _gun_machine_cirlce_h + +#include "gunobj.h" + +class SpaceContainer; + +class WeaponMachineCircleGun: public WeaponObject{ +public: + + WeaponMachineCircleGun( int z, int d, int smp, int al ); + + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + +protected: + int angle; + +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_efsingle.cpp +++ rafkill-1.2.2/build/guns/gun_efsingle.cpp @@ -0,0 +1,32 @@ +#include "gunobj.h" +#include "weaponobj.h" +#include "gun_efsingle.h" +#include "hulls/hull_weapon_s_s.h" +#include "trigtable.h" +#include "spaceobj.h" +#include + +using namespace std; + +EnemyFindSingle::EnemyFindSingle( int d, int al ): +WeaponObject( d, "Find Single", 0, al, 0, 0 ){} + +void EnemyFindSingle::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + setShotCounter( 40 ); + + if ( fight == NULL ) return; + if ( fight->empty() ) return; + + SpaceObject obj( 0, 0, 0, 0, NULL, NULL, PLANE_AIR, this->getTeam() ); + const SpaceObject * use = getCollidableObject( fight, &obj ); + // SpaceObject * use = fight->front(); + + if ( use != NULL ) { + const double FIND_BULLET = 1.2 * 8; + int sang = getAngle( x, y, use->getX(), use->getY()+7 ); + double sx = Tcos(sang)*FIND_BULLET; + double sy = Tsine(sang)*FIND_BULLET; + Ammo->push_back( new WeaponNode(x,y,sx,sy,new SS_WHull(), alignment ) ); + } +} --- rafkill-1.2.2.orig/build/guns/gun_rotate.cpp +++ rafkill-1.2.2/build/guns/gun_rotate.cpp @@ -0,0 +1,49 @@ +#include "gunobj.h" +#include "gun_rotate.h" +#include "trigtable.h" +#include "ebox.h" +#include "spaceobj.h" +#include "defs.h" +#include "weapons/weapon_rotate.h" +#include "hulls/hull_weapon_rotate.h" + +WeaponRotateGun::WeaponRotateGun( int z, int d, int _smp, int al ): +WeaponObject( d, "Rotate Gun", 250000, al, z, 4 ) { + smp = _smp; + + angX = Util::rnd( 360 ); + angY = Util::rnd( 360 ); + dX = (Util::rnd( 8 ) + 10 ) * (Util::rnd(2)*2-1); + dY = (Util::rnd( 8 ) + 10 ) * (Util::rnd(2)*2-1); + dwX = dX; + dwY = dY; + maxX = 400; + maxY = 400; + + Bitmap temp( 20, 20 ); + temp.fill( Bitmap::MaskColor ); + temp.circleFill( 10, 10, 10, Bitmap::makeColor( 255, 0, 0 ) ); + collide = new ECollide( temp ); + +} + +WeaponRotateGun::~WeaponRotateGun() { + delete collide; +} + +void WeaponRotateGun::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + shot_counter = 24; + int dam = 40 + (strength + 1 ) * 10; + + const double speed = -6.5; + + int base = Util::rnd( 100 ); + for ( int q = 0; q < 360; q += 360 / (strength + 4) ){ + Ammo->push_back( new Rotate( x, y, 0, speed, (q+base) % 360, 55, new Rotate_WHull( dam, collide->copy() ), alignment ) ); + } +} + +WeaponObject * WeaponRotateGun::copy() { + return new WeaponRotateGun( strength, dir, smp, alignment ); +} --- rafkill-1.2.2.orig/build/guns/gun_elarge.h +++ rafkill-1.2.2/build/guns/gun_elarge.h @@ -0,0 +1,16 @@ +#ifndef _gun_enemy_large_straight_shooter_h +#define _gun_enemy_large_straight_shooter_h + +#include "gunobj.h" +#include "spaceobj.h" +#include + +using namespace std; + +class EnemyLargeStraightShooter:public WeaponObject{ +public: + EnemyLargeStraightShooter( int d, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_swirl.cpp +++ rafkill-1.2.2/build/guns/gun_swirl.cpp @@ -0,0 +1,117 @@ +#include "gun_swirl.h" +#include "trigtable.h" +#include "gunobj.h" +#include "hulls/hull_weapon_dissipate.h" +#include "weapons/weapon_damage.h" +#include "spaceobj.h" +#include "bitmap.h" +#include "ebox.h" +#include + +using namespace std; + +static const int MAX_RISING = 100; +static const double RISE_SPEED = 1.5 * 8; +static const int MAX_SWIRL_RAD = 15; + +WeaponSwirlGun::WeaponSwirlGun( int z, int d, int smp, int al ): +WeaponObject( d, "Swirl Gun", 92450, al, z, 0 ), +rising( 0 ) { + + /* + BITMAP * dopey = create_bitmap( 12, 12 ); + clear_to_color( dopey, makecol(255,0,255) ); + circlefill(dopey,6,6,6,makecol(20,0,0) ); + // diss_collide = new ECollide( dopey,4,makecol(255,0,255),52); + diss_collide = new ECollide( dopey ); + destroy_bitmap( dopey ); + shade = new int[ MAX_SWIRL_RAD ]; + blend_palette( shade, MAX_SWIRL_RAD, makecol( 100, 0, 0 ), makecol(250,250,250) ); + feel = new int[ MAX_SWIRL_RAD ]; + for ( int q = 0; q < MAX_SWIRL_RAD; q++ ) + feel[q] = 0; + */ + Bitmap dopey( 12, 12 ); + dopey.fill( Bitmap::MaskColor ); + dopey.circleFill( 6, 6, 6, Bitmap::makeColor(20,0,0) ); + diss_collide = new ECollide( &dopey ); + + shade = new int[ MAX_SWIRL_RAD ]; + Util::blend_palette( shade, MAX_SWIRL_RAD, Bitmap::makeColor( 100, 0, 0 ), Bitmap::makeColor(250,250,250) ); + feel = new int[ MAX_SWIRL_RAD ]; + for ( int q = 0; q < MAX_SWIRL_RAD; q++ ){ + feel[q] = 0; + } + + radius = 30; + cur_rad = radius-(MAX_SWIRL_RAD-1); + dir = 1; + +} + +WeaponObject * WeaponSwirlGun::copy() { + return new WeaponSwirlGun( strength, dir, smp, alignment ); +} + +WeaponSwirlGun::~WeaponSwirlGun() { + delete diss_collide; + delete[] shade; + delete[] feel; +} + +void WeaponSwirlGun::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + shot_counter = 0; + + if ( rising == 0 ) rising = 1; + //if ( rising < 100 ) + // rising+=2; + +} + + +void WeaponSwirlGun::Idle( int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + if ( rising == 0 ) return; + + for ( int q = 0; q < 360; q+=3 ) + Ammo->push_back( new Damage_Weapon(x,y,Tcos(q)*RISE_SPEED,Tsine(q)*RISE_SPEED,1,new Dissipate_WHull(rising/4,diss_collide), alignment ) ); rising = 0; + radius = 0; + dir = 1; +} + + +void WeaponSwirlGun::Draw( const Bitmap & less, int x, int y) { + + if ( rising == 0 ) return; + + for ( int z = 0; z < 3; z++ ) { + if ( dir == 1 ) { + cur_rad++; + if ( cur_rad >= radius ) { + radius += 1; + if ( rising < 100 ) + rising += 4; + dir = -1; + if ( radius > rising*3/2 ) radius = rising*3/2; + if ( radius < 40 ) radius = 40; + } + } + else { + cur_rad--; + if ( cur_rad <= radius - (MAX_SWIRL_RAD-1) ) { + dir = 1; + } + } + + for ( int q = 0; q < MAX_SWIRL_RAD; q++ ) { + if ( radius-cur_rad == q ) { + feel[q] = MAX_SWIRL_RAD-1; + } + else if ( feel[q] > 0 ) feel[q]--; + } + } + + for ( int q = 0; q < MAX_SWIRL_RAD; q++ ) { + less.circle( x, y, radius-(MAX_SWIRL_RAD-1)-q, shade[ feel[q] ] ); + } +} --- rafkill-1.2.2.orig/build/guns/gun_missle.cpp +++ rafkill-1.2.2/build/guns/gun_missle.cpp @@ -0,0 +1,69 @@ +#include "gunobj.h" +#include "gun_missle.h" + +#include "weapons/weapon_rocket.h" +#include "hulls/hull_weapon_rocket_normal.h" +#include "hulls/hull_weapon_rocket_heavy.h" + +WeaponMissle::WeaponMissle( int z, int d, int al ): +WeaponObject( d, "Missle", 45000, al, z, 4 ) { +} + + +WeaponObject * WeaponMissle::copy() { + return new WeaponMissle( strength, dir, alignment ); +} + + +void WeaponMissle::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + const double speed = -2.0 * 8; + + switch( strength ) { + case 0 : { + + shot_counter = 17; + Ammo->push_back( new Rocket(x,y,0,speed, new NormalRocket_WHull(), alignment ) ); + break; + + } + case 1 : { + + shot_counter = 17; + Ammo->push_back( new Rocket(x-10,y,0,speed, new NormalRocket_WHull(), alignment ) ); + Ammo->push_back( new Rocket(x+10,y,0,speed, new NormalRocket_WHull(), alignment ) ); + break; + + } + + case 2 : { + shot_counter = 15; + Ammo->push_back( new Rocket(x-15,y,0,speed, new NormalRocket_WHull(), alignment ) ); + Ammo->push_back( new Rocket(x+15,y,0,speed, new NormalRocket_WHull(), alignment ) ); + Ammo->push_back( new Rocket(x,y,0,speed, new NormalRocket_WHull(), alignment ) ); + break; + } + + case 3 : { + + shot_counter = 15; + Ammo->push_back( new Rocket(x-15,y,0,speed, new NormalRocket_WHull(), alignment ) ); + Ammo->push_back( new Rocket(x+15,y,0,speed, new NormalRocket_WHull(), alignment ) ); + Ammo->push_back( new Rocket(x-25,y,0,speed, new NormalRocket_WHull(), alignment ) ); + Ammo->push_back( new Rocket(x+25,y,0,speed, new NormalRocket_WHull(), alignment ) ); + Ammo->push_back( new Rocket(x,y-5,0,speed, new HeavyRocket_WHull(), alignment ) ); + + } + + case 4 : { + + shot_counter = 15; + Ammo->push_back( new Rocket(x-15,y+5,0,speed, new HeavyRocket_WHull(), alignment ) ); + Ammo->push_back( new Rocket(x+15,y+5,0,speed, new HeavyRocket_WHull(), alignment ) ); + Ammo->push_back( new Rocket(x, y, 0,speed, new HeavyRocket_WHull(), alignment ) ); + break; + } + + } //switch + +} --- rafkill-1.2.2.orig/build/guns/gun_yehat.cpp +++ rafkill-1.2.2/build/guns/gun_yehat.cpp @@ -0,0 +1,85 @@ +#include "gunobj.h" +#include "gun_yehat.h" +#include "weapons/weapon_yehat.h" +#include "hulls/hull_weapon_yehat.h" +#include "defs.h" + +WeaponYehatGun::WeaponYehatGun( int z, int d, int _smp, int al ): +WeaponObject( d, "Yehat Gun", 180000, al, z, 10 ) { + smp = _smp; +} + + +WeaponObject * WeaponYehatGun::copy() { + return new WeaponYehatGun( strength, dir, smp, alignment ); +} + + +void WeaponYehatGun::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + if ( smp != -1 ){ + Util::playSound( smp, 255 ); + } + + shot_counter = 2; + + const double speed = -2.6 * 8; + + Ammo->push_back( new Yehat_Weapon(x-8,y,0,speed, new Yehat_WHull(10+strength*6), alignment ) ); + Ammo->push_back( new Yehat_Weapon(x+8,y,0,speed, new Yehat_WHull(10+strength*6), alignment ) ); + /* + switch( strength ) { + case 0 : { + + shot_counter = 1; + + Ammo->push_back( new WeaponNode(x-8,y,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) ); + Ammo->push_back( new WeaponNode(x+8,y,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) ); + + break; + + } + case 1 : { + + shot_counter = 2; + + Ammo->push_back( new WeaponNode(x-9,y,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) ); + Ammo->push_back( new WeaponNode(x+9,y,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) ); + Ammo->push_back( new WeaponNode(x-4,y-1,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) ); + Ammo->push_back( new WeaponNode(x+4,y-1,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) ); + Ammo->push_back( new WeaponNode(x,y-2,0,MACHINE_SPEED, new Machine_WHull(1), alignment ) ); + + break; + } + case 2 : { + shot_counter = 2; + Ammo->push_back( new WeaponNode(x-9,y-3,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) ); + Ammo->push_back( new WeaponNode(x+9,y-3,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) ); + Ammo->push_back( new WeaponNode(x-4,y-2,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) ); + Ammo->push_back( new WeaponNode(x+4,y-2,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) ); + break; + } + case 3 : { + shot_counter = 0; + + Ammo->push_back( new WeaponNode(x+7,y-3,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) ); + Ammo->push_back( new WeaponNode(x-7,y-3,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) ); + //Ammo->push_back( new WeaponNode(x,y-2,0,MACHINE_SPEED, new Machine_WHull(2), alignment ) ); + break; + } + case 4 : { + dang = (dang+30)%360; + shot_counter = 2; + + #define magx(x) ( (int)( (x)+tcos[dang]*6 ) ) + #define magy(y) ( (int)( (y)+tsine[dang] ) ) + + Ammo->push_back( new WeaponNode(magx(x-8),y-2,0,MACHINE_SPEED, new Machine_WHull(3), alignment ) ); + Ammo->push_back( new WeaponNode(magx(x-5),y,0,MACHINE_SPEED, new Machine_WHull(3), alignment ) ); + Ammo->push_back( new WeaponNode(magx(x+5),y,0,MACHINE_SPEED, new Machine_WHull(3), alignment ) ); + Ammo->push_back( new WeaponNode(magx(x+8),y-2,0,MACHINE_SPEED, new Machine_WHull(3), alignment ) ); + + } + } + */ + +} --- rafkill-1.2.2.orig/build/guns/gun_arc.cpp +++ rafkill-1.2.2/build/guns/gun_arc.cpp @@ -0,0 +1,75 @@ +#include "allegro.h" +#include "gunobj.h" +#include "gun_arc.h" +#include "trigtable.h" +#include "spaceobj.h" +#include +#include "weaponobj.h" +#include "hulls/hull_weapon_arc.h" +#include "ebox.h" + +using namespace std; + +WeaponArc::WeaponArc( int z, int d, int _smp, int al ): +WeaponObject( d, "Arc", 43000, al, z, -1 ) { + smp = _smp; + + Bitmap temp( 4, 16 ); + temp.rectangleFill( 0, 0, 3, 15, Bitmap::makeColor(40,40,40) ); + arc_collide = new ECollide( &temp ); + + /* fixed + BITMAP * temp = create_bitmap( 4, 16 ); + rectfill( temp, 0, 0, 3, 15, makecol(40,40,40) ); + // arc_collide = new ECollide( temp, 3, makecol(255,0,255), 40 ); + arc_collide = new ECollide( temp ); + destroy_bitmap( temp ); + */ + +} + + +void WeaponArc::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + if ( smp != -1 ){ + Util::playSound( smp, 255 ); + } + + shot_counter = 13; + + for ( int ang = 2; ang <= 90; ang+=7 ) { + int ang1 = (720+90-ang)%360; + int ang2 = (720+90+ang)%360; + + const double speed_div = 4.8 / 8.0; + int xput = (int)( x + Tcos(ang1) * 4 ); + int yput = (int)( y + Tsine(ang1) * 12 ); + double xspeed = Tcos(ang1) / speed_div; + double yspeed = -1.72 * 8.0; + + Ammo->push_back( new WeaponNode(xput, yput, xspeed, yspeed, new Arc_WHull(strength*2+1,arc_collide), alignment ) ); + + xput = (int)( x + Tcos(ang2) * 4 ); + yput = (int)( y + Tsine(ang2) * 12 ); + xspeed = Tcos(ang2) / speed_div; + yspeed = -1.72 * 8.0; + Ammo->push_back( new WeaponNode(xput, yput, xspeed, yspeed, new Arc_WHull(strength*2+1,arc_collide), alignment ) ); + + /* + Ammo->push_back( new WeaponNode((int)(x+tcos[ang1]*4),(int)(y+tsine[ang1]*12),tcos[ang1]/4.8,-1.72, new Arc_WHull(strength*2+1,arc_collide), alignment ) ); + Ammo->push_back( new WeaponNode((int)(x+tcos[ang2]*4),(int)(y+tsine[ang2]*12),tcos[ang2]/4.8,-1.72, new Arc_WHull(strength*2+1,arc_collide), alignment ) ); + */ + } + +} + + +WeaponObject * WeaponArc::copy() { + + return new WeaponArc( strength, dir, smp, alignment ); + +} + + +WeaponArc::~WeaponArc() { + delete arc_collide; +} --- rafkill-1.2.2.orig/build/guns/gun_edfstraight.h +++ rafkill-1.2.2/build/guns/gun_edfstraight.h @@ -0,0 +1,16 @@ +#ifndef _gun_enemy_double_far_straight_shooter_h +#define _gun_enemy_double_far_straight_shooter_h + +#include "gunobj.h" +#include +#include "spaceobj.h" + +using namespace std; + +class EnemyDoubleFarStraightShooter:public WeaponObject{ +public: + EnemyDoubleFarStraightShooter( int d, int al); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_spread.h +++ rafkill-1.2.2/build/guns/gun_spread.h @@ -0,0 +1,18 @@ +#ifndef _gun_spread_h +#define _gun_spread_h + +#include "gunobj.h" + +class SpaceObject; + +class WeaponSpreadGun: public WeaponObject{ +public: + + WeaponSpreadGun( int z, int d, int smp, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_angle.h +++ rafkill-1.2.2/build/guns/gun_angle.h @@ -0,0 +1,22 @@ +#ifndef _weapon_angle_h +#define _weapon_angle_h + +#include "gunobj.h" + +class SpaceObject; +class ECollide; + +class WeaponAngle: public WeaponObject{ +public: + WeaponAngle( int z, int d, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + + virtual WeaponObject * copy(); + virtual ~WeaponAngle(); + +protected: + int * shade; + ECollide * ecollide; +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_shatter.cpp +++ rafkill-1.2.2/build/guns/gun_shatter.cpp @@ -0,0 +1,31 @@ +#include "gunobj.h" +#include "gun_shatter.h" +#include "weaponobj.h" +#include "hulls/hull_weapon_shatter.h" +#include "weapons/weapon_shatter.h" +#include "defs.h" +#include + +using namespace std; + +WeaponShatter::WeaponShatter( int z, int d, int _smp, int al ): +WeaponObject( d, "Shatter Gun", 38000, al, z, 4 ) { + smp = _smp; +} + + +WeaponObject * WeaponShatter::copy() { + return new WeaponShatter( strength, dir, smp, alignment ); +} + + +void WeaponShatter::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + if ( smp != -1 ){ + Util::playSound( smp, 255 ); + } + + shot_counter = 10; + + Ammo->push_back( new Shatter(x,y,0,-2.1*8, new Shatter_WHull(6+strength*2), alignment, Ammo ) ); + +} --- rafkill-1.2.2.orig/build/guns/gun_efsingle.h +++ rafkill-1.2.2/build/guns/gun_efsingle.h @@ -0,0 +1,17 @@ +#ifndef _gun_enemy_find_single_h +#define _gun_enemy_find_single_h + +#include "weaponobj.h" +#include "spaceobj.h" +#include + +using namespace std; + +class EnemyFindSingle:public WeaponObject{ +public: + EnemyFindSingle( int d, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_etwirl.h +++ rafkill-1.2.2/build/guns/gun_etwirl.h @@ -0,0 +1,23 @@ +#ifndef _gun_enemy_twirl_straight_h +#define _gun_enemy_twirl_straight_h + +#include "gunobj.h" +#include "spaceobj.h" +#include + +using namespace std; + +class ECollide; + +class EnemyTwirlStraight:public WeaponObject{ +public: + EnemyTwirlStraight( int d, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + + virtual ~EnemyTwirlStraight(); + +protected: + ECollide * ecollide; +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_emissle.cpp +++ rafkill-1.2.2/build/guns/gun_emissle.cpp @@ -0,0 +1,23 @@ +#include "gunobj.h" +#include "gun_emissle.h" + +#include "weapons/weapon_emissle.h" + +#include "defs.h" + +EnemyMissle::EnemyMissle( int d, int al ): +WeaponObject( d, "Missle", 0, al, 0, 0 ), +tear( 3 ){} + +void EnemyMissle::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + shot_counter = 50; + if ( tear > 0 ) { + tear--; + shot_counter = 8; + } else tear = 3; + + const double ENEMY_MISSLE = 1.9 * 8; + Ammo->push_back( new normalMissle(x,y,0,ENEMY_MISSLE,alignment) ); + +} --- rafkill-1.2.2.orig/build/guns/gun_elarge.cpp +++ rafkill-1.2.2/build/guns/gun_elarge.cpp @@ -0,0 +1,18 @@ +#include "gunobj.h" +#include "weaponobj.h" +#include "gun_elarge.h" +#include "hulls/hull_weapon_s_l.h" +#include "defs.h" +#include "spaceobj.h" +#include + +using namespace std; + +EnemyLargeStraightShooter::EnemyLargeStraightShooter( int d, int al ): +WeaponObject( d, "Large Straight Shooter", 0, al, 0, 0 ){} + +void EnemyLargeStraightShooter::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + setShotCounter( 60 ); + const double LARGE_BULLET = 1.6 * 8; + Ammo->push_back( new WeaponNode(x,y,0,LARGE_BULLET, new SL_WHull(), alignment ) ); +} --- rafkill-1.2.2.orig/build/guns/gun_laser.cpp +++ rafkill-1.2.2/build/guns/gun_laser.cpp @@ -0,0 +1,134 @@ +#include "gunobj.h" +#include "gun_laser.h" +#include "weapons/weapon_laser.h" +#include "hulls/hull_weapon_laser.h" +#include "trigtable.h" +#include "defs.h" +#include +#include + +using namespace std; + +WeaponLaser::WeaponLaser( int z, int d, int al ): +WeaponObject( d, "Laser", 36000, al, z, 4 ) { +} + +WeaponObject * WeaponLaser::copy() { + return new WeaponLaser( strength, dir, alignment ); +} + +void WeaponLaser::produceLaser( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, int x, int y, HullObject * hwho, int al ) { + + // if ( fight == NULL || fight->empty() ) return; + vector< SpaceObject * > fight_hold; + SpaceObject * use = NULL; + + // SpaceObject * gay = new SpaceObject(0,0,0,0,NULL,NULL,PLANE_AIR|PLANE_GROUND, alignment ); + SpaceObject gay(0,0,0,0,NULL, NULL, PLANE_AIR|PLANE_GROUND, alignment ); + // bool quit = fight->empty(); + int ang = 0; + + for ( vector< SpaceObject * >::const_iterator it = fight->begin(); it != fight->end(); it++ ){ + if ( (*it)->CanbeHit( &gay ) ){ + + SpaceObject * look = *it; + ang = getAngle( x, y, look->getX(), look->getY() ); + if ( ang > 75 && ang < 105 ) { + fight_hold.push_back( look ); + } + + } + } + + if ( !fight_hold.empty() ){ + use = fight_hold[ Util::rnd( fight_hold.size() ) ]; + } + + /* + while ( !quit ) { + + / * + SpaceObject * look = fight->front(); + fight_hold.push_back( look ); + fight->erase( fight->begin() ); + * / + SpaceObject * look = (*fight)[ rnd( fight->size() ) ]; + fight_hold.push_back( look ); + vector< SpaceObject * >::iterator erase_it; + for ( erase_it = fight->begin(); *erase_it != look; erase_it++ ); + + // fight->erase( erase_it ); + + if ( look->CanbeHit( &gay ) ) { + + ang = gang( x, y, look->getX(), look->getY() ); + if ( ang > 70 && ang < 110 ) { + quit = true; + use = look; + } + + } + + quit = quit || fight->empty(); + + } + */ + + double dx, dy; + dx = 0; + const double speed = 22; + dy = -speed; + if ( use != NULL ) { + ang = getAngle( x, y, use->getX(), use->getY() ); + dx = Tcos( ang ) * speed; + dy = Tsine( ang) * speed; + } + + Ammo->push_back( new LaserBullet( x, y, dx, dy, hwho, al ) ); + + /* + for ( vector::iterator it = fight_hold.begin(); it != fight_hold.end(); ) { + fight->push_back( *it ); + fight_hold.erase( it ); + } + */ + +} + + +void WeaponLaser::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + shot_counter = 7; + + switch( strength ) { + case 0 : { + produceLaser( Ammo, fight, x, y, new Laser_WHull(0), alignment ); + break; + } + case 1 : { + produceLaser( Ammo, fight, x-4*3, y, new Laser_WHull(0), alignment ); + produceLaser( Ammo, fight, x+4*3, y, new Laser_WHull(0), alignment ); + break; + } + case 2 : { + produceLaser( Ammo, fight, x-8*3, y, new Laser_WHull(0), alignment ); + produceLaser( Ammo, fight, x+8*3, y, new Laser_WHull(0), alignment ); + produceLaser( Ammo, fight, x-3*3, y, new Laser_WHull(0), alignment ); + produceLaser( Ammo, fight, x+3*3, y, new Laser_WHull(0), alignment ); + + break; + } + case 3 : { + produceLaser( Ammo, fight, x, y, new Laser_WHull(1), alignment ); + produceLaser( Ammo, fight, x-4*4, y, new Laser_WHull(0), alignment ); + produceLaser( Ammo, fight, x+4*4, y, new Laser_WHull(0), alignment ); + break; + } + case 4 : { + produceLaser( Ammo, fight, x, y, new Laser_WHull(1), alignment ); + produceLaser( Ammo, fight, x-4*4, y, new Laser_WHull(1), alignment ); + produceLaser( Ammo, fight, x+4*4, y, new Laser_WHull(1), alignment ); + break; + } + } +} --- rafkill-1.2.2.orig/build/guns/gun_etwirl_find.h +++ rafkill-1.2.2/build/guns/gun_etwirl_find.h @@ -0,0 +1,23 @@ +#ifndef _gun_enemy_twirl_find_h +#define _gun_enemy_twirl_find_h + +#include "gunobj.h" +#include "spaceobj.h" +#include + +using namespace std; + +class ECollide; + +class EnemyTwirlFind:public WeaponObject{ +public: + EnemyTwirlFind( int d, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + + virtual ~EnemyTwirlFind(); + +protected: + ECollide * ecollide; +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_machine.h +++ rafkill-1.2.2/build/guns/gun_machine.h @@ -0,0 +1,21 @@ +#ifndef _gun_machine_h +#define _gun_machine_h + +#include "gunobj.h" + +class SpaceContainer; + +class WeaponMachineGun: public WeaponObject{ +public: + + WeaponMachineGun( int z, int d, int smp, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + +protected: + int dang; + +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_tractor_beam.cpp +++ rafkill-1.2.2/build/guns/gun_tractor_beam.cpp @@ -0,0 +1,116 @@ +#include "gunobj.h" +#include "gun_tractor_beam.h" +#include "trigtable.h" +#include "weapons/weapon_damage.h" +#include "hulls/hull_weapon_tractor_beam.h" +#include "spaceobj.h" +#include "ebox.h" +#include +#include + +using namespace std; + +WeaponTractorBeam::WeaponTractorBeam( int z, int d, int al ): +WeaponObject( d, "Tractor Beam", 405000, al, z, 4 ) { + look = NULL; + + Bitmap temp( 8, 8 ); + temp.fill( Bitmap::makeColor(255,0,255) ); + temp.circleFill( 4, 4, 3, Bitmap::makeColor(255,0,0) ); + collide = new ECollide( &temp ); + +} + + +WeaponObject * WeaponTractorBeam::copy() { + return new WeaponTractorBeam( strength, dir, alignment ); +} + + +WeaponTractorBeam::~WeaponTractorBeam() { + delete collide; +} + + +void WeaponTractorBeam::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + if ( fight == NULL ) return; + if ( fight->empty() ) { + look = NULL; + return; + } + + // SpaceObject * gay = new SpaceObject(0,0,0,0,NULL,NULL,PLANE_AIR|PLANE_GROUND, alignment ); + SpaceObject gay(0,0,0,0, NULL, NULL, PLANE_AIR|PLANE_GROUND, alignment ); + bool cy = false; + + for ( vector< SpaceObject * >::const_iterator it = fight->begin(); it != fight->end(); it++ ) + if ( (*it)->CanbeHit( &gay ) ) cy = true; + + if ( !cy ) { + look = NULL; + // delete gay; + return; + } + + shot_counter = 0; + + vector< SpaceObject * >::const_iterator find_next = fight->begin(); + + cy = true; + if ( look != NULL ) { + for ( vector< SpaceObject * >::const_iterator it = fight->begin(); it != fight->end(); ) { + if ( look == (*it) ) { + cy = false; + it = fight->end(); + } else it++; + } + } + if ( cy ) look = NULL; + else { + if ( look->getX()>640||look->getX()<0||look->getY()>480|| + look->getY()<0 ) + cy = true; + if ( !look->CanbeHit( &gay ) ) + cy = true; + } + + if ( cy ) { + + look = *find_next; + while ( !look->CanbeHit( &gay ) ) { + + find_next++; + if ( find_next == fight->end() ) find_next = fight->begin(); + look = *find_next; + + } + find_next++; + if ( find_next == fight->end() ) find_next = fight->begin(); + + } + + int r, g, b; + int h = ( (strength + 2 ) * 50 ) % 360; + Bitmap::hsvToRGB( (float)h, 1.0, 1.0, &r, &g, &b ); + + SpaceObject * choose = look; + if ( choose != NULL ) { + + int d = (int) dist( x, y, choose->getX(), choose->getY() ); + + int fx, fy; + fx = choose->getX(); + fy = choose->getY(); + int ang = getAngle( x, y, fx, fy ); + + for ( int s = 0; s < d; s += 5 ) { + int qx = (int)( (double)x + Tcos(ang)*(double)s ); + int qy = (int)( (double)y + Tsine(ang)*(double)s ); + Ammo->push_back(new Damage_Weapon(qx,qy,0,0,1, new Tractor_WHull(strength*2+1, Bitmap::makeColor(r,g,b), collide->copy() ),alignment ) ); + } + + } + // delete gay; + +} --- rafkill-1.2.2.orig/build/guns/gun_rotate.h +++ rafkill-1.2.2/build/guns/gun_rotate.h @@ -0,0 +1,33 @@ +#ifndef _gun_rotate_h +#define _gun_rotate_h + +#include "gunobj.h" + +class SpaceObject; +class ECollide; + +class WeaponRotateGun: public WeaponObject{ +public: + + WeaponRotateGun( int z, int d, int smp, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + virtual ~WeaponRotateGun(); + +protected: + + int angX; + int angY; + int dX; + int dY; + int dwX; + int dwY; + int sd; + int maxX, maxY; + + ECollide * collide; + +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_yehat.h +++ rafkill-1.2.2/build/guns/gun_yehat.h @@ -0,0 +1,18 @@ +#ifndef _gun_yehat_h +#define _gun_yehat_h + +#include "gunobj.h" + +class SpaceContainer; + +class WeaponYehatGun: public WeaponObject{ +public: + + WeaponYehatGun( int z, int d, int smp, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_missle.h +++ rafkill-1.2.2/build/guns/gun_missle.h @@ -0,0 +1,18 @@ +#ifndef _gun_missle_h +#define _gun_missle_h + +#include "gunobj.h" + +class SpaceContainer; + +class WeaponMissle: public WeaponObject{ +public: + + WeaponMissle( int z, int d, int al ); + + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_minimissle.h +++ rafkill-1.2.2/build/guns/gun_minimissle.h @@ -0,0 +1,18 @@ +#ifndef _gun_minimissle_ +#define _gun_minimissle_ + +#include "gunobj.h" + +class SpaceContainer; + +class WeaponMiniMissle: public WeaponObject{ +public: + + WeaponMiniMissle( int z, int d, int al ); + + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_eside.h +++ rafkill-1.2.2/build/guns/gun_eside.h @@ -0,0 +1,14 @@ +#ifndef _gun_enemy_side_h +#define _gun_enemy_side_h + +#include "gunobj.h" + +class SpaceObject; + +class EnemySide:public WeaponObject{ +public: + EnemySide( int d, int al); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_eflarge.cpp +++ rafkill-1.2.2/build/guns/gun_eflarge.cpp @@ -0,0 +1,31 @@ +#include "gunobj.h" +#include "weaponobj.h" +#include "gun_eflarge.h" +#include "hulls/hull_weapon_s_l.h" +#include "trigtable.h" +#include "spaceobj.h" +#include + +using namespace std; + +EnemyFindLarge::EnemyFindLarge( int d, int al ): +WeaponObject( d, "Find Large", 0, al, 0, 0 ){} + +void EnemyFindLarge::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + shot_counter = 40; + if ( fight == NULL ) return; + if ( fight->empty() ) return; + + // SpaceObject * use = fight->front(); + SpaceObject obj( 0, 0, 0, 0, NULL, NULL, PLANE_AIR, this->getTeam() ); + const SpaceObject * use = getCollidableObject( fight, &obj ); + + if ( use != NULL ) { + const double FIND_BULLET = -1.2 * 8; + int sang = gang( x, y, use->getX(), use->getY()+7 ); + double sx = Tcos(sang)*FIND_BULLET; + double sy = Tsine(sang)*FIND_BULLET; + Ammo->push_back( new WeaponNode( x, y, sx, sy, new SL_WHull(), this->getTeam() ) ); + } + +} --- rafkill-1.2.2.orig/build/guns/gun_etwirl.cpp +++ rafkill-1.2.2/build/guns/gun_etwirl.cpp @@ -0,0 +1,40 @@ +#include "gunobj.h" +#include "weaponobj.h" +#include "gun_etwirl.h" +#include "hulls/hull_weapon_twirl.h" +#include "defs.h" +#include "spaceobj.h" +#include "ebox.h" +#include "raptor.h" +#include + +using namespace std; + +EnemyTwirlStraight::EnemyTwirlStraight( int d, int al ): +WeaponObject( d, "Twirl Straight", 0, al, 0, 0 ) { + + Bitmap tmp( 6, 12 ); + tmp.fill( Bitmap::MaskColor ); + tmp.ellipseFill( 3, 6, 3, 6, Bitmap::makeColor( 255, 255, 255 ) ); + ecollide = new ECollide( tmp ); + + /* + BITMAP * temp = create_bitmap( 6, 12 ); + clear_to_color( temp, makecol(255,0,255) ); + ellipsefill( temp, 3, 6, 3, 6, makecol(255,255,255) ); + // ecollide = new ECollide( temp,2,makecol(255,0,255), 52 ); + ecollide = new ECollide( temp ); + destroy_bitmap( temp ); + */ + +} + +EnemyTwirlStraight::~EnemyTwirlStraight() { + delete ecollide; +} + +void EnemyTwirlStraight::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + shot_counter = 45; + const double speed = 8; + Ammo->push_back( new WeaponNode(x,y,0,speed, new Twirl_WHull( Util::getDataSprite( BULLET_TWIRL ), ecollide->copy() ), alignment ) ); +} --- rafkill-1.2.2.orig/build/guns/gun_chain.cpp +++ rafkill-1.2.2/build/guns/gun_chain.cpp @@ -0,0 +1,138 @@ +#include "gunobj.h" +#include "defs.h" +#include "gun_chain.h" +#include "weapons/weapon_damage.h" +#include "hulls/hull_weapon_chain.h" +#include "trigtable.h" +#include "raptor.h" +#include "ebox.h" +#include "bitmap.h" + +#define chain_length 145 + +WeaponChainGun::WeaponChainGun( int z, int d, const char * name, int wor, int smp, int al, ECollide * eb ): +WeaponObject( d, name, wor, al, z, 0 ) { + + lx = -1; + ly = -1; + fx = -1; + fy = -1; + dx = 0; + dy = 0; + d_length = 0; + + chain_collide = eb; + + draw_number = 0; + +} + + +WeaponChainGun::~WeaponChainGun() { + if ( chain_collide != NULL ) + delete chain_collide; +} + + +void WeaponChainGun::Idle(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight) { + lx = -1; + dx = 0; + dy = 0; + draw_number = 0; +} + + +void WeaponChainGun::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + if ( lx == -1 ) { + lx = x+3; + ly = y+3; + fx = x+3; + fy = y+3; + } + + draw_number = (draw_number + 1 ) % ( IRON_012 - IRON_000 + 1 ); + Bitmap * pic = new Bitmap( Util::getDataSprite( IRON_000 + draw_number ) ); + + int mx = pic->getWidth() / 2; + int my = pic->getHeight() / 2; + + shot_counter = 0; + + ox = lx; + oy = ly; + + fx += dx; + fy += dy; + lx = (int)fx; + ly = (int)fy; + int d = (int) dist( x, y, lx, ly ); + if ( d < 2 ) return; + int ang = getAngle( lx, ly, x, y ); + if ( d > chain_length ) { + + if ( d-chain_length > d_length ) d_length = d-chain_length; + + dx += Tcos(ang)*d_length/2; + dy += Tsine(ang)*d_length/2; + fx = x+Tcos((ang+180)%360)*chain_length; + fy = y+Tsine((ang+180)%360)*chain_length; + lx = (int)fx; + ly = (int)fy; + } else d_length = 0; + + dx += Tcos(ang)*2; + dy += Tsine(ang)*2; + + /* + #define sma 0.1 + if ( dx > sma ) dx -= sma; + else if ( dx < -sma ) dx += sma; + else dx = 0; + + if ( dy > sma ) dy -= sma; + else if ( dy < -sma ) dy += sma; + else dy = 0; + */ + + int fin = (int) tsqrt( dx*dx + dy*dy ); + + double zd = zdist( lx, ly, ox, oy ); + double gx, gy; + int zang = getAngle(ox,oy,lx,ly); + + + #define CHAIN_MAX 6 + for ( int q = 0; q < zd/CHAIN_MAX; q++ ) { + + gx = ox+Tcos(zang)*zd*(double)q/(zd/CHAIN_MAX); + gy = oy+Tsine(zang)*zd*(double)q/(zd/CHAIN_MAX); + + switch( strength ) { + + case 0 : Ammo->push_back(new Damage_Weapon((int)gx-mx,(int)gy-my,0,0,1,new Chain_WHull(NULL,strength,fin,ang,d,chain_collide->copy()), alignment ));break; + + //case 1 : Ammo->push_back(new FireChain(lx,ly,0,0,new Chain_WHull(NULL,strength,fin,ang,d,chain_collide->copy()), alignment ));break; + + } //switch + + } + + /* + BITMAP ** pics = new BITMAP*[ IRON_012 - IRON_000 + 1 ]; + for ( int q = 0; q < IRON_012 - IRON_000 +1; q++ ) + pics[q] = (BITMAP *)global_data[ IRON_000 + q ].dat; + */ + + switch( strength ) { + case 0 : Ammo->push_back(new Damage_Weapon(lx,ly,0,0,1,new Chain_WHull(pic,strength,fin,ang,d,chain_collide->copy()), alignment ));break; + + //case 1 : Ammo->push_back(new FireChain(lx,ly,0,0,new Chain_WHull(pic,strength,fin,ang,d,chain_collide->copy()), alignment ));break; + } //switch + +} + + +WeaponObject * WeaponChainGun::copy() { + return new WeaponChainGun( strength, dir, this->GetName(), worth, smp, alignment, chain_collide->copy() ); +} --- rafkill-1.2.2.orig/build/guns/gun_stick.h +++ rafkill-1.2.2/build/guns/gun_stick.h @@ -0,0 +1,23 @@ +#ifndef _gun_stick_h +#define _gun_stick_h + +#include "gunobj.h" + +class SpaceObject; +class ECollide; + +class WeaponStick: public WeaponObject{ +public: + WeaponStick( int z, int d, int al, ECollide ** _collide_list, int _max_collide ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + + virtual WeaponObject * copy(); + virtual ~WeaponStick(); + +protected: + ECollide ** collide_list; + int max_collide; + ECollide * ecollide; +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_fire.h +++ rafkill-1.2.2/build/guns/gun_fire.h @@ -0,0 +1,19 @@ +#ifndef _gun_fire_h +#define _gun_fire_h + +#include "gunobj.h" +#include "spaceobj.h" +#include + +using namespace std; + +class WeaponFire: public WeaponObject{ +public: + WeaponFire( int z, int d, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + +}; + +#endif + --- rafkill-1.2.2.orig/build/guns/gun_swirl.h +++ rafkill-1.2.2/build/guns/gun_swirl.h @@ -0,0 +1,36 @@ +#ifndef _gun_swirl_h +#define _gun_swirl_h + +#include "gunobj.h" +#include +#include "bitmap.h" + +using namespace std; + +class ECollide; +class SpaceObject; + +class WeaponSwirlGun: public WeaponObject{ +public: + + WeaponSwirlGun( int z, int d, int smp, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual void Idle(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual void Draw( const Bitmap & less, int x, int y); + virtual WeaponObject * copy(); + ~WeaponSwirlGun(); + +protected: + + int rising; + ECollide * diss_collide; + int * shade; + int * feel; + int radius; + int dir; + int cur_rad; + +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_eside.cpp +++ rafkill-1.2.2/build/guns/gun_eside.cpp @@ -0,0 +1,27 @@ +#include "gunobj.h" +#include "gun_eside.h" + +#include "weaponobj.h" +#include "hulls/hull_weapon_s_l.h" + +#include "trigtable.h" + +EnemySide::EnemySide( int d, int al ): +WeaponObject( d, "Side", 0, al, 0, 0 ){} + +void EnemySide::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + shot_counter = 25; + + const double LARGE_BULLET = 1.6 * 8; + double dx = Tcos(270-25)*LARGE_BULLET; + double dy = Tsine(270-25)*LARGE_BULLET; + + Ammo->push_back( new WeaponNode(x+5,y,dx,dy, new SL_WHull(), alignment ) ); + + dx = Tcos(270+25)*LARGE_BULLET; + dy = Tsine(270+25)*LARGE_BULLET; + + Ammo->push_back( new WeaponNode(x-5,y,dx,dy, new SL_WHull(), alignment ) ); + +} --- rafkill-1.2.2.orig/build/guns/gun_eflarge.h +++ rafkill-1.2.2/build/guns/gun_eflarge.h @@ -0,0 +1,16 @@ +#ifndef _gun_enemy_find_large_h +#define _gun_enemy_find_large_h + +#include "gunobj.h" +#include "spaceobj.h" +#include + +using namespace std; + +class EnemyFindLarge:public WeaponObject{ +public: + EnemyFindLarge( int d, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_spread.cpp +++ rafkill-1.2.2/build/guns/gun_spread.cpp @@ -0,0 +1,57 @@ +#include "gunobj.h" +#include "gun_spread.h" +#include "hulls/hull_weapon_spread.h" +#include "weaponobj.h" +#include "spaceobj.h" +#include "trigtable.h" + +WeaponSpreadGun::WeaponSpreadGun( int z, int d, int _smp, int al ): +WeaponObject( d, "Spread Gun", 31500, al, z, 4 ) { + smp = _smp; +} + + +WeaponObject * WeaponSpreadGun::copy() { + return new WeaponSpreadGun( strength, dir, smp, alignment ); +} + + +void WeaponSpreadGun::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight) { + if ( smp != -1 ){ + Util::playSound( smp, 255 ); + } + + shot_counter = 5; + int ang = (strength+1) * 30; + int ds = 50 / (strength+2); + + int xpos = x; + int ypos = y; + double xspeed = 0; + double yspeed = -2.6*8.0; + + Ammo->push_back( new WeaponNode(xpos,ypos,xspeed,yspeed, new Spread_WHull(7), alignment ) ); + + for ( int q = ds; q < ang; q += ds ) { + + xpos = (int)( x + Tcos( (90 + q + 360 ) % 360 ) ); + ypos = (int)( y + Tsine((90 + q + 360 ) % 360 ) ); + xspeed = Tcos((90+q+360)%360)*2.6 * 8.0; + yspeed = Tsine((90+q+360)%360)*2.6 * 8.0; + + Ammo->push_back( new WeaponNode(xpos,ypos,xspeed,yspeed, new Spread_WHull(7), alignment ) ); + + xpos = (int)( x + Tcos( (90 - q + 360 ) % 360 ) ); + ypos = (int)( y + Tsine((90 - q + 360 ) % 360 ) ); + xspeed = Tcos((90-q+360)%360)*2.6 * 8.0; + yspeed = Tsine((90-q+360)%360)*2.6 * 8.0; + + Ammo->push_back( new WeaponNode(xpos,ypos,xspeed,yspeed, new Spread_WHull(7), alignment ) ); + + /* + Ammo->push_back( new WeaponNode((int)(x+tcos[(90+q+360)%360]),(int)(y+tsine[(90+q+360)%360]),tcos[(90+q+360)%360]*2.6,tsine[(90+q+360)%360]*2.6, new Spread_WHull(7), alignment ) ); + Ammo->push_back( new WeaponNode((int)(x+tcos[(90-q+360)%360]),(int)(y+tsine[(90-q+360)%360]),tcos[(90-q+360)%360]*2.6,tsine[(90-q+360)%360]*2.6, new Spread_WHull(7), alignment ) ); + */ + } + +} --- rafkill-1.2.2.orig/build/guns/gun_beam.cpp +++ rafkill-1.2.2/build/guns/gun_beam.cpp @@ -0,0 +1,54 @@ +#include "gunobj.h" +#include "gun_beam.h" +// #include "spaceobj.h" + +#include "weapons/weapon_beam.h" +#include "hulls/hull_weapon_beam.h" +#include + +using namespace std; + +WeaponBeam::WeaponBeam( int z, int d, int al ): +WeaponObject( d, "Beam", 36300, al, z, 6 ), +tear( 90 ), +length( 0 ), +fat( 20 ), +angle( 0 ) { +} + + +void WeaponBeam::Idle( int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + tear = 0; +} + + +void WeaponBeam::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + shot_counter = 30; + if ( tear > 0 ) { + shot_counter = 0; + tear--; + length += 63; + if( length > 480 ) length = 480; + fat--; + if ( fat < 1 ) { + fat = 1; + tear = 0; + } + } + else { + tear = 90; + length = 0; + fat = 18+(strength+1)*3; + return; + } + + angle = (angle-17+360) % 360; + Ammo->push_back( new Beam(x,y-length/2,0,0,1, new Beam_WHull((strength+1.0)*2.0,fat*2,length,angle), alignment ) ); + +} + + +WeaponObject * WeaponBeam::copy() { + return new WeaponBeam( strength, dir, alignment ); +} --- rafkill-1.2.2.orig/build/guns/gun_estraight.h +++ rafkill-1.2.2/build/guns/gun_estraight.h @@ -0,0 +1,17 @@ +#ifndef _gun_enemy_straight_shooter_h +#define _gun_enemy_straight_shooter_h + +#include "gunobj.h" +#include + +class SpaceObject; + +class EnemyStraightShooter:public WeaponObject{ +public: + EnemyStraightShooter( int d, int al ); + + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_pulse.h +++ rafkill-1.2.2/build/guns/gun_pulse.h @@ -0,0 +1,16 @@ +#ifndef _weapon_pulse_h +#define _weapon_pulse_h + +#include "gunobj.h" + +class SpaceObject; + +class WeaponPulse: public WeaponObject{ +public: + WeaponPulse( int z, int d, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + + virtual WeaponObject * copy(); +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_saber.h +++ rafkill-1.2.2/build/guns/gun_saber.h @@ -0,0 +1,45 @@ +#ifndef _gun_saber_h +#define _gun_saber_h + +#include "gunobj.h" +#include "bitmap.h" +#include + +#define MAX_GLOW 8 + +using namespace std; + +class ECollide; +class SpaceObject; + +class saber_point{ +public: + saber_point(); + int ang; + double distance; +}; + +class WeaponSaber: public WeaponObject{ +public: + + WeaponSaber( int z, int d, int smp, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual void Idle(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual void Draw( const Bitmap & less, int x, int y); + virtual WeaponObject * copy(); + ~WeaponSaber(); + +protected: + + int rising; + saber_point glow[ MAX_GLOW ]; + int * shade; + int min_color_r; + int min_color_g; + bool shooting; + int fat; + +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_emlight.h +++ rafkill-1.2.2/build/guns/gun_emlight.h @@ -0,0 +1,20 @@ +#ifndef _gun_enemy_machine_light_h +#define _gun_enemy_machine_light_h + +#include "gunobj.h" +#include "spaceobj.h" +#include + +using namespace std; + +class EnemyMachineLight:public WeaponObject{ +public: + EnemyMachineLight( int d, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual ~EnemyMachineLight(); + +protected: + int tear; +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_follow.cpp +++ rafkill-1.2.2/build/guns/gun_follow.cpp @@ -0,0 +1,26 @@ +#include "gunobj.h" +#include "gun_follow.h" +#include "weapons/weapon_follow.h" +#include "defs.h" +#include "spaceobj.h" +#include + +WeaponFollow::WeaponFollow( int z, int d, int al ): +WeaponObject( d, "Tracker", 40000, al, z, 4 ) { +} + + +WeaponObject * WeaponFollow::copy() { + return new WeaponFollow( strength, dir, alignment ); +} + + +void WeaponFollow::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + shot_counter = 12; + + if ( fight == NULL ) return; + for ( int q = 0; q <= strength; q++ ) + Ammo->push_back( new Follow(x,y,90,fight,alignment, 10+strength*8 ) ); + +} --- rafkill-1.2.2.orig/build/guns/gun_stick.cpp +++ rafkill-1.2.2/build/guns/gun_stick.cpp @@ -0,0 +1,81 @@ +#include "gunobj.h" +#include "gun_stick.h" +#include "ebox.h" +#include "hulls/hull_animation.h" +#include "weapons/weapon_stick.h" +#include "raptor.h" +#include "defs.h" +#include "bitmap.h" +#include + +using namespace std; + +WeaponStick::WeaponStick( int z, int d, int al, ECollide ** _collide_list, int _max_collide ): +WeaponObject( d, "Sticky Bomb", 350000, al, z, 4 ) { + + max_collide = _max_collide; + collide_list = _collide_list; + + /* + max_collide = 40; + collide_list = new ECollide*[ max_collide ]; + for ( int q = 0; q < max_collide; q++ ){ + Bitmap * temp = create_Bitmap( (3 + q * 3)*2, (3 + q * 3)*2 ); + int mask = makecol( 255, 0, 255 ); + clear_to_color( temp, mask ); + circlefill( temp, 3 + q * 3, 3 + q * 3, 3 + q * 3, makecol(255,0,0) ); + collide_list[q] = new ECollide( temp, 3, mask, 35.0 ); + destroy_Bitmap( temp ); + } + */ + // ecollide = new ECollide( (Bitmap *)global_data[ WEAPON_BOMB_1 ].dat, 2, makecol(255,0,255), 30.0 ); + Bitmap l( Util::getDataSprite( WEAPON_BOMB_1 ) ); + ecollide = new ECollide( &l ); + +} + + +void WeaponStick::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + shot_counter = 17; + + /* + ECollide ** temp_collide = new ECollide*[ max_collide ]; + for ( int q = 0; q < max_collide; q++ ) + temp_collide[q] = collide_list[q]->copy(); + */ + + int mpics = WEAPON_BOMB_7 - WEAPON_BOMB_1 + 1; + + vector< Bitmap > pics; + // Bitmap ** pics = new Bitmap*[ mpics ]; + for ( int q = 0; q < mpics; q++ ){ + pics.push_back( Util::getDataSprite( WEAPON_BOMB_1 + q ) ); + } + + const double speed = -1.4 * 8; + + vector< Bitmap > shadows; + + Ammo->push_back( new Sticky( x, y, 0, speed, new HullAnimation( pics, shadows, 1, 0, 0, 0, 10, false, ecollide->copy() ), alignment, collide_list, max_collide, (strength)*3+2 ) ); + +} + + +WeaponObject * WeaponStick::copy() { + //ECollide ** temp_list = new ECollide*[ max_collide ]; + //for ( int q = 0; q < max_collide; q++ ) + // temp_list[q] = collide_list[q]->copy(); + //return new WeaponStick( strength, dir, alignment, temp_list, max_collide ); + return new WeaponStick( strength, dir, alignment, collide_list, max_collide ); +} + + +WeaponStick::~WeaponStick() { + + //for ( int q = 0; q < max_collide; q++ ) + // delete collide_list[q]; + //delete[] collide_list; + delete ecollide; + +} --- rafkill-1.2.2.orig/build/guns/gun_ecork.h +++ rafkill-1.2.2/build/guns/gun_ecork.h @@ -0,0 +1,14 @@ +#ifndef _gun_enemy_cork_h +#define _gun_enemy_cork_h + +#include "gunobj.h" + +class SpaceObject; + +class EnemyCork:public WeaponObject{ +public: + EnemyCork( int d, int al); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_angle.cpp +++ rafkill-1.2.2/build/guns/gun_angle.cpp @@ -0,0 +1,74 @@ +#include "gunobj.h" +#include "gun_angle.h" +#include "bitmap.h" +#include "weapons/weapon_angle.h" +#include "hulls/hull_weapon_angle.h" +#include "trigtable.h" +#include "ebox.h" + +static const int MAX_ANGLE_SHADE = 20; + +WeaponAngle::WeaponAngle( int z, int d, int al ): +WeaponObject( d, "Taurus Gun", 145000, al, z, 4 ) { + //strength = z; + shade = new int[ MAX_ANGLE_SHADE ]; + + Bitmap weapon_bitmap(6,6); + weapon_bitmap.fill( Bitmap::makeColor(255,0,255) ); + weapon_bitmap.circleFill( 3, 3, 2, Bitmap::makeColor(255,0,0) ); + ecollide = new ECollide( weapon_bitmap ); +} + +WeaponAngle::~WeaponAngle() { + delete[] shade; + delete ecollide; +} + +WeaponObject * WeaponAngle::copy() { + return new WeaponAngle( strength, dir, alignment ); +} + + +void WeaponAngle::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + // shot_counter = 13; + setShotCounter( 13 ); + + int r1, g1, b1, r2, g2, b2; + + r1 = (255-(strength+1)*13+256)%256; + g1 = (90+(strength+1)*2+256)%256; + b1 = (20+(strength+1)*6+256)%256; + + r2 = (r1-(strength+1)*11+256)%256; + g2 = (g1+(strength+1)*8+256)%256; + b2 = (b1+(strength+1)*19+256)%256; + + Util::blend_palette( shade, MAX_ANGLE_SHADE/2, Bitmap::makeColor(r1,g1,b1), Bitmap::makeColor(r2,g2,b2) ); + Util::blend_palette( shade+MAX_ANGLE_SHADE/2, MAX_ANGLE_SHADE-MAX_ANGLE_SHADE/2, Bitmap::makeColor(r2,g2,b2), Bitmap::makeColor(r1,g1,b1) ); + + const double speed = -1.65 * 8; + + int color = 0; + const double angle_dist = 26; + for ( int q = 0; q < 360; q+= 8, color = (color+1) % MAX_ANGLE_SHADE ){ + + /* + int rx = (int)( x + Tcos(q) * angle_dist ); + int ry = (int)( y + Tsine(q) * angle_dist ); + */ + + int rx = x; + int ry = y; + + /* + double fx = Tcos(q+90) * 5; + double fy = Tsine(q+90) * 5; + */ + double fx = 0; + double fy = speed; + + Ammo->push_back( new Angle( rx, ry, fx, fy, angle_dist, new Angle_WHull( 3*(strength+1), shade[color], ecollide->copy() ), alignment, q%360 ) ); + } + +} --- rafkill-1.2.2.orig/build/guns/gun_etwirl_machine.h +++ rafkill-1.2.2/build/guns/gun_etwirl_machine.h @@ -0,0 +1,24 @@ +#ifndef _gun_enemy_twirl_machine_h +#define _gun_enemy_twirl_machine_h + +#include "gunobj.h" +#include "spaceobj.h" +#include + +using namespace std; + +class ECollide; + +class EnemyTwirlMachine:public WeaponObject{ +public: + EnemyTwirlMachine( int d, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + + virtual ~EnemyTwirlMachine(); + +protected: + ECollide * ecollide; + int tear; +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_machine_circle.cpp +++ rafkill-1.2.2/build/guns/gun_machine_circle.cpp @@ -0,0 +1,46 @@ +#include "gunobj.h" +#include "gun_machine_circle.h" +#include "weaponobj.h" +#include "hulls/hull_weapon_machine.h" +#include "trigtable.h" + +// #define d_circle_move (2.9*8) + +WeaponMachineCircleGun::WeaponMachineCircleGun( int z, int d, int _smp, int al ): +WeaponObject( d, "Radix Gun", 25000, al, z, 4 ), +angle( 0 ) { + smp = _smp; +} + + +WeaponObject * WeaponMachineCircleGun::copy() { + return new WeaponMachineCircleGun( strength, dir, smp, alignment ); +} + + +void WeaponMachineCircleGun::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + if ( smp != -1 ){ + Util::playSound( smp, 255 ); + } + + shot_counter = 1; + angle = (angle + 20 ) % 360; + + const double d_circle_move = 2.9 * 8; + + for ( int q = -(30+strength*2); q < 30+strength*2; q += 7-strength ) { + + int ra = ( angle + q + 360 ) % 360; + int bul; + if ( q != 0 ) + bul = (strength+1)*11 / abs( q ); + else bul = 3; + + if ( bul > 3 ) bul = 3; + if ( bul < 1 ) bul = 1; + Ammo->push_back( new WeaponNode(x,y,Tcos(ra)*d_circle_move,Tsine(ra)*d_circle_move, new Machine_WHull(bul), alignment ) ); + + } + +} --- rafkill-1.2.2.orig/build/guns/gun_chain.h +++ rafkill-1.2.2/build/guns/gun_chain.h @@ -0,0 +1,32 @@ +#ifndef _gun_chain_h +#define _gun_chain_h + +#include "gunobj.h" + +class SpaceObject; +class ECollide; + +class WeaponChainGun: public WeaponObject{ +public: + + WeaponChainGun( int z, int d, const char * name, int wor, int smp, int al, ECollide * eb ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual void Idle(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight); + virtual WeaponObject * copy(); + + ~WeaponChainGun(); + +protected: + + int lx, ly; + int ox, oy; + double fx, fy; + double dx, dy; + + int d_length; + int draw_number; + ECollide * chain_collide; + +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_etwirl_machine.cpp +++ rafkill-1.2.2/build/guns/gun_etwirl_machine.cpp @@ -0,0 +1,57 @@ +#include "gunobj.h" +#include "weaponobj.h" +#include "gun_etwirl_machine.h" +#include "hulls/hull_weapon_twirl.h" +#include "defs.h" +#include "trigtable.h" +#include "spaceobj.h" +#include "ebox.h" +#include "raptor.h" +#include + +using namespace std; + +EnemyTwirlMachine::EnemyTwirlMachine( int d, int al ): +WeaponObject( d, "Twirl Machine", 0, al, 0, 0 ), +tear( 5 ) { + + Bitmap tmp( 6, 12 ); + tmp.fill( Bitmap::MaskColor ); + tmp.ellipseFill( 3, 6, 3, 6, Bitmap::makeColor( 255, 255, 255 ) ); + ecollide = new ECollide( tmp ); + + /* + BITMAP * temp = create_bitmap( 6, 12 ); + clear_to_color( temp, makecol(255,0,255) ); + ellipsefill( temp, 3, 6, 3, 6, makecol(255,255,255) ); + // ecollide = new ECollide( temp,2,makecol(255,0,255), 52 ); + ecollide = new ECollide( temp ); + destroy_bitmap( temp ); + */ +} + +EnemyTwirlMachine::~EnemyTwirlMachine() { + delete ecollide; +} + +void EnemyTwirlMachine::MakeShot(int x, int y,vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + shot_counter = 40; + if ( fight == NULL ) return; + if ( tear > 0 ) { + tear--; + shot_counter = 10; + } else tear = 5; + + if ( fight->empty() ) return; + + SpaceObject obj( 0, 0, 0, 0, NULL, NULL, PLANE_AIR, this->getTeam() ); + const SpaceObject * use = getCollidableObject( fight, &obj ); + + const double speed = 8; + if ( use != NULL ) { + int sang = gang( x, y, use->getX(), use->getY()+7 ); + double sx = Tcos(sang) * speed; + double sy = Tsine(sang) * speed; + Ammo->push_back( new WeaponNode(x,y,sx,sy,new Twirl_WHull( Util::getDataSprite( BULLET_TWIRL ), ecollide->copy() ), alignment ) ); + } +} --- rafkill-1.2.2.orig/build/guns/gun_findgun.h +++ rafkill-1.2.2/build/guns/gun_findgun.h @@ -0,0 +1,28 @@ +#ifndef _gun_findgun_h +#define _gun_findgun_h + +#include "gunobj.h" +#include +#include "spaceobj.h" + +using namespace std; + +class WeaponFindGun: public WeaponObject{ +public: + + WeaponFindGun( int z, int d, int al ); + + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + +protected: + + //process: returns quick formula for distance + int mdist( int x1, int y1, int x2, int y2 ); + + SpaceObject * look[ 5 ]; + +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_emissle.h +++ rafkill-1.2.2/build/guns/gun_emissle.h @@ -0,0 +1,17 @@ +#ifndef _gun_enemy_missle_h +#define _gun_enemy_missle_h + +#include "gunobj.h" + +class SpaceObject; + +class EnemyMissle:public WeaponObject{ +public: + EnemyMissle( int d, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + +protected: + int tear; +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_shatter.h +++ rafkill-1.2.2/build/guns/gun_shatter.h @@ -0,0 +1,18 @@ +#ifndef _gun_shatter_h +#define _gun_shatter_h + +#include "gunobj.h" + +class SpaceContainer; + +class WeaponShatter: public WeaponObject{ +public: + + WeaponShatter( int z, int d, int smp, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_saber.cpp +++ rafkill-1.2.2/build/guns/gun_saber.cpp @@ -0,0 +1,138 @@ +#include "gun_saber.h" +#include "trigtable.h" +#include "gunobj.h" +#include "hulls/hull_weapon_saber.h" +#include "weapons/weapon_beam.h" +#include "spaceobj.h" +#include "ebox.h" +#include + +using namespace std; + +static const int MAX_GLOW_SHADE = 15; + +saber_point::saber_point() { + distance = 0; +} + +WeaponSaber::WeaponSaber( int z, int d, int smp, int al ): +WeaponObject( d, "Saber Gun", 285000, al, z, 0 ), +rising( 0 ) { + + shade = new int[ MAX_GLOW_SHADE ]; + min_color_r = 80; + min_color_g = 80; + shooting = false; + +} + + +WeaponObject * WeaponSaber::copy() { + return new WeaponSaber( strength, dir, smp, alignment ); +} + + +WeaponSaber::~WeaponSaber() { + delete[] shade; +} + + +void WeaponSaber::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + shot_counter = 0; + + if ( shooting ) { + + fat += 2; + if ( fat >= rising / 3 ) { + shooting = false; + rising = 0; + } + + int ff = rising/3 - abs(fat) + 1; + Ammo->push_back( new Beam(x,y-240,0,0,1, new Saber_WHull(ff/2,ff*2,480), alignment ) ); + + return; + + } + + if ( rising < 200 ) + rising++; + +} + + +void WeaponSaber::Idle( int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + if ( shooting ) { + + fat += 2; + if ( fat >= rising / 3 ) { + shooting = false; + rising = 0; + } + + int ff = rising/3 - abs(fat) + 1; + Ammo->push_back( new Beam(x,y-240,0,0,1, new Saber_WHull(ff/2,ff*2,480), alignment ) ); + + return; + + } + + if ( rising == 0 ) return; + min_color_r = 80; + min_color_g = 80; + + shooting = true; + fat = 1; + +} + + +void WeaponSaber::Draw( const Bitmap & less, int x, int y) { + + if ( rising == 0 ) return; + + int ry = y - 25; + + for ( int q = 0; q < MAX_GLOW_SHADE; q++ ){ + shade[q] = Bitmap::addColor( shade[q], Bitmap::makeColor( 6, 6, 7 ) ); + } + + min_color_r++; + min_color_g++; + + if ( min_color_r > 255 ) min_color_r = 255; + if ( min_color_g > 255 ) min_color_g = 255; + + Util::blend_palette( shade, MAX_GLOW_SHADE, Bitmap::makeColor(250,250,0), Bitmap::makeColor(min_color_r, min_color_g, 0 ) ); + + //circlefill( less, x, ry, rising/30 + 3, makecol( 255, 250, 0 ) ); + for ( int q = MAX_GLOW_SHADE-1; q >= 0; q-- ){ + less.circleFill( x, ry, (int)((double)q*(double)rising/100.0), shade[q] ); + } + + int g = Util::rnd( MAX_GLOW ); + if ( glow[ g ].distance <= 0 ) { + glow[ g ].distance = Util::rnd( 9 ) + (double)rising/3.0; + glow[ g ].ang = Util::rnd( 360 ); + } + + for ( int q = 0; q < MAX_GLOW; q++ ){ + if ( glow[q].distance > 0 ) { + + int rad = (int)( 20.0 / (fabs(glow[q].distance)+1) + 1 ); + + if ( rad > 4 ) rad = 4; + + int cx = (int)(x+Tcos(glow[q].ang)*glow[q].distance); + int cy = (int)(ry+Tsine(glow[q].ang)*glow[q].distance); + int color = Bitmap::makeColor( (int)(250-glow[q].distance*3),(int)(250-glow[q].distance*3), 0); + + less.circleFill( cx, cy, rad, color ); + + glow[q].distance -= 1.8; + + } + } + +} --- rafkill-1.2.2.orig/build/guns/gun_estraight.cpp +++ rafkill-1.2.2/build/guns/gun_estraight.cpp @@ -0,0 +1,16 @@ +#include "gunobj.h" +#include "gun_estraight.h" +#include "weaponobj.h" +#include "hulls/hull_weapon_s_s.h" +#include "spaceobj.h" +#include + +#include "defs.h" + +EnemyStraightShooter::EnemyStraightShooter( int d, int al ): +WeaponObject( d, "Straight Shooter", 0, al, 0, 0 ){} + +void EnemyStraightShooter::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + setShotCounter( 45 ); + Ammo->push_back( new WeaponNode(x,y,0,10, new SS_WHull(), alignment ) ); +} --- rafkill-1.2.2.orig/build/guns/gun_pulse.cpp +++ rafkill-1.2.2/build/guns/gun_pulse.cpp @@ -0,0 +1,65 @@ +#include "gunobj.h" +#include "gun_pulse.h" + +#include "weapons/weapon_pulse.h" +#include "hulls/hull_weapon_pulse_small.h" +#include "hulls/hull_weapon_pulse_large.h" + +WeaponPulse::WeaponPulse( int z, int d, int al ): +WeaponObject( d, "Pulse", 56000, al, z, 4 ) { +} + + +WeaponObject * WeaponPulse::copy() { + return new WeaponPulse( strength, dir, alignment ); +} + + +void WeaponPulse::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + const double speed1 = -2.0 * 8; + const double speed2 = -1.3 * 8; + const double speed3 = -1.1 * 8; + + switch( strength ) { + case 0 : { + + shot_counter = 10; + Ammo->push_back( new Pulse(x-6,y,0,speed1, new SmallPulse_WHull(), alignment ) ); + Ammo->push_back( new Pulse(x+6,y,0,speed1, new SmallPulse_WHull(), alignment ) ); + break; + + } + case 1 : { + + shot_counter = 12; + Ammo->push_back( new Pulse(x,y,0,speed1, new LargePulse_WHull(), alignment ) ); + break; + + } + case 2 : { + shot_counter = 13; + Ammo->push_back( new Pulse(x-9,y,0,speed1, new LargePulse_WHull(), alignment ) ); + Ammo->push_back( new Pulse(x+9,y,0,speed1, new LargePulse_WHull(), alignment ) ); + break; + + } + case 3 : { + shot_counter = 14; + Ammo->push_back( new NovaPulse(x,y,0.4*8,speed2,alignment) ); + Ammo->push_back( new Pulse(x,y,0,speed1, new LargePulse_WHull(), alignment ) ); + Ammo->push_back( new NovaPulse(x,y,-0.4*8,speed2,alignment) ); + break; + } + case 4 : { + shot_counter = 15; + Ammo->push_back( new NovaPulse(x,y,0.7*8,speed3,alignment) ); + Ammo->push_back( new NovaPulse(x,y,0.3*8,speed3,alignment) ); + Ammo->push_back( new NovaPulse(x,y,-0.3*8,speed3,alignment) ); + Ammo->push_back( new NovaPulse(x,y,-0.7*8,speed3,alignment) ); + Ammo->push_back( new Pulse(x,y,0,speed1, new LargePulse_WHull(), alignment ) ); + break; + } + + } //switch +} --- rafkill-1.2.2.orig/build/guns/gun_beam.h +++ rafkill-1.2.2/build/guns/gun_beam.h @@ -0,0 +1,28 @@ +#ifndef _gun_beam_h +#define _gun_beam_h + +#include "gunobj.h" +#include + +using namespace std; + +class SpaceObject; + +class WeaponBeam: public WeaponObject{ +public: + WeaponBeam( int z, int d, int al ); + + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual void Idle( int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + +protected: + + int tear; + int length; + int fat; + int angle; + +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_laser.h +++ rafkill-1.2.2/build/guns/gun_laser.h @@ -0,0 +1,20 @@ +#ifndef _gun_laser_h +#define _gun_laser_h + +#include "gunobj.h" + +class HullObject; +class SpaceObject; + +class WeaponLaser: public WeaponObject{ +public: + WeaponLaser( int z, int d, int al ); + + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight); + virtual WeaponObject * copy(); + +protected: + void produceLaser( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, int x, int y, HullObject * hwho, int al ); +}; + +#endif --- rafkill-1.2.2.orig/build/guns/gun_ednstraight.cpp +++ rafkill-1.2.2/build/guns/gun_ednstraight.cpp @@ -0,0 +1,18 @@ +#include "weaponobj.h" +#include "gunobj.h" +#include "gun_ednstraight.h" +#include "hulls/hull_weapon_s_s.h" +#include "spaceobj.h" +#include +#include "defs.h" + +using namespace std; + +EnemyDoubleNearStraightShooter::EnemyDoubleNearStraightShooter( int d, int al ): +WeaponObject( d, "Double Near Straight Shooter", 0, al, 0, 0 ){} + +void EnemyDoubleNearStraightShooter::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + setShotCounter( 45 ); + Ammo->push_back( new WeaponNode(x+5,y,0,10, new SS_WHull(), alignment ) ); + Ammo->push_back( new WeaponNode(x-5,y,0,10, new SS_WHull(), alignment ) ); +} --- rafkill-1.2.2.orig/build/guns/gun_findgun.cpp +++ rafkill-1.2.2/build/guns/gun_findgun.cpp @@ -0,0 +1,165 @@ +#include "gunobj.h" +#include "gun_findgun.h" +#include "spaceobj.h" +#include "trigtable.h" +#include "weaponobj.h" +#include "hulls/hull_weapon_machine.h" +#include "spaceobj.h" +#include +#include + +using namespace std; + +WeaponFindGun::WeaponFindGun( int z, int d, int al ): +WeaponObject( d, "Find Gun", 38500, al, z, -1 ) { + strength = z; + for ( int q = 0; q < 5; q++ ) + look[q] = NULL; +} + + +WeaponObject * WeaponFindGun::copy() { + return new WeaponFindGun( strength, dir, alignment ); +} + + +int WeaponFindGun::mdist( int x1, int y1, int x2, int y2 ) { + return ( abs(x1-x2) + abs(y1-y2) ); +} + + +void WeaponFindGun::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + if ( fight == NULL ) return; + if ( fight->empty() ) { + for ( int q = 0; q < 5; q++ ) + look[q] = NULL; + return; + } + + // SpaceObject * gay = new SpaceObject(0,0,0,0,NULL,NULL,PLANE_AIR|PLANE_GROUND, alignment ); + SpaceObject gay(0,0,0,0,NULL, NULL, PLANE_AIR|PLANE_GROUND, alignment ); + bool cy = false; + + for ( vector< SpaceObject * >::const_iterator it = fight->begin(); it != fight->end(); it++ ) + if ( (*it)->CanbeHit( &gay ) ) cy = true; + + if ( !cy ) { + for ( int q = 0; q < 5; q++ ) + look[q] = NULL; + // delete gay; + return; + } + + shot_counter = Util::rnd( 2 ); + + int mp = strength; + if ( mp > 4 ) mp = 4; + + vector< SpaceObject * >::const_iterator find_next = fight->begin(); + + for ( int q = 0; q <= mp; q++ ) { + + cy = true; + if ( look[q] != NULL ) { + for ( vector< SpaceObject * >::const_iterator it = fight->begin(); it != fight->end(); ) { + if ( look[q] == (*it) ) { + cy = false; + it = fight->end(); + } else it++; + } + } + if ( cy ) look[q] = NULL; + else { + if ( look[q]->getX()>640||look[q]->getX()<0||look[q]->getY()>480|| + look[q]->getY()<0 ) + cy = true; + if ( !look[q]->CanbeHit( &gay ) ) + cy = true; + } + + if ( cy ) { + + look[q] = *find_next; + while ( !look[q]->CanbeHit( &gay ) ) { + + find_next++; + if ( find_next == fight->end() ) find_next = fight->begin(); + look[q] = *find_next; + + } + find_next++; + if ( find_next == fight->end() ) find_next = fight->begin(); + + } + + SpaceObject * choose = look[q]; + if ( choose != NULL ) { + + /* + double odx = choose->DX(); + double ody = choose->DY(); + double speed = sqrt( odx*odx + ody*ody ); + double gamma = M_PI/2.0; + double omega = M_PI/2.0; + if ( choose->actualx - x != 0 ) gamma = atan2( (y-choose->actualy),x-choose->actualx); + if ( odx != 0 ) omega = atan2( ody, odx ); + double theta = gamma + asin( speed * sin( gamma - omega ) / 4.0 ); + int ang = (int)( 0.5 + theta * 180 / M_PI ); + */ + + int d = (int) dist( x, y, choose->getX(), choose->getY() ); + + int fx, fy; + + fx = (int)(choose->getX() + choose->getDX()*tsqrt(d)*2.0/3.0 ); + fy = (int)(choose->getY() + choose->getDY()*tsqrt(d)*2.0/3.0 ); + + int ang = getAngle( x, y, fx, fy ); + + /* + double odx = choose->DX(); + double ody = choose->DY(); + double Aspeed = sqrt( odx*odx + ody*ody ); + + //int alpha = gang( choose->actualx, choose->actualy, x, y ); + double alpha = atan2( -(choose->actualy-y), choose->actualx-x ); + double beta = asin( Aspeed * sin(alpha) / 4.0 ); + + printf("Object A dx = %0.5f dy = %0.5f\n", odx, ody );*/ + + /* + fixed odx = ftofix( (float)choose->DX() ); + fixed ody = ftofix( (float)choose->DY() ); + fixed speed = fixsqrt( fixadd( fixmul(odx,odx),fixmul(ody,ody) ) ); + fixed x1 = itofix( choose->actualx ); + fixed y1 = itofix( choose->actualy ); + fixed x2 = itofix( x ); + fixed y2 = itofix( y ); + fixed alpha = fixatan2( -fixsub(y2,y1), fixsub(x2,x1) ); + fixed beta = fixasin( fixdiv( fixmul(speed,fixsin(alpha) ), ftofix(4.0) ) ); + + int ang = (int)(0.5 + fixtof(beta) * 180.0 / M_PI); + ang = (ang+3600)%360; + printf("Object A = %0.5f. Beta = %0.5f Object b = %d.\n", fixtof(alpha), ftofix(beta), ang ); + if ( choose->actualx < x ){ + if ( ang < 90 ) ang = 180 - ang; + else ang = 360 - ang + 180; + } + printf("Beta = %d\n", ang );*/ + double dx = Tcos(ang) * 18.0; + double dy = Tsine(ang) * 18.0; + + int final = strength/2+1; + if ( final > 2 ) final = 2; + if ( strength == 4 ) final = 3; + + final = strength / 3 + q + 1; + + Ammo->push_back(new WeaponNode(x,y,dx,dy,new Machine_WHull(final), alignment ) ); + + } + } + // delete gay; + +} --- rafkill-1.2.2.orig/build/guns/gun_massive.cpp +++ rafkill-1.2.2/build/guns/gun_massive.cpp @@ -0,0 +1,66 @@ +#include "gun_massive.h" +#include "trigtable.h" +#include "gunobj.h" +#include "hulls/hull_weapon_massive.h" +#include "weaponobj.h" +#include "weapons/weapon_damage.h" +#include "weapons/weapon_massive.h" +#include "spaceobj.h" +#include "ebox.h" +#include "trigtable.h" +#include + +using namespace std; + +WeaponMassiveGun::WeaponMassiveGun( int z, int d, int smp, int al ): +WeaponObject( d, "Massive Gun", 43000, al, z, 0 ), +rising( 0 ) { + + Bitmap dopey( 16, 16 ); + dopey.fill( Bitmap::MaskColor ); + dopey.circleFill( 8, 8, 8, Bitmap::makeColor(20,0,0) ); + diss_collide = new ECollide( &dopey ); + ang = 0; + +} + + +WeaponObject * WeaponMassiveGun::copy() { + return new WeaponMassiveGun( strength, dir, smp, alignment ); +} + + +WeaponMassiveGun::~WeaponMassiveGun() { + delete diss_collide; +} + + +void WeaponMassiveGun::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + shot_counter = 0; + if ( rising < 200 ) + rising++; + ang = (ang + 13 ) % 360; + + if ( rising/20 >= 1 ) { + Ammo->push_back( new Damage_Weapon((int)(x+Tcos(ang)*50),(int)(y+Tsine(ang)*50),0,0,1,new Massive_WHull(rising/20,1,diss_collide), alignment ) ); + Ammo->push_back( new Damage_Weapon((int)(x+Tcos((ang+120)%360)*50),(int)(y+Tsine((ang+120)%360)*50),0,0,1,new Massive_WHull(rising/20,1,diss_collide), alignment ) ); + Ammo->push_back( new Damage_Weapon((int)(x+Tcos((ang+240)%360)*50),(int)(y+Tsine((ang+240)%360)*50),0,0,1,new Massive_WHull(rising/20,1,diss_collide), alignment ) ); + } + +} + + +void WeaponMassiveGun::Idle( int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + if ( rising == 0 ) return; + if ( rising/20 >= 1 ) { + const double speed = 2.0 * 8; + Ammo->push_back( new Massive_Weapon((int)(x+Tcos(ang)*50),(int)(y+Tsine(ang)*50),Tcos((ang+90)%360)*speed,Tsine((ang+90)%360)*speed,new Massive_WHull(rising/20,1,diss_collide), alignment ) ); + + Ammo->push_back( new Massive_Weapon((int)(x+Tcos((ang+120)%360)*50),(int)(y+Tsine((ang+120)%360)*50),Tcos((ang+90+120)%360)*speed,Tsine((ang+90+120)%360)*speed,new Massive_WHull(rising/20,1,diss_collide), alignment ) ); + + Ammo->push_back( new Massive_Weapon((int)(x+Tcos((ang+240)%360)*50),(int)(y+Tsine((ang+240)%360)*50),Tcos((ang+90+240)%360)*speed,Tsine((ang+90+240)%360)*speed,new Massive_WHull(rising/20,1,diss_collide), alignment ) ); + } + ang = 0; + rising = 0; +} --- rafkill-1.2.2.orig/build/guns/gun_fire.cpp +++ rafkill-1.2.2/build/guns/gun_fire.cpp @@ -0,0 +1,23 @@ +#include "gunobj.h" +#include "weaponobj.h" +#include "gun_fire.h" +#include "hulls/hull_weapon_fire.h" +#include "spaceobj.h" +#include + +using namespace std; + +WeaponFire::WeaponFire( int z, int d, int al ): +WeaponObject( d, "Fire", 12000, al, z, 0 ) { +} + + +WeaponObject * WeaponFire::copy() { + return new WeaponFire( strength, dir, alignment ); +} + +void WeaponFire::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + const double speed = 9.5; + shot_counter = 35; + Ammo->push_back( new WeaponNode(x-7,y,0,dir * speed, new Fire_WHull(), alignment ) ); +} --- rafkill-1.2.2.orig/build/guns/gun_emlight.cpp +++ rafkill-1.2.2/build/guns/gun_emlight.cpp @@ -0,0 +1,41 @@ +#include "gunobj.h" +#include "gun_emlight.h" +#include "weaponobj.h" +#include "hulls/hull_weapon_light.h" +#include "trigtable.h" +#include "spaceobj.h" +#include + +using namespace std; + +EnemyMachineLight::EnemyMachineLight( int d, int al ): +WeaponObject( d, "Machine Light", 0, al, 0, 0 ), +tear( 7 ){} + +void EnemyMachineLight::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + shot_counter = 45; + if ( fight == NULL ) return; + if ( tear > 0 ) { + tear--; + shot_counter = 3; + } else tear = 7; + + if ( fight->empty() ) return; + + SpaceObject obj( 0, 0, 0, 0, NULL, NULL, PLANE_AIR, this->getTeam() ); + const SpaceObject * use = getCollidableObject( fight, &obj ); + + if ( use != NULL ) { + int sang = getAngle( x, y, use->getX(), use->getY()+7 ); + const double FIND_BULLET = 1.2 * 8; + double sx = Tcos(sang)*FIND_BULLET; + double sy = Tsine(sang)*FIND_BULLET; + Ammo->push_back( new WeaponNode(x,y,sx,sy, new Light_WHull(), alignment ) ); + } + +} + + +EnemyMachineLight::~EnemyMachineLight() { +} --- rafkill-1.2.2.orig/build/guns/gun_minimissle.cpp +++ rafkill-1.2.2/build/guns/gun_minimissle.cpp @@ -0,0 +1,45 @@ +#include "gunobj.h" +#include "gun_minimissle.h" +#include "weaponobj.h" +#include "hulls/hull_weapon_mini.h" +#include "trigtable.h" +#include "spaceobj.h" +#include + +using namespace std; + +WeaponMiniMissle::WeaponMiniMissle( int z, int d, int al ): +WeaponObject( d, "MiniMissile", 31000, al, z, 4 ) { +} + + +WeaponObject * WeaponMiniMissle::copy() { + return new WeaponMiniMissle( strength, dir, alignment ); +} + + +void WeaponMiniMissle::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) { + + // #define ___sp 2.55 + const double speed = 2.55 * 8; + int wide = 0; + + shot_counter = 3; + switch( strength ) { + + case 0 : shot_counter = 3; break; + case 1 : shot_counter = 3; break; + case 2 : shot_counter = 3; break; + case 3 : shot_counter = 2; break; + case 4 : shot_counter = 2; break; + + } + + for ( int q = 0; q <= strength*3/2; q++ ) { + + wide = (5 + q * 5) * ( q > 0 ); + Ammo->push_back( new WeaponNode(x-9,y,Tcos(90-wide)*speed,Tsine(90-wide)*speed, new Mini_WHull(), alignment ) ); + Ammo->push_back( new WeaponNode(x+10,y,Tcos(90+wide)*speed,Tsine(90+wide)*speed, new Mini_WHull(), alignment ) ); + + } +} --- rafkill-1.2.2.orig/build/guns/gun_ednstraight.h +++ rafkill-1.2.2/build/guns/gun_ednstraight.h @@ -0,0 +1,18 @@ +#ifndef _gun_enemy_double_near_straight_shooter_h +#define _gun_enemy_double_near_straight_shooter_h + +#include "gunobj.h" +#include "spaceobj.h" +#include + +using namespace std; + +class EnemyDoubleNearStraightShooter:public WeaponObject{ +public: + EnemyDoubleNearStraightShooter( int d, int al); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_etwirl_find.cpp +++ rafkill-1.2.2/build/guns/gun_etwirl_find.cpp @@ -0,0 +1,44 @@ +#include "gunobj.h" +#include "weaponobj.h" +#include "gun_etwirl_find.h" +#include "hulls/hull_weapon_twirl.h" +#include "defs.h" +#include "trigtable.h" +#include "spaceobj.h" +#include "ebox.h" +#include "raptor.h" +#include + +using namespace std; + +EnemyTwirlFind::EnemyTwirlFind( int d, int al ): +WeaponObject( d, "Twirl Find", 0, al, 0, 0 ) { + + Bitmap tmp( 6, 12 ); + tmp.fill( Bitmap::MaskColor ); + tmp.ellipseFill( 3, 6, 3, 6, Bitmap::makeColor( 255, 255, 255 ) ); + ecollide = new ECollide( tmp ); + +} + +EnemyTwirlFind::~EnemyTwirlFind() { + delete ecollide; +} + +void EnemyTwirlFind::MakeShot(int x, int y,vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ){ + shot_counter = 40; + if ( fight == NULL ) return; + if ( fight->empty() ) return; + + // SpaceObject * use = fight->front(); + SpaceObject obj( 0, 0, 0, 0, NULL, NULL, PLANE_AIR, this->getTeam() ); + const SpaceObject * use = getCollidableObject( fight, &obj ); + + const double speed = 8; + if ( use != NULL ) { + int sang = getAngle( x, y, use->getX(), use->getY()+7 ); + double sx = Tcos(sang)* speed; + double sy = Tsine(sang) * speed; + Ammo->push_back( new WeaponNode(x,y,sx,sy,new Twirl_WHull( Util::getDataSprite( BULLET_TWIRL ), ecollide->copy() ), alignment ) ); + } +} --- rafkill-1.2.2.orig/build/guns/gun_tractor_beam.h +++ rafkill-1.2.2/build/guns/gun_tractor_beam.h @@ -0,0 +1,29 @@ +#ifndef _gun_tractor_beam_h +#define _gun_tractor_beam_h + +#include "gunobj.h" +#include + +class ECollide; +class SpaceObject; + +using namespace std; + +class WeaponTractorBeam: public WeaponObject{ +public: + + WeaponTractorBeam( int z, int d, int al ); + + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + virtual WeaponObject * copy(); + virtual ~WeaponTractorBeam(); + +protected: + + SpaceObject * look; + ECollide * collide; + +}; + + +#endif --- rafkill-1.2.2.orig/build/guns/gun_efmsingle.h +++ rafkill-1.2.2/build/guns/gun_efmsingle.h @@ -0,0 +1,20 @@ +#ifndef _gun_enemy_find_single_machine_h +#define _gun_enemy_find_single_machine_h + +#include "gunobj.h" +#include "spaceobj.h" +#include + +using namespace std; + +class EnemyFindSingleMachine:public WeaponObject{ +public: + EnemyFindSingleMachine( int d, int al ); + virtual void MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ); + + virtual ~EnemyFindSingleMachine(); +protected: + int tear; +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_s_s.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_s_s.cpp @@ -0,0 +1,15 @@ +#include "hull_weapon.h" +#include "bitmap.h" +#include "hull_weapon_s_s.h" + +SS_WHull::SS_WHull(): +HullWeapon( 0, 1, 1 ){} + +void SS_WHull::Draw( const Bitmap & who, int x, int y ) { + /* + circlefill( who, x, y, 3, makecol(255,0,0) ); + circlefill( who, x, y, 1, makecol(255,255,255) ); + */ + who.circleFill( x, y, 3, Bitmap::makeColor(255,0,0) ); + who.circleFill( x, y, 1, Bitmap::makeColor(255,255,255) ); +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_saber.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_saber.cpp @@ -0,0 +1,56 @@ +#include "defs.h" +#include "bitmap.h" +#include "hull_weapon.h" +#include "hull_weapon_saber.h" +#include "ebox.h" + +Saber_WHull::Saber_WHull( int str, int xf, int yf ): +HullWeapon( 0, 1, str*2 ), +x_size( xf ), +y_size( yf ) { + + drawLevel = 20; + shade = new int[ 6 ]; + + Util::blend_palette( shade, 6, Bitmap::makeColor(210,210,0), Bitmap::makeColor(250,250,0) ); + + collide = new ECollide( xf, yf ); + /* + collide = new ECollide(); + collide->setXS( xf/2 ); + collide->setYS( yf/2 ); + collide->my_size = xf/2; + EBox * arch = new EBox( 0, 0, xf, yf ); + collide->add( arch ); + + collide->finalize(); + */ + +} + + +void Saber_WHull::Draw( const Bitmap & who, int x, int y ) { + int mx = x_size/2; + int my = y_size/2; + + Bitmap::drawingMode( Bitmap::MODE_TRANS ); + + for ( int q = 0; q < 5 && x-mx+q < x; q++ ) { + who.line( x-mx+q, y-my, x-mx+q, y+my, shade[q] ); + who.line( x+mx-q, y-my, x+mx-q, y+my, shade[q] ); + } + + if ( x-mx+5 < x ){ + who.rectangleFill( x-mx+5, y-my, x+mx-5, y+my, shade[5] ); + } else { + who.line( x, y-my, x, y+my, shade[5] ); + } + + Bitmap::drawingMode( Bitmap::MODE_SOLID ); +} + + +Saber_WHull::~Saber_WHull() { + delete collide; + delete[] shade; +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_rocket_normal.h +++ rafkill-1.2.2/build/hulls/hull_weapon_rocket_normal.h @@ -0,0 +1,23 @@ +#ifndef _hull_weapon_rocket_normal_h_ +#define _hull_weapon_rocket_normal_h_ + +#include "hull_weapon.h" +#include "bitmap.h" + +class SpaceObject; + +/* + * NormalRocket + * + * normal sized rocket that cuases significant damage + * + */ + +class NormalRocket_WHull:public HullWeapon{ +public: + NormalRocket_WHull(); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual bool Collide( int mx, int my, SpaceObject * check ); +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_laser.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_laser.cpp @@ -0,0 +1,117 @@ +#include "defs.h" +#include "spaceobj.h" +#include "hull_weapon.h" +#include "hull_weapon_laser.h" +#include "ebox.h" + +static const int LASER_DIST = 4; + +Laser_WHull::Laser_WHull( int str ): +HullWeapon( 0, 1, 1 ) { + shade = new int[ LASER_DIST ]; + switch( str ) { + case 0 : { + life = 21; + strength = 3; + color = Bitmap::makeColor( 0,240,130 ); + break; + } + case 1 : { + life = 21; + strength = 6; + color = Bitmap::makeColor( 250,120,50 ); + break; + } + } + Util::blend_palette( shade, LASER_DIST, color, Bitmap::makeColor( 255, 255, 255 ) ); + + int length = getLife() * 3 / 2; + collide = new ECollide( LASER_DIST * 2, length ); + + // Bitmap = create_bitmap(1,1); + myBitmap = new Bitmap(); + drawSelf(); +} + +void Laser_WHull::Collided(){ + + int length = getLife() * 3 / 2; + delete collide; + collide = new ECollide( LASER_DIST * 2, length ); + + drawSelf(); +} + +/* +bool Laser_WHull::Collide( int mx, int my, SpaceObject * check ) { + for ( int qy = my; qy <= my + GetLife() * 3/2; qy+=5 ) + for ( int qx = mx - LASER_DIST; qx <= mx+LASER_DIST; qx += 3 ) + if ( check->HitMe( qx, qy ) ) + return true; + return false; +} +*/ + +void Laser_WHull::drawSelf(){ + + int length = getLife() * 3 / 2; + if ( length < 1 ){ + length = 1; + } + + // destroy_bitmap( Bitmap ); + delete myBitmap; + // Bitmap = create_bitmap( LASER_DIST*2, length ); + myBitmap = new Bitmap( LASER_DIST*2, length ); + + /* + int x1 = x-LASER_DIST; + int y1 = y - length/2; + int x2 = x+LASER_DIST; + int y2 = y + length/2; + */ + + int x1 = 0; + int x2 = LASER_DIST*2-1; + int y1 = 0; + int y2 = length; + + myBitmap->rectangleFill( x1, y1+1, x2, y2-1, shade[0] ); + + for ( int q = 1; q < LASER_DIST; q++ ) + myBitmap->rectangleFill( x1+q, y1, x2-q, y2, shade[q] ); + + /* + rectfill( Bitmap, x1, y1+1, x2, y2-1, shade[0] ); + + for ( int q = 1; q < LASER_DIST; q++ ) + rectfill( Bitmap, x1+q, y1, x2-q, y2, shade[q] ); + */ + +} + +/* +void Laser_WHull::Draw( BITMAP * who, int x, int y ) { + + int length = getLife() * 3 / 2; + + int x1 = x-LASER_DIST; + int y1 = y - length/2; + int x2 = x+LASER_DIST; + int y2 = y + length/2; + + rectfill( who, x1, y1+1, x2, y2-1, shade[0] ); + + for ( int q = 1; q < LASER_DIST; q++ ) + rectfill( who, x1+q, y1, x2-q, y2, shade[q] ); + + // collide->draw( who, x-LASER_DIST, y - length / 2 ); + +} +*/ + + +Laser_WHull::~Laser_WHull() { + delete[] shade; + delete collide; +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_pulse_nova.h +++ rafkill-1.2.2/build/hulls/hull_weapon_pulse_nova.h @@ -0,0 +1,25 @@ +#ifndef _hull_weapon_pulse_nova_h_ +#define _hull_weapon_pulse_nova_h_ + +#include "hull_weapon.h" +#include "bitmap.h" + +class SpaceObject; + +/* + * NovaPulse + * + * big green circle of doom + * + */ + +class NovaPulse_WHull:public HullWeapon{ +public: + + NovaPulse_WHull(); + + virtual void Draw( const Bitmap & who, int x, int y ); + virtual bool Collide( int mx, int my, SpaceObject * check ); +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_chain.h +++ rafkill-1.2.2/build/hulls/hull_weapon_chain.h @@ -0,0 +1,30 @@ +#ifndef _hull_weapon_chain_h +#define _hull_weapon_chain_h + +#include "hull_weapon.h" +#include "bitmap.h" + +/* + * Chain + * + * a spinning iron ball attached by a chain link + * + */ + +class Chain_WHull:public HullWeapon{ +public: + + Chain_WHull( Bitmap * _pics, int str, int power, int angle, int length, ECollide * ec ); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual ~Chain_WHull(); + +protected: + + int mx, my; + int angle, length; + Bitmap ** pics; + int max_pics; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_rotate.h +++ rafkill-1.2.2/build/hulls/hull_weapon_rotate.h @@ -0,0 +1,18 @@ +#ifndef _hull_weapon_rotate_h +#define _hull_weapon_rotate_h + +#include "hull_weapon.h" +#include "bitmap.h" + +class ECollide; + +class Rotate_WHull: public HullWeapon{ +public: + + Rotate_WHull( int str, ECollide * ec ); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual ~Rotate_WHull(); + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_arc.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_arc.cpp @@ -0,0 +1,65 @@ +#include "hull_weapon.h" +#include "hull_weapon_arc.h" +#include "spaceobj.h" +#include "defs.h" +#include "bitmap.h" +#include +#include "ebox.h" + +#define MAX_ARC_SHADE 16 + +Arc_WHull::Arc_WHull( int str, ECollide * mycollide ): +HullWeapon( 0, 1, str ) { + shade = new int[ MAX_ARC_SHADE ]; + strength = str; + + /* + switch( str ) { + case 1 : blend_palette( shade, MAX_ARC_SHADE, makecol(220,0,80), makecol(25,50,2) ); break; + case 3 : blend_palette( shade, MAX_ARC_SHADE, makecol(85,230,0), makecol(10,0,75) ); break; + case 5 : blend_palette( shade, MAX_ARC_SHADE, makecol(110,30,230), makecol(50,20,20) ); break; + case 7 : blend_palette( shade, MAX_ARC_SHADE, makecol(0,80,240), makecol(10,30,60) ); break; + case 9 : blend_palette( shade, MAX_ARC_SHADE, makecol(65,235,100), makecol(180,180,180) ); break; + } + */ + + int r1, g1, b1; + int r2, g2, b2; + int color; + + color = (str*25)%360; + Bitmap::hsvToRGB( (float)color, 1.0, 1.0, &r1, &g1, &b1 ); + color = (color + 12 ) % 360; + Bitmap::hsvToRGB( (float)color, 1.0, 0.8, &r2, &g2, &b2 ); + Util::blend_palette( shade, MAX_ARC_SHADE/3, Bitmap::makeColor(r1,g1,b1), Bitmap::makeColor(r2,g2,b2) ); + color = (color + 18 ) % 360; + Bitmap::hsvToRGB( (float)color, 1.0, 0.5, &r1, &g1, &b1 ); + Util::blend_palette( shade+MAX_ARC_SHADE/3, MAX_ARC_SHADE-MAX_ARC_SHADE/3, Bitmap::makeColor(r2,g2,b2), Bitmap::makeColor(r1,g1,b1) ); + + collide = mycollide; + + // look = create_bitmap( 5, MAX_ARC_SHADE ); + look = new Bitmap( 5, MAX_ARC_SHADE ); + // clear( look ); + look->clear(); + + //int c = shade[0]; + for ( int sy = 0; sy < MAX_ARC_SHADE; sy++ ){ + // hline( look, 0, sy, 4, shade[sy] ); + look->hLine( 0, sy, 4, shade[sy] ); + } + +} + + +void Arc_WHull::Draw( const Bitmap & who, int x, int y ) { + // draw_sprite( who, look, x-2, y ); + look->draw( x-2, y, who ); +} + + +Arc_WHull::~Arc_WHull() { + delete[] shade; + // destroy_bitmap( look ); + delete look; +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_chain.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_chain.cpp @@ -0,0 +1,58 @@ +#include "defs.h" +#include "hull_weapon.h" +#include "hull_weapon_chain.h" +#include "spaceobj.h" +#include "trigtable.h" +#include "ebox.h" +#include "raptor.h" +#include "bitmap.h" + +Chain_WHull::Chain_WHull( Bitmap * _pics, int str, int power, int ang, int len, ECollide * ec ): +HullWeapon( 0, 1, str ) { + + myBitmap = _pics; + + life = 1; + strength = power/5; + angle = ang; + length = len; + collide = ec; + +} + +Chain_WHull::~Chain_WHull() { + delete collide; +} + +void Chain_WHull::Draw( const Bitmap & who, int x, int y ) { + if ( myBitmap == NULL ) return; + + const int max_link = 9; + + // int mx = x + getWidth() / 2; + // int my = y + getHeight() / 2; + + int mx = x; + int my = y; + Bitmap linkCircle = Util::getDataSprite( CHAIN_LINK_CIRCLE ); + Bitmap link = Util::getDataSprite( CHAIN_LINK_LINK ); + + for (int q = 0; q < max_link; q++ ) { + + double ds = (double)length / max_link; + double fn = ds * (double)q; + + double lx = mx + Tcos( angle ) * fn; + double ly = my + Tsine( angle ) * fn; + + linkCircle.draw( (int) lx, (int) ly, who ); + + lx += Tcos( angle ) * ds / 2.0; + ly += Tsine( angle ) * ds / 2.0; + + link.drawRotate( (int) lx, (int) ly, angle + 90, who ); + + } + + HullObject::Draw( who, x, y ); +} --- rafkill-1.2.2.orig/build/hulls/hull_rotate.cpp +++ rafkill-1.2.2/build/hulls/hull_rotate.cpp @@ -0,0 +1,71 @@ +#include "trigtable.h" +#include "defs.h" +#include "hull_rotate.h" + +RotateHull::RotateHull( int _color, int mY, int mX, int sf, int * _shade ): +HullObject( NULL, 100, 0, 1, 1, 10, false, NULL ) { + + color = _color; + + maxX = mX; + maxY = mY; + + sd = sf; + + angX = Util::rnd(360); + angY = Util::rnd(360); + + dX = (Util::rnd( 8 ) + sd) * (Util::rnd( 2 ) * 2 - 1 ); + dY = (Util::rnd( 8 ) + sd) * (Util::rnd( 2 ) * 2 - 1 ); + + //dX = rnd(20) - 10; + //dY = rnd(20) - 10; + dwX = dX; + dwY = dY; + ox = angX; + oy = angY; + + ox2 = angX; + oy2 = angY; + shade = _shade; +} + + +void RotateHull::Draw( const Bitmap & who, int x, int y ) { + + /* + x += maxX / 2; + y += maxY / 2; + */ + + ox2 = ox; + oy2 = oy; + ox = angX; + oy = angY; + angX += dX; + angY += dY; + while ( angX >= 360 ) angX -= 360; + while ( angX < 0 ) angX += 360; + while ( angY >= 360 ) angY -= 360; + while ( angY < 0 ) angY += 360; + int zz = (Util::rnd( 2 ) * 2) - 1; + if ( Util::rnd(15) == Util::rnd(15) ) + dwX = (Util::rnd(8)+sd )*zz; + zz = (Util::rnd(2)*2)-1; + if ( Util::rnd(15) == Util::rnd(15) ) + dwY = (Util::rnd(8)+sd )*zz; + if ( dX < dwX ) dX++; + if ( dX > dwX ) dX--; + if ( dY < dwY ) dY++; + if ( dY > dwY ) dY--; + int nx = (int)(x+Tcos(angX)*maxX/2); + int ny = (int)(y+Tsine(angY)*maxY/2); + int lx = (int)(x+Tcos(ox)*maxX/2); + int ly = (int)(y+Tsine(oy)*maxY/2); + // line( who, lx, ly, nx, ny, shade[color] ); + who.line( lx, ly, nx, ny, shade[color] ); + nx = (int)(x+Tcos(ox2)*maxX/2); + ny = (int)(y+Tsine(oy2)*maxY/2); + who.line( lx, ly, nx, ny, shade[color] ); + +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_mini.h +++ rafkill-1.2.2/build/hulls/hull_weapon_mini.h @@ -0,0 +1,25 @@ +#ifndef _hull_weapon_mini_missle_h_ +#define _hull_weapon_mini_missle_h_ + +#include "hull_weapon.h" +#include "bitmap.h" + +/* + * Mini + * + * minimissle that is featured in Raptor(tm) by epic megagames + * + */ + +class Mini_WHull:public HullWeapon{ +public: + + Mini_WHull( ); + virtual void Draw( const Bitmap & who, int x, int y ); + +private: + int lx, ly; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_animation.h +++ rafkill-1.2.2/build/hulls/hull_animation.h @@ -0,0 +1,27 @@ +#ifndef _hull_animation_h +#define _hull_animation_h + +#include "hull.h" +#include "bitmap.h" +#include + +using namespace std; + +class HullAnimation: public HullObject{ +public: + + HullAnimation( const vector< Bitmap > & animations, const vector< Bitmap > & shadows, int _life, int _strength, int num_guns, int level, int _drawing_plane, bool _trans, ECollide * ec ); + + virtual void Draw( const Bitmap & who, int x, int y ); + virtual Bitmap * getShadow(); + //virtual void Shadow( Bitmap * who, int x, int y ); + ~HullAnimation(); + +protected: + vector< Bitmap > pics; + vector< Bitmap > pics_shadow; + unsigned int animation; + bool own_shadow; +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_num_show.h +++ rafkill-1.2.2/build/hulls/hull_num_show.h @@ -0,0 +1,26 @@ +#ifndef _hull_num_show_h +#define _hull_num_show_h + +#include "hull.h" +#include "bitmap.h" + +class HullShow: public HullObject{ +public: + + HullShow( int stupid_crap ); + + virtual void Draw( const Bitmap & who, int x, int y ); + virtual ~HullShow(); + +private: + + static const int MAX_SHADE = 20; + + int spc; + int col; + int shade[ MAX_SHADE ]; + Bitmap * mock; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_spread.h +++ rafkill-1.2.2/build/hulls/hull_weapon_spread.h @@ -0,0 +1,18 @@ +#ifndef _hull_weapon_spread_h +#define _hull_weapon_spread_h + +#include "hull_weapon.h" +#include "bitmap.h" + +class Spread_WHull: public HullWeapon{ +public: + + Spread_WHull( int str ); + virtual void Draw( const Bitmap & who, int x, int y ); + +protected: + int ang; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon.cpp @@ -0,0 +1,22 @@ +#include "spaceobj.h" +#include "defs.h" +#include "hull.h" +#include "hull_weapon.h" +#include "ebox.h" + +HullWeapon::HullWeapon( int drawnum, int life, double str ): +HullObject( NULL, life, str, 0, 0, 9, false, NULL ){} + +/* +bool HullWeapon::Collide( int mx, int my, SpaceObject * check ) { + if ( collide && check->getHull() && check->getHull()->collide ) + return collide->Collision( check->getHull()->collide, mx, my, check->getX(), check->getY() ); + return check->HitMe( mx, my ); +} +*/ + +/* +bool HullWeapon::hullCollide( ECollide * col, int mx, int my, int ax, int ay ){ + return false; +} +*/ --- rafkill-1.2.2.orig/build/hulls/hull_weapon_bomb.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_bomb.cpp @@ -0,0 +1,36 @@ +#include "defs.h" +#include "bitmap.h" +#include "raptor.h" + +#include "hull_weapon.h" +#include "hull_weapon_bomb.h" + +/* This class isnt used as far as I know */ +Bomb_WHull::Bomb_WHull(): +HullWeapon( WEAPON_BOMB_1, 1, 20 ), +frame( 0 ){} + +void Bomb_WHull::Draw( const Bitmap & who, int x, int y ) { + + if ( ++frame > 100 ) frame = 0; + if ( frame % 1 == 0 ) + if ( ++drawNum > WEAPON_BOMB_7 ) drawNum = WEAPON_BOMB_1; + + //int mx = ((BITMAP *)dat[ drawNum ].dat)->w/2; + //int my = ((BITMAP *)dat[ drawNum ].dat)->h/2; + + //draw_sprite( who, (BITMAP *)dat[ drawNum ].dat, x-mx, y-my ); + + //HullObject::Draw( who, dat, x, y ); + + /* TODO: fix, i think o_O + if ( ++frame > WEAPON_BOMB_7 ) frame = WEAPON_BOMB_1; + + drawNum = frame; + int mx = ((BITMAP *)dat[ drawNum ].dat)->w/2; + int my = ((BITMAP *)dat[ drawNum ].dat)->h/2; + draw_sprite( who, (BITMAP *)dat[ drawNum ].dat, x-mx, y-my ); + + */ + +} --- rafkill-1.2.2.orig/build/hulls/hull_ship_destruct.cpp +++ rafkill-1.2.2/build/hulls/hull_ship_destruct.cpp @@ -0,0 +1,14 @@ +#include "defs.h" +#include "spaceobj.h" +#include "trigtable.h" +#include "raptor.h" + +#include "hull.h" +#include "hull_ship_destruct.h" +#include "guns/gun_destruct.h" +#include "ebox.h" + +Destruct::Destruct( int life, int level, ECollide * eb ): +HullObject( NULL, life, SHIP_DAMAGE, 2, level, 10, false, eb ) { + guns[1] = new GunDestruct(1,TEAM_ENEMY); +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_cork.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_cork.cpp @@ -0,0 +1,71 @@ +#include "spaceobj.h" +#include "trigtable.h" +#include "hull_weapon.h" +#include "hull_weapon_cork.h" +#include "rgbhandle.h" +#include + +#include + +static const int MAX_CORKS = 14; + +Cork_WHull::Cork_WHull( int str ): +HullWeapon( 0, 1, str ), +ang( 0 ) { + + for ( int q = 0; q < 2; q++ ) + shade[q] = new int[ MAX_CORKS ]; + for ( int q = 0; q < MAX_CORKS; q++ ) + list.push_back( 0 ); + + int r, g, b; + float h, s, v; + h = Util::rnd( 360 ); + s = 0.9; + v = 1.0; + Bitmap::hsvToRGB( h, s, v, &r, &g, &b ); + + Util::blend_palette( shade[0], MAX_CORKS, Bitmap::makeColor(r,g,b), Bitmap::makeColor(0,0,0) ); + + h = Util::rnd( 360 ); + Bitmap::hsvToRGB( h, s, v, &r, &g, &b ); + Util::blend_palette( shade[1], MAX_CORKS, Bitmap::makeColor(r,g,b), Bitmap::makeColor(0,0,0) ); + +} + +Cork_WHull::~Cork_WHull() { + for ( int q = 0; q < 2; q++ ) + delete[] shade[q]; + list.clear(); +} + +void Cork_WHull::Draw( const Bitmap & who, int x, int y ) { + + ang = ( ang + 17 ) % 360; + + list.pop_back(); + list.push_front( ang ); + int yval = y; + int col = 0; + for ( deque< int >::iterator it = list.begin(); it != list.end(); it++, yval -= 2, col++) { + /* + circlefill( who, (int)(x+rsine[*it]*7), yval, 1, shade[0][col] ); + circlefill( who, (int)(x+rsine[360-*it]*7), yval, 1, shade[1][col] ); + */ + const int size = 4; + int mx = (int)(x + Rsine(*it) * size); + int my = yval; + who.circleFill( mx, my, 1, shade[0][col] ); + x = (int)(x + Rsine(360-*it) * size); + who.circleFill( mx, my, 1, shade[1][col] ); + } + +} + +bool Cork_WHull::Collide( int mx, int my, SpaceObject * check ) { + if ( check->HitMe( mx, my ) ) + return true; + + return false; + +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_rotate.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_rotate.cpp @@ -0,0 +1,20 @@ +#include "hull_weapon.h" +#include "hull_weapon_rotate.h" +#include "ebox.h" +#include "bitmap.h" + +Rotate_WHull::Rotate_WHull( int str, ECollide * ec ): +HullWeapon( 0, 1, str ) { + collide = ec; +} + + +Rotate_WHull::~Rotate_WHull() { + delete collide; +} + + +void Rotate_WHull::Draw( const Bitmap & who, int x, int y ) { + // circlefill( who, x, y, 10, makecol(255,255,255) ); + who.circleFill( x, y, 10, Bitmap::makeColor(255,255,255) ); +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_firetrail.h +++ rafkill-1.2.2/build/hulls/hull_weapon_firetrail.h @@ -0,0 +1,23 @@ +#ifndef _hull_weapon_firetrail_h +#define _hull_weapon_firetrail_h + +#include "hull_weapon.h" +#include "bitmap.h" + +/* + * FireTrail + * + * supposed to be a trail of flames left over from something else + * + */ + +class FireTrail_WHull:public HullWeapon{ +public: + + FireTrail_WHull( int str ); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual bool Collide ( int ax, int ay, SpaceObject * check ); + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_rocket_heavy.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_rocket_heavy.cpp @@ -0,0 +1,26 @@ +#include "spaceobj.h" +#include "hull_weapon.h" +#include "bitmap.h" +#include "hull_weapon_rocket_heavy.h" + +static const int HXFactor = 6; +static const int HYFactor = 30; + +HeavyRocket_WHull::HeavyRocket_WHull(): +HullWeapon( 0, 1, 40 ){} + +void HeavyRocket_WHull::Draw( const Bitmap & who, int x, int y ) { + + who.rectangleFill( x,y+3,x+HXFactor,y+HYFactor, Bitmap::makeColor(120,120,120) ); + who.triangle( x-2,y+3,x+HXFactor/2,y,x+HXFactor+2,y+3, Bitmap::makeColor(190,190,190) ); +} + +bool HeavyRocket_WHull::Collide( int mx, int my, SpaceObject * check ) { + + if ( check->HitMe( mx, my ) ) + return true; + if ( check->HitMe( mx+HXFactor/2, my+HYFactor*2/3 ) ) + return true; + return false; + +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_pulse_large.h +++ rafkill-1.2.2/build/hulls/hull_weapon_pulse_large.h @@ -0,0 +1,25 @@ +#ifndef _hull_weapon_pulse_large_h_ +#define _hull_weapon_pulse_large_h_ + +#include "hull_weapon.h" +#include "bitmap.h" + +class SpaceObject; + +/* + * LargePulse + * + * bullet that has streams of plasma coming off the back + * + */ + +class LargePulse_WHull:public HullWeapon{ +public: + + LargePulse_WHull(); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual bool Collide( int mx, int my, SpaceObject * check ); + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_bomb.h +++ rafkill-1.2.2/build/hulls/hull_weapon_bomb.h @@ -0,0 +1,26 @@ +#ifndef _hull_weapon_bomb_h_ +#define _hull_weapon_bomb_h_ + +#include "hull_weapon.h" +#include "bitmap.h" + + +/* + * Bomb + * + * uses the bomb image sequence in the data file to show a spinning bomb + * does a large amount of damage to all enemys + * + */ + +class Bomb_WHull:public HullWeapon{ +public: + + Bomb_WHull(); + virtual void Draw( const Bitmap & who, int x, int y ); + + int frame; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_laser.h +++ rafkill-1.2.2/build/hulls/hull_weapon_laser.h @@ -0,0 +1,31 @@ +#ifndef _hull_weapon_laser_h +#define _hull_weapon_laser_h + +#include "hull_weapon.h" + +/* + * Laser + * + * A laser beam like you see in other cool games. + * + */ + +class SpaceObject; +class Laser_WHull:public HullWeapon{ +public: + Laser_WHull( int str ); + // virtual bool Collide( int mx, int my, SpaceObject * check ); + // virtual void Draw( Bitmap * who, int x, int y ); + virtual void Collided(); + + + virtual ~Laser_WHull(); + +protected: + + void drawSelf(); + + int * shade; +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_yehat.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_yehat.cpp @@ -0,0 +1,31 @@ +#include "hull_weapon.h" +#include "bitmap.h" +#include "hull_weapon_yehat.h" +#include "ebox.h" + +Yehat_WHull::Yehat_WHull( int str ): +HullWeapon( 0, 1, str ) { + strength = str; + + collide = new ECollide( 2, 2 ); + /* + collide = new ECollide(); + collide->setXS( 1 ); + collide->setYS( 1 ); + collide->my_size = 2; + EBox * arch = new EBox( 0, 0, 2, 2 ); + collide->add( arch ); + collide->finalize(); + */ +} + + +void Yehat_WHull::Draw( const Bitmap & who, int x, int y ) { + + int str = (int)strength; + + int col = 150+str<255?150+str:255; + col = str*5<255?str*5:255; + // circlefill( who, x, y, 2, makecol(250,col,str%255) ); + who.circleFill( x, y, 2, Bitmap::makeColor(250,col,str%255) ); +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_explode.h +++ rafkill-1.2.2/build/hulls/hull_weapon_explode.h @@ -0,0 +1,29 @@ +#ifndef _hull_weapon_explode_h +#define _hull_weapon_explode_h + +#include "hull.h" +#include "bitmap.h" + +class ECollide; +class Section; + +class Explode_WHull:public HullObject{ +public: + + Explode_WHull( int str, ECollide ** _collide_list, int _max_list ); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual void Moved( double _dx, double _dy, double _ax, double _ay ); + //virtual void addSection( SpaceObject * who, Section * onscreen, int x, int y ); + + virtual ~Explode_WHull(); + +protected: + + int size; + int use; + ECollide ** collide_list; + int max_list; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_tractor_beam.h +++ rafkill-1.2.2/build/hulls/hull_weapon_tractor_beam.h @@ -0,0 +1,21 @@ +#ifndef _hull_weapon_tractor_beam_h +#define _hull_weapon_tractor_beam_h + +#include "hull_weapon.h" +#include "bitmap.h" + +class ECollide; + +class Tractor_WHull: public HullWeapon{ +public: + + Tractor_WHull( int str, int _color, ECollide * ec ); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual ~Tractor_WHull(); + +protected: + int color; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_rocket_heavy.h +++ rafkill-1.2.2/build/hulls/hull_weapon_rocket_heavy.h @@ -0,0 +1,25 @@ +#ifndef _hull_weapon_rocket_heavy_h_ +#define _hull_weapon_rocket_heavy_h_ + +#include "hull_weapon.h" +#include "bitmap.h" + +class SpaceObject; + +/* + * HeavyRocket + * + * giant rocket that should cuase significant damage to all who get in its path + * + */ + +class HeavyRocket_WHull:public HullWeapon{ +public: + + HeavyRocket_WHull(); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual bool Collide( int mx, int my, SpaceObject * check ); + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon.h +++ rafkill-1.2.2/build/hulls/hull_weapon.h @@ -0,0 +1,17 @@ +#ifndef _hull_general_weapon_h +#define _hull_general_weapon_h + +#include "hull.h" + +class SpaceObject; + +class HullWeapon: public HullObject{ +public: + + HullWeapon( int drawing, int life, double str ); + // virtual bool Collide ( int mx, int my, SpaceObject * check ); + // virtual bool hullCollide( ECollide * col, int mx, int my, int ax, int ay ); + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_emissle.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_emissle.cpp @@ -0,0 +1,33 @@ +#include "spaceobj.h" +#include "defs.h" +#include "bitmap.h" +#include "hull_weapon.h" +#include "hull_weapon_emissle.h" + +static const int normal_length = 20; + +EMissle_WHull::EMissle_WHull(): +HullWeapon( 0, 1, 7 ){} + +// #define normal_length 20 +void EMissle_WHull::Draw( const Bitmap & who, int x, int y ) { + /* + rectfill( who, x-2, y, x+2, y-normal_length, makecol(200,200,200) ); + circlefill( who, x, y, 3, makecol(235,235,235) ); + */ + who.rectangleFill( x-2, y, x+2, y-normal_length, Bitmap::makeColor(200,200,200) ); + who.circleFill( x, y, 3, Bitmap::makeColor(235,235,235) ); +} + + +bool EMissle_WHull::Collide( int mx, int my, SpaceObject * check ) { + + if ( check->HitMe( mx, my ) ) + return true; + if ( check->HitMe( mx, my-normal_length/2 ) ) + return true; + if ( check->HitMe( mx, my-normal_length ) ) + return true; + return false; + +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_twirl.h +++ rafkill-1.2.2/build/hulls/hull_weapon_twirl.h @@ -0,0 +1,22 @@ +#ifndef _hull_weapon_twirl_h_ +#define _hull_weapon_twirl_h_ + +#include "hull_weapon.h" +#include "bitmap.h" + +class ECollide; + +class Twirl_WHull:public HullWeapon{ +public: + Twirl_WHull( const Bitmap & who, ECollide * ec ); + virtual void Draw( const Bitmap & who, int x, int y ); + + virtual ~Twirl_WHull(); + +protected: + int ang; + Bitmap bitmap; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_spread.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_spread.cpp @@ -0,0 +1,28 @@ +#include "hull_weapon.h" +#include "bitmap.h" +#include "hull_weapon_spread.h" +#include "trigtable.h" + +Spread_WHull::Spread_WHull( int str ): +HullWeapon( 0, 1, str ) { + ang = 0; +} + + +void Spread_WHull::Draw( const Bitmap & who, int x, int y ) { + + ang = (ang+5)%360; + // circlefill( who, x, y, 5, makecol(235,20,0) ); + who.circleFill( x, y, 5, Bitmap::makeColor(235,20,0) ); + for ( int q = 0; q < 360; q += 120 ) { + + for ( int z = 0; z < 5; z++ ) { + int cx = (int)(x + Tcos((ang+q+z*3)%360)*z); + int cy = (int)(y + Tsine((ang+q+z*3)%360)*z); + // putpixel( who, cx, cy, makecol(0,20,235) ); + who.putPixel( cx, cy, Bitmap::makeColor(0,20,235) ); + } + + } + +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_shatter.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_shatter.cpp @@ -0,0 +1,32 @@ +#include "spaceobj.h" +#include "bitmap.h" +#include "trigtable.h" +#include "hull_weapon.h" +#include "hull_weapon_shatter.h" + +Shatter_WHull::Shatter_WHull( int str ): +HullWeapon( 0, 1, str ){} + +void Shatter_WHull::Draw( const Bitmap & who, int x, int y ) { + + who.circleFill( x, y, (int)strength, Bitmap::makeColor(255,20,30) ); + +} + + +bool Shatter_WHull::Collide( int mx, int my, SpaceObject * check ) { + if ( check->HitMe( mx, my ) ) + return true; + + for ( int ang = 0; ang < 360; ang += 65 ) { + + int tx = (int)(mx + Tcos(ang)*strength ); + int ty = (int)(my + Tsine(ang)*strength ); + if ( check->HitMe( tx, ty ) ) + return true; + + } + + return false; + +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_twirl.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_twirl.cpp @@ -0,0 +1,28 @@ +#include "hull_weapon.h" +#include "bitmap.h" +#include "hull_weapon_twirl.h" +#include "ebox.h" + +Twirl_WHull::Twirl_WHull( const Bitmap & who, ECollide * ec ): +HullWeapon( 0, 1, 3 ) { + collide = ec; + ang = 0; + // *Bitmap = who; + bitmap = who; + myBitmap = &bitmap; +} + +Twirl_WHull::~Twirl_WHull() { + delete collide; + myBitmap = NULL; +} + +void Twirl_WHull::Draw( const Bitmap & who, int x, int y ) { + + int mx = myBitmap->getWidth()/2; + int my = myBitmap->getHeight()/2; + + bitmap.drawRotate( x-mx, y-my, ang, who ); + ang = ( ang + 8 ) % 360; + +} --- rafkill-1.2.2.orig/build/hulls/hull_animation.cpp +++ rafkill-1.2.2/build/hulls/hull_animation.cpp @@ -0,0 +1,49 @@ +#include "hull.h" +#include "hull_animation.h" +#include "defs.h" +#include "bitmap.h" +#include + +HullAnimation::HullAnimation( const vector< Bitmap > & animations, const vector< Bitmap > & shadows, int _life, int _strength, int num_guns, int level, int _drawing_plane, bool _trans, ECollide * ec ): +HullObject( NULL, _life, _strength, num_guns, level, _drawing_plane, _trans, ec ) { + + pics = animations; + pics_shadow = shadows; + animation = 0; + + if ( pics_shadow.empty() ){ + for ( unsigned int q = 0; q < pics.size(); q++ ){ + pics_shadow.push_back( Bitmap( pics[ q ], true ) ); + int m = 22; + pics_shadow[ q ].fill( Bitmap::makeColor( m, m, m ) ); + pics[ q ].drawMask( 0, 0, pics_shadow[ q ] ); + } + } +} + +Bitmap * HullAnimation::getShadow(){ + return &(pics_shadow[ animation ]); +} + +void HullAnimation::Draw( const Bitmap & who, int x, int y ) { + + const Bitmap & bitmap = pics[ animation ]; + myBitmap = (Bitmap *)&bitmap; + HullObject::Draw( who, x, y ); + + if ( ++animation >= pics.size() ) animation = 0; +} + + +/* +void HullAnimation::Shadow( Bitmap * who, int x, int y ) { + Bitmap = pics[ animation ]; + HullObject::Shadow( who, x, y ); +} +*/ + + +HullAnimation::~HullAnimation() { + Shadow_Bitmap = NULL; + myBitmap = NULL; +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_saber.h +++ rafkill-1.2.2/build/hulls/hull_weapon_saber.h @@ -0,0 +1,23 @@ +#ifndef _hull_weapon_saber_h +#define _hull_weapon_saber_h + +#include "hull_weapon.h" +#include "bitmap.h" + +class Saber_WHull:public HullWeapon{ +public: + + Saber_WHull( int str, int xf, int yf ); + virtual void Draw( const Bitmap & who, int x, int y ); + + virtual ~Saber_WHull(); + +protected: + + int count_down; + int x_size, y_size; + int * shade; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_rocket_normal.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_rocket_normal.cpp @@ -0,0 +1,23 @@ +#include "spaceobj.h" +#include "bitmap.h" +#include "hull_weapon.h" +#include "hull_weapon_rocket_normal.h" + +static const int Xfactor = 4; +static const int Yfactor = 20; + +NormalRocket_WHull::NormalRocket_WHull(): +HullWeapon( 0, 1, 20 ){} + +void NormalRocket_WHull::Draw( const Bitmap & who, int x, int y ) { + who.rectangleFill( x, y+3, x+Xfactor, y+Yfactor, Bitmap::makeColor(200,200,200) ); + who.triangle( x, y+3, x+Xfactor/2, y, x+Xfactor, y+3, Bitmap::makeColor(230,230,230) ); +} + +bool NormalRocket_WHull::Collide( int mx, int my, SpaceObject * check ) { + if ( check->HitMe( mx, my ) ) + return true; + if ( check->HitMe( mx+Xfactor/2, my+Yfactor*2/3 ) ) + return true; + return false; +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_arc.h +++ rafkill-1.2.2/build/hulls/hull_weapon_arc.h @@ -0,0 +1,32 @@ +#ifndef _hull_weapon_arc_h_ +#define _hull_weapon_arc_h_ + +#include "hull_weapon.h" +#include "hull.h" +#include "bitmap.h" + +class SpaceObject; +class ECollide; + +/* + * Arc + * + * a small point which has fancy colors on its tail + * + */ + +class Arc_WHull:public HullWeapon{ +public: + Arc_WHull( int str, ECollide * mycollide ); + virtual void Draw( const Bitmap & who, int x, int y ); + + virtual ~Arc_WHull(); + +private: + + int * shade; + Bitmap * look; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_s_s.h +++ rafkill-1.2.2/build/hulls/hull_weapon_s_s.h @@ -0,0 +1,13 @@ +#ifndef _hull_weapon_straight_small_h_ +#define _hull_weapon_straight_small_h_ + +#include "hull_weapon.h" +#include "bitmap.h" + +class SS_WHull:public HullWeapon{ +public: + SS_WHull(); + virtual void Draw( const Bitmap & who, int x, int y ); +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_s_l.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_s_l.cpp @@ -0,0 +1,65 @@ +#include "spaceobj.h" +#include "bitmap.h" +#include "trigtable.h" +#include "hull_weapon.h" +#include "hull_weapon_s_l.h" + +SL_WHull::SL_WHull(): +HullWeapon( 0, 1, 3 ), +r1( 0 ), +r2( 3 ){} + +void SL_WHull::Draw( const Bitmap & who, int x, int y ) { + + int col1 = Bitmap::makeColor( 255, 0, 0 ); + int col2 = Bitmap::makeColor( 255, 250, 250 ); + + if ( r1 > r2 ) { + /* + circlefill( who, x, y, r1, col1 ); + circlefill( who, x, y, r2, col2 ); + */ + who.circleFill( x, y, r1, col1 ); + who.circleFill( x, y, r2, col2 ); + } + else { + /* + circlefill( who, x, y, r2, col2 ); + circlefill( who, x, y, r1, col1 ); + */ + who.circleFill( x, y, r2, col2 ); + who.circleFill( x, y, r1, col1 ); + } + + r2++; + r1++; + if ( r2 > 5 ){ + r2 = 1; + } + if ( r1 > 5 ){ + r1 = 1; + } +} + + +bool SL_WHull::Collide( int mx, int my, SpaceObject * check ) { + // return false; + + if ( check->HitMe( mx, my ) ){ + return true; + } + + const int LARGE = 5; + + for ( int sang = 0; sang < 360; sang += 45 ) { + + int ax = (int)(mx + Tcos(sang)*LARGE ); + int ay = (int)(my + Tsine(sang)*LARGE ); + if ( check->HitMe( ax, ay ) ) + return true; + + } + + return false; + +} --- rafkill-1.2.2.orig/build/hulls/hull_num_show.cpp +++ rafkill-1.2.2/build/hulls/hull_num_show.cpp @@ -0,0 +1,51 @@ +#include "strings.h" +#include "defs.h" +#include "bitmap.h" +#include "hull.h" +#include "hull_num_show.h" + +HullShow::HullShow( int sp ): +HullObject( NULL, 19, 0, 0, 0, MAX_PLANE, true, NULL ), +spc( sp ), +col( 0 ) { + + // shade = new int[ 20 ]; + if ( spc > 800 ) { + + Util::blend_palette( shade, 5, Bitmap::makeColor( 242,2,2 ), Bitmap::makeColor(49,244,19) ); + Util::blend_palette( shade+4, 5, Bitmap::makeColor(49,244,19), Bitmap::makeColor(234,242,4) ); + Util::blend_palette( shade+4+4,5, Bitmap::makeColor(234,242,4), Bitmap::makeColor(255,139,7) ); + Util::blend_palette( shade+4+4+4, 8, Bitmap::makeColor(255,139,7),Bitmap::makeColor(242,2,2) ); + + } else { + Util::blend_palette( shade, 20, Bitmap::makeColor(255,255,255), Bitmap::makeColor(30,30,30) ); + } + + char fx[ 128 ]; + sprintf( fx, "%d", spc ); + Font font = Util::getNormalFont(); + mock = new Bitmap( font.textLength( fx ), font.getHeight() + 1 ); + mock->fill( Bitmap::makeColor(255,0,255) ); +} + +void HullShow::Draw( const Bitmap & who, int x, int y ) { + + char fx[ 128 ]; + sprintf( fx, "%d", spc ); + + Font font = Util::getNormalFont(); + + int len = font.textLength( fx ); + + mock->printf( 0, 0, shade[col], &font, "%d", spc ); + mock->drawStretched( x, y - col, len + col, font.getHeight() + col + 1, who ); + + takeDamage( 1 ); + + col++; + if ( col >= MAX_SHADE ) col = MAX_SHADE - 1; +} + +HullShow::~HullShow() { + delete mock; +} --- rafkill-1.2.2.orig/build/hulls/hull_rotate.h +++ rafkill-1.2.2/build/hulls/hull_rotate.h @@ -0,0 +1,31 @@ +#ifndef _hull_rotate_h +#define _hull_rotate_h + +#include "hull.h" +#include "bitmap.h" + +class RotateHull:public HullObject{ +public: + RotateHull( int _color, int mX, int mY, int sf, int * _shade ); + + virtual void Draw( const Bitmap & who, int x, int y ); + +protected: + + int angX; + int angY; + int dX; + int dY; + int dwX; + int dwY; + + int sd; + + int ox, oy; + int ox2, oy2; + + int maxX, maxY; + int * shade; +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_beam.h +++ rafkill-1.2.2/build/hulls/hull_weapon_beam.h @@ -0,0 +1,31 @@ +#ifndef _hull_weapon_beam_h +#define _hull_weapon_beam_h + +#include "bitmap.h" +#include "hull_weapon.h" + +/* + * Beam + * + * just another simple hull that looks like a line + * + */ + +class Beam_WHull:public HullWeapon{ +public: + + Beam_WHull( double str, int xf, int yf, int ang ); + virtual void Draw( const Bitmap & who, int x, int y ); + + virtual ~Beam_WHull(); + +protected: + + int count_down; + int x_size, y_size; + int shade[6]; + int angle; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_ship_shield.cpp +++ rafkill-1.2.2/build/hulls/hull_ship_shield.cpp @@ -0,0 +1,42 @@ +#include "defs.h" +#include "trigtable.h" +#include "raptor.h" +#include "bitmap.h" +#include "hull.h" +#include "hull_ship_shield.h" +#include "hull_protect.h" +#include "ebox.h" + +#define shield_size 8 +ShieldHull::ShieldHull( Bitmap * me, double life, int level, ECollide * eb ): +HullObject( me, life, SHIP_DAMAGE, 1, level, 10, false, eb ) { + for ( int q = 0; q < shield_max; q++ ) + pr[ q ] = new ProtectHull( 1, level ); +} + + +void ShieldHull::Draw( const Bitmap & work, int x, int y ) { + + HullObject::Draw( work, x, y ); + + //circlefill( work, x, y, shield_size, color ); + for ( int q = 0; q < shield_max; q++ ) + pr[q]->Draw( work, x, y ); +} + + +double ShieldHull::Damage( double much ) { + + double total = much; + for ( int q = 0; q < shield_max; q++ ) + if ( pr[q]->haveBeenHit() ) + total = 0; + return total; + +} + + +ShieldHull::~ShieldHull() { + for ( int q = 0; q < shield_max; q++ ) + delete pr[q]; +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_machine.h +++ rafkill-1.2.2/build/hulls/hull_weapon_machine.h @@ -0,0 +1,24 @@ +#ifndef _hull_weapon_machine_h +#define _hull_weapon_machine_h + +#include "hull_weapon.h" +#include "bitmap.h" + +/* + * Machine + * + * classic machine gun bullet that is featured in Raptor(tm) by epic megagames. + * + */ + +class Machine_WHull: public HullWeapon{ +public: + + Machine_WHull( int str ); + virtual void Draw( const Bitmap & who, int x, int y ); + + virtual ~Machine_WHull(); + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_firetrail.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_firetrail.cpp @@ -0,0 +1,62 @@ +#include "spaceobj.h" +#include "bitmap.h" +#include "hull_weapon.h" +#include "hull_weapon_firetrail.h" +#include "trigtable.h" + +#define MAX_TRAIL_LIFE 13 + +FireTrail_WHull::FireTrail_WHull( int str ): +HullWeapon( 0, 1, str ) { + + life = 1*MAX_TRAIL_LIFE; + +} + + +void FireTrail_WHull::Draw( const Bitmap & who, int x, int y ) { + + /* + for ( int q = 0; q < life; q++ ){ + + for ( int z = 0; z < 10; z++ ){ + + int ang = rnd( 360 ); + int d = rnd(4); + int mx = (int)(x+tcos[ang]*d); + int my = (int)(y+tsine[ang]*d); + + int col = getpixel(who,mx,my); + int r = getr(col)+40; + if ( r > 255 ) r = 255; + col = makecol( r, getg(col), getb(col) ); + putpixel(who,mx,my,col); + + } + + } + */ + double col = (double)life/(double)(1*MAX_TRAIL_LIFE)*255.0; + // circlefill( who, x, y, 4, makecol((int)col,0,0) ); + who.circleFill( x, y, 4, Bitmap::makeColor((int)col, 0, 0 ) ); + +} + + +bool FireTrail_WHull::Collide( int mx, int my, SpaceObject * check ) { + if ( check->HitMe( mx, my ) ) + return true; + return false; + + for ( int ang = 0; ang < 360; ang += 35 ) { + + int tx = (int)(mx + Tcos(ang)*4 ); + int ty = (int)(my + Tsine(ang)*4 ); + if ( check->HitMe( tx, ty ) ) + return true; + + } + + return false; + +} --- rafkill-1.2.2.orig/build/hulls/hull_meteor.cpp +++ rafkill-1.2.2/build/hulls/hull_meteor.cpp @@ -0,0 +1,46 @@ +#include "defs.h" +#include "bitmap.h" +#include "raptor.h" +#include "trigtable.h" + +#include "spaceobj.h" +#include "hull.h" +#include "hull_meteor.h" +#include "ebox.h" + +MeteorHull::MeteorHull( int level, int lf, ECollide * eb ): +HullObject( NULL, lf, 20, 0, level, 10, false, eb ), +frame( 0 ){} + +bool MeteorHull::Collide( int ax, int ay, SpaceObject * check ) { + + return HullObject::Collide( ax, ay, check ); + + for ( int zx = ax - 25; zx <= ax + 25; zx += 5 ) + for ( int zy = ay - 25; zy <= ay + 25; zy += 5 ) + if ( Inside( ax, ay, zx, zy ) ) + if ( check->HitMe( zx, zy ) ) + return true; + return false; +} + + +bool MeteorHull::Inside( int mx, int my, int ax, int ay ) { + + return HullObject::Inside( mx, my, ax, ay ); + + if ( prect( ax, ay, mx-16, my-19, mx+16, my+19 ) ) return true; + + return false; +} + + +void MeteorHull::Draw( const Bitmap & who, int x, int y ) { + + if ( ++frame > 100 ) frame = 0; + if ( frame % 2 == 0 ) + if ( ++drawNum > METEOR_9_20 ) drawNum = METEOR_1; + + HullObject::Draw( who, x, y ); + +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_angle.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_angle.cpp @@ -0,0 +1,21 @@ +#include "hull_weapon.h" +#include "hull_weapon_angle.h" +#include "ebox.h" +#include "bitmap.h" + +Angle_WHull::Angle_WHull( int str, int _color, ECollide * ec ): +HullWeapon( 0, 1, str ), +color( _color ) { + collide = ec; +} + + +Angle_WHull::~Angle_WHull() { + delete collide; +} + + +void Angle_WHull::Draw( const Bitmap & who, int x, int y ) { + // circlefill( who, x, y, 2, color ); + who.circleFill( x, y, 2, color ); +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_angle.h +++ rafkill-1.2.2/build/hulls/hull_weapon_angle.h @@ -0,0 +1,21 @@ +#ifndef _hull_weapon_angle_h +#define _hull_weapon_angle_h + +#include "hull_weapon.h" +#include "bitmap.h" + +class ECollide; + +class Angle_WHull: public HullWeapon{ +public: + + Angle_WHull( int str, int _color, ECollide * ec ); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual ~Angle_WHull(); + +protected: + int color; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_tractor_beam.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_tractor_beam.cpp @@ -0,0 +1,21 @@ +#include "hull_weapon.h" +#include "hull_weapon_tractor_beam.h" +#include "ebox.h" +#include "bitmap.h" + +Tractor_WHull::Tractor_WHull( int str, int _color, ECollide * ec ): +HullWeapon( 0, 1, str ), +color( _color ) { + collide = ec; +} + + +Tractor_WHull::~Tractor_WHull() { + delete collide; +} + + +void Tractor_WHull::Draw( const Bitmap & who, int x, int y ) { + // circlefill( who, x, y, 3, color ); + who.circleFill( x, y, 3, color ); +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_beam.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_beam.cpp @@ -0,0 +1,88 @@ +#include "defs.h" +#include "bitmap.h" +#include "hull_weapon.h" +#include "hull_weapon_beam.h" +#include "trigtable.h" +#include "ebox.h" + +#ifndef debug +#include +#define debug std::cout<<"File: "<<__FILE__<<" Line: "<<__LINE__<= 3 ) { + + int color = 1; + int dir = 1; + for ( int q = y-my; q < y+my; q++ ) { + + int sang = (angle+q*4+360)%360; + if ( abs(q) % 10 == 0 ) { + color += dir; + if ( color == 5 ) dir = -1; + if ( color == 0 ) dir = 1; + } + if ( color < 0 ) color = 0; + if ( color > 5 ) color = 5; + if ( sang >= 90 && sang <= 270 ){ + if ( x_size/2 > 3 ){ + who.circleFill( (int)(x - Tsine(sang)*x_size/2), q, 1, shade[color] ); + } + } + + } + + } + + who.drawingMode( Bitmap::MODE_SOLID ); + + // collide->draw( who, x-x_size/2, y-y_size/2 ); +} + + +Beam_WHull::~Beam_WHull() { + delete collide; + // delete[] shade; +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_s_l.h +++ rafkill-1.2.2/build/hulls/hull_weapon_s_l.h @@ -0,0 +1,18 @@ +#ifndef _hull_weapon_straight_large_h_ +#define _hull_weapon_straight_large_h_ + +#include "hull_weapon.h" +#include "bitmap.h" +class SpaceObject; + +class SL_WHull:public HullWeapon{ +public: + SL_WHull(); + + virtual void Draw( const Bitmap & who, int x, int y ); + virtual bool Collide( int mx, int my, SpaceObject * check ); + + int r1, r2; +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_light.h +++ rafkill-1.2.2/build/hulls/hull_weapon_light.h @@ -0,0 +1,14 @@ +#ifndef _hull_weapon_light_h_ +#define _hull_weapon_light_h_ + +#include "hull_weapon.h" +#include "bitmap.h" + +class Light_WHull:public HullWeapon{ +public: + Light_WHull(); + virtual void Draw( const Bitmap & who, int x, int y ); + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_machine.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_machine.cpp @@ -0,0 +1,42 @@ +#include "hull_weapon.h" +#include "hull_weapon_machine.h" +#include "ebox.h" +#include "bitmap.h" + +Machine_WHull::Machine_WHull( int str ): +HullWeapon( 0, 1, str ) { + color = Bitmap::makeColor( 180, 20, 74 ); + switch ( str ) { + case 1 : color = Bitmap::makeColor(200,200,200); break; + case 2 : color = Bitmap::makeColor(40,210,95); break; + case 3 : color = Bitmap::makeColor(216,133,242); break; + default : { + int r = (int)(strength*10+strength)%255; + int g = (int)(strength*2+150)%255; + int b = (int)(strength * 14 + 100 ) % 255; + color = Bitmap::makeColor(r,g,b); + } + } + + collide = new ECollide( 1, 1 ); + /* + collide = new ECollide(); + collide->setXS( 0 ); + collide->setYS( 0 ); + collide->my_size = 1; + EBox * arch = new EBox( 0, 0, 1, 1 ); + collide->add( arch ); + collide->finalize(); + */ + +} + + +void Machine_WHull::Draw( const Bitmap & who, int x, int y ) { + // circlefill( who, x, y, 1, color ); + who.circleFill( x, y, 1, color ); +} + +Machine_WHull::~Machine_WHull(){ + delete collide; +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_fire.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_fire.cpp @@ -0,0 +1,36 @@ +#include "bitmap.h" +#include "trigtable.h" +#include "spaceobj.h" +#include "hull_weapon.h" +#include "hull_weapon_fire.h" + +Fire_WHull::Fire_WHull(): +HullWeapon( 0, 1, 9 ){} + +void Fire_WHull::Draw( const Bitmap & who, int x, int y ) { + int zx = x; + int zy = y-12; + for ( int q = 0; q < 6; q++ ) { + int sz = (q+3) / 2; + int col = (int)( (double)q / 6.0 * (double)(MAX_E_COLOR-20) + 19 ); + // circlefill( who, zx, zy, sz, e_color[col] ); + who.circleFill( zx, zy, sz, Util::e_color[col] ); + zy += 2; + } +} + + +bool Fire_WHull::Collide( int mx, int my, SpaceObject * check ) { + if ( check->HitMe( mx, my ) ) + return true; + + for ( int sang = 0; sang < 360; sang += 45 ) { + + int ax = (int)(mx + Tcos(sang)*4 ); + int ay = (int)(my + Tsine(sang)*4 ); + if ( check->HitMe( ax, ay ) ) + return true; + + } + return false; +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_follow.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_follow.cpp @@ -0,0 +1,37 @@ +#include "trigtable.h" +#include "bitmap.h" +#include "hull_weapon.h" +#include "hull_weapon_follow.h" + +Follow_WHull::Follow_WHull( int _life ): +HullWeapon( 0, _life, 2 ){} + +void Follow_WHull::Draw( const Bitmap & who, int x, int y ) { + + for ( int q = 0; q < 12; q++ ) { + double sx, sy; + sx = x; + sy = y; + double ox = sx; + double oy = sy; + int mang = Util::rnd( 360 ); + for ( int z = 0; z < 7; z++ ) { + + sx += Tcos(mang)*2; + sy += Tsine(mang)*2; + mang += (Util::rnd( 17 ) - 8) * 4; + mang += 360; + mang %= 360; + + int gf = 150 + z * 5; + // line( who, (int)sx, (int)sy, (int)ox, (int)oy, makecol(gf,gf,gf) ); + who.line( (int)sx, (int)sy, (int)ox, (int)oy, Bitmap::makeColor(gf,gf,gf) ); + ox = sx; + oy = sy; + + } + } + // circlefill( who, x, y, 3, makecol(255,255,255) ); + who.circleFill( x, y, 3, Bitmap::makeColor(255,255,255) ); + +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_pulse_small.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_pulse_small.cpp @@ -0,0 +1,11 @@ +#include "hull_weapon.h" +#include "bitmap.h" +#include "hull_weapon_pulse_small.h" + +SmallPulse_WHull::SmallPulse_WHull(): +HullWeapon( 0, 1, 1 ){} + +void SmallPulse_WHull::Draw( const Bitmap & who, int x, int y ) { + who.circleFill( x, y, 2, Bitmap::makeColor(0,200,250) ); + who.triangle( x-2, y+2, x+2, y+2, x, y+7, Bitmap::makeColor(90,245,140) ); +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_yehat.h +++ rafkill-1.2.2/build/hulls/hull_weapon_yehat.h @@ -0,0 +1,15 @@ +#ifndef _hull_weapon_yellow_h +#define _hull_weapon_yellow_h + +#include "hull_weapon.h" +#include "bitmap.h" + +class Yehat_WHull: public HullWeapon{ +public: + + Yehat_WHull( int str ); + virtual void Draw( const Bitmap & who, int x, int y ); + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_light.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_light.cpp @@ -0,0 +1,12 @@ +#include "defs.h" +#include "bitmap.h" +#include "hull_weapon.h" +#include "hull_weapon_light.h" + +Light_WHull::Light_WHull(): +HullWeapon( 0, 1, 1 ){} + +void Light_WHull::Draw( const Bitmap & who, int x, int y ) { + // circlefill( who, x, y, 2, makecol(0,100,250) ); + who.circleFill( x, y, 2, Bitmap::makeColor(0,100,250) ); +} --- rafkill-1.2.2.orig/build/hulls/hull_player.cpp +++ rafkill-1.2.2/build/hulls/hull_player.cpp @@ -0,0 +1,424 @@ +#include "defs.h" +#include "hull_player.h" +#include "hull_rotate.h" +#include "ebox.h" +#include "section.h" +#include "bitmap.h" +#include "gunobj.h" +#include +#include +#include + +#ifndef debug +#define debug cout << "File: " << __FILE__ << " Line: " << __LINE__ << endl +#endif + +using namespace std; + +// #define MAX_INTERNAL_DAMAGE 30 + +PlayerHull::PlayerHull( const vector< Bitmap * > & _pics, int _maxlife, int _maxshield, int _number_of_guns, int _hull_number, ECollide * eb ): +HullObject( NULL, _maxlife, SHIP_DAMAGE, _number_of_guns, 1, 10, false, eb ), +shield( 0 ), +cloak( 0 ), +MAX_SHIELD( _maxshield ), +MAX_LIFE( _maxlife ), +hull_num( _hull_number ), +internal_damage( 0 ), +current_accessory( 0 ), +animation_pic( pics.size()/2 ){ + pics = _pics; + max_pics = pics.size(); + + // pics_shadow = new Bitmap*[ max_pics ]; + for ( vector< Bitmap * >::iterator it = pics.begin(); it != pics.end(); it++ ){ + Bitmap * o = *it; + Bitmap * s = new Bitmap( o->getWidth(), o->getHeight() ); + s->fill( Bitmap::makeColor(22,22,22) ); + o->drawMask( 0, 0, *s ); + pics_shadow.push_back( s ); + } + + myBitmap = NULL; + + if ( ! pics.empty() ){ + myBitmap = pics[ max_pics / 2 ]; + } + + for ( int q = 0; q < MAX_ROTATE; q++ ) { + rotate[q] = NULL; + rotate_damage[q] = NULL; + } + + // shade_damage = new int[ MAX_INTERNAL_DAMAGE ]; + Util::blend_palette( shade_damage, MAX_INTERNAL_DAMAGE*3/5, Bitmap::makeColor(5,5,20), Bitmap::makeColor(60,60,250) ); + Util::blend_palette( shade_damage+MAX_INTERNAL_DAMAGE*3/5, MAX_INTERNAL_DAMAGE-MAX_INTERNAL_DAMAGE*3/5, Bitmap::makeColor(60,60,250), Bitmap::makeColor(255,255,255) ); + + for ( int q = 0; q < MAX_ACCESSORY; q++ ) + accessory[q] = NULL; + + true_guns = new WeaponObject*[ _number_of_guns + 1 ]; +} + + +PlayerHull::~PlayerHull() { + + + for ( int q = 0; q < MAX_ROTATE; q++ ) { + + if ( rotate[q] != NULL ){ + delete rotate[q]; + } + + if ( rotate_damage[q] != NULL ){ + delete rotate_damage[q]; + } + } + + for ( int q = 0; q < MAX_ACCESSORY; q++ ){ + if ( accessory[q] != NULL ){ + delete accessory[q]; + } + } + + for ( vector< Bitmap * >::iterator it = pics.begin(); it != pics.end(); it++ ){ + delete *it; + } + + for ( vector< Bitmap * >::iterator it = pics_shadow.begin(); it != pics_shadow.end(); it++ ){ + delete *it; + } + + if ( collide ){ + delete collide; + } + + // delete[] shade_damage; + delete[] true_guns; + + // delete[] pics; + // delete pics; + /* + Util::debug; + */ + + /* dont let ~Hull() delete these special member variables */ + Shadow_Bitmap = NULL; + myBitmap = NULL; +} + + +HullObject * PlayerHull::copy() { + + /* + Bitmap ** s_pics = new Bitmap*[ max_pics ]; + for ( int q = 0; q < max_pics; q++ ) + s_pics[q] = pics[q]; + */ + + vector< Bitmap * > newPics; + for ( vector< Bitmap * >::iterator it = pics.begin(); it != pics.end(); it++ ){ + Bitmap * bitmap = *it; + newPics.push_back( new Bitmap( *bitmap, false ) ); + } + + HullObject * who = new PlayerHull( newPics, MAX_LIFE, MAX_SHIELD, this->maxGuns()-1, hull_num, collide->copy() ); + PlayerHull * playerHull = (PlayerHull *) who; + + playerHull->life = getLife(); + playerHull->shield = getShield(); + + for ( int q = 0; q < this->maxGuns()-1; q++ ){ + if ( this->Guns()[q] != NULL ){ + playerHull->giveWeapon( this->Guns()[q]->copy(), q ); + } + } + + // who->Guns()[q] = this->Guns()[q]->copy(); + // else who->Guns()[q] = NULL; + + for ( int q = 0; q < MAX_ACCESSORY; q++ ){ + if ( this->accessory[q] != NULL ){ + playerHull->accessory[q] = this->accessory[q]->copy(); + } + } + // else ((PlayerHull *)who)->accessory[q] = NULL; + + return who; +} + +const int PlayerHull::getShield() const{ + return (int)shield; +} + +void PlayerHull::setShields( int s ){ + shield = s; + if ( shield < 0 ) shield = 0; + if ( shield > getMaxShield() ) shield = getMaxShield(); +} + +void PlayerHull::incShield( int q ){ + shield += q; + if ( shield > getMaxShield() ) shield = getMaxShield(); +} + +void PlayerHull::Moved( double _dx, double _dy, double _ax, double _ay ) { + if ( cloak > 0 ) cloak--; + + /* + if ( _dx < 0 && animation_pic > 0 ) + animation_pic--; + if ( _dx > 0 && animation_pic < max_pics-1 ) + animation_pic++; + if ( _dx == 0 ){ + + if ( animation_pic < max_pics/2 ) animation_pic++; + else if ( animation_pic > max_pics/2 ) animation_pic--; + + } + */ + if ( _ax > 0 && animation_pic < max_pics-1 ) + animation_pic++; + if ( _ax < 0 && animation_pic > 0 ) + animation_pic--; + if ( _ax == 0 ){ + if ( animation_pic < max_pics/2 ) animation_pic++; + else if ( animation_pic > max_pics/2 ) animation_pic--; + } + + HullObject::Moved(_dx,_dy,_ax,_ay); +} + +int PlayerHull::getMaxLife(){ + return MAX_LIFE; +} + +int PlayerHull::getMaxShield(){ + return MAX_SHIELD; +} + +/* +int PlayerHull::max( int q ) { + switch( q ) { + case 0 : return MAX_LIFE; + case 1 : return MAX_SHIELD; + } + return 0; +} +*/ + + +int PlayerHull::rank() { + return hull_num; +} + + +void PlayerHull::addSection( SpaceObject * who, Section * onscreen, int x, int y ) { + if ( cloak > 0 ) return; + HullObject::addSection( who, onscreen, x, y ); + + /* + + if ( Translucent() ) return; + if ( onscreen == NULL ) return; + + int y1 = y; + int y2 = y; + if ( collide ) { + y1 = collide->CY1( collide->ul_y + y ); + y2 = collide->CY1( collide->lr_y + y ); + } + + onscreen->add( who, x, y1 ); + for ( int q = y1+onscreen->spacer(); q < y2; q += onscreen->spacer() ) + onscreen->add( who, x, q ); + if ( y2 != y1 ) + onscreen->add( who, x, y2 ); + */ + +} + + +int PlayerHull::maxGuns() { + return max_guns+1; +} + + +WeaponObject ** PlayerHull::Guns() { + for ( int q = 0; q < maxGuns()-1; q++ ){ + true_guns[q] = HullObject::Guns()[q]; + } + true_guns[ maxGuns()-1 ] = accessory[ current_accessory ]; + + return true_guns; +} + + +WeaponObject ** PlayerHull::Accessories() { + return accessory; +} + + +void PlayerHull::NextAccessory() { + + //if ( pcount( (char **)accessory, MAX_ACCESSORY ) == 0 ) return; + + int old = current_accessory; + for ( old = current_accessory+1; old != current_accessory; old %= MAX_ACCESSORY ) { + if ( accessory[old] != NULL ) { + current_accessory = old; + } else old++; + } + +} + + +void PlayerHull::giveWeapon( WeaponObject * weap, int num ) { + + if ( num < maxGuns()-1 ) { + guns[ num ] = weap; + return; + } + + for ( int q = 0; q < MAX_ACCESSORY; q++ ) + if ( accessory[q] == NULL ) { + accessory[q] = weap; + return; + } +} + +Bitmap * PlayerHull::getShadow(){ + return pics_shadow[ animation_pic ]; +} + +/* +void PlayerHull::Shadow( Bitmap * who, int x, int y ) { + //int mx = ((Bitmap *)dat[ drawNum ].dat)->w/2; + //int my = ((Bitmap *)dat[ drawNum ].dat)->h/2; + //draw_lit_sprite( who, (Bitmap *)dat[ drawNum ].dat, (int)(x-mx+dx), (int)(y-my+dy), 250 ); + Bitmap = pics[ animation_pic ]; + //int mx = Bitmap->w/2; + //int my = Bitmap->h/2; + //draw_lit_sprite( who, Bitmap, (int)(x-mx+dx), (int)(y-my+dy), 250 ); + HullObject::Shadow( who, x, y ); +} +*/ + +void PlayerHull::Draw( const Bitmap & who, int x, int y ) { + + if ( pics.empty() ){ + return; + } + + //int xpl = ((Bitmap *)dat[ drawNum ].dat)->w; + //int ypl = ((Bitmap *)dat[ drawNum ].dat)->h; + + myBitmap = pics[ animation_pic ]; + int xpl = myBitmap->getWidth(); + int ypl = myBitmap->getHeight(); + + if ( internal_damage ) { + internal_damage--; + + for ( int q = 0; q < MAX_ROTATE; q++ ) { + if ( rotate_damage[q] == NULL ) + rotate_damage[q] = new RotateHull(MAX_INTERNAL_DAMAGE,xpl,ypl,7,shade_damage); + if ( rotate_damage[q] ) + rotate_damage[q]->color = internal_damage; + } + + } else { + for ( int q = 0; q < MAX_ROTATE; q++ ){ + if ( rotate_damage[q] ) { + delete rotate_damage[q]; + rotate_damage[q] = NULL; + } + } + } + + for ( int q = 0; q < MAX_ROTATE; q++ ){ + if ( shield <= MAX_SHIELD*q/MAX_ROTATE && rotate[q] != NULL ) { + delete rotate[q]; + rotate[q] = NULL; + } + } + + for ( int q = 0; q < MAX_ROTATE; q++ ){ + if ( shield > MAX_SHIELD*q/MAX_ROTATE && rotate[q] == NULL ) + rotate[q] = new RotateHull( ( MAX_E_COLOR - 1 ) * ( q + 1 ) / MAX_ROTATE, xpl, ypl, 15, Util::e_color ); + } + + if ( cloak == 0 ){ + HullObject::Draw( who, x, y ); + } else { + //int mx = ((Bitmap *)dat[ drawNum ].dat)->w/2; + //int my = ((Bitmap *)dat[ drawNum ].dat)->h/2; + //draw_trans_sprite( who, (Bitmap *)dat[ drawNum ].dat, x-mx, y-my ); + //draw_lit_sprite( who, (Bitmap *)dat[ drawNum ].dat, x-mx, y-my, 150 ); + int mx = xpl/2; + int my = ypl/2; + + // draw_lit_sprite( who, Bitmap, x-mx, y-my, 150 ); + myBitmap->drawLit( x-mx, y-my, 150, who ); + } + + for ( int q = 0; q < MAX_ROTATE; q++ ) { + if ( rotate[q] != NULL ){ + rotate[q]->Draw( who, x, y ); + } + if ( rotate_damage[q] != NULL ){ + rotate_damage[q]->Draw( who, x, y ); + } + } + +} + + +void PlayerHull::frameLeft() { + if ( animation_pic > 0 ) animation_pic--; +} + + +void PlayerHull::frameRight() { + if ( animation_pic < max_pics-1 ) animation_pic++; +} + + +void PlayerHull::frameStable() { + if ( animation_pic < max_pics / 2 ) animation_pic++; + if ( animation_pic > max_pics / 2 ) animation_pic--; +} + + +double PlayerHull::Damage( double r ) { + + double dam = 0; + if ( r > shield ) { + shield = 0; + dam = r-shield; + } else shield -= r; + + if ( dam > 0 ) + internal_damage = MAX_INTERNAL_DAMAGE; + return dam; + //life -= dam; + +} + + +void PlayerHull::drawGun( const Bitmap & who, int x, int y ) { +} + + +/* +void PlayerHull::showAttribute( Bitmap * who, int amount, int MAX, int start_x, int offset ) { + #define start_attr 470 + for ( int z = 0; z < amount; z++ ) { + int base = expl_color - 60; + base += z * 60 / MAX; + int start = start_attr * z / MAX; + base = (int)( (double)z / (double)MAX * (double)(MAX_E_COLOR-15) + 15 ); + rectfill( who, start_x, start_attr-start+offset, start_x+9, start_attr-start+1+offset, e_color[base] ); + } +} +*/ --- rafkill-1.2.2.orig/build/hulls/hull_ship_shield.h +++ rafkill-1.2.2/build/hulls/hull_ship_shield.h @@ -0,0 +1,22 @@ +#ifndef _hull_shield_h +#define _hull_shield_h + +#include "hull.h" +#include "bitmap.h" + +class ECollide; + +class ShieldHull:public HullObject{ +public: + ShieldHull( Bitmap * me, double life, int level, ECollide * eb ); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual double Damage( double much ); + #define shield_max 3 + + HullObject * pr[ shield_max ]; + + virtual ~ShieldHull(); + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_fire.h +++ rafkill-1.2.2/build/hulls/hull_weapon_fire.h @@ -0,0 +1,24 @@ +#ifndef _hull_weapon_fire_h_ +#define _hull_weapon_fire_h_ + +#include "hull_weapon.h" +#include "bitmap.h" + +class SpaceObject; + +/* + * Fire + * + * looks like a burning bullet + * + */ + +class Fire_WHull:public HullWeapon{ +public: + Fire_WHull(); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual bool Collide( int mx, int my, SpaceObject * check ); + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_dissipate.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_dissipate.cpp @@ -0,0 +1,56 @@ +#include "hull.h" +#include "hull_weapon_dissipate.h" +#include "spaceobj.h" +#include "ebox.h" +#include "defs.h" +#include "trigtable.h" + +const int MAX_DISSIPATE_SHADE = 25; + +Dissipate_WHull::Dissipate_WHull( int life, ECollide * ec ): +HullWeapon( 0, life, 1 ) { + shade = new int[ MAX_DISSIPATE_SHADE ]; + mlife = life; + Util::blend_palette( shade, MAX_DISSIPATE_SHADE, Bitmap::makeColor(10,10,0), Bitmap::makeColor(245,0,5) ); + collide = ec; + + strength = (int)( fsqr((double)life+(double)mlife/5.0) * 1.19 ); + strength = 0; +} + + +void Dissipate_WHull::Draw( const Bitmap & who, int x, int y ) { + // circlefill( who, x, y, 6, shade[ (int)((double)life/(double)mlife*(double)(MAX_DISSIPATE_SHADE-1))] ); + int color = (int)((double)life/(double)mlife*(double)(MAX_DISSIPATE_SHADE-1)); + who.circleFill( x, y, 6, shade[ color ] ); +} + + +void Dissipate_WHull::Moved( double _dx, double _dy, double _ax, double _ay ) { + strength = (int)( fsqr( ((double)life+(double)mlife/2.0) / 20 ) * 1.19 ); + if ( strength < 1 ) strength = 1; +} + + +/* +bool Dissipate_WHull::Collide( int mx, int my, SpaceObject * check ) { + if ( check->HitMe( mx, my ) ) + return true; + + for ( int ang = 0; ang < 360; ang += 60 ) { + + int tx = (int)(mx + tcos[ang]*6 ); + int ty = (int)(my + tsine[ang]*6 ); + if ( check->HitMe( tx, ty ) ) + return true; + +} + +return false; + +} +*/ + +Dissipate_WHull::~Dissipate_WHull() { + delete[] shade; +} --- rafkill-1.2.2.orig/build/hulls/hull_meteor.h +++ rafkill-1.2.2/build/hulls/hull_meteor.h @@ -0,0 +1,20 @@ +#ifndef _hull_meteor_h +#define _hull_meteor_h + +#include "hull.h" +#include "bitmap.h" + +class SpaceObject; +class ECollide; + +class MeteorHull:public HullObject{ +public: + MeteorHull( int level, int lf, ECollide * eb ); + virtual bool Inside( int mx, int my, int ax, int ay ); + virtual bool Collide( int ax, int ay, SpaceObject * check ); + virtual void Draw( const Bitmap & who, int x, int y ); + + int frame; +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_protect.h +++ rafkill-1.2.2/build/hulls/hull_protect.h @@ -0,0 +1,24 @@ +#ifndef _hull_protect_h +#define _hull_protect_h + +#include "hull.h" +#include "bitmap.h" + +class ProtectHull:public HullObject{ +public: + ProtectHull( int c, int level ); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual bool Inside( int mx, int my, int ax, int ay ); + +private: + + void angular( int & a, int d ); + + int angX; + int angY; + int dirX; + int dirY; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_pulse_small.h +++ rafkill-1.2.2/build/hulls/hull_weapon_pulse_small.h @@ -0,0 +1,22 @@ +#ifndef _hull_weapon_pulse_small_h_ +#define _hull_weapon_pulse_small_h_ + +#include "hull_weapon.h" +#include "bitmap.h" + +/* + * SmallPulse + * + * this sucks, i have to change it soon. + * + */ + +class SmallPulse_WHull:public HullWeapon{ +public: + + SmallPulse_WHull(); + virtual void Draw( const Bitmap & who, int x, int y ); + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_explode.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_explode.cpp @@ -0,0 +1,67 @@ +#include "hull.h" +#include "hull_weapon_explode.h" +#include "bitmap.h" +#include "ebox.h" +#include "section.h" + +Explode_WHull::Explode_WHull( int str, ECollide ** _collide_list, int _max_list ): +HullObject( NULL, 1, str, 0, 0, 20, false, NULL ), +size( 3 ), +use( 0 ) { + + collide_list = _collide_list; + max_list = _max_list; + collide = collide_list[use]; + +} + +void Explode_WHull::Draw( const Bitmap & who, int x, int y ) { + + Bitmap::drawingMode( Bitmap::MODE_TRANS ); + + int color = Bitmap::makeColor(150+size<255 ? 150+size : 255, size*((int)strength/2)<255?size*((int)strength/2):255, size*(int)strength/3<255?size*(int)strength/3:255 ); + + who.circleFill( x, y, size, color ); + + Bitmap::drawingMode( Bitmap::MODE_SOLID ); +} + + +/* +void Explode_WHull::addSection( SpaceObject * who, Section * onscreen, int x, int y ){ + + int y1 = y; + int y2 = y; + if ( collide ) { + //y1 = collide->CY1( collide->ul_y + y ); + //y2 = collide->CY1( collide->lr_y + y ); + y1 = collide->upperY( y ); + y2 = collide->lowerY( y ); + } + +onscreen->add( who, x, y1 ); +for ( int q = y1+onscreen->spacer(); q <= y2; q += onscreen->spacer() ) +onscreen->add( who, x, q ); + +} +*/ + +void Explode_WHull::Moved( double _dx, double _dy, double _ax, double _ay ) { + + if ( use < max_list ) { + collide = collide_list[ use++ ]; + size += 6; + } + if ( use >= max_list ) life = -1; + +} + + +Explode_WHull::~Explode_WHull() { + + collide = NULL; + //for ( int q = 0; q < max_list; q++ ) + // delete collide_list[q]; + //delete[] collide_list; + +} --- rafkill-1.2.2.orig/build/hulls/hull_ship_destruct.h +++ rafkill-1.2.2/build/hulls/hull_ship_destruct.h @@ -0,0 +1,14 @@ +#ifndef _hull_ship8_h +#define _hull_ship8_h + +#include "hull.h" + +class SpaceObject; +class ECollide; + +class Destruct:public HullObject{ +public: + Destruct( int life, int level, ECollide * eb ); +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_pulse_nova.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_pulse_nova.cpp @@ -0,0 +1,47 @@ +#include "spaceobj.h" +#include "bitmap.h" +#include "trigtable.h" +#include "hull_weapon.h" +#include "hull_weapon_pulse_nova.h" + +NovaPulse_WHull::NovaPulse_WHull(): +HullWeapon( 0, 1, 3 ){} + +void NovaPulse_WHull::Draw( const Bitmap & who, int x, int y ) { + // circlefill( who, x, y, 7, makecol(0,255,10) ); + who.circleFill( x, y, 7, Bitmap::makeColor(0,255,10) ); + return; + + /* + for ( int tri = 0; tri < 2; tri++ ){ + + int x1 = actualx + rnd(7) - 3; + int x2 = actualx + rnd(7) - 3; + int y1 = actualy + 10 + rnd(8); + triangle( who, x1, actualy, x2, actualy, (x1+x2)/2, y1-2, 44); + triangle( who, x1, actualy, x2, actualy, (x1+x2)/2, y1, 42 ); + + } + + ellipsefill( who, actualx, actualy-1, 3, 6, 39 ); + ellipsefill( who, actualx, actualy, 3, 6, 41 ); + */ +} + + +bool NovaPulse_WHull::Collide( int mx, int my, SpaceObject * check ) { + if ( check->HitMe( mx, my ) ) + return true; + + for ( int ang = 0; ang < 360; ang += 45 ) { + + int tx = (int)(mx + Tcos(ang) * 7 ); + int ty = (int)(my + Tsine(ang) * 7 ); + if ( check->HitMe( tx, ty ) ) + return true; + + } + + return false; + +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_massive.h +++ rafkill-1.2.2/build/hulls/hull_weapon_massive.h @@ -0,0 +1,26 @@ +#ifndef _hull_weapon_massive_h +#define _hull_weapon_massive_h + +#include "hull_weapon.h" +#include "bitmap.h" + +class ECollide; +class RGBHandle; + +class Massive_WHull:public HullWeapon{ +public: + + Massive_WHull( int str, int life, ECollide * ecollide ); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual ~Massive_WHull(); + +protected: + + int side[ 10 ]; + int ang; + int max_massive; + RGBHandle * handle; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_protect.cpp +++ rafkill-1.2.2/build/hulls/hull_protect.cpp @@ -0,0 +1,50 @@ +#include "trigtable.h" +#include "bitmap.h" +#include "hull.h" +#include "hull_protect.h" + +#define protect_length 35 +#define protect_size 9 + +ProtectHull::ProtectHull( int c, int level ): +HullObject( NULL, 100000, 3, 0, level, 9, false, NULL ) { + color = c; + angX = Util::rnd(360); + angY = Util::rnd(360); + + dirX = Util::rnd(2) * 2 - 1; + dirY = Util::rnd(2) * 2 - 1; +} + + +void ProtectHull::angular( int & a, int d ) { + a += d*10; + while ( a < 0 ) a += 360; + while ( a >= 360 ) a -= 360; +} + + +void ProtectHull::Draw( const Bitmap & work, int x, int y ) { + angular( angX, dirX ); + angular( angY, dirY ); + int x1 = (int)( x + Tcos( angX ) * protect_length ); + int y1 = (int)( y + Tsine( angY ) * protect_length ); + // circlefill( work, x1, y1, protect_size, makecol( 186, 16, 16 ) ); + // circle( work, x1, y1, protect_size, makecol( 40, 40, 40 ) ); + work.circleFill( x1, y1, protect_size, Bitmap::makeColor(186,16,16)); + work.circle( x1, y1, protect_size, Bitmap::makeColor(40,40,40) ); +} + + +bool ProtectHull::Inside( int mx, int my, int ax, int ay ) { + //if ( abs(mx-ax)>=protect_size*2 || abs(my-ay)>=protect_size*2 ) + // return false; + int x1 = (int)( mx + Tcos( angX ) * protect_length ); + int y1 = (int)( my + Tsine(angY ) * protect_length ); + if ( dist( x1, y1, ax, ay ) < protect_size ) { + crash = true; + return true; + } + crash = false; + return false; +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_mini.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_mini.cpp @@ -0,0 +1,45 @@ +#include "hull_weapon.h" +#include "bitmap.h" +#include "hull_weapon_mini.h" + +Mini_WHull::Mini_WHull( ): +HullWeapon( 0, 1, 4 ) { + lx = -1; + ly = -1; +} + + +void Mini_WHull::Draw( const Bitmap & who, int x, int y ) { + + if ( lx == -1 ) { + lx = x; + ly = y; + } + + //int sx = (int)( x ); + //int sy = (int)( y - 3 ); + + double cx = (double)(lx-x)/8.0; + double cy = (double)(ly-y)/8.0; + + /* + double rx = x; + double ry = y; + for ( int q = 0; q < 3; q++ ) { + int c = 230-q*16; + line( who, (int)rx, (int)ry, (int)(rx+cx), (int)(ry+cy), makecol(c,c,c) ); + rx += cx; + ry += cy; + } + */ + + /* + line( who, x, y, (int)(x+cx*4), (int)(y+cy*4), makecol(255,243,48) ); + + putpixel( who, x, y, makecol(255,20,20) ); + */ + who.line( x, y, (int)(x+cx*4), (int)(y+cy*4), Bitmap::makeColor(255,243,48) ); + who.putPixel( x, y, Bitmap::makeColor(255,20,20) ); + lx = x; + ly = y; +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_follow.h +++ rafkill-1.2.2/build/hulls/hull_weapon_follow.h @@ -0,0 +1,22 @@ +#ifndef _hull_weapon_follow_h_ +#define _hull_weapon_follow_h_ + +#include "hull_weapon.h" +#include "bitmap.h" + +/* + * Follow + * + * a ball of lightning + * + */ + +class Follow_WHull:public HullWeapon{ +public: + + Follow_WHull( int _life ); + virtual void Draw( const Bitmap & who, int x, int y ); + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_massive.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_massive.cpp @@ -0,0 +1,51 @@ +#include "bitmap.h" +#include "hull_weapon.h" +#include "hull_weapon_massive.h" +#include "spaceobj.h" +#include "trigtable.h" +#include "ebox.h" +#include "raptor.h" +#include "rgbhandle.h" + +Massive_WHull::Massive_WHull( int str, int life, ECollide * ecollide ): +HullWeapon( 0, life, str ) { + + collide = ecollide; + ang = 0; + max_massive = str*3/2; + for ( int q = 0; q < 10; q++ ) + side[q] = Util::rnd( max_massive/2 ) + max_massive; + handle = new RGBHandle(); + +} + + +Massive_WHull::~Massive_WHull() { + delete handle; +} + + +void Massive_WHull::Draw( const Bitmap & who, int x, int y ) { + + for ( int q = 0; q < 10; q++ ) { + side[q] += Util::rnd( 2 ) * 2 - 1; + if ( side[q] < max_massive/2 ) side[q] = max_massive/2; + if ( side[q] > max_massive*2 ) side[q] = max_massive*2; + } + handle->update( 180, 130 ); + + ang = (ang+5) % 360; + + // int * verts = new int[ 20 ]; + int verts[ 20 ]; + for ( int q = 0; q < 10; q++ ) { + verts[q*2] = (int)(x + Tcos((ang+q*36)%360) * side[q] ); + verts[q*2+1] = (int)(y + Tsine((ang+q*36)%360) * side[q] ); + } + + who.polygon( verts, 10, handle->Get() ); + // polygon( who, 10, verts, handle->Get() ); + + // delete[] verts; + +} --- rafkill-1.2.2.orig/build/hulls/hull_player.h +++ rafkill-1.2.2/build/hulls/hull_player.h @@ -0,0 +1,90 @@ +#ifndef _player_hull_h +#define _player_hull_h + +#include "hull.h" +#include "bitmap.h" +#include + +using namespace std; + +/* +#define MAX_ROTATE 7 +#define MAX_ACCESSORY 3 +*/ +static const int MAX_ROTATE = 7; +static const int MAX_ACCESSORY = 3; + +// #define MAX_INTERNAL_DAMAGE 30 +static const int MAX_INTERNAL_DAMAGE = 30; + +class WeaponObject; + +class PlayerHull:public HullObject{ +public: +//inherited function + PlayerHull( const vector< Bitmap * > & pics, int _maxlife,int _maxshield,int _number_of_guns,int _hull_number,ECollide *eb); + + virtual void Draw( const Bitmap & who, int x, int y ); + //virtual void Shadow( Bitmap * who, int x, int y ); + virtual Bitmap * getShadow(); + virtual double Damage( double much ); + + virtual int maxGuns(); + virtual WeaponObject ** Guns(); + virtual void giveWeapon( WeaponObject * weap, int num ); + + virtual void Moved( double _dx, double _dy, double _ax, double _ay ); + virtual void addSection( SpaceObject * who, Section * onscreen, int x, int y ); + virtual HullObject * copy(); + + virtual const int getShield() const; + virtual void setShields( int s ); + virtual void incShield( int q ); + int getMaxLife(); + int getMaxShield(); + + virtual ~PlayerHull(); + +public: +//new functions + void frameRight(); + void frameLeft(); + void frameStable(); + + // virtual void showAttribute( Bitmap * who, int amount, int MAX, int start_x, int offset ); + + // int max( int q ); + int rank(); + virtual WeaponObject ** Accessories(); + virtual void NextAccessory(); + +protected: + double shield; + +public: + int frame; + int cloak; + +public: + virtual void drawGun( const Bitmap & who, int x, int y ); + + HullObject * rotate[ MAX_ROTATE ]; + HullObject * rotate_damage[ MAX_ROTATE ]; + int MAX_SHIELD; + int MAX_LIFE; + int hull_num; // records which player hull we are using + int internal_damage; //set to MAX_INTERNAL_DAMAGE when struck to show rotate_damage + // int * shade_damage; //blended palette for rotate_damage + int shade_damage[ MAX_INTERNAL_DAMAGE ]; + + int current_accessory; + WeaponObject * accessory[ MAX_ACCESSORY ]; + WeaponObject ** true_guns; + vector< Bitmap * > pics; + vector< Bitmap * > pics_shadow; + // Bitmap ** pics_shadow; + int animation_pic; + int max_pics; + +}; +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_shatter.h +++ rafkill-1.2.2/build/hulls/hull_weapon_shatter.h @@ -0,0 +1,26 @@ +#ifndef _hull_weapon_shatter_h_ +#define _hull_weapon_shatter_h_ + +#include "hull_weapon.h" +#include "spaceobj.h" +#include "bitmap.h" + + +/* + * + * Shatter + * + * big red ball that will eventually shatter + * + */ + +class Shatter_WHull:public HullWeapon{ +public: + + Shatter_WHull( int str ); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual bool Collide( int mx, int my, SpaceObject * check ); + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_emissle.h +++ rafkill-1.2.2/build/hulls/hull_weapon_emissle.h @@ -0,0 +1,17 @@ +#ifndef _hull_weapon_enemy_missle_h_ +#define _hull_weapon_enemy_missle_h_ + +#include "hull_weapon.h" +class SpaceObject; +class Bitmap; + +class EMissle_WHull:public HullWeapon{ +public: + EMissle_WHull(); + + virtual void Draw( const Bitmap & who, int x, int y ); + virtual bool Collide( int mx, int my, SpaceObject * check ); + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_pulse_large.cpp +++ rafkill-1.2.2/build/hulls/hull_weapon_pulse_large.cpp @@ -0,0 +1,43 @@ +#include "spaceobj.h" +#include "bitmap.h" +#include "hull_weapon.h" +#include "trigtable.h" +#include "hull_weapon_pulse_large.h" + +LargePulse_WHull::LargePulse_WHull(): +HullWeapon( 0, 1, 3 ){} + +void LargePulse_WHull::Draw( const Bitmap & who, int x, int y ) { + + for ( int tri = 0; tri < 2; tri++ ) { + + int x1 = x + Util::rnd(7) - 3; + int x2 = x + Util::rnd(7) - 3; + int y1 = y + 10 + Util::rnd(8); + who.triangle( x1, y, x2, y, (x1+x2)/2, y1-2, Bitmap::makeColor(255,20,0)); + who.triangle( x1, y, x2, y, (x1+x2)/2, y1, Bitmap::makeColor(240,20,0) ); + + } + + who.ellipseFill( x, y-1, 3, 6, Bitmap::makeColor(255,0,0) ); + who.ellipseFill( x, y, 3, 6, Bitmap::makeColor(240,100,0) ); + +} + + +bool LargePulse_WHull::Collide( int mx, int my, SpaceObject * check ) { + if ( check->HitMe( mx, my ) ) + return true; + + for ( int ang = 0; ang < 360; ang += 65 ) { + + int tx = (int)(mx + Tcos(ang)*6 ); + int ty = (int)(my + Tsine(ang)*6 ); + if ( check->HitMe( tx, ty ) ) + return true; + + } + + return false; + +} --- rafkill-1.2.2.orig/build/hulls/hull_weapon_cork.h +++ rafkill-1.2.2/build/hulls/hull_weapon_cork.h @@ -0,0 +1,28 @@ +#ifndef _hull_weapon_cork_h +#define _hull_weapon_cork_h + +#include "hull_weapon.h" +#include "spaceobj.h" +#include +#include "bitmap.h" + +using namespace std; + +class RGBHandle; + +class Cork_WHull:public HullWeapon{ +public: + + Cork_WHull( int str ); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual bool Collide( int mx, int my, SpaceObject * check ); + virtual ~Cork_WHull(); + +protected: + int * shade[ 2 ]; + int ang; + deque< int > list; + +}; + +#endif --- rafkill-1.2.2.orig/build/hulls/hull_weapon_dissipate.h +++ rafkill-1.2.2/build/hulls/hull_weapon_dissipate.h @@ -0,0 +1,34 @@ +#ifndef _hull_weapon_dissipate_h_ +#define _hull_weapon_dissipate_h_ + +#include "hull_weapon.h" +#include "bitmap.h" + +class SpaceObject; +class ECollide; + +/* + * Dissipate + * + * loses energy as it moves + * given an initial life, strength is computed as life/(USE_AMMO*C) + * + */ + +class Dissipate_WHull:public HullWeapon{ +public: + Dissipate_WHull( int str, ECollide * ec ); + virtual void Draw( const Bitmap & who, int x, int y ); + virtual void Moved( double _dx, double _dy, double _ax, double _ay ); + //virtual bool Collide( int mx, int my, SpaceObject * check ); + + virtual ~Dissipate_WHull(); + +private: + + int * shade; + int mlife; + +}; + +#endif --- rafkill-1.2.2.orig/build/weapons/weapon_damage.cpp +++ rafkill-1.2.2/build/weapons/weapon_damage.cpp @@ -0,0 +1,30 @@ +#include "hull.h" +#include "spaceobj.h" +#include "weapon_damage.h" +#include "weaponobj.h" +#include + +using namespace std; + +Damage_Weapon::Damage_Weapon( int qx, int qy, double kx, double ky, int dam, HullObject * hnew, int al ): +WeaponNode( qx, qy, kx, ky, hnew, al ), +damage( dam ){} + +void Damage_Weapon::MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ){ + if ( hull ) hull->takeDamage( damage ); + MoveReal(); + if ( hull ) hull->Moved( this->getDX(), this->getDY(), this->getAccelX(), this->getAccelY() ); +} + +/* +void Damage_Weapon::MoveReal() { + / * + virtualx += dx; + virtualy += dy; + actualx = (int)virtualx; + actualy = (int)virtualy; + * / + SpaceObject::MoveReal(); + hull->takeDamage( damage ); +} +*/ --- rafkill-1.2.2.orig/build/weapons/weapon_pulse.cpp +++ rafkill-1.2.2/build/weapons/weapon_pulse.cpp @@ -0,0 +1,45 @@ +#include "hull.h" +#include "hulls/hull_weapon_pulse_nova.h" +#include "weaponobj.h" +#include "weapon_pulse.h" +#include "defs.h" +#include "explode.h" + +Pulse::Pulse( int qx, int qy, double kx, double ky, HullObject * hnew, int al ): +WeaponNode(qx,qy,kx,ky,hnew, al){} + +bool Pulse::Damage( double much ) { + return false; +} + + +void Pulse::Collided( SpaceObject * who, ExplosionClass ** explr, int M_EX ) { + addExplode( explr, M_EX, new ExplosionClass(getX(),getY(),0,0, Util::rnd(6) + 3 ) ); + if ( hull ) hull->Collided(); +} + + +NovaPulse::NovaPulse(int qx, int qy, double kx, double ky, int al): +Pulse(qx,qy,kx,ky,new NovaPulse_WHull(), al ){} + +void NovaPulse::MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ){ + setDY( getDY() - 0.20 ); + MoveReal(); + if ( hull ) hull->Moved( getDX(), getDY(), getAccelX(), getAccelY() ); +} + +/* +void NovaPulse::MoveReal() { + + // dy -= 0.02; + setDY( getDY() - 0.30 ); + SpaceObject::MoveReal(); + / * + virtualx += dx; + virtualy += dy; + actualx = (int)virtualx; + actualy = (int)virtualy; + * / + +} +*/ --- rafkill-1.2.2.orig/build/weapons/weapon_rocket.cpp +++ rafkill-1.2.2/build/weapons/weapon_rocket.cpp @@ -0,0 +1,23 @@ +#include "weaponobj.h" +#include "weapon_rocket.h" +#include "hull.h" + +Rocket::Rocket(int qx, int qy, double kx, double ky, HullObject * hnew, int al ): +WeaponNode(qx,qy,kx,ky,hnew, al), +speed( 0.2 ){} + +#define ROCKETSPEED 0.02 +void Rocket::MoveReal() { + + /* + virtualx += dx*speed; + virtualy += dy*speed; + actualx = (int)virtualx; + actualy = (int)virtualy; + */ + SpaceObject::MoveReal(); + + speed += ROCKETSPEED; + if ( speed > 3.2 ) + speed = 3.2; +} --- rafkill-1.2.2.orig/build/weapons/weapon_chain.cpp +++ rafkill-1.2.2/build/weapons/weapon_chain.cpp @@ -0,0 +1,19 @@ +#include "hull.h" +#include "weapon_chain.h" +#include "weapon_damage.h" + +Chain::Chain( int qx, int qy, double kx, double ky, HullObject * hnew, int al ): +Damage_Weapon( qx, qy, kx, ky, 1, hnew, al ){} + +/* +void Chain::MoveReal() { + / * + virtualx += dx; + virtualy += dy; + actualx = (int)virtualx; + actualy = (int)virtualy; + * / + SpaceObject::MoveReal(); + hull->takeDamage( 1 ); +} +*/ --- rafkill-1.2.2.orig/build/weapons/weapon_angle.cpp +++ rafkill-1.2.2/build/weapons/weapon_angle.cpp @@ -0,0 +1,88 @@ +#include "weaponobj.h" +#include "weapon_angle.h" +#include "hull.h" +#include "trigtable.h" + +Angle::Angle( int qx, int qy, double kx, double ky, double _speed, HullObject * hnew, int al, int _ang ): +WeaponNode(qx,qy,kx,ky,hnew,al), +ang_vel( (_ang+90)%360 ), +ang_accel( (_ang+180) % 360 ), +speed( _speed ){ + + /* + setDX( Tcos(ang_vel) * speed ); + setDY( Tsine(ang_vel) * speed ); + */ + + /* + center_x = getX(); + center_y = getY(); + */ +} + +void Angle::MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ){ + + /* + center_x += getDX(); + center_y += getDY(); + + setX( center_x ); + setY( center_y ); + + MoveReal(); + + double fx, fy; + + fx = center_x + Tcos(ang_vel) * speed; + fy = center_y + Tsine(ang_vel) * speed; + ang_vel = (ang_vel + 20 ) % 360; + + setX( fx ); + setY( fy ); + */ + + setOffsetX( (int)( Tcos(ang_vel) * speed ) ); + setOffsetY( (int)( Tsine(ang_vel) * speed ) ); + ang_vel = (ang_vel + 20 ) % 360; + + MoveReal(); + + /* + fx = getDX(); + fy = getDY(); + + int ix = (int)fx; + int iy = (int)fy; + int sang = gang( 0, 0, ix, iy ); + ang_vel = (sang+5) % 360; + + fx = Tcos( ang_vel ) * speed; + fy = Tsine( ang_vel ) * speed; + setDX( fx ); + setDY( fy ); + // ang = (ang+5)%360; + */ + + if ( hull ) hull->Moved( this->getDX(), this->getDY(), this->getAccelX(), this->getAccelY() ); + +} + +/* +void Angle::MoveReal() { + + //virtualx += dx + tcos[ ang ]; + //virtualy += dy + tsine[ ang ]; + //actualx = (int)virtualx; + //actualy = (int)virtualy; + + / * + virtualx += dx; + virtualy += dy; + actualx = (int)(virtualx + tcos[ang] * 25 ); + actualy = (int)(virtualy + tsine[ang] * 25 ); + * / + + ang = ( ang + 2 ) % 360; + +} +*/ --- rafkill-1.2.2.orig/build/weapons/weapon_follow.h +++ rafkill-1.2.2/build/weapons/weapon_follow.h @@ -0,0 +1,29 @@ +#ifndef _follow_h +#define _follow_h + +#include "weaponobj.h" +#include "spaceobj.h" +#include + +using namespace std; + +class Follow:public WeaponNode{ +public: + + Follow( int qx, int qy, int sang, const vector< SpaceObject * > * f, int al, int _life ); + + virtual void MoveReal(); + virtual bool Damage( double much ); + virtual void Collided( SpaceObject * who, ExplosionClass ** explr, int M_EX ); + +protected: + + SpaceObject * getFight(); + + int ang; + const vector< SpaceObject * > * fight; + SpaceObject * murder; + +}; + +#endif --- rafkill-1.2.2.orig/build/weapons/weapon_rocket.h +++ rafkill-1.2.2/build/weapons/weapon_rocket.h @@ -0,0 +1,19 @@ +#ifndef _weapon_rocket_h +#define _weapon_rocket_h + +#include "weaponobj.h" +class HullObject; + +class Rocket:public WeaponNode{ +public: + Rocket(int qx, int qy, double kx, double ky, HullObject * hnew, int al); + virtual void MoveReal(); + +protected: + +double speed; + +}; + +#endif + --- rafkill-1.2.2.orig/build/weapons/weapon_pulse.h +++ rafkill-1.2.2/build/weapons/weapon_pulse.h @@ -0,0 +1,27 @@ +#ifndef _pulse_h +#define _pulse_h + +#include + +using namespace std; + +#include "weaponobj.h" +class SpaceObject; +class HullObject; +class ExplosionClass; + +class Pulse:public WeaponNode{ +public: + Pulse( int qx, int qy, double kx, double ky, HullObject * hnew, int al ); + virtual bool Damage( double much ); + virtual void Collided( SpaceObject * who, ExplosionClass ** explr, int M_EX ); +}; + +class NovaPulse:public Pulse{ +public: + + NovaPulse(int qx, int qy, double kx, double ky, int al ); + virtual void MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ); +}; + +#endif --- rafkill-1.2.2.orig/build/weapons/weapon_chain.h +++ rafkill-1.2.2/build/weapons/weapon_chain.h @@ -0,0 +1,14 @@ +#ifndef _weapon_chain_h +#define _weapon_chain_h + +#include "weapon_damage.h" +class HullObject; + +class Chain:public Damage_Weapon{ +public: + Chain(int qx, int qy, double kx, double ky, HullObject * hnew, int al ); + // virtual void MoveReal(); +}; + +#endif + --- rafkill-1.2.2.orig/build/weapons/weapon_shatter.h +++ rafkill-1.2.2/build/weapons/weapon_shatter.h @@ -0,0 +1,22 @@ +#ifndef _weapon_shatter_h +#define _weapon_shatter_h + +#include "weaponobj.h" +#include +#include "spaceobj.h" + +class HullObject; + +using namespace std; + +class Shatter:public WeaponNode{ +public: + Shatter( int qx, int qy, double kx, double ky, HullObject * hnew, int al, vector< SpaceObject * > * Ammo ); + + virtual bool Damage( double much ); + virtual void Died(SpaceObject * check,ExplosionClass ** explr, int ME ); +protected: + vector< SpaceObject * > * myAmmo; +}; + +#endif --- rafkill-1.2.2.orig/build/weapons/weapon_angle.h +++ rafkill-1.2.2/build/weapons/weapon_angle.h @@ -0,0 +1,22 @@ +#ifndef _angle_h +#define _angle_h + +#include "weaponobj.h" + +class HullObject; + +class Angle:public WeaponNode{ +public: + Angle( int qx, int qy, double kx, double ky, double speed, HullObject * hnew, int al, int _ang ); + // virtual void MoveReal(); + + virtual void MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ); + +protected: + double center_x, center_y; + int ang_vel; + int ang_accel; + double speed; +}; + +#endif --- rafkill-1.2.2.orig/build/weapons/weapon_emissle.h +++ rafkill-1.2.2/build/weapons/weapon_emissle.h @@ -0,0 +1,14 @@ +#ifndef _weapon_enemy_missle_h +#define _weapon_enemy_missle_h + +#include "weaponobj.h" + +class normalMissle: public WeaponNode{ +public: + + normalMissle(int qx, int qy, double kx, double ky, int al ); + virtual void MoveReal(); + +}; + +#endif --- rafkill-1.2.2.orig/build/weapons/weapon_rotate.h +++ rafkill-1.2.2/build/weapons/weapon_rotate.h @@ -0,0 +1,20 @@ +#ifndef _rotate_h +#define _rotate_h + +#include "weaponobj.h" +class HullObject; + +class Rotate:public WeaponNode{ +public: + Rotate( int qx, int qy, double kx, double ky, int _ang, int _max, HullObject * hnew, int al ); + + virtual void MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ); + +protected: + int ang; + int max; + int rad; + int dir; +}; + +#endif --- rafkill-1.2.2.orig/build/weapons/weapon_only_damage.cpp +++ rafkill-1.2.2/build/weapons/weapon_only_damage.cpp @@ -0,0 +1,12 @@ +#include "hull.h" +#include "weapon_damage.h" +#include "weapon_only_damage.h" + +Only_Damage_Weapon::Only_Damage_Weapon(int qx, int qy, double kx, double ky, int dam, HullObject * hnew, int al ): +Damage_Weapon(qx,qy,kx,ky,dam,hnew,al) { +} + + +bool Only_Damage_Weapon::Damage( double much ) { + return false; +} --- rafkill-1.2.2.orig/build/weapons/weapon_shatter.cpp +++ rafkill-1.2.2/build/weapons/weapon_shatter.cpp @@ -0,0 +1,38 @@ +#include "weapon_shatter.h" +#include "weapon_bounce.h" +#include "weaponobj.h" +#include "hull.h" +#include "trigtable.h" +#include "sound.h" +#include "hulls/hull_weapon_shatter.h" +#include "hulls/hull_weapon_machine.h" + +Shatter::Shatter( int qx, int qy, double kx, double ky, HullObject * hnew, int al, vector< SpaceObject * > * Ammo ): +WeaponNode(qx,qy,kx,ky,hnew, al) { + myAmmo = Ammo; +} + +bool Shatter::Damage( double much ) { + if ( !hull ) return true; + hull->takeDamage( getLife() ); + return true; + // return ( getLife() <= 0 ); +} + +void Shatter::Died(SpaceObject * check,ExplosionClass ** explr,int ME ){ + + Util::playSound( SND_SUSTAIN, 50 ); + Explode( explr, ME ); + + if ( myAmmo == NULL ) return; + for ( int q = 0; q < hull->strength*3; q++ ) { + int ang = Util::rnd( 360 ); + + HullObject * add_h = new Machine_WHull( 1 ); + add_h->life = 4; + myAmmo->push_back( new Bounce(getX(),getY(),Tcos(ang)*2.1,Tsine(ang)*2.1,add_h,alignment ) ); + + //myAmmo->add( new Shatter(actualx,actualy,tcos[ang]*2.1,tsine[ang]*2.1, new Shatter_WHull(hull->strength/2), alignment, myAmmo ) ); + } + +} --- rafkill-1.2.2.orig/build/weapons/weapon_yehat.cpp +++ rafkill-1.2.2/build/weapons/weapon_yehat.cpp @@ -0,0 +1,20 @@ +#include "weaponobj.h" +#include "weapon_yehat.h" +#include "hull.h" +#include "trigtable.h" + +Yehat_Weapon::Yehat_Weapon( int qx, int qy, double kx, double ky, HullObject * hnew, int al ): +WeaponNode(qx,qy,kx,ky,hnew,al) { +} + + +void Yehat_Weapon::Collided( SpaceObject * who, ExplosionClass ** explr, int M_EX ) { + + double d = dist( getX(), getY(), who->getX(), who->getY() ); + int ang = gang( getX(), getY(), who->getX(), who->getY() ); + who->SetCoordXY( (int)(who->getX() + Tcos(ang)*d/1.3), (int)(who->getY() + Tsine(ang)*d/1.3) ); + //who->SetCoordXY( who->actualx, who->actualy + 10 ); + + if ( hull ) hull->Collided(); + this->addCollide( who ); +} --- rafkill-1.2.2.orig/build/weapons/weapon_stick.h +++ rafkill-1.2.2/build/weapons/weapon_stick.h @@ -0,0 +1,29 @@ +#ifndef _weapon_stick_h +#define _weapon_stick_h + +#include "weaponobj.h" +class HullObject; +class ECollide; + +class Sticky:public WeaponNode{ +public: + Sticky( int qx, int qy, double kx, double ky, HullObject * hnew, int al, ECollide ** _collide_list, int _max_collide, int _strength ); + virtual bool Damage( double much ); + virtual void Collided( SpaceObject * who, ExplosionClass ** explr, int M_EX ); + virtual bool Collide( SpaceObject * check); + virtual void MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ); + virtual ~Sticky(); + +protected: + SpaceObject * station; + ECollide ** collide_list; + int max_collide; + + int tick; + int bomb_rad; + int ang, ds; + int strength; +}; + +#endif + --- rafkill-1.2.2.orig/build/weapons/weapon_damage.h +++ rafkill-1.2.2/build/weapons/weapon_damage.h @@ -0,0 +1,23 @@ +#ifndef _hooray_damage_weapon_h +#define _hooray_damage_weapon_h + +#include "weaponobj.h" +#include + +class HullObject; +class SpaceObject; +class Section; + +using namespace std; + +class Damage_Weapon:public WeaponNode{ +public: + Damage_Weapon(int qx, int qy, double kx, double ky, int dam, HullObject * hnew, int al ); + virtual void MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ); + +protected: + int damage; +}; + +#endif + --- rafkill-1.2.2.orig/build/weapons/weapon_massive.h +++ rafkill-1.2.2/build/weapons/weapon_massive.h @@ -0,0 +1,14 @@ +#ifndef _massive_weapon_h +#define _massive_weapon_h + +#include "weaponobj.h" +class SpaceObject; +class HullObject; + +class Massive_Weapon:public WeaponNode{ +public: + Massive_Weapon( int qx, int qy, double kx, double ky, HullObject * hnew, int al ); + virtual bool Damage( double much ); +}; + +#endif --- rafkill-1.2.2.orig/build/weapons/weapon_beam.cpp +++ rafkill-1.2.2/build/weapons/weapon_beam.cpp @@ -0,0 +1,46 @@ +#include "hull.h" +#include "weapon_damage.h" +#include "weapon_beam.h" +#include "explode.h" +#include "ebox.h" +#include "defs.h" + +Beam::Beam(int qx, int qy, double kx, double ky, int dam, HullObject * hnew, int al ): +Damage_Weapon(qx,qy,kx,ky,dam,hnew,al) { +} + + +bool Beam::Damage( double much ) { + return false; +} + +void Beam::Collided( SpaceObject * who, ExplosionClass ** explr, int M_EX ) { + + int mw = getMaxX() / 2; + int mh = getMaxY() / 2; + + int mx1 = getX() - mw; + int mx2 = getX() + mw; + int my1 = getY() - mh; + int my2 = getY() + mh; + + int aw = who->getMaxX() / 2; + int ah = who->getMaxY() / 2; + + int ax1 = who->getX() - aw;; + int ay1 = who->getY() - ah; + int ax2 = who->getX() + aw; + int ay2 = who->getY() + ah; + + int x1 = ax1 > mx1 ? ax1 : mx1; + int x2 = mx2 < ax2 ? mx2 : ax2; + int y1 = ay1 > my1 ? ay1 : my1; + int y2 = ay2 < ay2 ? my2 : ay2; + + for ( int x = x1; x < x2; x += Util::rnd(5)+7 ) + for ( int y = y1; y < y2; y += Util::rnd(5)+7 ) + addExplode( explr, M_EX, new ExplosionClass(x,y,0,-20,Util::rnd(6) + 3 ) ); + + + // this->addCollide( who ); +} --- rafkill-1.2.2.orig/build/weapons/weapon_follow.cpp +++ rafkill-1.2.2/build/weapons/weapon_follow.cpp @@ -0,0 +1,124 @@ +#include "trigtable.h" +#include "weaponobj.h" +#include "weapon_follow.h" +#include "hulls/hull_weapon_follow.h" +#include "spaceobj.h" +#include + +using namespace std; + +#define FOLLOW_SPEED 2.1 + +Follow::Follow(int qx, int qy, int sang, const vector< SpaceObject * > * f, int al, int _life ): +WeaponNode( qx, qy, 0, 0, new Follow_WHull( _life ), al ), +ang( sang ) { + fight = f; + murder = NULL; +} + + +void Follow::Collided( SpaceObject * who, ExplosionClass ** explr, int M_EX ) { + addExplode( explr, M_EX, new ExplosionClass(getX(),getY(),0,0,Util::rnd(6) + 3 ) ); +} + + +SpaceObject * Follow::getFight() { + + if ( fight->empty() ) { + murder = NULL; + return murder; + } + + SpaceObject * gay = new SpaceObject(0,0,0,0,NULL,NULL,PLANE_AIR|PLANE_GROUND, alignment ); + bool cy = false; + + for ( vector< SpaceObject * >::const_iterator it = fight->begin(); it != fight->end(); it++ ) + if ( (*it)->CanbeHit( gay ) ) cy = true; + if ( !cy ) { + delete gay; + murder = NULL; + return murder; + } + + cy = true; + if ( murder != NULL ) { + for ( vector< SpaceObject * >::const_iterator it = fight->begin(); it != fight->end(); ) { + if ( murder == (*it) ) { + cy = false; + it = fight->end(); + } else it++; + } + } + + if ( cy ) { + murder = (*fight)[ Util::rnd( fight->size() ) ]; + while ( !murder->CanbeHit( gay ) ) murder = (*fight)[ Util::rnd( fight->size() ) ]; + } + + delete gay; + return murder; + +} + + +bool Follow::Damage( double much ) { + return SpaceObject::Damage( much ); +} + + +/* +void Follow::Explode( ExplosionClass ** explr, int ME ) { + int q = 0; + while ( q < ME && explr[q] != NULL ) + q++; + if ( q >= ME ) + return; + double a = (double)( Util::rnd( 45 ) + 15 ) / -10.0; + explr[q] = new ExplosionClass( actualx, actualy, 0, a, Util::rnd( 9 ) + 6 ); +} +*/ + +void Follow::MoveReal() { + + getFight(); + + if ( murder != NULL && Util::rnd( 3 ) ) { + int bang = gang( getX(), getY(), murder->getX(), murder->getY() ); + for ( int q = 0; q < 2; q++ ) { + if ( abs( bang - ang ) <= 180 ) { + if ( ang < bang ) ang++; + else ang--; + } + else if ( abs( bang - ang ) >= 270 ) { + if ( bang > ang ) + ang--; + else ang++; + } + else { + if( bang > ang ) ang--; + else ang++; + } + ang += 360; + ang %= 360; + } + } + + /* + dx = tcos[ ang ] * FOLLOW_SPEED; + dy = tsine[ ang ] * FOLLOW_SPEED; + */ + setDX( Tcos( ang ) * FOLLOW_SPEED ); + setDY( Tsine( ang ) * FOLLOW_SPEED ); + + setX( getVX() + getDX() ); + setY( getVY() + getDY() ); + /* + virtualx += getDX(); + virtualy += getDY(); + */ + /* + actualx = (int)virtualx; + actualy = (int)virtualy; + */ + +} --- rafkill-1.2.2.orig/build/weapons/weapon_beam.h +++ rafkill-1.2.2/build/weapons/weapon_beam.h @@ -0,0 +1,19 @@ +#ifndef _weapon_beam_h +#define _weapon_beam_h + +#include "weaponobj.h" +#include "weapon_damage.h" + +class HullObject; +class ExplosionClass; + +class Beam:public Damage_Weapon{ +public: + Beam(int qx, int qy, double kx, double ky, int dam, HullObject * hnew, int al ); + virtual bool Damage( double much ); + virtual void Collided( SpaceObject * who, ExplosionClass ** explr, int M_EX ); + +}; + +#endif + --- rafkill-1.2.2.orig/build/weapons/weapon_laser.cpp +++ rafkill-1.2.2/build/weapons/weapon_laser.cpp @@ -0,0 +1,17 @@ +#include "hull.h" +#include "weaponobj.h" +#include "weapon_laser.h" +#include "defs.h" + +LaserBullet::LaserBullet( int qx, int qy, double kx, double ky, HullObject * hnew, int al ): +WeaponNode( qx, qy, kx, ky, hnew, al ){} + +bool LaserBullet::Damage( double much ) { + hull->takeDamage( 2 ); + return false; +} + +void LaserBullet::Collided( SpaceObject * who, ExplosionClass ** explr, int M_EX ) { + addExplode( explr, M_EX, new ExplosionClass(getX(),getY(),0,0,Util::rnd(6) + 3 ) ); + if ( hull ) hull->Collided(); +} --- rafkill-1.2.2.orig/build/weapons/weapon_laser.h +++ rafkill-1.2.2/build/weapons/weapon_laser.h @@ -0,0 +1,15 @@ +#ifndef _weapon_laser_h +#define _weapon_laser_h + +#include "weaponobj.h" +class HullObject; + +class LaserBullet:public WeaponNode{ +public: + LaserBullet( int qx, int qy, double kx, double ky, HullObject * hnew, int al ); + virtual bool Damage( double much ); + virtual void Collided( SpaceObject * who, ExplosionClass ** explr, int M_EX ); +}; + +#endif + --- rafkill-1.2.2.orig/build/weapons/weapon_only_damage.h +++ rafkill-1.2.2/build/weapons/weapon_only_damage.h @@ -0,0 +1,17 @@ +#ifndef _only_damage_weapon_h +#define _only_damage_weapon_h + +#include "weaponobj.h" +#include "weapon_damage.h" + +class HullObject; + +class Only_Damage_Weapon:public Damage_Weapon{ +public: + Only_Damage_Weapon(int qx, int qy, double kx, double ky, int dam, HullObject * hnew, int al ); + virtual bool Damage( double much ); + +}; + +#endif + --- rafkill-1.2.2.orig/build/weapons/weapon_massive.cpp +++ rafkill-1.2.2/build/weapons/weapon_massive.cpp @@ -0,0 +1,10 @@ +#include "hull.h" +#include "weaponobj.h" +#include "weapon_massive.h" + +Massive_Weapon::Massive_Weapon( int qx, int qy, double kx, double ky, HullObject * hnew, int al ): +WeaponNode(qx,qy,kx,ky,hnew,al){} + +bool Massive_Weapon::Damage( double much ) { + return false; +} --- rafkill-1.2.2.orig/build/weapons/weapon_stick.cpp +++ rafkill-1.2.2/build/weapons/weapon_stick.cpp @@ -0,0 +1,114 @@ +#include "weaponobj.h" +#include "weapon_stick.h" +#include "hull.h" +#include "hulls/hull_weapon_explode.h" +#include "ebox.h" +#include "trigtable.h" +#include +using namespace std; + +Sticky::Sticky( int qx, int qy, double kx, double ky, HullObject * hnew, int al, ECollide ** _collide_list, int _max_collide, int _strength ): +WeaponNode(qx,qy,kx,ky,hnew,al), +max_collide( _max_collide ), +tick( -1 ), +bomb_rad( 0 ), +strength( _strength ) { + + collide_list = _collide_list; + station = NULL; + +} + + +bool Sticky::Damage( double much ) { + return false; +} + + +void Sticky::Collided( SpaceObject * who, ExplosionClass ** explr, int M_EX ) { + if ( tick == -1 ) { + tick = 30; + station = who; + ang = getAngle( station->getX(), station->getY(), getX(), getY() ); + ds = (int) dist( station->getX(), station->getY(), getX(), getY() ); + } + + if ( tick == 0 ) { + + ECollide * ec = hull->getCollide(); + EQuad * e = ec->getLast(); + int x = e->getPosX(); + int y = e->getPosY(); + addExplode( explr, M_EX, new ExplosionClass(x,y,0,0,Util::rnd(6) + 3 ) ); + } + + setDX( 0 ); + setDY( 0 ); + + /* + station = check; + ang = gang( station->actualx, station->actualy, actualx, actualy ); + ds = dist( station->actualx, station->actualy, actualx, actualy ); + */ + +} + + +bool Sticky::Collide(SpaceObject * check) { + // if ( !CanbeHit( check ) ) return false; + + if ( tick > 0 ) return false; + /* + bool cy = hull->Collide( actualx, actualy, check ); + if ( cy ){ + station = check; + ang = gang( station->actualx, station->actualy, actualx, actualy ); + ds = dist( station->actualx, station->actualy, actualx, actualy ); + } + */ + return hull->Collide( getX(), getY(), check ); +} + + +void Sticky::MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ){ + + if ( tick > 0 ) { + tick--; + if ( tick == 0 ) { + + this->giveHull( new Explode_WHull( strength, collide_list, max_collide ) ); + collide_list = NULL; + + } + } + + if ( tick == 0 ) { + /* + bomb_rad = (bomb_rad+1) % 3; + if ( bomb_rad == 0 ) hull->Moved( 0, 0, 0, 0 ); + */ + hull->Moved( 0, 0, 0, 0 ); + } + MoveReal(); + if ( station != NULL && tick != 0 ) { + + vector< SpaceObject * >::const_iterator it; + for ( it = fight->begin(); station != *it && it != fight->end(); it++ ); + if ( it == fight->end() )tick = 1; + else this->SetCoordXY( (int)(station->getX()+Tcos(ang)*ds), (int)(station->getY()+Tsine(ang)*ds) ); + + } + + // if ( hull ) hull->addSection( this, onscreen, getX(), getY() ); + // return ( getX() < -20 || getX() > screen_x + 20 || getY() < -10 || getY() > screen_y + 20 ); + +} + + +Sticky::~Sticky() { + if ( collide_list != NULL ) { + //for ( int q = 0; q < max_collide; q++ ) + // delete collide_list[q]; + //delete[] collide_list; + } +} --- rafkill-1.2.2.orig/build/weapons/weapon_rotate.cpp +++ rafkill-1.2.2/build/weapons/weapon_rotate.cpp @@ -0,0 +1,42 @@ +#include "weaponobj.h" +#include "weapon_rotate.h" +#include "hull.h" +#include "trigtable.h" + +Rotate::Rotate( int qx, int qy, double kx, double ky, int _ang, int _max, HullObject * hnew, int al ): +WeaponNode( qx, qy, kx, ky, hnew, al ), +ang( _ang ), +max( _max ), +rad( 0 ), +dir( 1 ){} + +void Rotate::MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ){ + + MoveReal(); + if ( hull ) hull->Moved( this->getDX(), this->getDY(), this->getAccelX(), this->getAccelY() ); + + rad += dir; + if ( rad < -max ) dir = 1; + if ( rad > max ) dir = -1; + setOffsetX( (int)( Tcos( ang ) * rad ) ); + setOffsetY( (int)( Tsine( ang) * rad ) ); + +} + + +/* +void Rotate::MoveReal() { + + / * + virtualx += dx; + virtualy += dy; + actualx = (int)( virtualx + tcos[ang] * rad ); + actualy = (int)( virtualy + tsine[ang] * rad ); + * / + + rad += dir; + if ( rad < -max ) dir = 1; + if ( rad > max ) dir = -1; + +} +*/ --- rafkill-1.2.2.orig/build/weapons/weapon_bounce.h +++ rafkill-1.2.2/build/weapons/weapon_bounce.h @@ -0,0 +1,17 @@ +#ifndef _weapon_bounce_h +#define _weapon_bounce_h + +#include "weaponobj.h" +class HullObject; + +class Bounce:public WeaponNode{ +public: + Bounce( int qx, int qy, double kx, double ky, HullObject * hnew, int al ); + virtual bool Damage( double much ); + // virtual void MoveReal(); + +protected: + int bounces; +}; + +#endif --- rafkill-1.2.2.orig/build/weapons/weapon_emissle.cpp +++ rafkill-1.2.2/build/weapons/weapon_emissle.cpp @@ -0,0 +1,18 @@ +#include "weaponobj.h" +#include "weapon_emissle.h" +#include "hulls/hull_weapon_emissle.h" + +normalMissle::normalMissle(int qx, int qy, double kx, double ky, int al): +WeaponNode( qx, qy, kx, ky, new EMissle_WHull(), al ){} + +void normalMissle::MoveReal() { + // dy += 0.01; + setDY( getDY() + 0.01 ); + SpaceObject::MoveReal(); + /* + virtualx += dx; + virtualy += dy; + actualx = (int)virtualx; + actualy = (int)virtualy; + */ +} --- rafkill-1.2.2.orig/build/weapons/weapon_bounce.cpp +++ rafkill-1.2.2/build/weapons/weapon_bounce.cpp @@ -0,0 +1,91 @@ +#include "defs.h" +#include "weapon_bounce.h" +#include "weaponobj.h" +#include "hull.h" + +Bounce::Bounce( int qx, int qy, double kx, double ky, HullObject * hnew, int al ): +WeaponNode(qx,qy,kx,ky,hnew, al){} + +bool Bounce::Damage( double much ) { + hull->takeDamage( 1 ); + + bool ch[ 2 ]; + if ( Util::rnd(2) ) ch[0] = true;else ch[0]=false; + if ( Util::rnd(2) ) ch[1] = true;else ch[1]=false; + + if ( !ch[0] && !ch[1] ) + switch( Util::rnd(2) ) { + case 0 : ch[0] = true;break; + case 1 : ch[1] = true;break; + } + + /* TODO: + * Cleanup + */ + + /* + if ( ch[0] ) dx *= -1; + if ( ch[1] ) dy *= -1; + */ + + return getLife(); +} + + +/* +void Bounce::MoveReal() { + / * + virtualx += dx; + virtualy += dy; + actualx = (int)virtualx; + actualy = (int)virtualy; + * / + SpaceObject::MoveReal(); + + + / * TODO: + * Cleanup this code + * / + + / * + bool change = false; + + if ( actualx < 0 ) { + virtualx = 0; + dx *= -1; + change = true; + } + + if ( actualx > 640 ) { + virtualx = 640; + dx *= -1; + change = true; + } + + if ( actualy < 0 ) { + virtualy = 0; + dy *= -1; + change = true; + } + + if ( actualy > 480 ) { + virtualy = 480; + dy *= -1; + change = true; + } + + if ( change ) { + double ox = dx; + double oy = dy; + if ( !Damage(0) ) { + actualx = -100; + actualy = -100; + } + else { + dx = ox; + dy = oy; + } + } + * / +} +*/ --- rafkill-1.2.2.orig/build/weapons/weapon_yehat.h +++ rafkill-1.2.2/build/weapons/weapon_yehat.h @@ -0,0 +1,16 @@ +#ifndef _weapon_yehat_h +#define _weapon_yehat_h + +#include "weaponobj.h" +class SpaceObject; +class HullObject; + +class Yehat_Weapon:public WeaponNode{ +public: + Yehat_Weapon( int qx, int qy, double kx, double ky, HullObject * hnew, int al ); + virtual void Collided( SpaceObject * who, ExplosionClass ** explr, int M_EX ); +}; + + + +#endif --- rafkill-1.2.2.orig/debian/rafkill.6 +++ rafkill-1.2.2/debian/rafkill.6 @@ -0,0 +1,73 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH RAFKILL 6 "24 April 2003" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +Rafkill \- a vertical shoot'em-up +.SH SYNOPSIS +.B rafkill [ -l ] [ -w ] [ -g ] [ -h ] +.SH DESCRIPTION +.B Rafkill +is a clone of Raptor: Call of the Shadows, a classic shoot'em-up game. + +You have a bird's eye view of the playing field, which is an alien world, +and your job is to destroy the enemies that are flying towards you shooting +bullets. The score lets you buy life, shield, better weapons or even new +spaceships. + +Killing enemies gives you money, or score. If you kill a group of enemies, +you might get a handy coin which gives you more score. There are other +powerups, so look for them too. + +The score lets you buy more weapons and hull parts. There are 5 weapon groups +and a few weapons in each group, but you can only have one weapon per group +except for the accessory weapons in which you can have up to 3 weapons. Once +you buy 3, you cannot buy any more. There are 3 hulls, which have each higher +life and shield than the previous one and gives you access to a new set of +weapons. Buying a new hull does not throw away your weapons, but it does +throw away your accessory weapons. +.SH OPTIONS +.TP +\fB\-l\fR +run the game without displaying the background +.TP +\fB\-w\fR +run the game in windowed mode instead of full screen +.TP +\fB\-g\fR +run the game at a different speed (default is 40) +.TP +\fB\-h, \-help, \-\-help\fR +display help message and exit +.SH KEYS +.TP +.B Left, Right, Up, Down +move the ship across the screen +.TP +.B Space or Enter +fire the main weapon +.TP +.B Alt +switch between alternate weapons +.TP +.B Esc +return to the game menu +.BR +.SH AUTHOR +Rafkill was written by Jon Rafkind . + +This manual page was written by Sam Hocevar , +for the Debian GNU/Linux system (but may be used by others). --- rafkill-1.2.2.orig/debian/rafkill-data.preinst +++ rafkill-1.2.2/debian/rafkill-data.preinst @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ -L /usr/share/doc/rafkill-data ]; then + rm -f /usr/share/doc/rafkill-data +fi + +#DEBHELPER# + --- rafkill-1.2.2.orig/debian/copyright +++ rafkill-1.2.2/debian/copyright @@ -0,0 +1,23 @@ +This package was debianized by Sam Hocevar on +Thu, 24 Apr 2003 15:25:45 +0200. + +It was downloaded from http://raptorv2.sourceforge.net/ + +Upstream Author: Jon Rafkind + + This program 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, or (at your option) any + later version. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. --- rafkill-1.2.2.orig/debian/rafkill.xpm +++ rafkill-1.2.2/debian/rafkill.xpm @@ -0,0 +1,395 @@ +/* XPM */ +static char * foo_xpm[] = { +"32 32 360 2", +" c None", +". c #595C59", +"+ c #555755", +"@ c #4C4D4C", +"# c #565756", +"$ c #4E4F4E", +"% c #1F1E9A", +"& c #1D1E64", +"* c #2B2B2B", +"= c #6F6F6F", +"- c #6C6B6C", +"; c #2728C2", +"> c #0505FD", +", c #3939E6", +"' c #171783", +") c #20202F", +"! c #636666", +"~ c #707270", +"{ c #4F5251", +"] c #3D3F3D", +"^ c #616190", +"/ c #2A2CD7", +"( c #2B2CFF", +"_ c #3032FF", +": c #7F7EFE", +"< c #0404D4", +"[ c #02028C", +"} c #1C1C38", +"| c #464946", +"1 c #434343", +"2 c #2F3330", +"3 c #1E221E", +"4 c #6E7273", +"5 c #9C9EA2", +"6 c #555857", +"7 c #393B3B", +"8 c #201F20", +"9 c #707078", +"0 c #2527E8", +"a c #5050FF", +"b c #5B5BFF", +"c c #7070FE", +"d c #4646DA", +"e c #3030F5", +"f c #0102C1", +"g c #0B0B76", +"h c #2A292A", +"i c #5B5B5B", +"j c #9B9D9B", +"k c #5C5B5D", +"l c #424646", +"m c #232725", +"n c #606262", +"o c #9C9C9D", +"p c #5F5F60", +"q c #424243", +"r c #1F1F1F", +"s c #555555", +"t c #3031B8", +"u c #2F31FF", +"v c #8C8BFF", +"w c #4B4AF7", +"x c #7979C0", +"y c #626499", +"z c #2021F7", +"A c #181AE4", +"B c #0506A3", +"C c #292A3F", +"D c #5A5D5A", +"E c #C4C6C6", +"F c #676968", +"G c #565957", +"H c #252825", +"I c #555855", +"J c #7A7C7C", +"K c #646465", +"L c #4B4E4D", +"M c #252525", +"N c #797979", +"O c #383AE5", +"P c #5A5BFF", +"Q c #4949ED", +"R c #222384", +"S c #757677", +"T c #7A797A", +"U c #4747BF", +"V c #2425FB", +"W c #1112C4", +"X c #2C2C60", +"Y c #292A29", +"Z c #545654", +"` c #BFC1C2", +" . c #6E7072", +".. c #6C6E6F", +"+. c #252725", +"@. c #505051", +"#. c #5A5B5A", +"$. c #5D6060", +"%. c #4D4E4D", +"&. c #2B2C2B", +"*. c #AFADBC", +"=. c #393AF8", +"-. c #4142F7", +";. c #3C3CA2", +">. c #454649", +",. c #6E6E6E", +"'. c #787878", +"). c #7C7C83", +"!. c #3536DF", +"~. c #3132E5", +"{. c #161782", +"]. c #454745", +"^. c #565857", +"/. c #919392", +"(. c #676768", +"_. c #66686A", +":. c #262626", +"<. c #454748", +"[. c #4F524F", +"}. c #444644", +"|. c #2F3130", +"1. c #A09ECD", +"2. c #0B0CFF", +"3. c #3B3BD3", +"4. c #747479", +"5. c #424242", +"6. c #696969", +"7. c #737373", +"8. c #767776", +"9. c #6767A7", +"0. c #3737F8", +"a. c #1011A2", +"b. c #4C4B5C", +"c. c #595959", +"d. c #5E615F", +"e. c #5D5E5D", +"f. c #202221", +"g. c #3E423F", +"h. c #4D4F4D", +"i. c #4D524F", +"j. c #3D3E3F", +"k. c #2B2D2B", +"l. c #9896C5", +"m. c #0607FF", +"n. c #2F3093", +"o. c #6F706F", +"p. c #3C3D3C", +"q. c #666666", +"r. c #6E6D6E", +"s. c #6E6F6E", +"t. c #2326CD", +"u. c #1517B4", +"v. c #5B5B72", +"w. c #555655", +"x. c #5B5A5B", +"y. c #5B5D5D", +"z. c #484A49", +"A. c #1F2021", +"B. c #363836", +"C. c #484A48", +"D. c #474947", +"E. c #343736", +"F. c #585985", +"G. c #0102FF", +"H. c #6767A4", +"I. c #757675", +"J. c #343634", +"K. c #5A5A5A", +"L. c #676767", +"M. c #6B6A6B", +"N. c #6C6D6C", +"O. c #2022C5", +"P. c #1011B4", +"Q. c #73738A", +"R. c #4F5150", +"S. c #696B6C", +"T. c #555656", +"U. c #3D403E", +"V. c #212222", +"W. c #434545", +"X. c #404140", +"Y. c #2D2F31", +"Z. c #626262", +"`. c #7475A1", +" + c #0202FE", +".+ c #6768A0", +"++ c #7E7E7E", +"@+ c #575857", +"#+ c #656565", +"$+ c #636363", +"%+ c #636463", +"&+ c #1C1DC2", +"*+ c #0507AC", +"=+ c #6F6F87", +"-+ c #717371", +";+ c #474C4A", +">+ c #323637", +",+ c #1A1D1A", +"'+ c #383B38", +")+ c #414342", +"!+ c #343635", +"~+ c #2D2E2C", +"{+ c #595B59", +"]+ c #6E6F9B", +"^+ c #0000FA", +"/+ c #65649C", +"(+ c #707170", +"_+ c #353635", +":+ c #585858", +"<+ c #646464", +"[+ c #1113B5", +"}+ c #0101A1", +"|+ c #65647B", +"1+ c #686868", +"2+ c #656665", +"3+ c #4A4C4B", +"4+ c #3A3A3C", +"5+ c #1B1E1B", +"6+ c #303231", +"7+ c #3B3F3C", +"8+ c #363837", +"9+ c #2C2C2A", +"0+ c #5B5D5B", +"a+ c #6D6D99", +"b+ c #0102F9", +"c+ c #626298", +"d+ c #525152", +"e+ c #585758", +"f+ c #616061", +"g+ c #5F605F", +"h+ c #626362", +"i+ c #1213AF", +"j+ c #000096", +"k+ c #5F5E73", +"l+ c #535755", +"m+ c #2C2C2C", +"n+ c #4C4F4F", +"o+ c #414341", +"p+ c #3C3E3C", +"q+ c #292B29", +"r+ c #777677", +"s+ c #7D7B8A", +"t+ c #3232D2", +"u+ c #656599", +"v+ c #4F514F", +"w+ c #5C5D5C", +"x+ c #1518A6", +"y+ c #101180", +"z+ c #646569", +"A+ c #616361", +"B+ c #535555", +"C+ c #252625", +"D+ c #222322", +"E+ c #5B5C5B", +"F+ c #3B3E3D", +"G+ c #3E403E", +"H+ c #2C2E2C", +"I+ c #848384", +"J+ c #545560", +"K+ c #7C7C88", +"L+ c #666766", +"M+ c #706F70", +"N+ c #696A69", +"O+ c #404171", +"P+ c #48486E", +"Q+ c #6A696A", +"R+ c #807E80", +"S+ c #646769", +"T+ c #5B5C5C", +"U+ c #232624", +"V+ c #747374", +"W+ c #7C7B7C", +"X+ c #404340", +"Y+ c #454847", +"Z+ c #282A28", +"`+ c #868786", +" @ c #727272", +".@ c #7D7B7D", +"+@ c #818081", +"@@ c #7D7C7D", +"#@ c #676667", +"$@ c #676867", +"%@ c #6B6D6B", +"&@ c #414241", +"*@ c #595A59", +"=@ c #646664", +"-@ c #676869", +";@ c #5A5B5B", +">@ c #303330", +",@ c #474847", +"'@ c #494D4B", +")@ c #282828", +"!@ c #A2A2A2", +"~@ c #989998", +"{@ c #838383", +"]@ c #6C6C6C", +"^@ c #5E5F5E", +"/@ c #4B4C4B", +"(@ c #464546", +"_@ c #3F3F3F", +":@ c #5A5C5A", +"<@ c #5D5F5D", +"[@ c #3F3E3F", +"}@ c #545554", +"|@ c #5F5E5F", +"1@ c #666968", +"2@ c #3B3D3F", +"3@ c #212521", +"4@ c #363936", +"5@ c #2A2C2A", +"6@ c #6B696B", +"7@ c #494B4B", +"8@ c #272725", +"9@ c #797A79", +"0@ c #6A6B6A", +"a@ c #393939", +"b@ c #292829", +"c@ c #2E302E", +"d@ c #3C3B3C", +"e@ c #404240", +"f@ c #373937", +"g@ c #464846", +"h@ c #4A4B4A", +"i@ c #4E4E4E", +"j@ c #404442", +"k@ c #262826", +"l@ c #4A4C4A", +"m@ c #686768", +"n@ c #7C7C7C", +"o@ c #696968", +"p@ c #4D4F4F", +"q@ c #282926", +"r@ c #333533", +"s@ c #424342", +"t@ c #2C2F2C", +"u@ c #373737", +"v@ c #3E3D3F", +"w@ c #787A78", +"x@ c #373735", +"y@ c #2B2E2B", +"z@ c #343534", +"A@ c #232523", +"B@ c #4A4D4A", +"C@ c #4D504D", +"D@ c #515251", +"E@ c #515451", +"F@ c #444642", +"G@ c #595A58", +"H@ c #2D302D", +"I@ c #454645", +"J@ c #6E716E", +"K@ c #323432", +"L@ c #242524", +"M@ c #333233", +"N@ c #2F2F2F", +"O@ c #212221", +"P@ c #1C1E1C", +"Q@ c #646364", +"R@ c #1E2221", +"S@ c #1F211F", +" ", +" ", +" ", +" ", +" ", +" . + @ ", +" # $ % & * ", +" = - ; > , ' ) ", +" ! ~ { ] ^ / ( _ : < [ } | 1 2 3 ", +" 4 5 6 7 8 9 0 a b c d e f g h i j k l m ", +" n o p q r s t u v w x y z A B C D E F G H ", +" I J K L M N O P Q R S T U V W X Y Z ` ...+. ", +" @.#.$.%.&.*.=.-.;.>.,.'.).!.~.{.].^./.(._.:. ", +" <.[.# }.|.1.2.3.4.5.6.7.8.9.0.a.b.c.7.d.e.f. ", +" g.h.i.j.k.l.m.n.o.p.q.r.s.4.t.u.v.w.x.y.z.A. ", +" B.C.D.E.p.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V. ", +" J.W.X.Y.Z.`. +.+++@+s.#+$+%+&+*+=+-+#+;+>+,+ ", +" '+)+!+~+{+]+^+/+(+_+:+$+$+<+[+}+|+1+2+3+4+5+ ", +" 6+7+8+9+0+a+b+c+o.d+e+f+g+h+i+j+k+$+0+l+m+ ", +" n+o+p+q+r+s+t+u+= v+w.D w+Z.x+y+z+A+%+B+C+D+ ", +" E+F+G+H+I+f+J+K+r+L+M+h+L+N+O+P+Q+R+S+T+U+J. ", +" V+W+X+Y+Z+`+ @.@+@@@#@$@h.%@L+&@*@L.=@-@;@C+@ >@ ", +" I.+@,@'@)@!@~@{@]@^@/@(@_@:@<@[@}@:@|@1@2@3@4@5@ ", +" 6@N N.]@7@8@9@0@w+/@a@b@Z+c@d@e@f@g@h@i@ @j@k@l@J.Y ", +" i m@n@o@p@q@r@].s@ k@t@u@v@w@x@y@&@z@A@ ", +" B@C@D@E@F@G@H@+. I@J@K@L@M@N@O@P@ ", +" s@I@ Q@/@ R@ S@ ", +" ", +" ", +" ", +" ", +" "}; --- rafkill-1.2.2.orig/debian/rules +++ rafkill-1.2.2/debian/rules @@ -0,0 +1,79 @@ +#!/usr/bin/make -f +# debian/rules for rafkill - uses debhelper. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +build: build-stamp +build-stamp: + dh_testdir + QUILT_PATCHES=debian/patches quilt push -a || test $$? = 2 + mkdir install + mkdir bin + scons prefix=install bin=bin + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + scons --clean + rm -Rf install bin + rm -f rafkill.conf .sconsign.dblite + rm -Rf .sconf_temp + QUILT_PATCHES=debian/patches quilt pop -a -R || test $$? = 2 + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + + dh_installdirs -prafkill usr/games usr/share/doc usr/share/games/rafkill + dh_installdirs -prafkill-data usr/share/doc usr/share/games/rafkill + + scons install + + dh_install -prafkill-data install/rafkill/data usr/share/games/rafkill + dh_install -prafkill-data install/rafkill/music usr/share/games/rafkill + dh_install -prafkill install/rafkill/rafkill usr/games + + ln -s rafkill-data `pwd`/debian/rafkill/usr/share/doc/rafkill + + # Store our icon in the main package so that lintian does not + # complain about a missing icon. + cp debian/rafkill.xpm `pwd`/debian/rafkill/usr/share/games/rafkill/ + +# Build architecture-independent files here. +binary-indep: build install + dh_testdir + dh_testroot + dh_installdocs -i README + dh_installchangelogs -i + dh_link -i + dh_compress -i + dh_fixperms -i + dh_installdeb -i + dh_gencontrol -i + dh_md5sums -i + dh_builddeb -i + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installmenu -a + dh_installman -a debian/rafkill.6 + dh_link -a + dh_strip -a + dh_compress -a + dh_fixperms -a + dh_installdeb -a + dh_shlibdeps -a + dh_gencontrol -a + dh_md5sums -a + dh_builddeb -a + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install + --- rafkill-1.2.2.orig/debian/menu +++ rafkill-1.2.2/debian/menu @@ -0,0 +1,3 @@ +?package(rafkill):needs="X11" section="Games/Arcade" \ + title="Rafkill" command="/usr/games/rafkill" \ + icon="/usr/share/games/rafkill/rafkill.xpm" --- rafkill-1.2.2.orig/debian/rafkill.postinst +++ rafkill-1.2.2/debian/rafkill.postinst @@ -0,0 +1,13 @@ +#! /bin/sh + +DOCDIR="/usr/share/doc/rafkill" + +if [ -d "$DOCDIR" -a ! -L "$DOCDIR" ]; then + rmdir --ignore-fail-on-non-empty "$DOCDIR" + if [ ! -d "$DOCDIR" ]; then + ln -s rafkill-data "$DOCDIR" + fi +fi + +#DEBHELPER# + --- rafkill-1.2.2.orig/debian/changelog +++ rafkill-1.2.2/debian/changelog @@ -0,0 +1,199 @@ +rafkill (1.2.2-3.2) unstable; urgency=high + + * Non-maintainer upload. + * debian/patches/103_gcc_4.3_fixes: + + Fix paths to apply to src/ instead of build/. + + Fix more gcc-4.3 FTBFS problems (Closes: #474823). + * Remove debian/patches/patch and an extra copy of 103_gcc_4.3_fixes + in root of source tree, both introduced in last NMU. + + -- Ian Beckwith Thu, 10 Apr 2008 01:07:50 +0100 + +rafkill (1.2.2-3.1) unstable; urgency=low + + * Non-maintainer upload. + * debian/patches/103_gcc_4.3_fixes: + + Fix gcc-4.3 FTBFS, patch by tbm. (Closes: #417510) + + -- Marc 'HE' Brockschmidt Sun, 16 Mar 2008 23:16:02 +0100 + +rafkill (1.2.2-3) unstable; urgency=high + + * debian/patches/101_shatter_crash.diff: + + New patch from upstream's 1.2.3 branch, don't crash when using the + shatter gun (Closes: #379274). + + * debian/patches/102_fullscreen_crash.diff: + + Exit gracefully if the video mode (eg. fullscreen) could not be set + instead of crashing. + + -- Sam Hocevar (Debian packages) Sat, 10 Feb 2007 22:48:26 +0100 + +rafkill (1.2.2-2) unstable; urgency=high + + * debian/control: + + Added XS-Vcs-Svn field. + + * debian/patches/100_save_game_crash.diff: + + Save games in the home directory instead of $PWD (Closes: #406432) and + do not crash if the directory is not writable (Closes: #406646). + + -- Sam Hocevar (Debian packages) Fri, 9 Feb 2007 23:43:28 +0100 + +rafkill (1.2.2-1) unstable; urgency=low + + * New upstream release. + * This release really fixes the "maxout shield" price issue. + + * debian/patches/030_doc_spelling.diff: + + Patch was merged upstream. Dropping it. + + * debian/patches/020_missing_strdup.diff: + + Patch rendered unnecessary by upstream fix. Dropping it. + + -- Sam Hocevar (Debian packages) Fri, 9 Feb 2007 23:43:25 +0100 + +rafkill (1.2.1-3) unstable; urgency=low + + * debian/rakfill.postinst: + + Do not try to remove the symlink we just set (Closes: #375142). + + -- Sam Hocevar (Debian packages) Mon, 26 Jun 2006 11:07:28 +0200 + +rafkill (1.2.1-2) unstable; urgency=low + + * debian/rules: + + Properly clean the build tree in the clean rule, thanks to Damyan Ivanov + (Closes: #368812). + + -- Sam Hocevar (Debian packages) Sun, 11 Jun 2006 17:18:23 +0200 + +rafkill (1.2.1-1) unstable; urgency=low + + * New upstream release. + * Upstream merged many Debian bugfixes and improvements, as well as the + new title screen. + * debian/control: + + Set policy to 3.7.2. + + Build-depend on scons that upstream now uses. + + Removed build-dependencies on sharutils and bzip2. + * Got rid of the rafkill/rafkill-data dependency loop. + * "Maxout shield" is now far more expensive (Closes: #292742). + + -- Sam Hocevar (Debian packages) Tue, 16 May 2006 01:47:44 -0500 + +rafkill (1.2.0-4) unstable; urgency=low + + * debian/control: + + Build-depend on liballegro4.2-dev (>= 2:4.2.0-4) to fix the missing + libxcursor-dev build-dependency (Closes: #360195). + + Dropped the rafkill/rafkill-data circular dependency (Closes: #339892). + + -- Sam Hocevar (Debian packages) Fri, 31 Mar 2006 11:22:22 +0200 + +rafkill (1.2.0-3) unstable; urgency=low + + * Maintainer Upload. + * Acknowledging previous NMUs (Closes: #350167, #345248, #348808). Thanks + to AurĂ©lien Jarno and Steinar H. Gunderson. + + * Moved development to Alioth. + * debian/rules + + Switched to quilt for patch handling. + * debian/control: + + Build-depend on quilt. + + Build-depend on liballegro4.2-dev (>= 2:4.2.0-2) instead of + libxcursor-dev. + + -- Sam Hocevar (Debian packages) Thu, 30 Mar 2006 15:29:57 +0200 + +rafkill (1.2.0-2.2) unstable; urgency=low + + * Non-Maintainer Upload. + * Build-depends on liballegro4.2-dev instead of liballegro4-dev, and on + libxcursor-dev (closes: bug#350167). + + -- Aurelien Jarno Wed, 8 Feb 2006 00:06:10 +0100 + +rafkill (1.2.0-2.1) unstable; urgency=low + + * Non-Maintainer Upload. + * Rebuild against libaldmb1-dev, since libaldmb0-dev doesn't exist in + Debian anymore. Update Build-Depends accordingly. (Closes: #345248) + + -- Steinar H. Gunderson Thu, 19 Jan 2006 02:35:19 +0100 + +rafkill (1.2.0-2) unstable; urgency=low + + * g++ transition upload. + * debian/control: + + Set policy to 3.6.2.1. + * debian/changelog: + + Fixed the FSF address. + * debian/rules: + + Fixed build rules that caused _arch and _all packages to be created in + both the arch-dep and arch-indep targets. + + -- Sam Hocevar (Debian packages) Mon, 3 Oct 2005 23:13:50 +0200 + +rafkill (1.2.0-1) unstable; urgency=low + + * New upstream release (Closes: #259935). + * debian/rules: + + Use debian/compat instead of DH_COMPAT. + * debian/control: + + Set policy to 3.6.1.1. + + Set a strict versioned dependency for the -data package. + * debian/menu: + + Quoted strings where appropriate. + + -- Sam Hocevar (Debian packages) Thu, 29 Jul 2004 18:31:12 +0200 + +rafkill (1.1.0-6) unstable; urgency=low + + * This build contains the -data package. + + -- Sam Hocevar (Debian packages) Tue, 20 Jan 2004 15:37:39 +0100 + +rafkill (1.1.0-5) unstable; urgency=low + + * debian/rules: + + Build the arch-indep packages in the binary-indep rule (Closes: #214605). + + -- Sam Hocevar (Debian packages) Tue, 7 Oct 2003 19:30:09 +0200 + +rafkill (1.1.0-4) unstable; urgency=low + + * src/rfield.cpp: + + Duplicate the text handle with strdup() and free it with free(), not + delete[]. Fixes a crash when selling the main weapon (Closes: #198604). + * debian/control: + + Set policy to 3.6.1.0. + + Wrote more meaningful long descriptions (Closes: #209748). + + -- Sam Hocevar (Debian packages) Thu, 2 Oct 2003 15:17:21 +0200 + +rafkill (1.1.0-3) unstable; urgency=low + + * Fixed a massive memory leak in hull_weapon_machine.cpp, thanks to Danko + Miklos (Closes: #198212). + + -- Sam Hocevar (Debian packages) Sat, 21 Jun 2003 17:43:23 +0200 + +rafkill (1.1.0-2) unstable; urgency=low + + * debian/control: + + Forgot bzip2 in the build dependencies (Closes: #198000). + + -- Sam Hocevar (Debian packages) Thu, 19 Jun 2003 03:15:55 +0200 + +rafkill (1.1.0-1) unstable; urgency=low + + * First Debian release (Closes: #195490). + * Wrote a manpage for rafkill(6). + * Drew an icon for rafkill. + * Drew a splash screen which says "rafkill" instead of "raptor", and stored + it using "bzip2 -9 < logo.pcx | uuencode foo >| debian/newlogo.pcx.bz2.uu". + * Re-ran "aclocal-1.7 && automake-1.7 && autoconf". + + -- Sam Hocevar (Debian packages) Wed, 11 Jun 2003 15:06:39 +0200 --- rafkill-1.2.2.orig/debian/compat +++ rafkill-1.2.2/debian/compat @@ -0,0 +1 @@ +4 --- rafkill-1.2.2.orig/debian/control +++ rafkill-1.2.2/debian/control @@ -0,0 +1,32 @@ +Source: rafkill +Section: games +Priority: optional +Maintainer: Debian allegro packages maintainers +Uploaders: Sam Hocevar (Debian packages) +Build-Depends: debhelper (>= 4.0), quilt, scons, liballegro4.2-dev (>= 2:4.2.0-4), libaldmb1-dev +Standards-Version: 3.7.2 +XS-Vcs-Svn: svn://svn.debian.org/svn/pkg-allegro/unstable/rafkill/ + +Package: rafkill +Section: games +Architecture: any +Depends: rafkill-data, ${shlibs:Depends} +Description: vertical shoot'em-up similar to Raptor: Call of the Shadows + Rafkill is a clone of Raptor: Call of the Shadows, a classic shoot'em-up game. + . + You have a bird's eye view of the playing field, which is an alien world, + and your job is to destroy the enemies that are flying towards you shooting + bullets. The score lets you buy life, shield, better weapons or even new + spaceships. + . + Rafkill features three spaceships, more than twenty weapons, colourful + graphics with transparency effects, music and sound. + +Package: rafkill-data +Section: games +Architecture: all +Description: graphics and audio data for rafkill + Rafkill is a clone of Raptor: Call of the Shadows, a classic shoot'em-up game. + . + This package contains the architecture-independent data for rafkill. For more + information, see the rafkill package. --- rafkill-1.2.2.orig/debian/patches/100_save_game_crash.diff +++ rafkill-1.2.2/debian/patches/100_save_game_crash.diff @@ -0,0 +1,114 @@ +Index: rafkill-1.2.2/src/loadsave.cpp +=================================================================== +--- rafkill-1.2.2.orig/src/loadsave.cpp 2006-05-02 03:43:33.000000000 +0200 ++++ rafkill-1.2.2/src/loadsave.cpp 2007-02-10 13:58:13.000000000 +0100 +@@ -2,6 +2,7 @@ + */ + + #include "loadsave.h" ++#include "system.h" + #include + #include "spaceobj.h" + #include "strings.h" +@@ -50,15 +51,15 @@ + #endif + + /* savePlayer: +- * Saves the player in at player#.rap where # = game_slot ++ * Saves the player in at .rafkill#.rap where # = game_slot + */ + int savePlayer( SpaceObject * player, int game_slot ){ + + if ( player == NULL ) return 1; + printf("Save player\n"); + +- char filename[ 64 ]; +- snprintf( filename, 64, "player%d.rap", game_slot ); ++ char filename[ 2048 + 64 ]; ++ snprintf( filename, 2048 + 64, "%s/.rafkill%d.rap", System::getHomeDirectory().c_str(), game_slot ); + + // PlayerHull * hull = dynamic_cast(player->getHull()); + PlayerHull * hull = (PlayerHull *)(player->getHull() ); +@@ -101,8 +102,10 @@ + + // printf("Save string = %s\n", final ); + FILE * fv = fopen( filename, "wb" ); +- fwrite( final, sizeof(char), strlen(final), fv ); +- fclose( fv ); ++ if( fv != NULL ) { ++ fwrite( final, sizeof(char), strlen(final), fv ); ++ fclose( fv ); ++ } + + return 0; + +@@ -247,8 +250,8 @@ + + FILE * fv; + +- char filename[ 64 ]; +- snprintf( filename, 64, "player%d.rap", game_slot ); ++ char filename[ 2048 + 64 ]; ++ snprintf( filename, 2048 + 64, "%s/.rafkill%d.rap", System::getHomeDirectory().c_str(), game_slot ); + fv = fopen( filename, "rb" ); + if ( fv == NULL ){ + printf("Could not open %s\n", filename ); +Index: rafkill-1.2.2/src/menu.cpp +=================================================================== +--- rafkill-1.2.2.orig/src/menu.cpp 2006-08-23 02:39:42.000000000 +0200 ++++ rafkill-1.2.2/src/menu.cpp 2007-02-10 13:58:13.000000000 +0100 +@@ -2,6 +2,7 @@ + #include "defs.h" + #include "menu.h" + #include "loadsave.h" ++#include "system.h" + #include "trigtable.h" + #include "strings.h" + #include +@@ -610,8 +611,8 @@ + char * menuClass::getFileInfo( int number ){ + + char * temp = (char *)malloc( sizeof(char) * 1024 ); +- char buf[ 64 ]; +- sprintf( buf, "player%d.rap", number+1 ); ++ char buf[ 2048 + 64 ]; ++ sprintf( buf, "%s/.rafkill%d.rap", System::getHomeDirectory().c_str(), number+1 ); + FILE * fv = fopen( buf, "rb" ); + if ( !fv ){ + sprintf( temp, "Slot %d Empty", number+1 ); +Index: rafkill-1.2.2/src/raptor.cpp +=================================================================== +--- rafkill-1.2.2.orig/src/raptor.cpp 2006-08-22 04:28:18.000000000 +0200 ++++ rafkill-1.2.2/src/raptor.cpp 2007-02-10 13:58:13.000000000 +0100 +@@ -12,6 +12,7 @@ + #include + #include + #include "loadsave.h" ++#include "system.h" + #include "defs.h" + #include "ebox.h" + #include "raptor.h" +@@ -217,8 +218,8 @@ + + menu->clear(); + for ( int q = 0; q < 6; q++ ){ +- char filename[ 64 ]; +- snprintf( filename, 64, "player%d.rap", q+1 ); ++ char filename[ 2048 + 64 ]; ++ snprintf( filename, 2048 + 64, "%s/.rafkill%d.rap", System::getHomeDirectory().c_str(), q+1 ); + if ( Util::exists( filename ) ){ + time_t tl = Util::fileTime( filename ); + struct tm * real_time = localtime( &tl ); +Index: rafkill-1.2.2/src/defs.cpp +=================================================================== +--- rafkill-1.2.2.orig/src/defs.cpp 2007-02-10 13:58:17.000000000 +0100 ++++ rafkill-1.2.2/src/defs.cpp 2007-02-10 13:58:43.000000000 +0100 +@@ -133,7 +133,7 @@ + } + + bool Util::exists( const char * filename ){ +- return ::exists( filename ); ++ return ::file_exists( filename, FA_ALL, NULL ); + } + + const char * Util::getOS() { --- rafkill-1.2.2.orig/debian/patches/102_fullscreen_crash.diff +++ rafkill-1.2.2/debian/patches/102_fullscreen_crash.diff @@ -0,0 +1,15 @@ +Index: rafkill-1.2.2/src/bitmap.cpp +=================================================================== +--- rafkill-1.2.2.orig/src/bitmap.cpp 2007-02-11 00:37:39.000000000 +0100 ++++ rafkill-1.2.2/src/bitmap.cpp 2007-02-11 00:38:44.000000000 +0100 +@@ -478,6 +478,10 @@ + + static int setGfxMode( int mode, int x, int y ){ + int ret = ::set_gfx_mode( mode, x, y, 0, 0 ); ++ if ( ::screen == NULL ){ ++ cerr << "Could not set graphics mode! (try -w)" << endl; ++ exit(-1); ++ } + if ( Bitmap::Screen != NULL ){ + delete Bitmap::Screen; + } --- rafkill-1.2.2.orig/debian/patches/101_shatter_crash.diff +++ rafkill-1.2.2/debian/patches/101_shatter_crash.diff @@ -0,0 +1,157 @@ +diff -puriN rafkill-1.2.2/src/hulls/hull_weapon_shatter.cpp rafkill-1.2.3/src/hulls/hull_weapon_shatter.cpp +--- rafkill-1.2.2/src/hulls/hull_weapon_shatter.cpp 2006-04-03 02:14:04 +0200 ++++ rafkill-1.2.3/src/hulls/hull_weapon_shatter.cpp 2006-09-30 03:20:42 +0200 +@@ -18,13 +18,15 @@ bool Shatter_WHull::Collide( int mx, int + if ( check->HitMe( mx, my ) ) + return true; + +- for ( int ang = 0; ang < 360; ang += 65 ) { +- +- int tx = (int)(mx + Tcos(ang)*strength ); +- int ty = (int)(my + Tsine(ang)*strength ); +- if ( check->HitMe( tx, ty ) ) +- return true; ++ for ( double f = 2; f < getStrength(); f += 3 ){ ++ for ( int ang = 0; ang < 360; ang += 60 ) { + ++ int tx = (int)(mx + Tcos(ang) * f ); ++ int ty = (int)(my + Tsine(ang) * f ); ++ if ( check->HitMe( tx, ty ) ){ ++ return true; ++ } ++ } + } + + return false; +diff -puriN rafkill-1.2.2/src/hull.cpp rafkill-1.2.3/src/hull.cpp +--- rafkill-1.2.2/src/hull.cpp 2006-05-02 05:39:39 +0200 ++++ rafkill-1.2.3/src/hull.cpp 2006-09-29 03:28:21 +0200 +@@ -25,9 +25,9 @@ using namespace std; + HullObject::HullObject( Bitmap * _drawBitmap, double _life, double _strength, int num_guns, int level, int _drawing_plane, bool _trans, ECollide * ec): + crash( false ), + trans( _trans ), +-strength( _strength ), + drawLevel( _drawing_plane ), + guns( NULL ), ++strength( _strength ), + max_guns( num_guns ) { + myBitmap = _drawBitmap; + Shadow_Bitmap = NULL; +diff -puriN rafkill-1.2.2/src/hull.h rafkill-1.2.3/src/hull.h +--- rafkill-1.2.2/src/hull.h 2006-05-02 05:39:36 +0200 ++++ rafkill-1.2.3/src/hull.h 2006-09-29 03:28:50 +0200 +@@ -45,6 +45,10 @@ public: + //process: returns whether or not hull can be hit by bullets + bool Translucent(); + ++ virtual inline const double getStrength() const{ ++ return strength; ++ } ++ + virtual inline int getHeight(){ + if ( myBitmap ) return myBitmap->getHeight(); + if ( collide ) return collide->getHeight(); +@@ -111,7 +115,6 @@ public: + double original_life; + bool trans; + +- double strength; + + int drawNum; + int drawLevel; +@@ -121,6 +124,8 @@ protected: + Bitmap * Shadow_Bitmap; + WeaponObject ** guns; + ECollide * collide; ++ ++ double strength; + + public: + +diff -puriN rafkill-1.2.2/src/spaceobj.cpp rafkill-1.2.3/src/spaceobj.cpp +--- rafkill-1.2.2/src/spaceobj.cpp 2006-05-07 05:51:24 +0200 ++++ rafkill-1.2.3/src/spaceobj.cpp 2006-09-29 03:14:54 +0200 +@@ -75,6 +75,10 @@ void SpaceObject::MoveMe( vector< SpaceO + // return ( actualx < -20 || actualx > screen_x + 20 || actualy < -10 || actualy > screen_y + 20 ); + } + ++void SpaceObject::destroy( vector< SpaceObject * > * objects ){ ++ /* do nothing */ ++} ++ + void SpaceObject::addSection( Section * onscreen ){ + if ( hull ) hull->addSection( this, onscreen, actualx, actualy ); + } +diff -puriN rafkill-1.2.2/src/spaceobj.h rafkill-1.2.3/src/spaceobj.h +--- rafkill-1.2.2/src/spaceobj.h 2006-05-07 03:52:43 +0200 ++++ rafkill-1.2.3/src/spaceobj.h 2006-09-29 03:40:47 +0200 +@@ -70,6 +70,11 @@ public: + // fight - array of pointers to ships + virtual void MoveMe( vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight, Section * onscreen ); + ++ /* the absolute last method called on this object. ++ * gives this object a chance to spawn new objects ++ */ ++ virtual void destroy( vector< SpaceObject * > * objects ); ++ + //process: changes check according to death of object + virtual void Died(SpaceObject * check,ExplosionClass ** explr, int ME ); + +diff -puriN rafkill-1.2.2/src/weapons/weapon_shatter.cpp rafkill-1.2.3/src/weapons/weapon_shatter.cpp +--- rafkill-1.2.2/src/weapons/weapon_shatter.cpp 2006-05-02 03:19:50 +0200 ++++ rafkill-1.2.3/src/weapons/weapon_shatter.cpp 2006-09-30 03:14:14 +0200 +@@ -9,7 +9,7 @@ + + Shatter::Shatter( int qx, int qy, double kx, double ky, HullObject * hnew, int al, vector< SpaceObject * > * Ammo ): + WeaponNode(qx,qy,kx,ky,hnew, al) { +- myAmmo = Ammo; ++ // myAmmo = Ammo; + } + + bool Shatter::Damage( double much ) { +@@ -19,11 +19,25 @@ bool Shatter::Damage( double much ) { + // return ( getLife() <= 0 ); + } + ++void Shatter::destroy( vector< SpaceObject * > * objects ){ ++ for ( int q = 0; q < hull->getStrength() * 4; q++ ) { ++ int ang = Util::rnd( 360 ); ++ double speed = 8 + (double)Util::rnd( 20 ) / 5.0; ++ ++ HullObject * add_h = new Machine_WHull( 1 ); ++ add_h->life = hull->getStrength() / 3 + 1; ++ objects->push_back( new Bounce(getX(),getY(),Tcos(ang)*speed,Tsine(ang)*speed,add_h,alignment ) ); ++ ++ //myAmmo->add( new Shatter(actualx,actualy,tcos[ang]*2.1,tsine[ang]*2.1, new Shatter_WHull(hull->strength/2), alignment, myAmmo ) ); ++ } ++} ++ + void Shatter::Died(SpaceObject * check,ExplosionClass ** explr,int ME ){ + + Util::playSound( SND_SUSTAIN, 50 ); + Explode( explr, ME ); + ++ /* + if ( myAmmo == NULL ) return; + for ( int q = 0; q < hull->strength*3; q++ ) { + int ang = Util::rnd( 360 ); +@@ -34,5 +48,6 @@ void Shatter::Died(SpaceObject * check,E + + //myAmmo->add( new Shatter(actualx,actualy,tcos[ang]*2.1,tsine[ang]*2.1, new Shatter_WHull(hull->strength/2), alignment, myAmmo ) ); + } ++ */ + + } +diff -puriN rafkill-1.2.2/src/weapons/weapon_shatter.h rafkill-1.2.3/src/weapons/weapon_shatter.h +--- rafkill-1.2.2/src/weapons/weapon_shatter.h 2006-05-02 03:11:48 +0200 ++++ rafkill-1.2.3/src/weapons/weapon_shatter.h 2006-09-29 03:22:33 +0200 +@@ -15,8 +15,7 @@ public: + + virtual bool Damage( double much ); + virtual void Died(SpaceObject * check,ExplosionClass ** explr, int ME ); +-protected: +- vector< SpaceObject * > * myAmmo; ++ void destroy( vector< SpaceObject * > * objects ); + }; + + #endif --- rafkill-1.2.2.orig/debian/patches/103_gcc_4.3_fixes +++ rafkill-1.2.2/debian/patches/103_gcc_4.3_fixes @@ -0,0 +1,106 @@ +Index: rafkill-1.2.2/src/guns/gun_findgun.cpp +=================================================================== +--- rafkill-1.2.2.orig/src/guns/gun_findgun.cpp 2006-05-07 15:50:04.000000000 +0100 ++++ rafkill-1.2.2/src/guns/gun_findgun.cpp 2008-04-09 22:54:54.000000000 +0100 +@@ -5,6 +5,7 @@ + #include "weaponobj.h" + #include "hulls/hull_weapon_machine.h" + #include "spaceobj.h" ++#include + #include + #include + +Index: rafkill-1.2.2/src/guns/gun_machine_circle.cpp +=================================================================== +--- rafkill-1.2.2.orig/src/guns/gun_machine_circle.cpp 2006-05-02 02:50:40.000000000 +0100 ++++ rafkill-1.2.2/src/guns/gun_machine_circle.cpp 2008-04-09 22:54:54.000000000 +0100 +@@ -3,6 +3,7 @@ + #include "weaponobj.h" + #include "hulls/hull_weapon_machine.h" + #include "trigtable.h" ++#include + + // #define d_circle_move (2.9*8) + +Index: rafkill-1.2.2/src/guns/gun_saber.cpp +=================================================================== +--- rafkill-1.2.2.orig/src/guns/gun_saber.cpp 2006-05-02 02:52:23.000000000 +0100 ++++ rafkill-1.2.2/src/guns/gun_saber.cpp 2008-04-09 22:54:54.000000000 +0100 +@@ -5,6 +5,7 @@ + #include "weapons/weapon_beam.h" + #include "spaceobj.h" + #include "ebox.h" ++#include + #include + + using namespace std; +Index: rafkill-1.2.2/src/menu.cpp +=================================================================== +--- rafkill-1.2.2.orig/src/menu.cpp 2008-04-09 22:53:35.000000000 +0100 ++++ rafkill-1.2.2/src/menu.cpp 2008-04-09 22:54:54.000000000 +0100 +@@ -1,4 +1,5 @@ + #include ++#include + #include "defs.h" + #include "menu.h" + #include "loadsave.h" +Index: rafkill-1.2.2/src/weapons/weapon_follow.cpp +=================================================================== +--- rafkill-1.2.2.orig/src/weapons/weapon_follow.cpp 2006-03-25 23:29:05.000000000 +0000 ++++ rafkill-1.2.2/src/weapons/weapon_follow.cpp 2008-04-09 22:54:54.000000000 +0100 +@@ -3,6 +3,7 @@ + #include "weapon_follow.h" + #include "hulls/hull_weapon_follow.h" + #include "spaceobj.h" ++#include + #include + + using namespace std; +Index: rafkill-1.2.2/src/hulls/hull_weapon_beam.cpp +=================================================================== +--- rafkill-1.2.2.orig/src/hulls/hull_weapon_beam.cpp 2006-05-02 03:12:50.000000000 +0100 ++++ rafkill-1.2.2/src/hulls/hull_weapon_beam.cpp 2008-04-09 22:54:54.000000000 +0100 +@@ -4,6 +4,7 @@ + #include "hull_weapon_beam.h" + #include "trigtable.h" + #include "ebox.h" ++#include + + #ifndef debug + #include +Index: rafkill-1.2.2/src/drawer.cpp +=================================================================== +--- rafkill-1.2.2.orig/src/drawer.cpp 2008-04-09 22:55:06.000000000 +0100 ++++ rafkill-1.2.2/src/drawer.cpp 2008-04-09 22:55:55.000000000 +0100 +@@ -11,6 +11,7 @@ + #include "trigtable.h" + #include "pck.h" + #include ++#include + + /* TODO: + * Add weapon icons to HUD +Index: rafkill-1.2.2/src/loadsave.cpp +=================================================================== +--- rafkill-1.2.2.orig/src/loadsave.cpp 2008-04-09 22:55:19.000000000 +0100 ++++ rafkill-1.2.2/src/loadsave.cpp 2008-04-09 22:55:55.000000000 +0100 +@@ -7,6 +7,7 @@ + #include "spaceobj.h" + #include "strings.h" + #include ++#include + #include + #include "gunobj.h" + #include "hull.h" +Index: rafkill-1.2.2/src/system.cpp +=================================================================== +--- rafkill-1.2.2.orig/src/system.cpp 2008-04-09 22:55:29.000000000 +0100 ++++ rafkill-1.2.2/src/system.cpp 2008-04-09 22:55:55.000000000 +0100 +@@ -1,6 +1,7 @@ + #include "system.h" + #include + #include ++#include + + #ifdef WINDOWS + static const char * type(){ --- rafkill-1.2.2.orig/debian/patches/series +++ rafkill-1.2.2/debian/patches/series @@ -0,0 +1,5 @@ +000_install_path.diff +100_save_game_crash.diff +101_shatter_crash.diff -p1 +102_fullscreen_crash.diff +103_gcc_4.3_fixes --- rafkill-1.2.2.orig/debian/patches/000_install_path.diff +++ rafkill-1.2.2/debian/patches/000_install_path.diff @@ -0,0 +1,13 @@ +Index: rafkill-1.2.2/SConstruct +=================================================================== +--- rafkill-1.2.2.orig/SConstruct 2006-08-23 02:40:57.000000000 +0200 ++++ rafkill-1.2.2/SConstruct 2007-02-09 23:56:28.000000000 +0100 +@@ -46,7 +46,7 @@ + # print "Install directory = $prefix" + # print "Directory where symlinked binary will go = $bin" + +-flags = [ '-g3', '-Wall', '-fno-rtti', '-Woverloaded-virtual', '-O2', '-DINSTALL_DIR=\\\"$prefix\\\"' ]; ++flags = [ '-g3', '-Wall', '-fno-rtti', '-Woverloaded-virtual', '-O2', '-DINSTALL_DIR=\\\"/usr/share/games\\\"' ]; + env.Append( CCFLAGS = flags, CPPPATH = [ "build" ] ) + + # SConscript( 'src/SConscript', build_dir='build', exports = 'env' );