/* etc.h - Contains everything which is not somewhere else Copyright (C) 2006 Mark boyd 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 of the License, or (at your option) any later version. This program is distributed in the hope that it will be fun to play, 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef ETC_H #define ETC_H #include #include #include //constant constants const double pi=4.0*std::atan(1.0); const int TILE_SIZE=32; //ship constants const float d_angle=0.1; const int ship_empty_mass=8; const float ship_base_battery=10; const float ship_base_generate=0.05; const int system_slots=20; const float MAX_INVULNERABILITY=5; //seconds const int ball_mass=15; //laws of physics :) const float tractor_force = 1875; const float tractor_elastic = 128; const float gravity = 43.75; //in pixels/second^2 const float air_resistance = 1.0; const int MAX_SHIELD=10; Uint32 getpixel(SDL_Surface *surface, int x, int y); void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel); float dist(float x, float y); enum alphanity { alpha_channel, no_alpha_channel }; SDL_Surface *create_surface(int w, int h, alphanity a = alpha_channel); void rotate(SDL_Surface *from, SDL_Surface *to, double angle); //Returns the closest point to mid in the range [min,max] template T minmax(T min, T mid, T max) {return std::max(min, std::min(max, mid));} //U(0,1) inline float randu() {return 1.0*rand()/RAND_MAX;} //Random integer from 0 to i-1 int randint(int i); //N(0,1) float randn(); class do_later { public: do_later (void (*fn)()){m_fn=fn;} ~do_later() {(*m_fn)();} private: void (*m_fn)(); }; std::string int2str(int i); void fade_out(SDL_Surface *screen, SDL_Rect rect); void update_player_status(SDL_Surface *screen); //Useful for creating and filling containers. //(make >(),t1,t2,t3,t4,t5) is castable to container namespace private_ { template class nasty { T m_t; public: nasty &operator,(const typename T::value_type &v) {m_t.insert(m_t.end(), v); return *this;} operator T() {return m_t;} }; } template private_::nasty make(){return private_::nasty();} int calc_ship_mass(); float calc_ship_battery(); float calc_ship_generate(); //typedefs for the shot class class mover; typedef void detonation_fn_t(mover *, mover *); typedef void expiration_fn_t(mover *); #endif