From: <the...@us...> - 2007-06-12 11:59:51
|
Revision: 26 http://qonk.svn.sourceforge.net/qonk/?rev=26&view=rev Author: thebohemian Date: 2007-06-12 04:59:50 -0700 (Tue, 12 Jun 2007) Log Message: ----------- - merged changes from autoconf branch back into trunk - fix for autogen.sh to copy missing files - fix for src/fonts.cpp to allow running the game from the source directory Added Paths: ----------- trunk/Makefile.am trunk/autogen.sh trunk/config.h.in trunk/configure.ac trunk/data/ trunk/data/Makefile.am trunk/data/font.ttf trunk/src/ trunk/src/Makefile.am trunk/src/actions.cpp trunk/src/actions.h trunk/src/animations.cpp trunk/src/animations.h trunk/src/canvas.cpp trunk/src/canvas.h trunk/src/coordinate.cpp trunk/src/coordinate.h trunk/src/extensions.cpp trunk/src/extensions.h trunk/src/fonts.cpp trunk/src/fonts.h trunk/src/main.cpp trunk/src/messages.cpp trunk/src/messages.h trunk/src/planets.cpp trunk/src/planets.h trunk/src/players.cpp trunk/src/players.h trunk/src/readconf.cpp trunk/src/readconf.h trunk/src/selection.cpp trunk/src/selection.h trunk/src/settings.cpp trunk/src/settings.h trunk/src/ships.cpp trunk/src/ships.h trunk/src/stars.cpp trunk/src/stars.h trunk/src/timer.cpp trunk/src/timer.h trunk/src/universe.cpp trunk/src/universe.h Removed Paths: ------------- trunk/Makefile trunk/ReadConf.cpp trunk/ReadConf.h trunk/actions.cpp trunk/actions.h trunk/animations.cpp trunk/animations.h trunk/config.cpp trunk/config.h trunk/coordinate.cpp trunk/coordinate.h trunk/data/Makefile.am trunk/data/font.ttf trunk/extensions.cpp trunk/extensions.h trunk/font.ttf trunk/fonts.cpp trunk/fonts.h trunk/main.cpp trunk/messages.cpp trunk/messages.h trunk/planets.cpp trunk/planets.h trunk/players.cpp trunk/players.h trunk/selection.cpp trunk/selection.h trunk/ships.cpp trunk/ships.h trunk/src/Makefile.am trunk/src/actions.cpp trunk/src/actions.h trunk/src/animations.cpp trunk/src/animations.h trunk/src/canvas.cpp trunk/src/canvas.h trunk/src/coordinate.cpp trunk/src/coordinate.h trunk/src/extensions.cpp trunk/src/extensions.h trunk/src/fonts.cpp trunk/src/fonts.h trunk/src/main.cpp trunk/src/messages.cpp trunk/src/messages.h trunk/src/planets.cpp trunk/src/planets.h trunk/src/players.cpp trunk/src/players.h trunk/src/readconf.cpp trunk/src/readconf.h trunk/src/selection.cpp trunk/src/selection.h trunk/src/settings.cpp trunk/src/settings.h trunk/src/ships.cpp trunk/src/ships.h trunk/src/stars.cpp trunk/src/stars.h trunk/src/timer.cpp trunk/src/timer.h trunk/src/universe.cpp trunk/src/universe.h trunk/stars.cpp trunk/stars.h trunk/timer.cpp trunk/timer.h trunk/universe.cpp trunk/universe.h Deleted: trunk/Makefile =================================================================== --- trunk/Makefile 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/Makefile 2007-06-12 11:59:50 UTC (rev 26) @@ -1,59 +0,0 @@ -PREFIX=/home/rob/INSTALL/qonk -BIN=/home/rob/INSTALL/qonk/bin - -CXX=g++ -CFLAGS=`sdl-config --cflags` -O3 -LIBS=`sdl-config --libs` -lSDL_ttf -lSDL_gfx - -WCC=i586-mingw32msvc-g++ -WC=i586-mingw32msvc-gcc -WCFLAGS=-c -WLDFLAGS=-lmingw32 -lSDLmain -lSDL -lSDL_ttf -lSDL_gfx -WLIBS=-lmingw32 -lSDLmain -lSDL -lSDL_ttf -lSDL_gfx - -OBJECTS=extensions.o coordinate.o stars.o planets.o selection.o ships.o main.o actions.o players.o universe.o animations.o fonts.o messages.o timer.o config.o ReadConf.o - -all: qonk - -qonk: $(OBJECTS) - $(CXX) $(CFLAGS) $(LIBS) $(OBJECTS) -o qonk - -windows: wob - $(WCC) $(WLDFLAGS) $(OBJECTS) -o qonk.exe $(WLIBS) - -wob: - $(WCC) $(WCFLAGS) *.cpp - -.cpp.o: - $(CXX) $(CFLAGS) -c $< - -clean: - @rm -vf *.o *~ qonk screenshot.bmp DEADJOE - -dist: clean - mkdir -p qonk/ - cp *.cpp qonk/ - cp *.h qonk/ - cp Makefile qonk/ - cp TODO qonk/ - cp README qonk/ - cp COPYING qonk/ - cp font.ttf qonk/ - cp qonk.conf qonk/ - tar -cvzf ../qonk.tar.gz qonk/ - rm -rf qonk/ - -install: all - mkdir -p $(PREFIX)/qonk - mkdir -p $(BIN) - cp qonk $(PREFIX)/qonk/ - cp font.ttf $(PREFIX)/qonk/ - cp qonk.conf $(PREFIX)/qonk/ - echo "cd $(PREFIX)/qonk" > $(BIN)/qonk - echo "./qonk" >> $(BIN)/qonk - chmod +x $(BIN)/qonk - - -uninstall: - rm -rf $(PREFIX)/qonk - rm $(BIN)/qonk Copied: trunk/Makefile.am (from rev 25, branches/autoconf-2007-03-26-thebohemian/Makefile.am) =================================================================== --- trunk/Makefile.am (rev 0) +++ trunk/Makefile.am 2007-06-12 11:59:50 UTC (rev 26) @@ -0,0 +1,4 @@ +SUBDIRS = src data + +EXTRA_DIST = README COPYING missing Makefile.manual TODO + Deleted: trunk/ReadConf.cpp =================================================================== --- trunk/ReadConf.cpp 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/ReadConf.cpp 2007-06-12 11:59:50 UTC (rev 26) @@ -1,91 +0,0 @@ -#include "ReadConf.h" - -Config::Config( const std::string& configFileName ){ - std::ifstream file( configFileName.c_str() ); - while (!file.eof()){ - std::string line; - getline( file, line ); - std::string::size_type loc = line.find( "=", 0 ); - if( line[0] != '#' ) - if( loc != std::string::npos ) { - std::string parameter = stripWhiteSpace( line.substr( 0, loc ) ); - std::string value = stripWhiteSpace( line.substr( loc + 1 ) ); - data[ parameter ] = value; - } - } - file.close(); - std::cout << "config file read" << std::endl; -} - -std::string -Config::getValue( const std::string& parameter ) const { - std::map< std::string, std::string >::const_iterator i = data.find( parameter ); - if( i != data.end() ) - return i->second; - else - return ""; -} - -bool -Config::getValueBOOL( const std::string& parameter ) const { - std::string s = getValue(parameter); - return str2bool(s); -} - -int -Config::getValueINT( const std::string& parameter ) const { - std::string s = getValue(parameter); - return str2int(s); -} - -void -Config::print() const { - for( std::map< std::string, std::string >::const_iterator i = data.begin(); i != data.end(); i++ ) - std::cout << "'" << i->first << "' => '" << i->second << "'" << std::endl; -} - -bool -fileExists( const std::string& fileName ) { - std::ifstream infile( fileName.c_str() ); - bool result = infile.good(); - infile.close(); - return result; -} - -void -createFile( const std::string& fileName, std::vector< std::string > content ){ - if( !fileExists( fileName ) ){ - std::ofstream outfile( fileName.c_str() ); - for( std::vector< std::string >::const_iterator iter = content.begin(); iter != content.end(); iter++ ) { - outfile.write( (*iter).data(), (*iter).size() ); - outfile.write( "\n", 1 ); - } - outfile.close(); - } -} - -bool -str2bool( const std::string& s ) { - if (s == std::string("true")) { - return true; - } else if (s == std::string("false")){ - return false; - } else { - std::cerr << "Invalid bool type"; - } -} - -int -str2int( const std::string& s ) { - std::istringstream i(s); - int x; - i>>x; - return x; -} - -std::string -stripWhiteSpace( const std::string& original ) { - int begin = original.find_first_not_of( " " ); - int end = original.find_last_not_of( " " ); - return original.substr( begin, end - begin + 1 ); -} Deleted: trunk/ReadConf.h =================================================================== --- trunk/ReadConf.h 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/ReadConf.h 2007-06-12 11:59:50 UTC (rev 26) @@ -1,36 +0,0 @@ -// ReadConf.h -// Class for reading named values from configuration files -// Troels Kofoed Jacobsen, Mar 19 2007, tkj...@gm... -// Licensed under GPLv2 -#ifndef READCONF_H -#define READCONF_H - -#include <string> -#include <map> -#include <vector> -#include <fstream> -#include <iostream> -#include <cctype> -#include <sstream> - -class Config { -public: - Config( const std::string& fileName ); - - std::string getValue( const std::string& parameter ) const; - bool getValueBOOL( const std::string& parameter ) const; - int getValueINT( const std::string& parameter ) const; - - void print() const; - -private: - std::map< std::string, std::string > data; -}; - -bool fileExists( const std::string& ); -void createFile( const std::string&, std::vector< std::string > ); -bool str2bool(const std::string& ); -int str2int(const std::string& ); -std::string stripWhiteSpace( const std::string& ); - -#endif Deleted: trunk/actions.cpp =================================================================== --- trunk/actions.cpp 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/actions.cpp 2007-06-12 11:59:50 UTC (rev 26) @@ -1,74 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "actions.h" - -#include "config.h" -#include <iostream> - -// ##### ACTION ##### - -Action::Action() { - actionID = 0; -} - -void -Action::setActionQueue( ActionQueue* actionQueue ) { - this->actionQueue = actionQueue; -} - -ActionQueue* -Action::getActionQueue() const { - return actionQueue; -} - -// ##### ACTIONQUEUE ##### - -ActionQueue::ActionQueue() { - clear(); - time = 0; -} - -void -ActionQueue::scheduleAction( Uint32 time, Action* action ) { - if( this->time > time ) { - std::cerr << "Action was inserted before action that has already been executed" << endl; - } - action->setActionQueue( this ); - insert( pair< Uint32, Action* >( time, action ) ); -} - -Uint32 -ActionQueue::timeOfNextEvent() { - return this->begin()->first; -} - -void -ActionQueue::executeNextEvent() { - time = this->begin()->first; - Action* a = this->begin()->second; -// if( time > timer.getTime() ) { -// SDL_Delay( time - timer.getTime() ); -// } - a->execute( time ); - erase( this->begin() ); - delete a; -} - -void -ActionQueue::executeAllEvents() { - while( size() > 0 ) { - executeNextEvent(); - } -} - -void ActionQueue::executeEventsBefore( Uint32 time ) { - while( ( size() > 0 ) && ( timeOfNextEvent() < time ) ) { - executeNextEvent(); - } -} - -void -ActionQueue::executePastEvents() { - executeEventsBefore( timer.getTime() ); -} - Deleted: trunk/actions.h =================================================================== --- trunk/actions.h 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/actions.h 2007-06-12 11:59:50 UTC (rev 26) @@ -1,41 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef ACTIONS_H -#define ACTIONS_H - -#include <SDL/SDL.h> -#include <map> -using namespace std; - -class ActionQueue; - -class Action { -private: - ActionQueue* actionQueue; -protected: - int actionID; -public: - Action(); - virtual void execute( const Uint32& time ) = 0; - virtual ~Action() {} - void setActionQueue( ActionQueue* actionQueue ); - ActionQueue* getActionQueue() const; - int getActionID() { return actionID; } -}; - -class ActionQueue : public multimap< Uint32, Action* > { -private: - Uint32 time; -public: - ActionQueue(); - void scheduleAction( Uint32 time, Action* action ); - - Uint32 timeOfNextEvent(); - - void executeNextEvent(); - void executeAllEvents(); - void executeEventsBefore( Uint32 time ); - void executePastEvents(); -}; - -#endif Deleted: trunk/animations.cpp =================================================================== --- trunk/animations.cpp 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/animations.cpp 2007-06-12 11:59:50 UTC (rev 26) @@ -1,40 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "animations.h" -#include <SDL_gfxPrimitives.h> - -#include <iostream> - -void -AnimationQueue::render( SDL_Surface* screen ) { - for( iterator i = begin(); i != end(); i++ ) { - Animation* animation = (Animation*)( i->second ); - animation->render( screen ); - } -} - -SonarAnimation::SonarAnimation() { -} - -SonarAnimation::SonarAnimation( Planet* planet, const Uint32& color, const int& size, const Uint32& startTime, const Uint32& endTime, bool circle ) { - this->circle = circle; - this->planet = planet; - r = ( color & 0xFF0000 ) >> 16; - g = ( color & 0x00FF00 ) >> 8; - b = ( color & 0x0000FF ); -// this->color = color; - this->size = size; - this->startTime = startTime; - this->endTime = endTime; -} - -void -SonarAnimation::render( SDL_Surface* screen ) { - Uint32 currentTime = timer.getTime(); - if( ( currentTime > startTime ) && ( currentTime < endTime ) ) { - double percentage = (double)( currentTime - startTime ) / ( endTime - startTime ); - filledCircleRGBA( screen, planet->getLocation().getXMapped(), planet->getLocation().getYMapped(), (int)( size * sin( percentage * PI ) ), r, g, b, (int)( ( 255 - 255 * percentage ) * 0.05 ) ); - if( circle ) - aacircleRGBA( screen, planet->getLocation().getXMapped(), planet->getLocation().getYMapped(), (int)( size * sin( percentage * PI ) ), r, g, b, 255 - (int)( 255 * percentage ) ); - } -} Deleted: trunk/animations.h =================================================================== --- trunk/animations.h 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/animations.h 2007-06-12 11:59:50 UTC (rev 26) @@ -1,39 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef ANIMATIONS_H -#define ANIMATIONS_H - -#include "actions.h" -#include "coordinate.h" -#include "config.h" -#include "planets.h" - -#include <math.h> - -class Planet; - -class Animation : public Action { -public: - void execute( const Uint32& time ) {} - virtual void render( SDL_Surface* screen ) = 0; -}; - -class AnimationQueue : public ActionQueue { -public: - void render( SDL_Surface* screen ); -}; - -class SonarAnimation : public Animation { -private: - bool circle; - Planet* planet; - Uint32 startTime, endTime; - Uint8 r, g, b; - int size; -public: - SonarAnimation(); - SonarAnimation( Planet* planet, const Uint32& color, const int& size, const Uint32& startTime, const Uint32& endTime, bool circle = false ); - void render( SDL_Surface* screen ); -}; - -#endif Copied: trunk/autogen.sh (from rev 25, branches/autoconf-2007-03-26-thebohemian/autogen.sh) =================================================================== --- trunk/autogen.sh (rev 0) +++ trunk/autogen.sh 2007-06-12 11:59:50 UTC (rev 26) @@ -0,0 +1,3 @@ +#!/bin/sh + +aclocal && automake --foreign --add-missing --copy && autoheader && autoconf Deleted: trunk/config.cpp =================================================================== --- trunk/config.cpp 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/config.cpp 2007-06-12 11:59:50 UTC (rev 26) @@ -1,76 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "config.h" -#include <iostream> - -class Config; - -Settings::Settings() { - //setResolution( 800, 600 ); - //setFullscreen( true ); - - //Create configuration file if it does not exist - if (!fileExists("qonk.conf")){ - vector<string> v; - v.push_back("# Qonk configuration file "); - v.push_back("# Format: entry = value (The spaces is optional)\n"); - v.push_back("# Window"); - v.push_back("fullscreen = true"); - v.push_back("width = 1024"); - v.push_back("height = 768\n"); - v.push_back("# Settings for first round"); - v.push_back("numberOfPlanets = 6"); - v.push_back("numberOfComputerPlayers = 1"); - createFile("qonk.conf",v); - } - Config config("qonk.conf"); - //Read settings form qonk.conf - bool fs = config.getValueBOOL("fullscreen"); - int h = config.getValueINT("height"); - int w = config.getValueINT("width"); - setResolution(w, h ); - setFullscreen( fs ); -} - -Settings::Settings(int w, int h, bool fs) { - setResolution( w, h ); - setFullscreen( fs ); -} - -void -Settings::setResolution( int width, int height ) { - screenWidth = width; - screenHeight = height; - gameWidth = height; - gameHeight = height; - gameOffsetX = ( width - height ) / 2; -} - -void -Settings::setFullscreen( bool b ) { - fullscreen = b; -} - -int Settings::getScreenWidth() { - return screenWidth; -} - -int Settings::getScreenHeight() { - return screenHeight; -} - -int Settings::getGameWidth() { - return gameWidth; -} - -int Settings::getGameHeight() { - return gameHeight; -} - -int Settings::getGameOffsetX() { - return gameOffsetX; -} - -bool Settings::getFullscreen() { - return fullscreen; -} Deleted: trunk/config.h =================================================================== --- trunk/config.h 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/config.h 2007-06-12 11:59:50 UTC (rev 26) @@ -1,35 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef CONFIG_H -#define CONFIG_H - -#define PI 3.14159265 - -#include "timer.h" -#include "ReadConf.h" -#include <vector> -#include <string> - -static Timer timer; - -class Settings { -private: - int screenWidth, screenHeight, gameWidth, gameHeight, gameOffsetX; - bool fullscreen; -public: - Settings(); - Settings(int, int, bool); - void setResolution( int width, int height ); - void setFullscreen( bool b ); - int getScreenWidth(); - int getScreenHeight(); - int getGameWidth(); - int getGameHeight(); - int getGameOffsetX(); - bool getFullscreen(); -}; - -static Settings settings; -//static Config config("qonk.conf"); - -#endif Copied: trunk/config.h.in (from rev 25, branches/autoconf-2007-03-26-thebohemian/config.h.in) =================================================================== --- trunk/config.h.in (rev 0) +++ trunk/config.h.in 2007-06-12 11:59:50 UTC (rev 26) @@ -0,0 +1,106 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `atexit' function. */ +#undef HAVE_ATEXIT + +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `SDL' library (-lSDL). */ +#undef HAVE_LIBSDL + +/* Define to 1 if you have the `SDL_gfx' library (-lSDL_gfx). */ +#undef HAVE_LIBSDL_GFX + +/* Define to 1 if you have the `SDL_ttf' library (-lSDL_ttf). */ +#undef HAVE_LIBSDL_TTF + +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `mkdir' function. */ +#undef HAVE_MKDIR + +/* Define to 1 if you have the <SDL/SDL_gfxPrimitives.h> header file. */ +#undef HAVE_SDL_SDL_GFXPRIMITIVES_H + +/* Define to 1 if you have the <SDL/SDL.h> header file. */ +#undef HAVE_SDL_SDL_H + +/* Define to 1 if you have the <SDL/SDL_ttf.h> header file. */ +#undef HAVE_SDL_SDL_TTF_H + +/* Define to 1 if you have the `select' function. */ +#undef HAVE_SELECT + +/* Define to 1 if you have the `sqrt' function. */ +#undef HAVE_SQRT + +/* Define to 1 if stdbool.h conforms to C99. */ +#undef HAVE_STDBOOL_H + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the <sys/select.h> header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define to 1 if you have the <sys/socket.h> header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if the system has the type `_Bool'. */ +#undef HAVE__BOOL + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to the type of arg 1 for `select'. */ +#undef SELECT_TYPE_ARG1 + +/* Define to the type of args 2, 3 and 4 for `select'. */ +#undef SELECT_TYPE_ARG234 + +/* Define to the type of arg 5 for `select'. */ +#undef SELECT_TYPE_ARG5 + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const Copied: trunk/configure.ac (from rev 25, branches/autoconf-2007-03-26-thebohemian/configure.ac) =================================================================== --- trunk/configure.ac (rev 0) +++ trunk/configure.ac 2007-06-12 11:59:50 UTC (rev 26) @@ -0,0 +1,42 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.61) +AC_INIT([qonk], [0.0.3], [qon...@li...]) +AC_CANONICAL_TARGET +AM_INIT_AUTOMAKE + +AC_CONFIG_SRCDIR([src/animations.h]) +AC_CONFIG_HEADER([config.h]) + +# Checks for programs. +AC_PROG_CXX +AC_PROG_CC + +AC_LANG_C + +AM_PATH_SDL([1.2.0], [:], + AC_MSG_ERROR([No proper SDL found. Please install at least version 1.2.0!])) + + +# Checks for libraries. +AC_CHECK_LIB([SDL], [SDL_Init]) +AC_CHECK_LIB([SDL_ttf], [TTF_Init], ,AC_MSG_ERROR([SDL_ttf missing. Please install at least version 2.0!])) +AC_CHECK_LIB([SDL_gfx], [pixelColor], ,AC_MSG_ERROR([SDL_gfx missing. Please install at least version 1.2!])) + +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([stdlib.h SDL/SDL.h SDL/SDL_gfxPrimitives.h SDL/SDL_ttf.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_C_CONST + +# Checks for library functions. +AC_FUNC_SELECT_ARGTYPES +AC_CHECK_FUNCS([atexit mkdir select sqrt]) + +AC_CONFIG_FILES([Makefile + data/Makefile + src/Makefile]) +AC_OUTPUT Deleted: trunk/coordinate.cpp =================================================================== --- trunk/coordinate.cpp 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/coordinate.cpp 2007-06-12 11:59:50 UTC (rev 26) @@ -1,64 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "coordinate.h" - -#include "config.h" -#include <math.h> - -Coordinate::Coordinate() { - x = 0; - y = 0; -} - -Coordinate::Coordinate( double x, double y ) { - this->x = x; - this->y = y; -} - -void -Coordinate::setX( double x ) { - this->x = x; -} - -void -Coordinate::setY( double y ) { - this->y = y; -} - -void -Coordinate::setXMapped( int x ) { - this->x = ( (double)x - settings.getGameOffsetX() ) / settings.getGameWidth(); -} - -void -Coordinate::setYMapped( int y ) { - this->y = (double)y / settings.getGameHeight(); -} - -double -Coordinate::getX() const { - return x; -} - -double -Coordinate::getY() const { - return y; -} - -int -Coordinate::getXMapped() const { - return settings.getGameOffsetX() + ( int )( settings.getGameWidth() * x ); -} - -int -Coordinate::getYMapped() const { - return ( int )( settings.getGameHeight() * y ); -} - -double -Coordinate::distance( const Coordinate& c ) const { - double dx = c.getX() - getX(); - double dy = c.getY() - getY(); - return sqrt( dx * dx + dy * dy ); -} - Deleted: trunk/coordinate.h =================================================================== --- trunk/coordinate.h 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/coordinate.h 2007-06-12 11:59:50 UTC (rev 26) @@ -1,27 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef COORDINATE_H -#define COORDINATE_H - -class Coordinate { -private: - double x, y; -public: - Coordinate(); - Coordinate( double x, double y ); - - void setX( double x ); - void setY( double y ); - void setXMapped( int x ); - void setYMapped( int y ); - - double getX() const; - double getY() const; - int getXMapped() const; - int getYMapped() const; - - double distance( const Coordinate& c ) const; - -}; - -#endif Copied: trunk/data (from rev 25, branches/autoconf-2007-03-26-thebohemian/data) Deleted: trunk/data/Makefile.am =================================================================== --- branches/autoconf-2007-03-26-thebohemian/data/Makefile.am 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/data/Makefile.am 2007-06-12 11:59:50 UTC (rev 26) @@ -1,3 +0,0 @@ -pkgdata_DATA = font.ttf - -EXTRA_DIST = $(pkgdata_DATA) Copied: trunk/data/Makefile.am (from rev 25, branches/autoconf-2007-03-26-thebohemian/data/Makefile.am) =================================================================== --- trunk/data/Makefile.am (rev 0) +++ trunk/data/Makefile.am 2007-06-12 11:59:50 UTC (rev 26) @@ -0,0 +1,3 @@ +pkgdata_DATA = font.ttf + +EXTRA_DIST = $(pkgdata_DATA) Deleted: trunk/data/font.ttf =================================================================== (Binary files differ) Copied: trunk/data/font.ttf (from rev 25, branches/autoconf-2007-03-26-thebohemian/data/font.ttf) =================================================================== (Binary files differ) Deleted: trunk/extensions.cpp =================================================================== --- trunk/extensions.cpp 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/extensions.cpp 2007-06-12 11:59:50 UTC (rev 26) @@ -1,135 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "extensions.h" -#include <SDL_gfxPrimitives.h> - -void -alphaBlend( SDL_Surface* surface, Uint8 alpha ) { - if( alpha == 0 ) { - for( int x = 0; x < surface->w; x++ ) - for( int y = 0; y < surface->h; y++ ) { - Uint32 *bufp; - bufp = (Uint32 *)surface->pixels + y*surface->pitch/4 + x; - if( *bufp != 0 ) - *bufp &= 0x00ffffff; - } - } if( alpha != 255 ) { - for( int x = 0; x < surface->w; x++ ) - for( int y = 0; y < surface->h; y++ ) { - Uint32 *bufp; - bufp = (Uint32 *)surface->pixels + y*surface->pitch/4 + x; - if( *bufp != 0 ) { - // seperate RGB from A, update A for new value, OR them together again - Uint32 color = ( *bufp & 0x00ffffff ) | ( ( *bufp >> 24 ) * alpha >> 8 ) << 24; - *bufp = color; - } - } - } -} - -void -drawSelector( SDL_Surface *screen, Sint16 x1, Sint16 y1, Sint16 width, Sint16 height, Uint8 R, Uint8 G, Uint8 B ) { - hlineRGBA( screen, x1, x1 + 2, y1, R, G, B, 255 ); - hlineRGBA( screen, x1 + width - 2, x1 + width, y1, R, G, B, 255 ); - hlineRGBA( screen, x1, x1 + 2, y1 + height, R, G, B, 255 ); - hlineRGBA( screen, x1 + width - 2, x1 + width, y1 + height, R, G, B, 255 ); - vlineRGBA( screen, x1, y1, y1 + 2, R, G, B, 255 ); - vlineRGBA( screen, x1, y1 + height, y1 + height - 2, R, G, B, 255 ); - vlineRGBA( screen, x1 + width, y1, y1 + 2, R, G, B, 255 ); - vlineRGBA( screen, x1 + width, y1 + height, y1 + height - 2, R, G, B, 255 ); -} - -void -drawPlanet( SDL_Surface* screen, Sint16 x, Sint16 y, int size, Uint8 R, Uint8 G, Uint8 B ) { - filledCircleRGBA( screen, x, y, size + 2, 0, 0, 0, 128 ); - filledCircleRGBA( screen, x, y, size, R, G, B, 255 ); - aacircleRGBA( screen, x, y, size, R, G, B, 255 ); - filledEllipseRGBA( screen, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); - aaellipseRGBA( screen, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); -} - -void -drawPlanet( SDL_Surface* screen, Sint16 x, Sint16 y, int size, Uint32 color ) { - drawPlanet( screen, x, y, size, getRed( color ), getGreen( color ), getBlue( color ) ); -} - -double -frand() { - return (double)rand() / RAND_MAX; -} - -double -frand( double max ) { - return max * frand(); -} - -Uint32 HSVtoRGB( float h, float s, float v ) -{ - int i; - float f, p, q, t, r, g, b; - - if( s == 0 ) { - - // achromatic (grey) - r = g = b = v; - - } else { - - h /= 60; // sector 0 to 5 - i = (int)h; - f = h - i; // factorial part of h - p = v * ( 1 - s ); - q = v * ( 1 - s * f ); - t = v * ( 1 - s * ( 1 - f ) ); - - switch( i ) { - case 0: - r = v; - g = t; - b = p; - break; - case 1: - r = q; - g = v; - b = p; - break; - case 2: - r = p; - g = v; - b = t; - break; - case 3: - r = p; - g = q; - b = v; - break; - case 4: - r = t; - g = p; - b = v; - break; - default: // case 5: - r = v; - g = p; - b = q; - break; - } - - } - - return 256 * 256 * (int)( 255 * r ) + 256 * (int)( 255 * g ) + (int)( 255 * b ); - -} - -Uint8 getRed( Uint32 color ) { - return ( color & 0xFF0000 ) >> 16; -} - -Uint8 getGreen( Uint32 color ) { - return ( color & 0x00FF00 ) >> 8; -} - -Uint8 getBlue( Uint32 color ) { - return color & 0x0000FF; -} - Deleted: trunk/extensions.h =================================================================== --- trunk/extensions.h 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/extensions.h 2007-06-12 11:59:50 UTC (rev 26) @@ -1,24 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef EXTENSIONS_H -#define EXTENSIONS_H - -#include "config.h" -#include <SDL/SDL.h> -#include <sstream> -using namespace std; - -void alphaBlend( SDL_Surface* surface, Uint8 alpha ); - -void drawSelector( SDL_Surface *screen, Sint16 x1, Sint16 y1, Sint16 width, Sint16 height, Uint8 R, Uint8 G, Uint8 B ); -void drawPlanet( SDL_Surface* screen, Sint16 x, Sint16 y, int size, Uint8 R, Uint8 G, Uint8 B ); -void drawPlanet( SDL_Surface* screen, Sint16 x, Sint16 y, int size, Uint32 color ); -double frand(); -double frand( double max ); -Uint32 HSVtoRGB( float h, float s, float v ); - -Uint8 getRed( Uint32 color ); -Uint8 getGreen( Uint32 color ); -Uint8 getBlue( Uint32 color ); - -#endif Deleted: trunk/font.ttf =================================================================== (Binary files differ) Deleted: trunk/fonts.cpp =================================================================== --- trunk/fonts.cpp 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/fonts.cpp 2007-06-12 11:59:50 UTC (rev 26) @@ -1,67 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "fonts.h" - -#include "extensions.h" - -Font::Font( char* fileName, int size ) { - font = TTF_OpenFont( fileName, size ); - if ( font == NULL ) { - cerr << "Couldn't load " << size << "pt font from " << fileName << ": " << SDL_GetError() << endl; - exit( 1 ); - } - TTF_SetFontStyle( font, TTF_STYLE_NORMAL ); -} - -void -Font::render( SDL_Surface* screen, int x, int y, const char* text, Uint8 r, Uint8 g, Uint8 b, Uint8 a ) { - SDL_Color color = { r, g, b, a }; - SDL_Surface* textSurface = TTF_RenderText_Blended( font, text, color ); - if ( textSurface != NULL ) { - SDL_Rect dstrect; - dstrect.x = x; - dstrect.y = y; - dstrect.w = textSurface->w; - dstrect.h = textSurface->h; - alphaBlend( textSurface, a ); - SDL_BlitSurface( textSurface, NULL, screen, &dstrect ); - SDL_FreeSurface( textSurface ); - } -} - -void -Font::renderCenterJustified( SDL_Surface* screen, int x, int y, const char* text, Uint8 r, Uint8 g, Uint8 b, Uint8 a ) { - SDL_Color color = { r, g, b, 0 }; - SDL_Surface* textSurface = TTF_RenderText_Blended( font, text, color ); - if ( textSurface != NULL ) { - SDL_Rect dstrect; - dstrect.x = x - textSurface->w / 2; - dstrect.y = y - textSurface->h / 2; - dstrect.w = textSurface->w; - dstrect.h = textSurface->h; - alphaBlend( textSurface, a ); - SDL_BlitSurface( textSurface, NULL, screen, &dstrect ); - SDL_FreeSurface( textSurface ); - } -} - -void -Font::renderRightJustified( SDL_Surface* screen, int x, int y, const char* text, Uint8 r, Uint8 g, Uint8 b, Uint8 a ) { - SDL_Color color = { r, g, b, 0 }; - SDL_Surface* textSurface = TTF_RenderText_Blended( font, text, color ); - if ( textSurface != NULL ) { - SDL_Rect dstrect; - dstrect.x = x - textSurface->w; - dstrect.y = y; - dstrect.w = textSurface->w; - dstrect.h = textSurface->h; - alphaBlend( textSurface, a ); - SDL_BlitSurface( textSurface, NULL, screen, &dstrect ); - SDL_FreeSurface( textSurface ); - } -} - -int -Font::getHeight() { - return TTF_FontHeight( font ); -} Deleted: trunk/fonts.h =================================================================== --- trunk/fonts.h 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/fonts.h 2007-06-12 11:59:50 UTC (rev 26) @@ -1,24 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef FONTS_H -#define FONTS_H - -#include <SDL/SDL.h> -#include <SDL/SDL_ttf.h> -#include <iostream> -using namespace std; - -class Font { -private: - TTF_Font* font; -public: - Font( char* fileName, int size ); - - void render( SDL_Surface* screen, int x, int y, const char* text, Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255 ); - void renderCenterJustified( SDL_Surface* screen, int x, int y, const char* text, Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255 ); - void renderRightJustified( SDL_Surface* screen, int x, int y, const char* text, Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255 ); - - int getHeight(); -}; - -#endif Deleted: trunk/main.cpp =================================================================== --- trunk/main.cpp 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/main.cpp 2007-06-12 11:59:50 UTC (rev 26) @@ -1,318 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "coordinate.h" -#include "stars.h" -#include "planets.h" -#include "selection.h" -#include "players.h" -#include "universe.h" -#include "fonts.h" -#include "ReadConf.h" -#include "config.h" - -#include <SDL_gfxPrimitives.h> -#include <SDL/SDL.h> -#include <SDL/SDL_ttf.h> -#include <math.h> - -#include <iostream> -#include <iomanip> -#include <sstream> -#include <vector> -#include <string> -#include <list> - -Font* font; -Uint32 FPStimer, FPScounter; -double FPS; - -enum States { PLAYING, LOST, WON }; -States state; - -void render( SDL_Surface* screen, Universe* universe, Players* players ) { - - boxRGBA( screen, 0, 0, settings.getScreenWidth(), settings.getScreenHeight(), 0, 0, 0, 255 ); - - universe->renderBackground( screen ); - players->render( screen ); - universe->renderForeground( screen ); - - stringstream s; - s << timer.getTimeMMSSHH(); - - FPScounter++; - if( SDL_GetTicks() - FPStimer >= 1000 ) { - if( FPS == 0 ) - FPS = ( FPS + 1000.0 * FPScounter / ( SDL_GetTicks() - FPStimer ) ) / 2; - else - FPS = 1000.0 * FPScounter / ( SDL_GetTicks() - FPStimer ); - FPStimer = SDL_GetTicks(); - FPScounter = 0; - } - s << " (" << setiosflags(ios::fixed) << setprecision(2) << FPS << "FPS)"; - font->render( screen, 13, settings.getGameHeight() - 30, s.str().c_str(), 0x80, 0x80, 0x80 ); - - SDL_UpdateRect(screen, 0, 0, settings.getScreenWidth(), settings.getScreenHeight() ); - -} - -void changeScreen(SDL_Surface **screen) { - - if( settings.getFullscreen() ) - *screen = SDL_SetVideoMode( settings.getScreenWidth(), settings.getScreenHeight(), 32, SDL_SWSURFACE | SDL_FULLSCREEN ); - else - *screen = SDL_SetVideoMode( settings.getScreenWidth(), settings.getScreenHeight(), 32, SDL_SWSURFACE ); -} - - -int main(int argc, char** argv) { - -/* bool fullscreen = config.getValueBOOL("fullscreen"); - int h = config.getValueINT("height"); - int w = config.getValueINT("width"); - - settings.setResolution( w, h ); - settings.setFullscreen( fullscreen ); -*/ - bool FirstRun = true; - - int numberOfPlanets; - int numberOfComputerPlayers; - - bool NextRound = true; - while (NextRound){ - state = PLAYING; - - if (FirstRun){ - FirstRun=false; - if( argc != 3 ) { - //cerr << "Usage: " << argv[ 0 ] << " numberOfPlanets numberOfComputerPlayers" << endl; - //cerr << "Setting to default 6 planets and 1 computer player" << endl; -// numberOfPlanets = config.getValueINT("numberOfPlanets"); -// numberOfComputerPlayers = config.getValueINT("numberOfComputerPlayers"); - numberOfPlanets = 6; - numberOfComputerPlayers = 1; - } else { - numberOfPlanets = atoi( argv[ 1 ] ); - numberOfComputerPlayers = atoi( argv[ 2 ] ); - } - if( numberOfPlanets <= 1 ) { - cerr << "Resetting to least of 2 planets" << endl; - numberOfPlanets = 2; - } - if( numberOfComputerPlayers > numberOfPlanets - 1 ) { - cerr << "Resetting computer players to maximum of " << numberOfPlanets - 1 << endl; - numberOfComputerPlayers = numberOfPlanets - 1; - } - if( numberOfComputerPlayers <= 1 ) { - cerr << "Resetting computer players to at least 1" << endl; - numberOfComputerPlayers = 1; - } - } - // determine next level when this was passed successfully - - int nextPlanets = numberOfPlanets + 1; - int nextComputerPlayers = numberOfComputerPlayers + 1; - if( nextPlanets == 11 ) { - int d = nextPlanets - nextComputerPlayers; - if( d != 1 ) { - nextPlanets = 10; - } - } - - /* Init SDL */ - if( SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO ) < 0 ) { - cerr << "Couldn't initialize SDL: " << SDL_GetError() << endl; - exit( 1 ); - } - timer.start(); - atexit( SDL_Quit ); - if ( TTF_Init() < 0 ) { - cerr << "Couldn't initialize TTF: " << SDL_GetError() << endl; - exit( 1 ); - } - atexit( TTF_Quit ); - font = new Font( "font.ttf", 18 ); - - srand( time( NULL) ); - - /* Set window title */ - SDL_WM_SetCaption( "Qonk", "Qonk" ); - - /* Initialize the display */ - SDL_Surface *screen; -// cout << settings.getGameWidth() << "+" << settings.getGameOffsetX() << endl; - - changeScreen(&screen); - - Universe* universe = new Universe( numberOfPlanets ); - - Players* players = new Players( universe ); - universe->actionQueue->scheduleAction( 1000, new UpdatePlayersStatsAction( players ) ); - - Planets::iterator planetIterator = universe->planets->begin(); - HumanPlayer* humanPlayer = new HumanPlayer( universe, &(*planetIterator), 3, 0xffffff ); - players->push_back( humanPlayer ); - planetIterator++; - - int hueCounter = rand() % 360; - int counter = 0; - do { - if( counter < numberOfComputerPlayers ) { - players->push_back( new ComputerPlayer( universe, &(*planetIterator), 3, HSVtoRGB( hueCounter, 0.9, 0.9 ) ) ); - counter++; - hueCounter = ( hueCounter + 360 / numberOfComputerPlayers ) % 360; - } else - if( !(&(*planetIterator))->getMoon() ) - players->push_back( new NeutralPlayer( universe, &(*planetIterator), 1 + rand() % 3, 0x606060 ) ); - else - players->push_back( new NeutralPlayer( universe, &(*planetIterator), 1 + rand() % 2, 0x606060 ) ); - planetIterator++; - } while( planetIterator != universe->planets->end() ); - - - Selection selection; - - int iteration = 0; - - bool showEnemyShips = false; - - bool quit = false; - - // Main loop: loop forever. - while( !quit ) { - - render( screen, universe, players ); - - if( !timer.isPaused() ) { - - // update the universe - - universe->update(); - - // let players update their states - - players->update(); - - } - - // Poll for events, and handle the ones we care about. - SDL_Event event; - while (SDL_PollEvent(&event)) { - - switch (event.type) { - - case SDL_KEYDOWN: - break; - case SDL_KEYUP: - if( event.key.keysym.sym == SDLK_p ) { - timer.pause(); - } -// if( event.key.keysym.sym == SDLK_t ) -// showEnemyShips = !showEnemyShips; - // If escape is pressed, return (and thus, quit) - if(event.key.keysym.sym == SDLK_ESCAPE){ - quit = true; - NextRound = false; - } - if(event.key.keysym.sym == SDLK_n) - if (state==WON) - quit = true; - - if(event.key.keysym.sym == SDLK_r){ - quit = true; - nextPlanets=numberOfPlanets; - nextComputerPlayers = numberOfComputerPlayers; - } - if(event.key.keysym.sym == SDLK_f){ - if(settings.getFullscreen()){ - settings.setFullscreen( false ); - } - else if(!settings.getFullscreen()){ - settings.setFullscreen( true ); - } - - changeScreen(&screen); - } - break; - case SDL_QUIT: - quit = true; - NextRound = false; - - } - - } - - if( humanPlayer->getPoints() == 0 ) { - showEnemyShips = true; - state = LOST; - } - - if( state == PLAYING ) { - bool allPlayersDead = true; - for( Players::iterator i = players->begin(); i != players->end(); i++ ) { - if( (*i)->getPlayerType() == Player::COMPUTER ) - if( ((ComputerPlayer*)(*i))->getPoints() > 0 ) - allPlayersDead = false; - } - if( allPlayersDead == true ) { - MSGwon(universe, nextPlanets, nextComputerPlayers); - state = WON; - } - } - - Uint8 *keystate = SDL_GetKeyState(NULL); - bool show = false; - if( keystate[SDLK_e] ) { - show = true; - } - if( keystate[SDLK_a] ) { - humanPlayer->selectAllPlanets(); - } - if( keystate[SDLK_s] ) { - SDL_SaveBMP( SDL_GetVideoSurface(), "screenshot.bmp" ); - } - for ( int i=SDLK_0; i<=SDLK_9; i++ ) { - if (keystate[i]) { - int sel = (i == SDLK_0) - ? 100 - : (i-SDLK_0) * 10; - humanPlayer->setFleetSelection(sel); - } - } - - for( Players::iterator i = players->begin(); i != players->end(); i++ ) { - if( (*i)->getPlayerType() == Player::COMPUTER ) - ((ComputerPlayer*)(*i))->setDisplayShips( show || showEnemyShips ); - if( (*i)->getPlayerType() == Player::NEUTRAL ) - ((NeutralPlayer*)(*i))->setDisplayShips( show || showEnemyShips ); - } - - // Keep shut for some time, not to use too much CPU - - // SDL_Delay( 20 ); - - } - - delete font; - delete universe; - delete players; - - /* // We dont want to much output to cout - if( state == LOST ) { - cout << "The AI players have kicked you out? Bastards!" << endl; - cout << "Try harder, run QONK again, with \n\n\t" << argv[ 0 ] << " " << numberOfPlanets << " " << numberOfComputerPlayers << "\n" << endl; - } else if ( state == PLAYING ) { - cout << "You gave up early?!" << endl; - cout << "Try again, run QONK again, with \n\n\t" << argv[ 0 ] << " " << numberOfPlanets << " " << numberOfComputerPlayers << "\n" << endl; - } else { - cout << "You have QONKuered the solar system! You won!" << endl; - cout << "Move on to the next level, and run QONK again with \n\n\t" << argv[ 0 ] << " " << nextPlanets << " " << nextComputerPlayers << "\n" << endl; - }*/ - - numberOfPlanets = nextPlanets; - numberOfComputerPlayers = nextComputerPlayers; - } - return 0; - -} Deleted: trunk/messages.cpp =================================================================== --- trunk/messages.cpp 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/messages.cpp 2007-06-12 11:59:50 UTC (rev 26) @@ -1,134 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "messages.h" - - -Message::Message( string message, Uint32 displayTime, Uint8 r, Uint8 g, Uint8 b ) { - this->message = string( "[" ) + timer.getTimeMMSS() + "] " + message; - this->displayTime= displayTime; - this->r = r; - this->g = g; - this->b = b; -} - -Message::Message( string message, Uint32 displayTime, Uint32 color ) { - this->message = string( "[" ) + timer.getTimeMMSS() + "] " + message; - this->displayTime = displayTime; - this->r = getGreen( color ); - this->g = getRed( color ); - this->b = getBlue( color ); -} - -Message::Message( string message, Uint8 r, Uint8 g, Uint8 b ) { - this->message = string( "[" ) + timer.getTimeMMSS() + "] " + message; - this->displayTime= 10000; - this->r = r; - this->g = g; - this->b = b; -} - -Message::Message( string message, Uint32 color ) { - this->message = string( "[" ) + timer.getTimeMMSS() + "] " + message; - this->displayTime = 10000; - this->r = getGreen( color ); - this->g = getRed( color ); - this->b = getBlue( color ); -} - -void -Message::render( SDL_Surface* screen, int &x, int &y, Font* font, int time ) { - if( time > 0 ) { - - // default parameters for showing a message - - int dx = font->getHeight(); - int alpha = 255; - - // fading in a message - if( time < 500 ) { - dx = (int)( ( dx * time ) / 600.0 ); - alpha = (int)( ( alpha * time ) / 600.0 ); - } - - // fading out a message - if( time > displayTime - 500 ) { - int timeleft = displayTime - time; - dx = (int)( ( dx * timeleft ) / 600.0 ); - alpha = (int)( ( alpha * timeleft ) / 600.0 ); - } - - // do we still show ourselves? - if( time > displayTime ) { - - dx = 0; - alpha = 0; - - } else { - - font->render( screen, x, y - dx, message.c_str(), r, g, b, alpha ); - - } - - y -= dx; - } -} - -Uint32 -Message::getDisplayTime() { - return displayTime; -} - -Messages::Messages() { - font = new Font( "font.ttf", 12 ); -} - -Messages::~Messages() { - clear(); -} - -void -Messages::addMessage( Uint32 time, Message m ) { - insert( pair< Uint32, Message>( time, m ) ); -} - -void -Messages::cleanup() { - while( ( size() > 0 ) && ( begin()->first + begin()->second.getDisplayTime() < timer.getTime() ) ) - erase( begin() ); -} - -void -Messages::render( SDL_Surface* screen ) { - cleanup(); - int x = 12; - int y = settings.getGameHeight() - 28; - for( reverse_iterator i = rbegin(); i != rend(); i++ ) { - i->second.render( screen, x, y, font, (int)timer.getTime() - (int)i->first ); - } -} - -void -MSGwon(Universe* universe, int nextPlanets, int nextComputerPlayers){ - universe->messages->addMessage( timer.getTime() + 200, Message( "You have QONKuered the solar system! You won!", 20000, 0xffffff ) ); - stringstream s; - s << "Try again, with " << nextPlanets << " planets and " << nextComputerPlayers << " AI players!"; - universe->messages->addMessage( timer.getTime() + 400, Message( s.str(), 20000, 0x808080 ) ); - universe->messages->addMessage( timer.getTime() + 600, Message( "Press [N] ...", 40000, 0x808080 ) ); -} - -void -MSGlost(Universe* universe) { - universe->messages->addMessage( timer.getTime(), Message( "GAME OVER!!! You lost all your planets and ships, you are dead!", 20000, 0xffffff ) ); - universe->messages->addMessage( timer.getTime() + 200, Message( "Press [R] ...", 40000, 0x808080 ) ); -} - -void -MSGstart(Universe* universe) { - universe->messages->addMessage( timer.getTime() + 000, Message( "Let's QONK! Kick the AI players out!", 15000, 0xffffff ) ); - universe->messages->addMessage( timer.getTime() + 200, Message( "[Left click and drag] for multi select, [Middle click] for single select.", 10000, 0x808080 ) ); - universe->messages->addMessage( timer.getTime() + 400, Message( "[Right click] to send ships.", 10000, 0x808080 ) ); - universe->messages->addMessage( timer.getTime() + 600, Message( "[P]ause,[A]ll planets,[R]estart.", 10000, 0x808080 ) ); - universe->messages->addMessage( timer.getTime() + 700, Message( "[Escape] to quit", 10000, 0x808080 ) ); - universe->messages->addMessage( timer.getTime() + 800, Message( "[1]-[0] fleet selection (10%-100%)", 10000, 0x808080 ) ); - universe->messages->addMessage( timer.getTime() + 1000, Message( "Initial fleet selection is 50%", 10000, 0x808080 ) ); -} Deleted: trunk/messages.h =================================================================== --- trunk/messages.h 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/messages.h 2007-06-12 11:59:50 UTC (rev 26) @@ -1,46 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef MESSAGES_H -#define MESSAGES_H - -#include "fonts.h" -#include "extensions.h" -#include "config.h" -#include "universe.h" -#include <SDL/SDL.h> -#include <map> -#include <string> -using namespace std; - -class Universe; - -class Message { -private: - Uint8 r, g, b; - Uint32 displayTime; - string message; -public: - Message( string message, Uint32 displayTime, Uint8 r, Uint8 g, Uint8 b ); - Message( string message, Uint32 displayTime, Uint32 color ); - Message( string message, Uint8 r, Uint8 g, Uint8 b ); - Message( string message, Uint32 color ); - void render( SDL_Surface* screen, int &x, int &y, Font* f, int time ); - Uint32 getDisplayTime(); -}; - -class Messages : multimap< Uint32, Message > { -private: - Font* font; -public: - Messages(); - ~Messages(); - void addMessage( Uint32 time, Message m ); - void cleanup(); - void render( SDL_Surface* screen ); - Font* getFont() { return font; } -}; - -void MSGwon(Universe*, int, int); -void MSGlost(Universe*); -void MSGstart(Universe*); -#endif Deleted: trunk/planets.cpp =================================================================== --- trunk/planets.cpp 2007-06-12 11:18:17 UTC (rev 25) +++ trunk/planets.cpp 2007-06-12 11:59:50 UTC (rev 26) @@ -1,462 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "planets.h" - -#include <SDL_gfxPrimitives.h> - -#include <iostream> -#include <math.h> - -// ##### PLANET ##### - -Planet::Planet() { - rotationSpeed = ( ( rand() % 2 ) * 2 - 1 ) * ( rand() % 60000 + 20000 ); - rotationDistance = 0.05 + 0.4 * ( double )rand() / RAND_MAX; - rotationOffset = rand() % 10000000; - size = 4 + rand() % 4; // [4 ... 8) - isAMoon = false; - mother = NULL; - selected = false; - sourceSelected = false; - owner = NULL; - shipCreationSpeed = 12500 - size*1000; -} - -void -Planet::makeMoon( Planet* mother ) { - rotationSpeed = ( ( rand() % 2 ) * 2 - 1 ) * ( rand() % 2000 + 2000 ); - rotationDistance = 0.01 + 0.03 * ( double )rand() / RAND_MAX; - rotationOffset = rand() % 100000; - size = 2 + rand() % 2; // [2 ... 4) - isAMoon = true; - this->mother = mother; - shipCreationSpeed = 15000 - size*1000; -} - -Coordinate -Planet::getVector( Uint32 time ) const { - double angle = (double)( rotationOffset + time ) / rotationSpeed; - return Coordinate( cos( angle ), sin( angle ) ); -} - -Coordinate -Planet::getLocation( Uint32 time ) const { - Coordinate motherLocation; - if( isAMoon ) { - motherLocation = mother->getLocation(); - } else { - motherLocation.setX( 0.5 ); - motherLocation.setY( 0.5 ); - } - Coordinate v = getVector( time ); - double x = motherLocation.getX() + rotationDistance * v.getX(); - double y = motherLocation.getY() + rotationDistance * v.getY(); - return Coordinate( x, y ); -} - -Coordinate -Planet::getLocation() const { - return getLocation( timer.getTime() ); -} - -void -Planet::addResident( Ship* ship, Uint32 time ) { - if( ( owner == NULL ) || ( owner == ship->getOwner() ) || ( residentShips.size() == 0 ) ) { - if( owner != ship->getOwner() ) { - - // clear out "create ship" actions scheduled for this planet - vector< ActionQueue::iterator > removes; - for( ActionQueue::iterator i = universe->actionQueue->begin(); i != universe->actionQueue->end(); i++ ) { - if( (i->second)->getActionID() == 1 ) { - Planet* planetOfIterator = ((CreateShipAction*)(i->second))->getPlanet(); - if( planetOfIterator == this ) - removes.push_back( i ); - } - } - - for( vector< ActionQueue::iterator >::iterator i = removes.begin(); i != removes.end(); i++ ) { - universe->actionQueue->erase( *i ); - } - - // create a new "create ship" action - buildStartTime = time; - buildEndTime = time + shipCreationSpeed; - universe->actionQueue->scheduleAction( buildEndTime, new CreateShipAction( ship->getOwner(), this ) ); - - // show an animation of planet conquests that are of our interest - Uint32 color = 0; - color = ship->getOwner()->getColor(); - if( owner != NULL ) - if( isAMoon ) - universe->animationQueue->scheduleAction( time + 1200, new SonarAnimation( this, color, 50, time, time + 1000, true ) ); - else - universe->animationQueue->scheduleAction( time + 1200, new SonarAnimation( this, color, 100, time, time + 1000, true ) ); - - } - residentShips.push_back( ship ); - setOwner(ship->getOwner()); - - } else { - ship->die(); - Ship* resident = *( residentShips.begin() ); - removeResident( resident ); - resident->die(); - - // show an animation of die'ing ships that are of our interest - if( ( ship->getOwner()->getPlayerType() == Player::HUMAN ) || ( owner->getPlayerType() == Player::HUMAN ) ) { - universe->animationQueue->scheduleAction( time + 1000, new SonarAnimation( this, ship->getOwner()->getColor(), 20, time, time + 1000, true ) ); - } -// if( owner->getPlayerType() == Player::HUMAN ) { -// universe->animationQueue->scheduleAction( time + 1000, new SonarAnimation( this, 0xc00000, 20, time, time + 1000 ) ); -// } - } -} - -void -Planet::setOwner(Player *newOwner) -{ - if (owner != NULL) - owner->removePlanet(this); - - owner = newOwner; - - newOwner->addPlanet(this); -} - -void -Planet::removeResident( Ship* ship ) { - residentShips.remove( ship ); -} - -void -Planet::render( SDL_Surface* screen ) const { - if( owner->getPlayerType() == Player::HUMAN ) - renderBuildProgress( screen ); - Coordinate location = getLocation(); - int x = location.getXMapped(); - int y = location.getYMapped(); - drawPlanet( screen, x, y, size, owner->getColor() ); - if( selected ) - renderSelector( screen ); - - if( sourceSelected ) - renderSourceSelector( screen ); -} - -void -Planet::renderOrbit( SDL_Surface* screen ) const { - Coordinate centerLocation; - if( isAMoon ) { - centerLocation = mother->getLocation(); - } else { - centerLocation.setX( 0.5 ); - centerLocation.setY( 0.5 ); - } - if( owner != NULL ) - aaellipseRGBA( screen, centerLocation.getXMapped(), centerLocation.getYMapped(), (int)( rotationDistance * settings.getGameWidth() ), (int)( rotationDistance * settings.getGameHeight() ), getRed( owner->getColor() ), getGreen( owner->getColor() ), getBlue( owner->getColor() ), 64 ); - if( getMoon() ) { - mother->renderOrbit( screen ); - } -} - -void -Planet::renderSelector( SDL_Surface* screen ) const { - Coordinate location = getLocation(); - int x = location.getXMapped(); - int y = location.getYMapped(); - drawSelector( screen, x - 4, y - 4, 10, 10, 0, 0, 0 ); - drawSelector( screen, x - 5, y - 5, 10, 10, 255, 192, 0 ); -} - -void -Planet::renderSourceSelector( SDL_Surface* screen ) const { - Coordinate location = getLocation(); - int x = location.getXMapped(); - int y = location.getYMapped(); - drawSelector( screen, x - 4, y - 4, 10, 10, 0, 0, 0 ); - drawSelector( screen, x - 5, y - 5, 10, 10, 255, 255, 255 ); -} - -void -Planet::renderBuildProgress( SDL_Surface* screen ) const { - - - Coordinate location = getLocation(); - Font* font = universe->messages->getFont(); - int x = location.getXMapped(); - int y = location.getYMapped(); - double percentage = 100.0 * ( timer.getTime() - buildStartTime ) / ( buildEndTime - buildStartTime ); - aacircleRGBA( screen, x, y, (int)( size + 102.5 - percentage ), 0xff, 0xff, 0xff, (int)( 0.2 * percentage ) ); - -} - -void -Planet::updateShipLocations() { - if( residentShips.size() > 0 ) { - Coordinate location = getLocation(); - int counter = 0; - double offset = 500 * rotationDistance + (double)timer.getTime() / 10000; - for( list< Ship* >::iterator i = residentShips.begin(); i != residentShips.end(); i++ ) { - double shipX = location.getX() + 0.02 * cos( offset + counter * 2 * PI / residentShips.size() ); - double shipY = location.getY() + 0.02 * sin( offset + counter * 2 * PI / residentShips.size() ); - (*i)->setLocation( shipX, shipY ); - counter++; - } - } -} - -double -Planet::distance( Planet* planet ) { - return planet->getLocation().distance( getLocation() ); -} - -void -Planet::setSourceSelected( bool selected ) { - this->sourceSelected = selected; -} - -void -Planet::setSelected( bool selected ) { - this->selected = selected; -} - -void -Planet::setUniverse( Universe* universe ) { - this->universe = universe; -} - -void -Planet::createShip( const Uint32& time, Player* player ) { - if( player->getPlayerType() != Player::NEUTRAL ) - if( owner == player ) { - player->addShips( this, 1 ); - buildStartTime = time; - buildEndTime = time + shipCreationSpeed; - universe->actionQueue->scheduleAction( buildEndTime, new CreateShipAction( player, this ) ); - } -} - -void -Planet::moveResidentsTo(Planet *destination, int fleetSelection) { - // Save same fuel ... :) - if (destination == this || !residentShips.size()) { - return; - } - - int decampeeCount = (fleetSelection * residentShips.size()) / 100; - if (!decampeeCount) - return; - - // Calling Ship->moveTo will affect the residentShips list so we have to - // copy the ships which are going for war into their own list. - list <Ship *> decampees; - for (list <Ship *>::iterator i = residentShips.begin(); decampeeCount > 0; i++) { - decampees.push_back(*i); - decampeeCount--; - } - - for (list <Ship *>::iterator i = decampees.begin(); i != decampees.end(); i++) { - (*i)->moveTo(timer.getTime() + rand() % 500, destination, universe->actionQueue); - } -} - -// ##### PLANETS ##### - -Planets::Planets() { -} - -Planets::Planets( int numberOfPlanets, int numberOfMoons ) { - - addPlanets( numberOfPlanets ); - addMoons( numberOfMoons ); - -} - -void -Planets::addPlanets( int numberOfPlanets ) { - - for( int i = 0; i < numberOfPlanets; i++ ) { - push_back( Planet() ); - } - -} - -void -Planets::addMoons( int numberOfMoons ) { - - if( size() == 0 ) { - cerr << "Error constructing moons, no planets yet" << endl; - exit( 1 ); - } - - for( int i = 0; i < numberOfMoons; i++ ) { - iterator motherPlanet; - bool done = false; - do { - int mother = rand() % size(); - motherPlanet = begin(); - for( int j = 0; j < mother; j++ ) motherPlanet++; - done = !motherPlanet->getMoon(); - } while( !done ); - Planet p; - p.makeMoon( &(*motherPlanet) ); - push_back( p ); - } - -} - -void -Planets::render( SDL_Surface* screen ) const { - for( const_iterator i = begin(); i != end(); i++ ) - i->render( screen ); -} - -void -Planets::renderOrbits( SDL_Surface* screen ) const { - for( const_iterator i = begin(); i != end(); i++ ) - i->renderOrbit( screen ); -} - -Planet* -Planets::closestToCoordinate( const Coordinate& c ) { - double closestDistance = 5000; - Planet* closestPlanet = NULL; - for( iterator i = begin(); i != end(); i++ ) { - double distance = i->getLocation().distance( c ); - if( distance < closestDistance ) { - closestDistance = distance; - closestPlanet = &(*i); - } - } - return closestPlanet; -} - -Planet* -Planets::closestToCoordinate( const Coordinate& c, double treshold ) { - Planet* closest = closestToCoordinate( c ); - if( closest->getLocation().distance( c ) < treshold ) - return closest; - else - return NULL; -} - -void -Planets::select( Selection selection ) { - - double minX = selection.getMinX(); - double maxX = selection.getMaxX(); - double minY = selection.getMinY(); - double maxY = selection.getMaxY(); - - for( iterator i = begin(); i != end(); i++ ) { - Coordinate location = i->getLocation(); - if( ( location.getX() > minX ) && ( location.getX() < maxX ) && ( location.getY() > minY ) && ( location.getY() < maxY ) ) - i->setSelected( true ); - else - i->setSelected( false ); - } - -} - -void -Planets::sourceSelect( Selection *selection, Player *owner ) { - - double minX = selection->getMinX(); - double maxX = selection->getMaxX(); - double minY = selection->getMinY(); - double maxY = selection->getMaxY(); - - for( iterator i = begin(); i != end(); i++ ) { - Coordinate location = i->getLocation(); - if( ( location.getX() > minX ) && ( location.getX() < maxX ) - && ( location.getY() > minY ) && ( location.getY() < maxY ) - && i->getOwner() == owner ) - i->setSourceSelected( true ); - else - i->setSourceSelected( false ); - } - -} - -void -Planets::updateShipLocations() { - for( iterator i = begin(); i != end(); i++ ) - i->updateShipLocations(); -} - -void -Planets::setUniverse( Universe* universe ) { - for( iterator i = begin(); i != end(); i++ ) - i->setUniverse( universe ); -} - -Planet* -Planets::getRandomPlanet() { - int number = rand() % size(); - iterator i = begin(); - for( int k = 0; k < number; k++ ) - i++; - return &(*i); -} - -Planet* -Planets::getRandomEnemyPlanet( Player* player ) { -} - -Planet* -Planets::getRandomNearbyPlanet( Planet* planet ) { - - Planet* result; - do { - result = getRandomPlanet(); - } while( result == planet ); - double distance = planet->distance( result ); - - for( int i = 0; i < size() / 2; i++ ) { - Planet* otherPlanet; - do { - otherPlanet = getRandomPlanet(); - } while( otherPlanet == planet ); - double otherDistance = planet->distance( otherPlanet ); - - // which planets do we prefer? - - if( otherPlanet->getOwner() != planet->getOwner() ) - otherDistance *= 0.1; - if( otherPlanet->getOwner()->getPlayerType() == Player::NEUTRAL ) - otherDistance *= 0.5; - if( ! otherPlanet->getMoon() ) - otherDistance *= 0.8; - - if( otherDistance < distance ) { - result = otherP... [truncated message content] |
From: <the...@us...> - 2007-07-28 10:16:28
|
Revision: 88 http://qonk.svn.sourceforge.net/qonk/?rev=88&view=rev Author: thebohemian Date: 2007-07-28 03:16:24 -0700 (Sat, 28 Jul 2007) Log Message: ----------- - merged changes from input-abstraction branch into trunk Modified Paths: -------------- trunk/Makefile.am trunk/README trunk/config.h.in trunk/configure.ac trunk/data/Makefile.am trunk/src/Makefile.am trunk/src/actions.cpp trunk/src/actions.h trunk/src/animations.cpp trunk/src/animations.h trunk/src/canvas.cpp trunk/src/canvas.h trunk/src/coordinate.cpp trunk/src/coordinate.h trunk/src/fonts.cpp trunk/src/fonts.h trunk/src/main.cpp trunk/src/messages.cpp trunk/src/messages.h trunk/src/planets.cpp trunk/src/planets.h trunk/src/players.cpp trunk/src/players.h trunk/src/selection.cpp trunk/src/selection.h trunk/src/settings.cpp trunk/src/settings.h trunk/src/ships.cpp trunk/src/ships.h trunk/src/stars.cpp trunk/src/stars.h trunk/src/timer.cpp trunk/src/timer.h trunk/src/universe.cpp trunk/src/universe.h Added Paths: ----------- trunk/BRANCH-README trunk/COPYING-GUICHAN trunk/data/README trunk/data/highlight.png trunk/data/normal.png trunk/guichan/ trunk/guichan/Makefile.am trunk/guichan/guichan/ trunk/guichan/guichan/Makefile.am trunk/guichan/guichan/README trunk/guichan/guichan/actionevent.cpp trunk/guichan/guichan/actionevent.hpp trunk/guichan/guichan/actionlistener.hpp trunk/guichan/guichan/basiccontainer.cpp trunk/guichan/guichan/basiccontainer.hpp trunk/guichan/guichan/cliprectangle.cpp trunk/guichan/guichan/cliprectangle.hpp trunk/guichan/guichan/color.cpp trunk/guichan/guichan/color.hpp trunk/guichan/guichan/deathlistener.hpp trunk/guichan/guichan/defaultfont.cpp trunk/guichan/guichan/defaultfont.hpp trunk/guichan/guichan/event.cpp trunk/guichan/guichan/event.hpp trunk/guichan/guichan/exception.cpp trunk/guichan/guichan/exception.hpp trunk/guichan/guichan/focushandler.cpp trunk/guichan/guichan/focushandler.hpp trunk/guichan/guichan/font.cpp trunk/guichan/guichan/font.hpp trunk/guichan/guichan/graphics.cpp trunk/guichan/guichan/graphics.hpp trunk/guichan/guichan/gui.cpp trunk/guichan/guichan/gui.hpp trunk/guichan/guichan/guichan.cpp trunk/guichan/guichan/image.cpp trunk/guichan/guichan/image.hpp trunk/guichan/guichan/imagefont.cpp trunk/guichan/guichan/imagefont.hpp trunk/guichan/guichan/imageloader.hpp trunk/guichan/guichan/input.hpp trunk/guichan/guichan/inputevent.cpp trunk/guichan/guichan/inputevent.hpp trunk/guichan/guichan/key.cpp trunk/guichan/guichan/key.hpp trunk/guichan/guichan/keyevent.cpp trunk/guichan/guichan/keyevent.hpp trunk/guichan/guichan/keyinput.cpp trunk/guichan/guichan/keyinput.hpp trunk/guichan/guichan/keylistener.hpp trunk/guichan/guichan/listmodel.hpp trunk/guichan/guichan/mouseevent.cpp trunk/guichan/guichan/mouseevent.hpp trunk/guichan/guichan/mouseinput.cpp trunk/guichan/guichan/mouseinput.hpp trunk/guichan/guichan/mouselistener.hpp trunk/guichan/guichan/opengl.hpp trunk/guichan/guichan/platform.hpp trunk/guichan/guichan/rectangle.cpp trunk/guichan/guichan/rectangle.hpp trunk/guichan/guichan/sdl/ trunk/guichan/guichan/sdl/Makefile.am trunk/guichan/guichan/sdl/sdl.cpp trunk/guichan/guichan/sdl/sdlgraphics.cpp trunk/guichan/guichan/sdl/sdlgraphics.hpp trunk/guichan/guichan/sdl/sdlimage.cpp trunk/guichan/guichan/sdl/sdlimage.hpp trunk/guichan/guichan/sdl/sdlimageloader.cpp trunk/guichan/guichan/sdl/sdlimageloader.hpp trunk/guichan/guichan/sdl/sdlinput.cpp trunk/guichan/guichan/sdl/sdlinput.hpp trunk/guichan/guichan/sdl/sdlpixel.hpp trunk/guichan/guichan/sdl.hpp trunk/guichan/guichan/widget.cpp trunk/guichan/guichan/widget.hpp trunk/guichan/guichan/widgets/ trunk/guichan/guichan/widgets/Makefile.am trunk/guichan/guichan/widgets/button.cpp trunk/guichan/guichan/widgets/button.hpp trunk/guichan/guichan/widgets/checkbox.cpp trunk/guichan/guichan/widgets/checkbox.hpp trunk/guichan/guichan/widgets/container.cpp trunk/guichan/guichan/widgets/container.hpp trunk/guichan/guichan/widgets/dropdown.cpp trunk/guichan/guichan/widgets/dropdown.hpp trunk/guichan/guichan/widgets/icon.cpp trunk/guichan/guichan/widgets/icon.hpp trunk/guichan/guichan/widgets/label.cpp trunk/guichan/guichan/widgets/label.hpp trunk/guichan/guichan/widgets/listbox.cpp trunk/guichan/guichan/widgets/listbox.hpp trunk/guichan/guichan/widgets/radiobutton.cpp trunk/guichan/guichan/widgets/radiobutton.hpp trunk/guichan/guichan/widgets/scrollarea.cpp trunk/guichan/guichan/widgets/scrollarea.hpp trunk/guichan/guichan/widgets/slider.cpp trunk/guichan/guichan/widgets/slider.hpp trunk/guichan/guichan/widgets/textbox.cpp trunk/guichan/guichan/widgets/textbox.hpp trunk/guichan/guichan/widgets/textfield.cpp trunk/guichan/guichan/widgets/textfield.hpp trunk/guichan/guichan/widgets/window.cpp trunk/guichan/guichan/widgets/window.hpp trunk/guichan/guichan.hpp trunk/src/controloptions.cpp trunk/src/controloptions.h trunk/src/game.cpp trunk/src/game.h trunk/src/gameoptions.cpp trunk/src/gameoptions.h trunk/src/input.h trunk/src/lisp/ trunk/src/lisp/Makefile.am trunk/src/lisp/README trunk/src/lisp/lexer.cpp trunk/src/lisp/lexer.hpp trunk/src/lisp/lisp.cpp trunk/src/lisp/lisp.hpp trunk/src/lisp/parser.cpp trunk/src/lisp/parser.hpp trunk/src/lisp/translation.hpp trunk/src/lisp/writer.cpp trunk/src/lisp/writer.hpp trunk/src/main.h trunk/src/menu.cpp trunk/src/menu.h trunk/src/menuaction.cpp trunk/src/menuaction.h trunk/src/menuentry.cpp trunk/src/menuentry.h trunk/src/menumanager.cpp trunk/src/menumanager.h trunk/src/menusystem.cpp trunk/src/menusystem.h trunk/src/sdl_driver.cpp trunk/src/sdl_driver.h trunk/src/videooptions.cpp trunk/src/videooptions.h Removed Paths: ------------- trunk/guichan/Makefile.am trunk/guichan/guichan/ trunk/guichan/guichan/Makefile.am trunk/guichan/guichan/README trunk/guichan/guichan/actionevent.cpp trunk/guichan/guichan/actionevent.hpp trunk/guichan/guichan/actionlistener.hpp trunk/guichan/guichan/basiccontainer.cpp trunk/guichan/guichan/basiccontainer.hpp trunk/guichan/guichan/cliprectangle.cpp trunk/guichan/guichan/cliprectangle.hpp trunk/guichan/guichan/color.cpp trunk/guichan/guichan/color.hpp trunk/guichan/guichan/deathlistener.hpp trunk/guichan/guichan/defaultfont.cpp trunk/guichan/guichan/defaultfont.hpp trunk/guichan/guichan/event.cpp trunk/guichan/guichan/event.hpp trunk/guichan/guichan/exception.cpp trunk/guichan/guichan/exception.hpp trunk/guichan/guichan/focushandler.cpp trunk/guichan/guichan/focushandler.hpp trunk/guichan/guichan/font.cpp trunk/guichan/guichan/font.hpp trunk/guichan/guichan/graphics.cpp trunk/guichan/guichan/graphics.hpp trunk/guichan/guichan/gui.cpp trunk/guichan/guichan/gui.hpp trunk/guichan/guichan/guichan.cpp trunk/guichan/guichan/image.cpp trunk/guichan/guichan/image.hpp trunk/guichan/guichan/imagefont.cpp trunk/guichan/guichan/imagefont.hpp trunk/guichan/guichan/imageloader.hpp trunk/guichan/guichan/input.hpp trunk/guichan/guichan/inputevent.cpp trunk/guichan/guichan/inputevent.hpp trunk/guichan/guichan/key.cpp trunk/guichan/guichan/key.hpp trunk/guichan/guichan/keyevent.cpp trunk/guichan/guichan/keyevent.hpp trunk/guichan/guichan/keyinput.cpp trunk/guichan/guichan/keyinput.hpp trunk/guichan/guichan/keylistener.hpp trunk/guichan/guichan/listmodel.hpp trunk/guichan/guichan/mouseevent.cpp trunk/guichan/guichan/mouseevent.hpp trunk/guichan/guichan/mouseinput.cpp trunk/guichan/guichan/mouseinput.hpp trunk/guichan/guichan/mouselistener.hpp trunk/guichan/guichan/opengl.hpp trunk/guichan/guichan/platform.hpp trunk/guichan/guichan/rectangle.cpp trunk/guichan/guichan/rectangle.hpp trunk/guichan/guichan/sdl/ trunk/guichan/guichan/sdl/Makefile.am trunk/guichan/guichan/sdl/sdl.cpp trunk/guichan/guichan/sdl/sdlgraphics.cpp trunk/guichan/guichan/sdl/sdlgraphics.hpp trunk/guichan/guichan/sdl/sdlimage.cpp trunk/guichan/guichan/sdl/sdlimage.hpp trunk/guichan/guichan/sdl/sdlimageloader.cpp trunk/guichan/guichan/sdl/sdlimageloader.hpp trunk/guichan/guichan/sdl/sdlinput.cpp trunk/guichan/guichan/sdl/sdlinput.hpp trunk/guichan/guichan/sdl/sdlpixel.hpp trunk/guichan/guichan/sdl.hpp trunk/guichan/guichan/widget.cpp trunk/guichan/guichan/widget.hpp trunk/guichan/guichan/widgets/ trunk/guichan/guichan/widgets/Makefile.am trunk/guichan/guichan/widgets/button.cpp trunk/guichan/guichan/widgets/button.hpp trunk/guichan/guichan/widgets/checkbox.cpp trunk/guichan/guichan/widgets/checkbox.hpp trunk/guichan/guichan/widgets/container.cpp trunk/guichan/guichan/widgets/container.hpp trunk/guichan/guichan/widgets/dropdown.cpp trunk/guichan/guichan/widgets/dropdown.hpp trunk/guichan/guichan/widgets/icon.cpp trunk/guichan/guichan/widgets/icon.hpp trunk/guichan/guichan/widgets/label.cpp trunk/guichan/guichan/widgets/label.hpp trunk/guichan/guichan/widgets/listbox.cpp trunk/guichan/guichan/widgets/listbox.hpp trunk/guichan/guichan/widgets/radiobutton.cpp trunk/guichan/guichan/widgets/radiobutton.hpp trunk/guichan/guichan/widgets/scrollarea.cpp trunk/guichan/guichan/widgets/scrollarea.hpp trunk/guichan/guichan/widgets/slider.cpp trunk/guichan/guichan/widgets/slider.hpp trunk/guichan/guichan/widgets/textbox.cpp trunk/guichan/guichan/widgets/textbox.hpp trunk/guichan/guichan/widgets/textfield.cpp trunk/guichan/guichan/widgets/textfield.hpp trunk/guichan/guichan/widgets/window.cpp trunk/guichan/guichan/widgets/window.hpp trunk/guichan/guichan.hpp trunk/src/lisp/Makefile.am trunk/src/lisp/README trunk/src/lisp/lexer.cpp trunk/src/lisp/lexer.hpp trunk/src/lisp/lisp.cpp trunk/src/lisp/lisp.hpp trunk/src/lisp/parser.cpp trunk/src/lisp/parser.hpp trunk/src/lisp/translation.hpp trunk/src/lisp/writer.cpp trunk/src/lisp/writer.hpp Copied: trunk/BRANCH-README (from rev 87, branches/input-abstraction-2007-06-12/BRANCH-README) =================================================================== --- trunk/BRANCH-README (rev 0) +++ trunk/BRANCH-README 2007-07-28 10:16:24 UTC (rev 88) @@ -0,0 +1,28 @@ +About this branch +----------------- + +This development branch has been created on 2007-06-12 to abstract the +way Qonk handles its input. The result of this work should be that it +will be much easier to change input mappings. This will allow playing Qonk +properly on devices with only a single mouse button or no keyboard. + +Scope: +------ + + - remove direct access to keysym values [done] + - introduce event layer which consists of stuff like quit game, + next level, set fleet strength [done] + - introduce input mapping [done] + - allow 2 inputs for one game action [done] + - read input mapping from config file [done] + - write input mapping to config file [done] + - write functions that creates a human readable string for an input + * one that can be used in messages like "press the [N] key for next level" + * one that can be used to present a mapping in detail: "cursor up: mouse y-" [done] + - introduce graphical items to trigger the events (perhaps buttons) [postponed] + - update game manual [done] + +Status: +------- + +- Basic input abstraction complete. Copied: trunk/COPYING-GUICHAN (from rev 87, branches/input-abstraction-2007-06-12/COPYING-GUICHAN) =================================================================== --- trunk/COPYING-GUICHAN (rev 0) +++ trunk/COPYING-GUICHAN 2007-07-28 10:16:24 UTC (rev 88) @@ -0,0 +1,38 @@ +This license applies to the embedded guichan distribution: + +Copyright (c) 2004, 2005, 2006 Olof Naessén and Per Larsson +Per Larsson a.k.a finalman +Olof Naessén a.k.a jansem/yakslem +All rights reserved. + +Redistribution and use in source and binary forms, +with or without modification, are permitted provided +that the following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. +* Redistributions in binary form must reproduce the + above copyright notice, this list of conditions and + the following disclaimer in the documentation and/or + other materials provided with the distribution. +* Neither the name of Guichan nor the names of its + contributors may be used to endorse or promote + products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2007-07-27 21:46:15 UTC (rev 87) +++ trunk/Makefile.am 2007-07-28 10:16:24 UTC (rev 88) @@ -1,4 +1,4 @@ -SUBDIRS = src data +SUBDIRS = guichan src data EXTRA_DIST = README COPYING missing Makefile.manual TODO Modified: trunk/README =================================================================== --- trunk/README 2007-07-27 21:46:15 UTC (rev 87) +++ trunk/README 2007-07-28 10:16:24 UTC (rev 88) @@ -1,5 +1,5 @@ -Qonk ----- +Qonk 0.0.3 +========== Qonk is a small build-and-conquer strategy game with very simple rules. A complete game only lasts for a few minutes and can be a fun break away from @@ -18,64 +18,96 @@ Dependencies ------------ -To compile the program you will need to install SDL, SDL_ttf and SDL_gfx. -Just do a simple "make", and the program should be compiling. +To compile the program you will need to install SDL, SDL_ttf and SDL_gfx. It is +built using GNU Autoconf. In a published tarball you only need to execute -Qonk-rs -------- -Qonk-rs is a simple functional change of the original name to denote that -I (Robert Schuster) modified it. Additionally I did not add a version number -but used the release date instead. + ./configure + make + make install -Modifications +You get helpful error messages if something is not correct with the +dependencies. + +If you want to built the sources from SVN you need to issue ./autogen.sh and +have the autotools installed (GNU Automake, GNU Autoconf, GNU libtool). + +How to play ------------- -(2007-02-17 Robert Schuster <rob...@fs...>) -Starting from the 0.0.2beta1 code[0] a simpler way of selecting the -ships has been implemented. Originally you had to draw a box around the -ships to form your fleet. Now you draw a box around your planets(use -the left mouse button) or select a single planet (currently with the middle -mouse button) and confirm the move with a right-click on the target. +Select a group of planets to put their ships into your selection for the next +move. Now do a right-click near the planet where you want to send you fleet to. +You can attack neutral (grey), enemy (some color) and reinforce your own planets +(the white ones). -In this moment a pre-defined percentag of the ships at each planet will -head towards the target. You can change the percentage any time by -pressing the number keys (1 -> 10%, ..., 9 -> 90%, 0 -> 100%). +The number of ships starting from a planets depends on the number of ships being +stationed there and the current fleet strength setting. In the beginning the +strength is set to 50%. That means that half of the ships on each planets will +take off when you order them to move. You can choose other strength settings by +pressing the number keys (1 -> 10%, 9 -> 90%, 0->100%). If you press the 's' key +you are in single ship mode. This means that on each move order one ship leaves +from the selected planets (there has to be at least one stationed, though). -If you know galcon you know how it works. +Besides setting the strength to certain values you can lower or higher the +strength by using the mouse wheel. Below 10% comes the single ship mode, +when requesting to lower the strength it switches to 100%. The same happens in +the reverse order when you increase the strength and are at 100%. -Ah yes. The second small modification changes the way ship build time -is calculated. It is simple: The bigger the planet the shorter the build -time. Unfortunately I haven't touched the AI to hunt for the rich planets -first. Any volunteers? +New ships are continuisly built on the planets (and moons) you own. Bigger +planets usually built ships faster than smaller ones. +Other options +------------- + +You can toggle displaying of enemy ships by pressing the 'e' key. + +If you see yourself losing and want to retry, press 'r'. If you have won instead +press 'n' to start the next round. + +Press 'f' to switch between fullscreen and windowed mode. In windowed mode you +need to make sure that the mouse cannot leave the game's window. Press 'g' to +activate input grabbing and press it again if you want to release the input. + +Last but not least 'p' can be used to pause and unpause the game and 'ESC' quits +it. + +Command line options +-------------------- + +Start the game with qonk <numberOfPlanets> <numberOfComputerPlayers> to run a +game with such a universe. + +Config file +----------- + +On GNU/Linux and other POSIX-like systems a config file is written in your +home directory at .qonk/qonk.config. + +The format is LISP-like (you remember it from SuperTuxKart probably :) ). At the +moment editing the config file is the only possibility to switch the various +of the game except for the fullscreen mode state and the game's progress which +are saved on exit. + +If you feel sufficiently experienced you can change the input configuration of +the game. Don't use escape or g in any of your mappings, because those are +hardcoded to quitting and toggling the input grab. + +Development +----------- + +Plans are there to add a menu system, some GUI components and perhaps +a single-computer multiplayer mode. Feel free to contact the development team +via the mailing-list. + Issues ------ - You cannot select ships which are already in the vasts of space. -Q & A ------ +Homepage +-------- -Q: You have stolen an idea from galcon. -A: Thanks goodness software ideas are not patentable (at least in europe). It - doesn't do galcon any harm if I implement a feature that they have and I like. - So the idea is not *stolen* it has spread. +http://qonk.sf.net -Q: What is your relation with galcon. -A: Nothing. I played it a while found it nice but found it inacceptable (for me) - that it is not free software. +Project page +------------- -Q: What is your relation with the original QONK. -A: People on happypenguin.org wrote about it in the comments for galcon. So I - downloaded, compiled and played it. I found it funny and wanted to add a few - features. At first I wanted to see whether they make sense for QONK (I think - they do) and then I wanted to push this back into the free and open-source - software realm in the hope that someone else will add even more good stuff. - -Q: Are you planning to do more work on QONK? -A: No. I don't have the time. However I would like to see that others pick it - up where I left or modify the original source to their needs. QONK is - well-written, add a bit more abstraction to e.g. the input handling and - one can push it much farther and make it the second best free software - time killer (after Frozen Bubble ;)). - -[0] - http://anthony.liekens.net/pub/files/qonk-0.0.2beta1.tar.gz +http://sf.net/projects/qonk Modified: trunk/config.h.in =================================================================== --- trunk/config.h.in 2007-07-27 21:46:15 UTC (rev 87) +++ trunk/config.h.in 2007-07-28 10:16:24 UTC (rev 88) @@ -12,6 +12,9 @@ /* Define to 1 if you have the `SDL_gfx' library (-lSDL_gfx). */ #undef HAVE_LIBSDL_GFX +/* Define to 1 if you have the `SDL_image' library (-lSDL_image). */ +#undef HAVE_LIBSDL_IMAGE + /* Define to 1 if you have the `SDL_ttf' library (-lSDL_ttf). */ #undef HAVE_LIBSDL_TTF @@ -27,6 +30,9 @@ /* Define to 1 if you have the <SDL/SDL.h> header file. */ #undef HAVE_SDL_SDL_H +/* Define to 1 if you have the <SDL/SDL_image.h> header file. */ +#undef HAVE_SDL_SDL_IMAGE_H + /* Define to 1 if you have the <SDL/SDL_ttf.h> header file. */ #undef HAVE_SDL_SDL_TTF_H Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-07-27 21:46:15 UTC (rev 87) +++ trunk/configure.ac 2007-07-28 10:16:24 UTC (rev 88) @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([qonk], [0.0.3], [qon...@li...]) +AC_INIT([qonk], [0.0.3+svn], [qon...@li...]) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE @@ -12,6 +12,7 @@ # Checks for programs. AC_PROG_CXX AC_PROG_CC +AC_PROG_RANLIB AC_LANG_C @@ -23,10 +24,11 @@ AC_CHECK_LIB([SDL], [SDL_Init]) AC_CHECK_LIB([SDL_ttf], [TTF_Init], ,AC_MSG_ERROR([SDL_ttf missing. Please install at least version 2.0!])) AC_CHECK_LIB([SDL_gfx], [pixelColor], ,AC_MSG_ERROR([SDL_gfx missing. Please install at least version 1.2!])) +AC_CHECK_LIB([SDL_image], [IMG_Load], ,AC_MSG_ERROR([SDL_image missing. Please install at least version 1.2!])) # Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS([stdlib.h SDL/SDL.h SDL/SDL_gfxPrimitives.h SDL/SDL_ttf.h]) +AC_CHECK_HEADERS([stdlib.h SDL/SDL.h SDL/SDL_gfxPrimitives.h SDL/SDL_ttf.h SDL/SDL_image.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL @@ -38,5 +40,10 @@ AC_CONFIG_FILES([Makefile data/Makefile - src/Makefile]) + src/lisp/Makefile + src/Makefile + guichan/Makefile + guichan/guichan/Makefile + guichan/guichan/sdl/Makefile + guichan/guichan/widgets/Makefile]) AC_OUTPUT Modified: trunk/data/Makefile.am =================================================================== --- trunk/data/Makefile.am 2007-07-27 21:46:15 UTC (rev 87) +++ trunk/data/Makefile.am 2007-07-28 10:16:24 UTC (rev 88) @@ -1,3 +1,3 @@ -pkgdata_DATA = font.ttf +pkgdata_DATA = font.ttf normal.png highlight.png EXTRA_DIST = $(pkgdata_DATA) Copied: trunk/data/README (from rev 87, branches/input-abstraction-2007-06-12/data/README) =================================================================== --- trunk/data/README (rev 0) +++ trunk/data/README 2007-07-28 10:16:24 UTC (rev 88) @@ -0,0 +1,40 @@ +Copyright: +highlight.png and normal.png are taken from the guichan demo 'fps' and are +licensed under the following license: + +Copyright (c) 2004, 2005, 2006 Olof Naessén and Per Larsson +Per Larsson a.k.a finalman +Olof Naessén a.k.a jansem/yakslem +All rights reserved. + +Redistribution and use in source and binary forms, +with or without modification, are permitted provided +that the following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. +* Redistributions in binary form must reproduce the + above copyright notice, this list of conditions and + the following disclaimer in the documentation and/or + other materials provided with the distribution. +* Neither the name of Guichan nor the names of its + contributors may be used to endorse or promote + products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + Copied: trunk/data/highlight.png (from rev 87, branches/input-abstraction-2007-06-12/data/highlight.png) =================================================================== (Binary files differ) Copied: trunk/data/normal.png (from rev 87, branches/input-abstraction-2007-06-12/data/normal.png) =================================================================== (Binary files differ) Copied: trunk/guichan (from rev 87, branches/input-abstraction-2007-06-12/guichan) Deleted: trunk/guichan/Makefile.am =================================================================== --- branches/input-abstraction-2007-06-12/guichan/Makefile.am 2007-07-27 21:46:15 UTC (rev 87) +++ trunk/guichan/Makefile.am 2007-07-28 10:16:24 UTC (rev 88) @@ -1,6 +0,0 @@ -SUBDIRS = guichan - -libguichanincludedir = guichan - -libguichaninclude_HEADERS = \ - guichan.hpp \ No newline at end of file Copied: trunk/guichan/Makefile.am (from rev 87, branches/input-abstraction-2007-06-12/guichan/Makefile.am) =================================================================== --- trunk/guichan/Makefile.am (rev 0) +++ trunk/guichan/Makefile.am 2007-07-28 10:16:24 UTC (rev 88) @@ -0,0 +1,6 @@ +SUBDIRS = guichan + +libguichanincludedir = guichan + +libguichaninclude_HEADERS = \ + guichan.hpp \ No newline at end of file Copied: trunk/guichan/guichan (from rev 87, branches/input-abstraction-2007-06-12/guichan/guichan) Deleted: trunk/guichan/guichan/Makefile.am =================================================================== --- branches/input-abstraction-2007-06-12/guichan/guichan/Makefile.am 2007-07-27 21:46:15 UTC (rev 87) +++ trunk/guichan/guichan/Makefile.am 2007-07-28 10:16:24 UTC (rev 88) @@ -1,66 +0,0 @@ -SUBDIRS = widgets sdl - -INCLUDES = -I$(top_srcdir)/guichan - -noinst_LIBRARIES = libguichan.a - -libguichan_a_LIBADD = widgets/libguichan_widgets.a sdl/libguichan_sdl.a - -#libguichan_a_DEPENDENCIES = \ -# widgets/libguichan_widgets.a \ -# sdl/libguichan_sdl.a - -# The Guichan library sources -libguichan_a_SOURCES = \ - actionevent.cpp \ - basiccontainer.cpp \ - cliprectangle.cpp \ - color.cpp \ - defaultfont.cpp \ - event.cpp \ - exception.cpp \ - focushandler.cpp \ - font.cpp \ - graphics.cpp \ - gui.cpp \ - guichan.cpp \ - image.cpp \ - imagefont.cpp \ - inputevent.cpp \ - key.cpp \ - keyevent.cpp \ - keyinput.cpp \ - mouseevent.cpp \ - mouseinput.cpp \ - rectangle.cpp \ - widget.cpp \ - actionevent.hpp \ - actionlistener.hpp \ - basiccontainer.hpp \ - cliprectangle.hpp \ - color.hpp \ - deathlistener.hpp \ - defaultfont.hpp \ - event.hpp \ - exception.hpp \ - focushandler.hpp \ - font.hpp \ - graphics.hpp \ - gui.hpp \ - imagefont.hpp \ - image.hpp \ - imageloader.hpp \ - inputevent.hpp \ - input.hpp \ - keyevent.hpp \ - key.hpp \ - keyinput.hpp \ - keylistener.hpp \ - listmodel.hpp \ - mouseevent.hpp \ - mouseinput.hpp \ - mouselistener.hpp \ - platform.hpp \ - rectangle.hpp \ - widget.hpp \ - x.hpp Copied: trunk/guichan/guichan/Makefile.am (from rev 87, branches/input-abstraction-2007-06-12/guichan/guichan/Makefile.am) =================================================================== --- trunk/guichan/guichan/Makefile.am (rev 0) +++ trunk/guichan/guichan/Makefile.am 2007-07-28 10:16:24 UTC (rev 88) @@ -0,0 +1,66 @@ +SUBDIRS = widgets sdl + +INCLUDES = -I$(top_srcdir)/guichan + +noinst_LIBRARIES = libguichan.a + +libguichan_a_LIBADD = widgets/libguichan_widgets.a sdl/libguichan_sdl.a + +#libguichan_a_DEPENDENCIES = \ +# widgets/libguichan_widgets.a \ +# sdl/libguichan_sdl.a + +# The Guichan library sources +libguichan_a_SOURCES = \ + actionevent.cpp \ + basiccontainer.cpp \ + cliprectangle.cpp \ + color.cpp \ + defaultfont.cpp \ + event.cpp \ + exception.cpp \ + focushandler.cpp \ + font.cpp \ + graphics.cpp \ + gui.cpp \ + guichan.cpp \ + image.cpp \ + imagefont.cpp \ + inputevent.cpp \ + key.cpp \ + keyevent.cpp \ + keyinput.cpp \ + mouseevent.cpp \ + mouseinput.cpp \ + rectangle.cpp \ + widget.cpp \ + actionevent.hpp \ + actionlistener.hpp \ + basiccontainer.hpp \ + cliprectangle.hpp \ + color.hpp \ + deathlistener.hpp \ + defaultfont.hpp \ + event.hpp \ + exception.hpp \ + focushandler.hpp \ + font.hpp \ + graphics.hpp \ + gui.hpp \ + imagefont.hpp \ + image.hpp \ + imageloader.hpp \ + inputevent.hpp \ + input.hpp \ + keyevent.hpp \ + key.hpp \ + keyinput.hpp \ + keylistener.hpp \ + listmodel.hpp \ + mouseevent.hpp \ + mouseinput.hpp \ + mouselistener.hpp \ + platform.hpp \ + rectangle.hpp \ + widget.hpp \ + x.hpp Deleted: trunk/guichan/guichan/README =================================================================== --- branches/input-abstraction-2007-06-12/guichan/guichan/README 2007-07-27 21:46:15 UTC (rev 87) +++ trunk/guichan/guichan/README 2007-07-28 10:16:24 UTC (rev 88) @@ -1,4 +0,0 @@ -This folder contains guichan 0.6.1 which has been customized -to use SDL. - -The source of this library is provided under the revised BSD license. Copied: trunk/guichan/guichan/README (from rev 87, branches/input-abstraction-2007-06-12/guichan/guichan/README) =================================================================== --- trunk/guichan/guichan/README (rev 0) +++ trunk/guichan/guichan/README 2007-07-28 10:16:24 UTC (rev 88) @@ -0,0 +1,4 @@ +This folder contains guichan 0.6.1 which has been customized +to use SDL. + +The source of this library is provided under the revised BSD license. Deleted: trunk/guichan/guichan/actionevent.cpp =================================================================== --- branches/input-abstraction-2007-06-12/guichan/guichan/actionevent.cpp 2007-07-27 21:46:15 UTC (rev 87) +++ trunk/guichan/guichan/actionevent.cpp 2007-07-28 10:16:24 UTC (rev 88) @@ -1,82 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004, 2005, 2006, 2007 Olof Naess\xE9n and Per Larsson - * - * Js_./ - * Per Larsson a.k.a finalman _RqZ{a<^_aa - * Olof Naess\xE9n a.k.a jansem/yakslem _asww7!uY`> )\a// - * _Qhm`] _f "'c 1!5m - * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[ - * .)j(] .d_/ '-( P . S - * License: (BSD) <Td/Z <fP"5(\"??"\a. .L - * Redistribution and use in source and _dV>ws?a-?' ._/L #' - * binary forms, with or without )4d[#7r, . ' )d`)[ - * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam' - * that the following conditions are met: j<<WP+k/);. _W=j f - * 1. Redistributions of source code must .$%w\/]Q . ."' . mj$ - * retain the above copyright notice, ]E.pYY(Q]>. a J@\ - * this list of conditions and the j(]1u<sE"L,. . ./^ ]{a - * following disclaimer. 4'_uomm\. )L);-4 (3= - * 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[ - * reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m - * this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/ - * following disclaimer in the <B!</]C)d_, '(<' .f. =C+m - * documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]' - * provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W" - * 3. Neither the name of Guichan nor the :$we` _! + _/ . j? - * names of its contributors may be used =3)= _f (_yQmWW$#( " - * to endorse or promote products derived - W, sQQQQmZQ#Wwa].. - * from this software without specific (js, \[QQW$QWW#?!V"". - * prior written permission. ]y:.<\.. . - * -]n w/ ' [. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ ! - * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , ' - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- % - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'., - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?" - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. . - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^ - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/actionevent.hpp" - -namespace gcn -{ - ActionEvent::ActionEvent(Widget* source, const std::string& id) - :Event(source), - mId(id) - { - - } - - ActionEvent::~ActionEvent() - { - - } - - const std::string& ActionEvent::getId() const - { - return mId; - } -} - Copied: trunk/guichan/guichan/actionevent.cpp (from rev 87, branches/input-abstraction-2007-06-12/guichan/guichan/actionevent.cpp) =================================================================== --- trunk/guichan/guichan/actionevent.cpp (rev 0) +++ trunk/guichan/guichan/actionevent.cpp 2007-07-28 10:16:24 UTC (rev 88) @@ -0,0 +1,82 @@ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004, 2005, 2006, 2007 Olof Naess\xE9n and Per Larsson + * + * Js_./ + * Per Larsson a.k.a finalman _RqZ{a<^_aa + * Olof Naess\xE9n a.k.a jansem/yakslem _asww7!uY`> )\a// + * _Qhm`] _f "'c 1!5m + * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[ + * .)j(] .d_/ '-( P . S + * License: (BSD) <Td/Z <fP"5(\"??"\a. .L + * Redistribution and use in source and _dV>ws?a-?' ._/L #' + * binary forms, with or without )4d[#7r, . ' )d`)[ + * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam' + * that the following conditions are met: j<<WP+k/);. _W=j f + * 1. Redistributions of source code must .$%w\/]Q . ."' . mj$ + * retain the above copyright notice, ]E.pYY(Q]>. a J@\ + * this list of conditions and the j(]1u<sE"L,. . ./^ ]{a + * following disclaimer. 4'_uomm\. )L);-4 (3= + * 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[ + * reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m + * this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/ + * following disclaimer in the <B!</]C)d_, '(<' .f. =C+m + * documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]' + * provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W" + * 3. Neither the name of Guichan nor the :$we` _! + _/ . j? + * names of its contributors may be used =3)= _f (_yQmWW$#( " + * to endorse or promote products derived - W, sQQQQmZQ#Wwa].. + * from this software without specific (js, \[QQW$QWW#?!V"". + * prior written permission. ]y:.<\.. . + * -]n w/ ' [. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ ! + * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , ' + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- % + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'., + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?" + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. . + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^ + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "guichan/actionevent.hpp" + +namespace gcn +{ + ActionEvent::ActionEvent(Widget* source, const std::string& id) + :Event(source), + mId(id) + { + + } + + ActionEvent::~ActionEvent() + { + + } + + const std::string& ActionEvent::getId() const + { + return mId; + } +} + Deleted: trunk/guichan/guichan/actionevent.hpp =================================================================== --- branches/input-abstraction-2007-06-12/guichan/guichan/actionevent.hpp 2007-07-27 21:46:15 UTC (rev 87) +++ trunk/guichan/guichan/actionevent.hpp 2007-07-28 10:16:24 UTC (rev 88) @@ -1,105 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004, 2005, 2006, 2007 Olof Naess\xE9n and Per Larsson - * - * Js_./ - * Per Larsson a.k.a finalman _RqZ{a<^_aa - * Olof Naess\xE9n a.k.a jansem/yakslem _asww7!uY`> )\a// - * _Qhm`] _f "'c 1!5m - * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[ - * .)j(] .d_/ '-( P . S - * License: (BSD) <Td/Z <fP"5(\"??"\a. .L - * Redistribution and use in source and _dV>ws?a-?' ._/L #' - * binary forms, with or without )4d[#7r, . ' )d`)[ - * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam' - * that the following conditions are met: j<<WP+k/);. _W=j f - * 1. Redistributions of source code must .$%w\/]Q . ."' . mj$ - * retain the above copyright notice, ]E.pYY(Q]>. a J@\ - * this list of conditions and the j(]1u<sE"L,. . ./^ ]{a - * following disclaimer. 4'_uomm\. )L);-4 (3= - * 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[ - * reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m - * this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/ - * following disclaimer in the <B!</]C)d_, '(<' .f. =C+m - * documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]' - * provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W" - * 3. Neither the name of Guichan nor the :$we` _! + _/ . j? - * names of its contributors may be used =3)= _f (_yQmWW$#( " - * to endorse or promote products derived - W, sQQQQmZQ#Wwa].. - * from this software without specific (js, \[QQW$QWW#?!V"". - * prior written permission. ]y:.<\.. . - * -]n w/ ' [. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ ! - * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , ' - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- % - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'., - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?" - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. . - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^ - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_ACTIONEVENT_HPP -#define GCN_ACTIONEVENT_HPP - -#include "guichan/event.hpp" -#include "guichan/platform.hpp" - -#include <string> - -namespace gcn -{ - class Widget; - - /** - * Represents an action event. - * - * @author Olof Naess\xE9n - * @since 0.6.0 - */ - class GCN_CORE_DECLSPEC ActionEvent: public Event - { - public: - - /** - * Constructor. - * - * @param source the source widget of the event. - * @param id the identifier of the event. - */ - ActionEvent(Widget* source, const std::string& id); - - /** - * Destructor. - */ - virtual ~ActionEvent(); - - /** - * Gets the id of the event. - * - * @return the id of the event. - */ - const std::string& getId() const; - - protected: - std::string mId; - }; -} - -#endif // GCN_ACTIONEVENT_HPP - Copied: trunk/guichan/guichan/actionevent.hpp (from rev 87, branches/input-abstraction-2007-06-12/guichan/guichan/actionevent.hpp) =================================================================== --- trunk/guichan/guichan/actionevent.hpp (rev 0) +++ trunk/guichan/guichan/actionevent.hpp 2007-07-28 10:16:24 UTC (rev 88) @@ -0,0 +1,105 @@ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004, 2005, 2006, 2007 Olof Naess\xE9n and Per Larsson + * + * Js_./ + * Per Larsson a.k.a finalman _RqZ{a<^_aa + * Olof Naess\xE9n a.k.a jansem/yakslem _asww7!uY`> )\a// + * _Qhm`] _f "'c 1!5m + * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[ + * .)j(] .d_/ '-( P . S + * License: (BSD) <Td/Z <fP"5(\"??"\a. .L + * Redistribution and use in source and _dV>ws?a-?' ._/L #' + * binary forms, with or without )4d[#7r, . ' )d`)[ + * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam' + * that the following conditions are met: j<<WP+k/);. _W=j f + * 1. Redistributions of source code must .$%w\/]Q . ."' . mj$ + * retain the above copyright notice, ]E.pYY(Q]>. a J@\ + * this list of conditions and the j(]1u<sE"L,. . ./^ ]{a + * following disclaimer. 4'_uomm\. )L);-4 (3= + * 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[ + * reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m + * this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/ + * following disclaimer in the <B!</]C)d_, '(<' .f. =C+m + * documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]' + * provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W" + * 3. Neither the name of Guichan nor the :$we` _! + _/ . j? + * names of its contributors may be used =3)= _f (_yQmWW$#( " + * to endorse or promote products derived - W, sQQQQmZQ#Wwa].. + * from this software without specific (js, \[QQW$QWW#?!V"". + * prior written permission. ]y:.<\.. . + * -]n w/ ' [. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ ! + * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , ' + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- % + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'., + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?" + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. . + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^ + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef GCN_ACTIONEVENT_HPP +#define GCN_ACTIONEVENT_HPP + +#include "guichan/event.hpp" +#include "guichan/platform.hpp" + +#include <string> + +namespace gcn +{ + class Widget; + + /** + * Represents an action event. + * + * @author Olof Naess\xE9n + * @since 0.6.0 + */ + class GCN_CORE_DECLSPEC ActionEvent: public Event + { + public: + + /** + * Constructor. + * + * @param source the source widget of the event. + * @param id the identifier of the event. + */ + ActionEvent(Widget* source, const std::string& id); + + /** + * Destructor. + */ + virtual ~ActionEvent(); + + /** + * Gets the id of the event. + * + * @return the id of the event. + */ + const std::string& getId() const; + + protected: + std::string mId; + }; +} + +#endif // GCN_ACTIONEVENT_HPP + Deleted: trunk/guichan/guichan/actionlistener.hpp =================================================================== --- branches/input-abstraction-2007-06-12/guichan/guichan/actionlistener.hpp 2007-07-27 21:46:15 UTC (rev 87) +++ trunk/guichan/guichan/actionlistener.hpp 2007-07-28 10:16:24 UTC (rev 88) @@ -1,98 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004, 2005, 2006, 2007 Olof Naess\xE9n and Per Larsson - * - * Js_./ - * Per Larsson a.k.a finalman _RqZ{a<^_aa - * Olof Naess\xE9n a.k.a jansem/yakslem _asww7!uY`> )\a// - * _Qhm`] _f "'c 1!5m - * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[ - * .)j(] .d_/ '-( P . S - * License: (BSD) <Td/Z <fP"5(\"??"\a. .L - * Redistribution and use in source and _dV>ws?a-?' ._/L #' - * binary forms, with or without )4d[#7r, . ' )d`)[ - * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam' - * that the following conditions are met: j<<WP+k/);. _W=j f - * 1. Redistributions of source code must .$%w\/]Q . ."' . mj$ - * retain the above copyright notice, ]E.pYY(Q]>. a J@\ - * this list of conditions and the j(]1u<sE"L,. . ./^ ]{a - * following disclaimer. 4'_uomm\. )L);-4 (3= - * 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[ - * reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m - * this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/ - * following disclaimer in the <B!</]C)d_, '(<' .f. =C+m - * documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]' - * provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W" - * 3. Neither the name of Guichan nor the :$we` _! + _/ . j? - * names of its contributors may be used =3)= _f (_yQmWW$#( " - * to endorse or promote products derived - W, sQQQQmZQ#Wwa].. - * from this software without specific (js, \[QQW$QWW#?!V"". - * prior written permission. ]y:.<\.. . - * -]n w/ ' [. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ ! - * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , ' - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- % - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'., - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?" - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. . - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^ - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_ACTIONLISTENER_HPP -#define GCN_ACTIONLISTENER_HPP - -#include <string> - -#include "guichan/actionevent.hpp" -#include "guichan/platform.hpp" - -namespace gcn -{ - /** - * Listener of action events from Widgets. To be able to - * listen for actions you must make a class which inherits - * from this class and implements the action function. - * - * @see Widget::addActionListener - * @author Olof Naess\xE9n - * @author Per Larsson - */ - class GCN_CORE_DECLSPEC ActionListener - { - public: - - /** - * Destructor. - */ - virtual ~ActionListener() { } - - /** - * Called when an action is recieved from a Widget. It is used - * to be able to recieve a notification that an action has - * occured. - * - * @param actionEvent the event of the action. - * @since 0.6.0 - */ - virtual void action(const ActionEvent& actionEvent) = 0; - - }; -} - -#endif // end GCN_ACTIONLISTENER_HPP Copied: trunk/guichan/guichan/actionlistener.hpp (from rev 87, branches/input-abstraction-2007-06-12/guichan/guichan/actionlistener.hpp) =================================================================== --- trunk/guichan/guichan/actionlistener.hpp (rev 0) +++ trunk/guichan/guichan/actionlistener.hpp 2007-07-28 10:16:24 UTC (rev 88) @@ -0,0 +1,98 @@ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004, 2005, 2006, 2007 Olof Naess\xE9n and Per Larsson + * + * Js_./ + * Per Larsson a.k.a finalman _RqZ{a<^_aa + * Olof Naess\xE9n a.k.a jansem/yakslem _asww7!uY`> )\a// + * _Qhm`] _f "'c 1!5m + * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[ + * .)j(] .d_/ '-( P . S + * License: (BSD) <Td/Z <fP"5(\"??"\a. .L + * Redistribution and use in source and _dV>ws?a-?' ._/L #' + * binary forms, with or without )4d[#7r, . ' )d`)[ + * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam' + * that the following conditions are met: j<<WP+k/);. _W=j f + * 1. Redistributions of source code must .$%w\/]Q . ."' . mj$ + * retain the above copyright notice, ]E.pYY(Q]>. a J@\ + * this list of conditions and the j(]1u<sE"L,. . ./^ ]{a + * following disclaimer. 4'_uomm\. )L);-4 (3= + * 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[ + * reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m + * this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/ + * following disclaimer in the <B!</]C)d_, '(<' .f. =C+m + * documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]' + * provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W" + * 3. Neither the name of Guichan nor the :$we` _! + _/ . j? + * names of its contributors may be used =3)= _f (_yQmWW$#( " + * to endorse or promote products derived - W, sQQQQmZQ#Wwa].. + * from this software without specific (js, \[QQW$QWW#?!V"". + * prior written permission. ]y:.<\.. . + * -]n w/ ' [. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ ! + * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , ' + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- % + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'., + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?" + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. . + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^ + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef GCN_ACTIONLISTENER_HPP +#define GCN_ACTIONLISTENER_HPP + +#include <string> + +#include "guichan/actionevent.hpp" +#include "guichan/platform.hpp" + +namespace gcn +{ + /** + * Listener of action events from Widgets. To be able to + * listen for actions you must make a class which inherits + * from this class and implements the action function. + * + * @see Widget::addActionListener + * @author Olof Naess\xE9n + * @author Per Larsson + */ + class GCN_CORE_DECLSPEC ActionListener + { + public: + + /** + * Destructor. + */ + virtual ~ActionListener() { } + + /** + * Called when an action is recieved from a Widget. It is used + * to be able to recieve a notification that an action has + * occured. + * + * @param actionEvent the event of the action. + * @since 0.6.0 + */ + virtual void action(const ActionEvent& actionEvent) = 0; + + }; +} + +#endif // end GCN_ACTIONLISTENER_HPP Deleted: trunk/guichan/guichan/basiccontainer.cpp =================================================================== --- branches/input-abstraction-2007-06-12/guichan/guichan/basiccontainer.cpp 2007-07-27 21:46:15 UTC (rev 87) +++ trunk/guichan/guichan/basiccontainer.cpp 2007-07-28 10:16:24 UTC (rev 88) @@ -1,376 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / ... [truncated message content] |
From: <the...@us...> - 2007-09-09 14:58:34
|
Revision: 100 http://qonk.svn.sourceforge.net/qonk/?rev=100&view=rev Author: thebohemian Date: 2007-09-09 07:58:32 -0700 (Sun, 09 Sep 2007) Log Message: ----------- - cleaned up INSTALL and README Modified Paths: -------------- trunk/INSTALL trunk/README Modified: trunk/INSTALL =================================================================== --- trunk/INSTALL 2007-09-09 14:52:59 UTC (rev 99) +++ trunk/INSTALL 2007-09-09 14:58:32 UTC (rev 100) @@ -1,5 +1,5 @@ -General compilation: ------------------ +General compilation notes +------------------------- Qonk uses GNU Autoconf to manage the compilation. Call @@ -11,8 +11,9 @@ to find its data files in ./data first and uses $(pkgdatadir)/data in a second attempt. -Dependencies: -------------- +Dependencies +------------ + Qonk tries to only use components available in free software operating systems. Install the development version of the following packages in order to compile @@ -27,3 +28,20 @@ links that into the executable. The build system was not tested to use a system-wide installation of guichan 0.6.1. Furthermore since guichan is not extensively used in Qonk it is planned to remove it in further releases. + +Compilation +----------- + +In a published tarball you only need to execute + + ./configure + make + make install + +(To avoid system-wide installation use the --prefix argument for ./configure !) + +You get helpful error messages if something is not correct with the +dependencies. + +If you want to built the sources from SVN you need to issue ./autogen.sh and +have the autotools installed (GNU Automake, GNU Autoconf, GNU libtool). Modified: trunk/README =================================================================== --- trunk/README 2007-09-09 14:52:59 UTC (rev 99) +++ trunk/README 2007-09-09 14:58:32 UTC (rev 100) @@ -15,23 +15,11 @@ The game is currently very much in beta. -Dependencies ------------- -To compile the program you will need to install SDL, SDL_ttf and SDL_gfx. It is -built using GNU Autoconf. In a published tarball you only need to execute +For information on how to compile the source code refer to the INSTALL file. - ./configure - make - make install - -You get helpful error messages if something is not correct with the -dependencies. - -If you want to built the sources from SVN you need to issue ./autogen.sh and -have the autotools installed (GNU Automake, GNU Autoconf, GNU libtool). - How to play -------------- +----------- + The goal is wipe out all enemies from the solar system. Select a group of planets to put their ships into your selection for the next This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-07-28 21:25:47
|
Revision: 93 http://qonk.svn.sourceforge.net/qonk/?rev=93&view=rev Author: thebohemian Date: 2007-07-28 14:25:43 -0700 (Sat, 28 Jul 2007) Log Message: ----------- - properly update screen size changes - allow removing input mappings - simplified initial planet claiming - remove need for static Timer variable Modified Paths: -------------- trunk/HISTORY trunk/src/actions.cpp trunk/src/actions.h trunk/src/animations.cpp trunk/src/animations.h trunk/src/controloptions.cpp trunk/src/controloptions.h trunk/src/game.cpp trunk/src/game.h trunk/src/main.cpp trunk/src/main.h trunk/src/menu.cpp trunk/src/menu.h trunk/src/menuaction.h trunk/src/menuentry.h trunk/src/menusystem.cpp trunk/src/messages.cpp trunk/src/messages.h trunk/src/planets.cpp trunk/src/planets.h trunk/src/players.cpp trunk/src/players.h trunk/src/sdl_driver.cpp trunk/src/settings.cpp trunk/src/settings.h trunk/src/ships.cpp trunk/src/ships.h trunk/src/timer.cpp trunk/src/timer.h trunk/src/universe.cpp trunk/src/universe.h Modified: trunk/HISTORY =================================================================== --- trunk/HISTORY 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/HISTORY 2007-07-28 21:25:43 UTC (rev 93) @@ -1,4 +1,5 @@ 0.0.3 - NOT_RELEASED_YET - +Features: - new project page: http//qonk.sf.net - public SVN repository: https://qonk.svn.sf.net/svnroot/qonk - freely chosable input (mouse, keyboard, gamepad, ...) @@ -8,6 +9,14 @@ - basic menu system with many working parts - autotools build system - single ship mode +Bugs fixed: + - do not call SDL functions in Timere before SDL_Init because of static + initialization + - properly update screen size changes + - allow removing input mappings +other: + - simplified initial planet claiming + - remove need for static Timer variable rs-2007-02-17 - 2007-02-17 A modificated version Modificated qonk based on 0.0.2beta1 by Robert Schuster: Modified: trunk/src/actions.cpp =================================================================== --- trunk/src/actions.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/actions.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -68,8 +68,3 @@ } } -void -ActionQueue::executePastEvents() { - executeEventsBefore( timer.getTime() ); -} - Modified: trunk/src/actions.h =================================================================== --- trunk/src/actions.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/actions.h 2007-07-28 21:25:43 UTC (rev 93) @@ -34,7 +34,6 @@ void executeNextEvent(); void executeAllEvents(); void executeEventsBefore( Uint32 time ); - void executePastEvents(); }; #endif Modified: trunk/src/animations.cpp =================================================================== --- trunk/src/animations.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/animations.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -7,10 +7,10 @@ #include "canvas.h" void -AnimationQueue::render( ) { +AnimationQueue::render(Uint32 time) { for( iterator i = begin(); i != end(); i++ ) { Animation* animation = (Animation*)( i->second ); - animation->render( ); + animation->render(time); } } @@ -30,10 +30,9 @@ } void -SonarAnimation::render( ) { - Uint32 currentTime = timer.getTime(); - if( ( currentTime > startTime ) && ( currentTime < endTime ) ) { - double percentage = (double)( currentTime - startTime ) / ( endTime - startTime ); +SonarAnimation::render(Uint32 time) { + if( ( time > startTime ) && ( time < endTime ) ) { + double percentage = (double)( time - startTime ) / ( endTime - startTime ); Canvas::drawSonar(planet->getLocation(), size, percentage, r, g, b, circle); } } Modified: trunk/src/animations.h =================================================================== --- trunk/src/animations.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/animations.h 2007-07-28 21:25:43 UTC (rev 93) @@ -10,12 +10,12 @@ class Animation : public Action { public: void execute( const Uint32& time ) {} - virtual void render( ) = 0; + virtual void render(Uint32) = 0; }; class AnimationQueue : public ActionQueue { public: - void render( ); + void render(Uint32); }; class SonarAnimation : public Animation { @@ -28,7 +28,7 @@ public: SonarAnimation(); SonarAnimation( Planet* planet, const Uint32& color, const int& size, const Uint32& startTime, const Uint32& endTime, bool circle = false ); - void render( ); + void render(Uint32); }; #endif Modified: trunk/src/controloptions.cpp =================================================================== --- trunk/src/controloptions.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/controloptions.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -30,6 +30,12 @@ main.finishSensing(ga, b); } +void +ControlOptions::reset(GameAction ga) +{ + main.resetGameAction(ga); +} + class ControlAction : public MenuAction { ControlOptions &controlOptions; @@ -80,6 +86,13 @@ } return sensing; } + + void reset() + { + controlOptions.reset(gameAction); + label->setCaption(base + Settings::getAsString(gameAction)); + label->adjustSize(); + } }; MenuAction * Modified: trunk/src/controloptions.h =================================================================== --- trunk/src/controloptions.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/controloptions.h 2007-07-28 21:25:43 UTC (rev 93) @@ -29,6 +29,8 @@ void startSensing(); void finishSensing(GameAction, bool); + + void reset(GameAction); }; #endif Modified: trunk/src/game.cpp =================================================================== --- trunk/src/game.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/game.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -1,6 +1,7 @@ #include "game.h" #include "gameoptions.h" +#include "timer.h" #include "planets.h" #include "players.h" #include "universe.h" @@ -15,54 +16,50 @@ using namespace std; Game::Game(GameOptions &go) - : gameOptions(go), nextNumberOfPlanets(0), nextNumberOfComputerPlayers(0) + : gameOptions(go), nextNumberOfPlanets(0), nextNumberOfComputerPlayers(0), timer(new Timer()), + players(0), universe(0), messages(0), selection(0) { int numberOfPlanets = gameOptions.getPlanets(); int numberOfComputerPlayers = gameOptions.getPlayers(); - state = PLAYING; - quit = false; + state = PLAYING; + quit = false; + timer->start(); - x = Settings::getScreenWidth()/2; - y = Settings::getScreenHeight()/2; - xp = xn = yp = yn = 0; + // Initialize selection + x = Settings::getScreenWidth()/2; + y = Settings::getScreenHeight()/2; + xp = xn = yp = yn = 0; - universe = new Universe( numberOfPlanets ); + universe = new Universe( numberOfPlanets ); - players = new Players( universe ); - universe->actionQueue->scheduleAction( 1000, new UpdatePlayersStatsAction( players) ); + players = new Players( universe ); + universe->actionQueue->scheduleAction( 1000, new UpdatePlayersStatsAction( players) ); - Planets::iterator planetIterator = universe->planets->begin(); - humanPlayer = new HumanPlayer( universe, &(*planetIterator), 3, 0xffffff, 1); - humanPlayer->setVisible(true); - players->push_back(humanPlayer); + humanPlayer = new HumanPlayer( universe, 0xffffff, 1); + humanPlayer->setVisible(true); + universe->claim(0, humanPlayer, 1, 3); + players->push_back(humanPlayer); + + bool vis = gameOptions.getEnemyVisibility(); + + int hueCounter = rand() % 360; + for (int i=0;i<numberOfComputerPlayers;i++) + { + Player *newPlayer = new ComputerPlayer( universe, HSVtoRGB( hueCounter, 0.9, 0.9 ), 2); + newPlayer->setVisible(vis); + universe->claim(0, newPlayer, 1, 3); + hueCounter = ( hueCounter + 360 / numberOfComputerPlayers ) % 360; + players->push_back(newPlayer); + } - planetIterator++; + NeutralPlayer *neutral = new NeutralPlayer(universe, 0x808080); + neutral->setVisible(vis); + universe->claimRemaining(0, neutral, 3, 2); + players->push_back(neutral); - int hueCounter = rand() % 360; - int counter = 0; - do { - Player *newPlayer; - - if( counter < numberOfComputerPlayers ) { - newPlayer = new ComputerPlayer( universe, &(*planetIterator), 3, HSVtoRGB( hueCounter, 0.9, 0.9 ), 2); - - counter++; - hueCounter = ( hueCounter + 360 / numberOfComputerPlayers ) % 360; - } else - if( !(&(*planetIterator))->getMoon() ) - newPlayer = new NeutralPlayer( universe, &(*planetIterator), 1 + rand() % 3, 0x606060 ); - else - newPlayer = new NeutralPlayer( universe, &(*planetIterator), 1 + rand() % 2, 0x606060 ); - players->push_back(newPlayer); - - planetIterator++; - } while( planetIterator != universe->planets->end() ); - - messages = new Messages(); - selection = new Selection(); - - setEnemyVisibility(gameOptions.getEnemyVisibility()); + messages = new Messages(); + selection = new Selection(); } Game::~Game() @@ -71,6 +68,7 @@ delete universe; delete messages; delete selection; + delete timer; } bool @@ -82,13 +80,14 @@ // TODO: Find a way to live without the next line. setPaused(menuVisible); - if (timer.isPaused()) + if (timer->isPaused()) return true; moveCursor(xp - xn, yp - yn); + Uint32 time = getTime(); // update the universe - universe->update(); + universe->update(time); // let players update their states players->update(this); @@ -123,7 +122,7 @@ void Game::handle(GameAction gameAction, int value) { - if (timer.isPaused()) + if (timer->isPaused()) return; switch (gameAction) @@ -268,19 +267,7 @@ Game::setFleetStrength(int str) { humanPlayer->setFleetStrength(str); -/* - stringstream s; - if (str == 1) - s << "Setting to single ship mode."; - else - { - s << "Setting fleet strength to " << str << "%"; - } - - messages->addMessage( timer.getTime(), Message(s.str(), 20000, 0x808080)); - */ - //Begin Jacobsen stringstream s; if (str == 1) s << "Single ship mode"; @@ -289,15 +276,14 @@ s << "Fleet strength " << str << "%"; } - messages->setFleetStrengthMessage( Message(s.str(), 0x808080) ); - //End Jacobsen + messages->setFleetStrengthMessage( Message(getTime(), s.str(), 0x808080) ); } void Game::setPaused(bool p) { - if (p ^ timer.isPaused()) - timer.pause(); + if (p ^ timer->isPaused()) + timer->pause(); } @@ -316,7 +302,7 @@ stringstream s; s << "Made enemies " << (visible ? "visible" : "invisible"); - messages->addMessage(timer.getTime(), Message(s.str(), 20000, 0x808080)); + messages->addMessage(timer->getTime(), Message(getTime(), s.str(), 20000, 0x808080)); } void @@ -334,7 +320,7 @@ void Game::moveToNearestPlanet(int x, int y) { - humanPlayer->moveToNearestPlanet(x, y); + humanPlayer->moveToNearestPlanet(getTime(), x, y); } void @@ -363,21 +349,29 @@ void Game::addMessage(int offset, Message msg) { - messages->addMessage( timer.getTime() + offset, msg); + messages->addMessage( timer->getTime() + offset, msg); } +Uint32 +Game::getTime() const +{ + return timer->getTime(); +} + void Game::render() { - universe->renderBackground(); - players->render(); + Uint32 time = getTime(); + + universe->renderBackground(time); + players->render(); - humanPlayer->render(); - selection->render(); + humanPlayer->render(); + selection->render(); - universe->renderForeground(); + universe->renderForeground(time); - messages->render(); + messages->render(time); - Canvas::drawCursor(x, y); + Canvas::drawCursor(x, y); } Modified: trunk/src/game.h =================================================================== --- trunk/src/game.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/game.h 2007-07-28 21:25:43 UTC (rev 93) @@ -10,6 +10,7 @@ #define GAME_H #include "input.h" +#include "timer.h" class Universe; class Players; @@ -39,6 +40,8 @@ void render(); void setPaused(bool); + + Uint32 getTime() const; private: void moveCursor(int, int); @@ -70,10 +73,10 @@ int xp, xn, yp, yn; Universe *universe; - Players *players; HumanPlayer *humanPlayer; Messages *messages; - + Timer *timer; + Players *players; Selection *selection; enum States { PLAYING, LOST, WON }; Modified: trunk/src/main.cpp =================================================================== --- trunk/src/main.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/main.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -108,8 +108,7 @@ showMenu(); Settings::setFullscreen(videoOptions.getFullscreen()); - Settings::setScreenWidth(videoOptions.getScreenWidth()); - Settings::setScreenHeight(videoOptions.getScreenHeight()); + Settings::setScreenSize(videoOptions.getScreenWidth(), videoOptions.getScreenHeight()); Canvas::initScreen(); @@ -169,12 +168,11 @@ Main::renderFPS() { stringstream s; - s << timer.getTimeMMSSHH(); - + fpsCounter++; - s << " (" << fps << " FPS)"; - Canvas::drawText( 13, Settings::getGameHeight() - 30, s.str().c_str(), 0x80, 0x80, 0x80 ); + s << fps; + Canvas::drawText( Settings::getScreenWidth() - 32, 5, s.str().c_str(), 0x80, 0x80, 0x80 ); if( SDL_GetTicks() - lastTicks >= 1000 ) { lastTicks = SDL_GetTicks(); @@ -195,14 +193,11 @@ Canvas::drawBox(0, 0, Settings::getScreenWidth(), Settings::getScreenHeight(), 0, 0, 0); if (game) - { game->render(); - } - menuManager->render(); renderFPS(); Canvas::updateScreen(); - + b = menuManager->update(); if (game) @@ -282,3 +277,11 @@ driver->setSenseMode(false); } +void +Main::resetGameAction(GameAction ga) +{ + Settings::unset(ga); + driver->setSenseMode(true); + driver->setSenseMode(false); +} + Modified: trunk/src/main.h =================================================================== --- trunk/src/main.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/main.h 2007-07-28 21:25:43 UTC (rev 93) @@ -33,6 +33,8 @@ void startSensing(); void finishSensing(GameAction, bool); + + void resetGameAction(GameAction); void quit(); Modified: trunk/src/menu.cpp =================================================================== --- trunk/src/menu.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/menu.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -85,9 +85,16 @@ Menu::resize(int w, int h) { container->setSize(w, h); + + int maxWidth = 0; + for (vector< MenuEntry * >::iterator i = entries->begin(); i != entries->end(); i++) + { + gcn::Widget *w = (*i)->getWidget(); + maxWidth = max(w->getWidth(), maxWidth); + } - int x = (!locx) ? w/3 : locx; - int y = 100; + int x = (!locx) ? (w/2 - maxWidth/2) : locx; + int y = h/8; title->setPosition(x, y); y += 2 * title->getHeight(); @@ -139,6 +146,12 @@ } void +Menu::reset() +{ + entries->at(selected)->reset(); +} + +void Menu::invoke() { entries->at(selected)->invoke(); @@ -193,6 +206,11 @@ { return action->cancel(); } + + void reset() + { + action->reset(); + } }; Modified: trunk/src/menu.h =================================================================== --- trunk/src/menu.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/menu.h 2007-07-28 21:25:43 UTC (rev 93) @@ -74,6 +74,8 @@ void next(); void previous(); + + void reset(); }; Modified: trunk/src/menuaction.h =================================================================== --- trunk/src/menuaction.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/menuaction.h 2007-07-28 21:25:43 UTC (rev 93) @@ -30,6 +30,8 @@ /** Returns true if some operation was cancelled or false if not. */ virtual bool cancel() { return false; } + + virtual void reset() { } }; class QuitAction : public MenuAction Modified: trunk/src/menuentry.h =================================================================== --- trunk/src/menuentry.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/menuentry.h 2007-07-28 21:25:43 UTC (rev 93) @@ -39,6 +39,13 @@ * on level up or not. */ virtual bool cancel() { return false; } + + /** + * Puts the underlying attribute to its default value. + * + * Needs only be implemented by entries that support this. + */ + virtual void reset() { }; }; Modified: trunk/src/menusystem.cpp =================================================================== --- trunk/src/menusystem.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/menusystem.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -258,6 +258,9 @@ switch (keyEvent.getKey().getValue()) { + case Key::BACKSPACE: + system.currentMenu->reset(); + break; case Key::ESCAPE: system.currentMenu->cancel(); break; Modified: trunk/src/messages.cpp =================================================================== --- trunk/src/messages.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/messages.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -10,32 +10,32 @@ using namespace std; -Message::Message( string message, Uint32 displayTime, Uint8 r, Uint8 g, Uint8 b ) { - this->message = string( "[" ) + timer.getTimeMMSS() + "] " + message; +Message::Message( Uint32 time, string message, Uint32 displayTime, Uint8 r, Uint8 g, Uint8 b ) { + this->message = string( "[" ) + Timer::getTimeMMSS(time) + "] " + message; this->displayTime= displayTime; this->r = r; this->g = g; this->b = b; } -Message::Message( string message, Uint32 displayTime, Uint32 color ) { - this->message = string( "[" ) + timer.getTimeMMSS() + "] " + message; +Message::Message( Uint32 time, string message, Uint32 displayTime, Uint32 color ) { + this->message = string( "[" ) + Timer::getTimeMMSS(time) + "] " + message; this->displayTime = displayTime; this->r = getGreen( color ); this->g = getRed( color ); this->b = getBlue( color ); } -Message::Message( string message, Uint8 r, Uint8 g, Uint8 b ) { - this->message = string( "[" ) + timer.getTimeMMSS() + "] " + message; +Message::Message( Uint32 time, string message, Uint8 r, Uint8 g, Uint8 b ) { + this->message = string( "[" ) + Timer::getTimeMMSS(time) + "] " + message; this->displayTime= 10000; this->r = r; this->g = g; this->b = b; } -Message::Message( string message, Uint32 color ) { - this->message = string( "[" ) + timer.getTimeMMSS() + "] " + message; +Message::Message( Uint32 time, string message, Uint32 color ) { + this->message = string( "[" ) + Timer::getTimeMMSS(time) + "] " + message; this->displayTime = 10000; this->r = getGreen( color ); this->g = getRed( color ); @@ -89,7 +89,7 @@ return displayTime; } //Jacobsen - added init of fleetStrengthMessage -Messages::Messages() : fleetStrengthMessage("Fleet strength 50%",0x808080) { +Messages::Messages() : fleetStrengthMessage(0, "Fleet strength 50%",0x808080) { } Messages::~Messages() { @@ -102,18 +102,18 @@ } void -Messages::cleanup() { - while( ( size() > 0 ) && ( begin()->first + begin()->second.getDisplayTime() < timer.getTime() ) ) +Messages::cleanup(Uint32 time) { + while( ( size() > 0 ) && ( begin()->first + begin()->second.getDisplayTime() < time ) ) erase( begin() ); } void -Messages::render() { - cleanup(); +Messages::render(Uint32 time) { + cleanup(time); int x = 12; int y = Settings::getGameHeight() - 28; for( reverse_iterator i = rbegin(); i != rend(); i++ ) { - i->second.render(x, y, (int)timer.getTime() - (int)i->first ); + i->second.render(x, y, (int)time - (int)i->first ); } //Begin Jacobsen @@ -131,31 +131,34 @@ void MSGwon(Game *game, int nextPlanets, int nextComputerPlayers){ - game->addMessage( 200, Message( "You have QONKuered the solar system! You won!", 20000, 0xffffff ) ); + Uint32 time = game->getTime(); + game->addMessage(200, Message(time, "You have QONKuered the solar system! You won!", 20000, 0xffffff ) ); stringstream s; s << "Try again, with " << nextPlanets << " planets and " << nextComputerPlayers << " AI players!"; - game->addMessage( 400, Message( s.str(), 20000, 0x808080 ) ); + game->addMessage(400, Message(time, s.str(), 20000, 0x808080 ) ); s.str(""); s << "Use [" << Settings::getAsString(GA_NEXT_ROUND); s << "] to start the next round"; - game->addMessage( 600, Message( s.str(), 40000, 0x808080 ) ); + game->addMessage(600, Message(time, s.str(), 40000, 0x808080 ) ); } void MSGlost(Game *game) { - game->addMessage(0, Message( "GAME OVER!!! You lost all your planets and ships, you are dead!", 20000, 0xffffff ) ); - game->addMessage(200, Message( "Press [R] ...", 40000, 0x808080 ) ); + Uint32 time = game->getTime(); + game->addMessage(0, Message(time, "GAME OVER!!! You lost all your planets and ships, you are dead!", 20000, 0xffffff ) ); + game->addMessage(200, Message(time, "Press [R] ...", 40000, 0x808080 ) ); } void MSGstart(Game *game) { - game->addMessage( 000, Message( "Let's QONK! Kick the AI players out!", 15000, 0xffffff ) ); - game->addMessage( 200, Message( "[Left click and drag] for multi select, [Middle click] for single select.", 10000, 0x808080 ) ); - game->addMessage( 400, Message( "[Right click] to send ships.", 10000, 0x808080 ) ); - game->addMessage( 600, Message( "[P]ause,[A]ll planets,[R]estart.", 10000, 0x808080 ) ); - game->addMessage( 700, Message( "[Escape] to quit", 10000, 0x808080 ) ); - game->addMessage( 800, Message( "[1]-[0] fleet selection (10%-100%)", 10000, 0x808080 ) ); - game->addMessage(1000, Message( "Initial fleet selection is 50%", 10000, 0x808080 ) ); + Uint32 time = game->getTime(); + game->addMessage( 000, Message(time, "Let's QONK! Kick the AI players out!", 15000, 0xffffff ) ); + game->addMessage( 200, Message(time, "[Left click and drag] for multi select, [Middle click] for single select.", 10000, 0x808080 ) ); + game->addMessage( 400, Message(time, "[Right click] to send ships.", 10000, 0x808080 ) ); + game->addMessage( 600, Message(time, "[P]ause,[A]ll planets,[R]estart.", 10000, 0x808080 ) ); + game->addMessage( 700, Message(time, "[Escape] to quit", 10000, 0x808080 ) ); + game->addMessage( 800, Message(time, "[1]-[0] fleet selection (10%-100%)", 10000, 0x808080 ) ); + game->addMessage(1000, Message(time, "Initial fleet selection is 50%", 10000, 0x808080 ) ); } Modified: trunk/src/messages.h =================================================================== --- trunk/src/messages.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/messages.h 2007-07-28 21:25:43 UTC (rev 93) @@ -17,10 +17,10 @@ Uint32 displayTime; std::string message; public: - Message( std::string message, Uint32 displayTime, Uint8 r, Uint8 g, Uint8 b ); - Message( std::string message, Uint32 displayTime, Uint32 color ); - Message( std::string message, Uint8 r, Uint8 g, Uint8 b ); - Message( std::string message, Uint32 color ); + Message( Uint32, std::string message, Uint32 displayTime, Uint8 r, Uint8 g, Uint8 b ); + Message( Uint32, std::string message, Uint32 displayTime, Uint32 color ); + Message( Uint32, std::string message, Uint8 r, Uint8 g, Uint8 b ); + Message( Uint32, std::string message, Uint32 color ); void render(int &x, int &y, int time ); Uint32 getDisplayTime(); }; @@ -34,8 +34,8 @@ Messages(); ~Messages(); void addMessage( Uint32 time, Message m ); - void cleanup(); - void render(); + void cleanup(Uint32); + void render(Uint32); //Begin Jacobsen void setFleetStrengthMessage( Message m ); Modified: trunk/src/planets.cpp =================================================================== --- trunk/src/planets.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/planets.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -19,17 +19,23 @@ // ##### PLANET ##### -Planet::Planet() : nearestPlanet(false) { +Planet::Planet() : nearestPlanet(false), owner(), mother() +{ rotationSpeed = ( ( rand() % 2 ) * 2 - 1 ) * ( rand() % 60000 + 20000 ); rotationDistance = 0.05 + 0.4 * ( double )rand() / RAND_MAX; rotationOffset = rand() % 10000000; size = 4 + rand() % 4; // [4 ... 8) isAMoon = false; - mother = NULL; selected = false; sourceSelected = false; - owner = NULL; shipCreationSpeed = 12500 - size*1000; + + double angle = rotationOffset / rotationSpeed; + locationVector.setX(cos(angle)); + locationVector.setY(sin(angle)); + + buildStartTime = 0; + buildEndTime = shipCreationSpeed; } void @@ -43,14 +49,36 @@ shipCreationSpeed = 15000 - size*1000; } -Coordinate -Planet::getVector( Uint32 time ) const { - double angle = (double)( rotationOffset + time ) / rotationSpeed; - return Coordinate( cos( angle ), sin( angle ) ); +void +Planet::update(Uint32 time) +{ + double angle = (double)(rotationOffset + time) / rotationSpeed; + locationVector.setX(cos(angle)); + locationVector.setY(sin(angle)); + + if (buildEndTime <= time) + { + createShip(time); + buildStartTime = time; + buildEndTime = time + shipCreationSpeed; + } + + if( residentShips.size() > 0 ) { + Coordinate location = getLocation(); + int counter = 0; + double offset = 500 * rotationDistance + (double) time / 10000; + for( list< Ship* >::iterator i = residentShips.begin(); i != residentShips.end(); i++ ) { + double shipX = location.getX() + 0.02 * cos( offset + counter * 2 * M_PI / residentShips.size() ); + double shipY = location.getY() + 0.02 * sin( offset + counter * 2 * M_PI / residentShips.size() ); + (*i)->setLocation( shipX, shipY ); + counter++; + } + } + } Coordinate -Planet::getLocation( Uint32 time ) const { +Planet::getLocation() const { Coordinate motherLocation; if( isAMoon ) { motherLocation = mother->getLocation(); @@ -59,79 +87,66 @@ motherLocation.setY( 0.5 ); } - Coordinate v = getVector( time ); - double x = motherLocation.getX() + rotationDistance * v.getX(); - double y = motherLocation.getY() + rotationDistance * v.getY(); + double x = motherLocation.getX() + rotationDistance * locationVector.getX(); + double y = motherLocation.getY() + rotationDistance * locationVector.getY(); return Coordinate( x, y ); } -Coordinate -Planet::getLocation() const { - return getLocation( timer.getTime() ); -} - void -Planet::addResident( Ship* ship, Uint32 time ) { - if( ( owner == NULL ) || ( owner == ship->getOwner() ) || ( residentShips.size() == 0 ) ) { - if( owner != ship->getOwner() ) { - - // clear out "create ship" actions scheduled for this planet - vector< ActionQueue::iterator > removes; - for( ActionQueue::iterator i = universe->actionQueue->begin(); i != universe->actionQueue->end(); i++ ) { - if( (i->second)->getActionID() == 1 ) { - Planet* planetOfIterator = ((CreateShipAction*)(i->second))->getPlanet(); - if( planetOfIterator == this ) - removes.push_back( i ); - } - } - - for( vector< ActionQueue::iterator >::iterator i = removes.begin(); i != removes.end(); i++ ) { - universe->actionQueue->erase( *i ); - } - - // create a new "create ship" action - buildStartTime = time; - buildEndTime = time + shipCreationSpeed; - universe->actionQueue->scheduleAction( buildEndTime, new CreateShipAction( ship->getOwner(), this ) ); - - // show an animation of planet conquests that are of our interest - Uint32 color = 0; - color = ship->getOwner()->getColor(); - if( owner != NULL ) - if( isAMoon ) - universe->animationQueue->scheduleAction( time + 1200, new SonarAnimation( this, color, 50, time, time + 1000, true ) ); - else - universe->animationQueue->scheduleAction( time + 1200, new SonarAnimation( this, color, 100, time, time + 1000, true ) ); - +Planet::addResident( Ship* ship, Uint32 time ) +{ + if (owner != ship->getOwner()) + { + // Planet is conquered. + if (residentShips.size() == 0) + { + setOwner(ship->getOwner()); + + // Plays correspoing animation. + // TODO: This should be triggered through player->removePlanet()/addPlanet() + Uint32 color = owner->getColor(); + universe->animationQueue->scheduleAction(time + 1200, + new SonarAnimation(this, + color, + isAMoon ? 50 : 100, + time, + time + 1000, + true)); + + residentShips.push_back( ship ); } - residentShips.push_back( ship ); - setOwner(ship->getOwner()); + else + { + ship->die(); + Ship* resident = *( residentShips.begin() ); + removeResident( resident ); + resident->die(); - } else { - ship->die(); - Ship* resident = *( residentShips.begin() ); - removeResident( resident ); - resident->die(); - - // show an animation of die'ing ships that are of our interest - if( ( ship->getOwner()->getPlayerType() == Player::HUMAN ) || ( owner->getPlayerType() == Player::HUMAN ) ) { - universe->animationQueue->scheduleAction( time + 1000, new SonarAnimation( this, ship->getOwner()->getColor(), 20, time, time + 1000, true ) ); - } -// if( owner->getPlayerType() == Player::HUMAN ) { -// universe->animationQueue->scheduleAction( time + 1000, new SonarAnimation( this, 0xc00000, 20, time, time + 1000 ) ); -// } + // show an animation of die'ing ships that are of our interest + if( ( ship->getOwner()->getPlayerType() == Player::HUMAN ) || ( owner->getPlayerType() == Player::HUMAN ) ) + universe->animationQueue->scheduleAction( time + 1000, new SonarAnimation( this, ship->getOwner()->getColor(), 20, time, time + 1000, true ) ); + } + + } + else + { + residentShips.push_back( ship ); } + } void Planet::setOwner(Player *newOwner) { - if (owner != NULL) - owner->removePlanet(this); - - owner = newOwner; + if (owner == newOwner) + return; + + if (owner != NULL) + owner->removePlanet(this); + + newOwner->addPlanet(this); + owner = newOwner; - newOwner->addPlanet(this); } void @@ -140,9 +155,9 @@ } void -Planet::render( ) const { +Planet::render(Uint32 time) const { if( owner->getPlayerType() == Player::HUMAN ) - renderBuildProgress( ); + renderBuildProgress(time); Coordinate location = getLocation(); Canvas::drawPlanet(location, size, owner->getColor() ); @@ -181,31 +196,16 @@ } void -Planet::renderBuildProgress( ) const { +Planet::renderBuildProgress(Uint32 time) const { Coordinate location = getLocation(); int x = location.getXMapped(); int y = location.getYMapped(); - double percentage = 100.0 * ( timer.getTime() - buildStartTime ) / ( buildEndTime - buildStartTime ); + double percentage = 100.0 * ( time - buildStartTime ) / ( buildEndTime - buildStartTime ); Canvas::drawBuildProgress(location, size, percentage); } -void -Planet::updateShipLocations() { - if( residentShips.size() > 0 ) { - Coordinate location = getLocation(); - int counter = 0; - double offset = 500 * rotationDistance + (double)timer.getTime() / 10000; - for( list< Ship* >::iterator i = residentShips.begin(); i != residentShips.end(); i++ ) { - double shipX = location.getX() + 0.02 * cos( offset + counter * 2 * M_PI / residentShips.size() ); - double shipY = location.getY() + 0.02 * sin( offset + counter * 2 * M_PI / residentShips.size() ); - (*i)->setLocation( shipX, shipY ); - counter++; - } - } -} - double Planet::distance( Planet* planet ) { return planet->getLocation().distance( getLocation() ); @@ -232,18 +232,13 @@ } void -Planet::createShip( const Uint32& time, Player* player ) { - if( player->getPlayerType() != Player::NEUTRAL ) - if( owner == player ) { - player->addShips( this, 1 ); - buildStartTime = time; - buildEndTime = time + shipCreationSpeed; - universe->actionQueue->scheduleAction( buildEndTime, new CreateShipAction( player, this ) ); - } +Planet::createShip(const Uint32& time) { + if( owner && owner->getPlayerType() != Player::NEUTRAL ) + owner->addShip(time, this); } void -Planet::moveResidentsTo(Planet *destination, int fleetSelection) { +Planet::moveResidentsTo(Uint32 time, Planet *destination, int fleetSelection) { // Save same fuel ... :) if (destination == this || !residentShips.size()) { return; @@ -266,7 +261,7 @@ } for (list <Ship *>::iterator i = decampees.begin(); i != decampees.end(); i++) { - (*i)->moveTo(timer.getTime() + rand() % 500, destination, universe->actionQueue); + (*i)->moveTo(time + rand() % 500, destination, universe->actionQueue); } } @@ -282,11 +277,19 @@ } +Planets::~Planets() +{ + for (list < Planet *>::iterator i = begin(); i != end(); i++) + { + delete *i; + } +} + void Planets::addPlanets( int numberOfPlanets ) { for( int i = 0; i < numberOfPlanets; i++ ) { - push_back( Planet() ); + push_back( new Planet() ); } } @@ -302,29 +305,31 @@ for( int i = 0; i < numberOfMoons; i++ ) { iterator motherPlanet; bool done = false; - do { + + do { int mother = rand() % size(); motherPlanet = begin(); for( int j = 0; j < mother; j++ ) motherPlanet++; - done = !motherPlanet->getMoon(); + done = !(*motherPlanet)->getMoon(); } while( !done ); - Planet p; - p.makeMoon( &(*motherPlanet) ); + + Planet *p = new Planet(); + p->makeMoon(*motherPlanet); push_back( p ); } } void -Planets::render( ) const { +Planets::render(Uint32 time) const { for( const_iterator i = begin(); i != end(); i++ ) - i->render( ); + (*i)->render(time); } void Planets::renderOrbits( ) const { for( const_iterator i = begin(); i != end(); i++ ) - i->renderOrbit( ); + (*i)->renderOrbit( ); } Planet* @@ -332,10 +337,10 @@ double closestDistance = 5000; Planet* closestPlanet = NULL; for( iterator i = begin(); i != end(); i++ ) { - double distance = i->getLocation().distance( c ); + double distance = (*i)->getLocation().distance( c ); if( distance < closestDistance ) { closestDistance = distance; - closestPlanet = &(*i); + closestPlanet = (*i); } } return closestPlanet; @@ -359,11 +364,11 @@ double maxY = selection.getMaxY(); for( iterator i = begin(); i != end(); i++ ) { - Coordinate location = i->getLocation(); + Coordinate location = (*i)->getLocation(); if( ( location.getX() > minX ) && ( location.getX() < maxX ) && ( location.getY() > minY ) && ( location.getY() < maxY ) ) - i->setSelected( true ); + (*i)->setSelected( true ); else - i->setSelected( false ); + (*i)->setSelected( false ); } } @@ -377,27 +382,27 @@ double maxY = selection->getMaxY(); for( iterator i = begin(); i != end(); i++ ) { - Coordinate location = i->getLocation(); + Coordinate location = (*i)->getLocation(); if( ( location.getX() > minX ) && ( location.getX() < maxX ) && ( location.getY() > minY ) && ( location.getY() < maxY ) - && i->getOwner() == owner ) - i->setSourceSelected( true ); + && (*i)->getOwner() == owner ) + (*i)->setSourceSelected( true ); else - i->setSourceSelected( false ); + (*i)->setSourceSelected( false ); } } void -Planets::updateShipLocations() { +Planets::update(Uint32 time) { for( iterator i = begin(); i != end(); i++ ) - i->updateShipLocations(); + (*i)->update(time); } void Planets::setUniverse( Universe* universe ) { for( iterator i = begin(); i != end(); i++ ) - i->setUniverse( universe ); + (*i)->setUniverse( universe ); } Planet* @@ -406,11 +411,12 @@ iterator i = begin(); for( int k = 0; k < number; k++ ) i++; - return &(*i); + return (*i); } Planet* Planets::getRandomEnemyPlanet( Player* player ) { + // TODO: This has to be implemented } Planet* @@ -449,24 +455,14 @@ } // ##### CREATESHIPACTION ##### - -CreateShipAction::CreateShipAction() : -Action::Action() { - actionID = 1; -} - -CreateShipAction::CreateShipAction( Player* player, Planet* planet ) { - this->player = player; +CreateShipAction::CreateShipAction(Planet *planet ) +{ this->planet = planet; actionID = 1; } void CreateShipAction::execute( const Uint32& time ) { - planet->createShip( time, player ); + planet->createShip(time); } -Planet* -CreateShipAction::getPlanet() const { - return planet; -} Modified: trunk/src/planets.h =================================================================== --- trunk/src/planets.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/planets.h 2007-07-28 21:25:43 UTC (rev 93) @@ -6,11 +6,11 @@ #include <list> #include "actions.h" +#include "coordinate.h" class Ship; class Universe; class Player; -class Coordinate; class Selection; class Planet { @@ -25,24 +25,26 @@ Planet* mother; std::list< Ship* > residentShips; Uint32 buildStartTime, buildEndTime; + + Coordinate locationVector; public: Planet(); // make a planet + void makeMoon( Planet* ); - Coordinate getVector( Uint32 time ) const; - Coordinate getLocation() const; - Coordinate getLocation( Uint32 time ) const; + Coordinate getLocation() const; void addResident( Ship* ship, Uint32 time ); - void createShip( const Uint32& time, Player* player ); + void createShip( const Uint32& time); void removeResident( Ship* ship ); - void render( ) const; + void render(Uint32) const; void renderOrbit( ) const; - void renderBuildProgress( ) const; + void renderBuildProgress(Uint32) const; + + void update(Uint32); + void updateShipLocations(Uint32); - void updateShipLocations(); - double distance( Planet* planet ); int numberOfResidentShips() { return residentShips.size(); } @@ -51,26 +53,29 @@ void setNearestPlanet(bool b); bool isNearestPlanet() { return nearestPlanet; } + + void moveResidentsTo(Uint32, Planet *, int); void setSelected( bool selected ); void setUniverse( Universe* universe ); bool getMoon() const { return isAMoon; } - Player* getOwner() { return owner; } - - void moveResidentsTo(Planet *, int); -private: - void setOwner(Player *); + + + void setOwner(Player *); + Player* getOwner() const { return owner; } + }; -class Planets : public std::list< Planet > { +class Planets : public std::list< Planet *> { public: Planets(); Planets( int numberOfPlanets, int numberOfMoons ); + ~Planets(); void addPlanets( int numberOfPlanets ); void addMoons( int numberOfMoons ); - void render( ) const; + void render(Uint32) const; void renderOrbits( ) const; Planet* closestToCoordinate( const Coordinate& c ); @@ -79,7 +84,7 @@ void select( Selection selection ); void sourceSelect( Selection *selection, Player *owner ); - void updateShipLocations(); + void update(Uint32); void setUniverse( Universe* universe ); @@ -92,13 +97,10 @@ class CreateShipAction : public Action { private: - Player* player; - Planet* planet; + Planet *planet; public: - CreateShipAction(); - CreateShipAction( Player* player, Planet* planet ); + CreateShipAction(Planet *); void execute( const Uint32& time ); - Planet* getPlanet() const; }; #endif Modified: trunk/src/players.cpp =================================================================== --- trunk/src/players.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/players.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -17,27 +17,18 @@ // ##### PLAYER ##### using namespace std; -Player::Player() : team(0) { +Player::Player( Universe* universe, Uint32 color, int t ) : visible(false), team(t) +{ ships = new Ships(); playerState = ALIVE; -} - -Player::Player( Universe* universe, Planet* homePlanet, int numberOfShips, Uint32 color, int t ) : visible(false), team(t) { - - ships = new Ships(); - playerState = ALIVE; this->universe = universe; - addShips( homePlanet, numberOfShips ); setColor( color ); - } void -Player::addShips( Planet* planet, int numberOfShips ) { - - for( int i = 0; i < numberOfShips; i++ ) - ships->push_back( new Ship( this, planet ) ); - +Player::addShip(Uint32 time, Planet * const planet) +{ + ships->push_back(new Ship(this, planet, time )); } void @@ -80,9 +71,9 @@ Player::renderStats( int height ) { int counter = 4; for( Planets::iterator i = universe->planets->begin(); i != universe->planets->end(); i++ ) { - if( i->getOwner() == this ) { + if( (*i)->getOwner() == this ) { int size = 3; - if( i->getMoon() ) size = 2; + if( (*i)->getMoon() ) size = 2; Canvas::drawPlanetMapped(counter, height + 5, size, color ); counter+= size * 2 + 3; } @@ -112,8 +103,8 @@ Player::getPoints() { double result = 0; for( Planets::iterator i = universe->planets->begin(); i != universe->planets->end(); i++ ) { - if( i->getOwner() == this ) { - if( i->getMoon() ) { + if( (*i)->getOwner() == this ) { + if( (*i)->getMoon() ) { result += 0.999; } else { result += 2; @@ -141,8 +132,8 @@ // ##### HUMANPLAYER ##### -HumanPlayer::HumanPlayer( Universe* universe, Planet* homePlanet, int numberOfShips, Uint32 color, int team ) : -Player( universe, homePlanet, numberOfShips, color, team ) { +HumanPlayer::HumanPlayer( Universe* universe, Uint32 color, int team ) : +Player( universe, color, team ) { playerType = Player::HUMAN; fleetStrength = 50; } @@ -190,7 +181,7 @@ } void -HumanPlayer::moveToNearestPlanet(int x, int y) +HumanPlayer::moveToNearestPlanet(Uint32 time, int x, int y) { double pointerX = ( (double)x - Settings::getGameOffsetX() ) / Settings::getGameWidth(); double pointerY = (double)y / Settings::getGameHeight(); @@ -199,7 +190,7 @@ if( closestPlanet != NULL ) { for (list <Planet *>::iterator i = occupiedPlanets.begin(); i != occupiedPlanets.end(); i++) { if ((*i)->isSourceSelected()) - (*i)->moveResidentsTo(closestPlanet, fleetStrength); + (*i)->moveResidentsTo(time, closestPlanet, fleetStrength); } } } @@ -216,6 +207,9 @@ return; removeDeadShips(); + + // TODO: Unify this with the other player types. + ships->update(game->getTime()); } @@ -234,8 +228,8 @@ // ##### COMPUTERPLAYER ##### -ComputerPlayer::ComputerPlayer( Universe* universe, Planet* homePlanet, int numberOfShips, Uint32 color, int team ) : -Player( universe, homePlanet, numberOfShips, color, team ) { +ComputerPlayer::ComputerPlayer( Universe* universe, Uint32 color, int team ) : +Player( universe, color, team ) { playerType = Player::COMPUTER; // give the computer player some values for determining strategic actions @@ -260,13 +254,17 @@ ComputerPlayer::update(Game *game) { if( playerState == ALIVE ) { if( getPoints() == 0 ) { - game->addMessage(0, Message( "AI player is dead", color)); + game->addMessage(0, Message(game->getTime(), "AI player is dead", color)); playerState = DEAD; return; } } else return; removeDeadShips(); + + // TODO: Unify this with the other player types. + ships->update(game->getTime()); + } @@ -397,14 +395,18 @@ // ##### NEUTRALPLAYER ##### -NeutralPlayer::NeutralPlayer( Universe* universe, Planet* homePlanet, int numberOfShips, Uint32 color ) : -Player( universe, homePlanet, numberOfShips, color, 0 ) { +NeutralPlayer::NeutralPlayer( Universe* universe, Uint32 color ) : +Player( universe, color, 0 ) { playerType = Player::NEUTRAL; } void NeutralPlayer::update(Game *game) { removeDeadShips(); + + // TODO: Unify this with the other player types. + ships->update(game->getTime()); + } // ##### PLAYERS ##### Modified: trunk/src/players.h =================================================================== --- trunk/src/players.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/players.h 2007-07-28 21:25:43 UTC (rev 93) @@ -30,12 +30,10 @@ int team; public: - Player(); - Player( Universe* universe, Planet* homePlanet, int numberOfShips, Uint32 color, int t ); + Player(Universe *, Uint32, int); virtual ~Player() {} - void addShips( Planet* planet, int numberOfShips ); - void createShip( Uint32& time, Planet* planet ); + void addShip(Uint32, Planet * const); void removeDeadShips(); void render(); @@ -64,7 +62,7 @@ private: int fleetStrength; public: - HumanPlayer( Universe* universe, Planet* homePlanet, int numberOfShips, Uint32 color, int team ); + HumanPlayer( Universe* universe, Uint32 color, int team ); void update(Game *game); @@ -78,7 +76,7 @@ void selectNearestPlanet(int, int); - void moveToNearestPlanet(int, int); + void moveToNearestPlanet(Uint32, int, int); }; class ComputerPlayer : public Player { @@ -91,7 +89,7 @@ std::list< Planet* > preferredPlanets; public: - ComputerPlayer( Universe* universe, Planet* homePlanet, int numberOfShips, Uint32 color, int team ); + ComputerPlayer( Universe* universe, Uint32 color, int team ); void update(Game *); @@ -104,7 +102,7 @@ class NeutralPlayer : public Player { public: - NeutralPlayer( Universe* universe, Planet* homePlanet, int numberOfShips, Uint32 color); + NeutralPlayer( Universe* universe, Uint32 color); void update(Game *); Modified: trunk/src/sdl_driver.cpp =================================================================== --- trunk/src/sdl_driver.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/sdl_driver.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -31,7 +31,6 @@ sdlInput = new gcn::SDLInput(); - timer.start(); atexit( SDL_Quit ); if ( TTF_Init() < 0 ) { Modified: trunk/src/settings.cpp =================================================================== --- trunk/src/settings.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/settings.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -72,7 +72,7 @@ if( !fileExists(fileName)) { cout << "configuration was not available - using defaults" << endl; - setResolution(800, 600); + setScreenSize(800, 600); setupDefaultActionMap(); return; } @@ -95,7 +95,7 @@ if (!(qonkReader = root->getLisp("qonk-config"))) { cout << "configuration file malformed - using defaults" << endl; - setResolution(800, 600); + setScreenSize(800, 600); setupDefaultActionMap(); delete root; @@ -109,7 +109,7 @@ if (configFileVersion < REQUIRED_CONFIG_FILE_VERSION) { cout << "configuration file version " << configFileVersion << " not supported - using default values." << endl; - setResolution(800, 600); + setScreenSize(800, 600); setupDefaultActionMap(); delete root; @@ -119,7 +119,7 @@ qonkReader->get("screenWidth", screenWidth); qonkReader->get("screenHeight", screenHeight); - setResolution(screenWidth, screenHeight); + setScreenSize(screenWidth, screenHeight); qonkReader->get("fullscreen", fullscreen); @@ -175,7 +175,7 @@ } void -Settings::setResolution( int width, int height ) { +Settings::setScreenSize( int width, int height ) { screenWidth = width; screenHeight = height; gameWidth = height; @@ -324,10 +324,25 @@ } void +Settings::unset(GameAction ga) +{ + // Deletion is implemented by shift the value to the left + // and creating an empty entry in the 2nd location. + inputMap[ga][0] = inputMap[ga][1]; + inputMap[ga][1].inputType = IT_NONE; +} + +void Settings::set(GameAction ga, InputType it, int id0, int id1, int id2) { - Input &im = (inputMap[ga][0].inputType == IT_NONE) ? inputMap[ga][0] : inputMap[ga][1]; + // Setting a new value is implemented by shifting the value to the + // right and applying the new values in the 1st location. + + inputMap[ga][1] = inputMap[ga][0]; + // New input is always placed on the first location. + Input &im = inputMap[ga][0]; + im.inputType = it; im.id0 = id0; im.id1 = id1; Modified: trunk/src/settings.h =================================================================== --- trunk/src/settings.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/settings.h 2007-07-28 21:25:43 UTC (rev 93) @@ -48,13 +48,11 @@ static void setFullscreen( bool b ) { fullscreen = b; } static bool getFullscreen() { return fullscreen; } - static void setResolution(int, int); + static void setScreenSize(int, int); static int getScreenWidth() { return screenWidth; } - static void setScreenWidth(int w) { screenWidth = w; } static int getScreenHeight() { return screenHeight; } - static void setScreenHeight(int h) { screenHeight = h; } static int getGameWidth() { return gameWidth; } static int getGameHeight() { return gameHeight; } @@ -76,6 +74,7 @@ static void printInput(char *); static void set(GameAction, Input &); + static void unset(GameAction); }; Modified: trunk/src/ships.cpp =================================================================== --- trunk/src/ships.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/ships.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -14,11 +14,10 @@ /* ##### SHIP ##### */ -Ship::Ship( Player* owner, Planet* planet ) { +Ship::Ship( Player* owner, Planet *planet, Uint32 time ) { this->owner = owner; this->planet = planet; - planet->addResident( this, timer.getTime() ); - planet->updateShipLocations(); + planet->addResident( this, time ); selected = false; shipState = RESIDENT; speed = 0.003 + frand( 0.002 ); @@ -64,7 +63,7 @@ fromTime = time; toTime = time + 100; fromLocation = location; - Coordinate destinationLocation = destinationPlanet->getLocation( time + 100 ); + Coordinate destinationLocation = destinationPlanet->getLocation(); double distance = fromLocation.distance( destinationLocation ); if( distance < speed ) { @@ -123,18 +122,25 @@ location = c; } -Coordinate -Ship::getLocation() const { - if( shipState == RESIDENT ) - return location; - else { - Coordinate result; - result.setX( fromLocation.getX() + ( toLocation.getX() - fromLocation.getX() ) * ( timer.getTime() - fromTime ) / ( toTime - fromTime ) ); - result.setY( fromLocation.getY() + ( toLocation.getY() - fromLocation.getY() ) * ( timer.getTime() - fromTime ) / ( toTime - fromTime ) ); - return result; +void +Ship::update(Uint32 time) +{ + if( shipState != RESIDENT ) + { + orbitLocation.setX( fromLocation.getX() + ( toLocation.getX() - fromLocation.getX() ) * ( time - fromTime ) / ( toTime - fromTime ) ); + orbitLocation.setY( fromLocation.getY() + ( toLocation.getY() - fromLocation.getY() ) * ( time - fromTime ) / ( toTime - fromTime ) ); } } +Coordinate +Ship::getLocation() const +{ + if( shipState == RESIDENT ) + return location; + else + return orbitLocation; +} + Ship::ShipStates Ship::getShipState() const { return shipState; @@ -160,7 +166,7 @@ return owner; } -Planet* +Planet * Ship::getPlanet() const { return planet; } @@ -187,10 +193,10 @@ } void -Ships::moveTo( Planet* destinationPlanet, ActionQueue* actionQueue ) { +Ships::moveTo( Uint32 time, Planet* destinationPlanet, ActionQueue* actionQueue ) { for( iterator i = begin(); i != end(); i++ ) { if( (*i)->getSelected() ) - (*i)->moveTo( timer.getTime() + rand() % 500, destinationPlanet, actionQueue ); + (*i)->moveTo( time + rand() % 500, destinationPlanet, actionQueue ); } } @@ -206,15 +212,23 @@ void Ships::render( Uint32 color ) const { - for( const_iterator i = begin(); i != end(); i++ ) { - (*i)->renderSelection(); - } - for( const_iterator i = begin(); i != end(); i++ ) { - (*i)->render(color ); - } + for( const_iterator i = begin(); i != end(); i++ ) { + (*i)->renderSelection(); + } + for( const_iterator i = begin(); i != end(); i++ ) { + (*i)->render(color ); + } } void +Ships::update(Uint32 time) +{ + for( const_iterator i = begin(); i != end(); i++ ) { + (*i)->update(time); + } +} + +void Ships::select( Selection* selection ) { double minX = selection->getMinX(); Modified: trunk/src/ships.h =================================================================== --- trunk/src/ships.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/ships.h 2007-07-28 21:25:43 UTC (rev 93) @@ -19,9 +19,10 @@ enum ShipStates { RESIDENT, MOVING, DEAD }; private: - Player* owner; - Planet* planet; + Player *owner; + Planet *planet; Coordinate location; + Coordinate orbitLocation; bool selected; double speed; @@ -33,11 +34,11 @@ Uint32 fromTime, toTime; public: - Ship( Player*, Planet* ); + Ship( Player*, Planet*, Uint32 ); void die(); - void moveTo( Uint32, Planet*, ActionQueue* ); + void moveTo( Uint32, Planet * const, ActionQueue* ); void render( Uint32 color ) const; void renderSelection( ) const; @@ -51,10 +52,12 @@ void setSelected( bool selected ); bool getSelected() const; double getSpeed() const; - Player* getOwner() const; - Planet* getPlanet() const; + Player *getOwner() const; + Planet *getPlanet() const; double getDirection() const; + + void update(Uint32); }; class Ships : public std::list< Ship* > { @@ -62,9 +65,10 @@ void removeDeadShips(); + void update(Uint32); void render( Uint32 color ) const; - void moveTo( Planet* destination, ActionQueue* actionQueue ); + void moveTo(Uint32, Planet* destination, ActionQueue* actionQueue ); int numberSelectedShips(); void select( Selection* selection ); Modified: trunk/src/timer.cpp =================================================================== --- trunk/src/timer.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/timer.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -4,12 +4,9 @@ using namespace std; -Uint32 Timer::startTime; -Uint32 Timer::pauseTime; -bool Timer::paused; - Timer::Timer() { start(); + pause(); } void @@ -42,10 +39,11 @@ Timer::getTimeMMSSHH() { if( paused ) return "PA:US:ED"; - stringstream s; + int hundreds = ( getTime() % 1000 ) / 10; int seconds = getTime() / 1000; int minutes = seconds / 60; + stringstream s; seconds = seconds % 60; if( minutes < 10 ) s << "0"; @@ -60,11 +58,9 @@ } string -Timer::getTimeMMSS() { - if( paused ) - return "PAUSED"; - stringstream s; - int seconds = getTime() / 1000; +Timer::getTimeMMSS(Uint32 time) { + stringstream s; + int seconds = time / 1000; int minutes = seconds / 60; seconds = seconds % 60; if( minutes < 10 ) Modified: trunk/src/timer.h =================================================================== --- trunk/src/timer.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/timer.h 2007-07-28 21:25:43 UTC (rev 93) @@ -10,8 +10,8 @@ class Timer { private: - static Uint32 startTime, pauseTime; - static bool paused; + Uint32 startTime, pauseTime; + bool paused; public: Timer(); @@ -21,10 +21,8 @@ bool isPaused(); Uint32 getTime(); std::string getTimeMMSSHH(); - std::string getTimeMMSS(); + static std::string getTimeMMSS(Uint32); }; -static Timer timer; - #endif Modified: trunk/src/universe.cpp =================================================================== --- trunk/src/universe.cpp 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/universe.cpp 2007-07-28 21:25:43 UTC (rev 93) @@ -5,6 +5,7 @@ #include "universe.h" #include "planets.h" +#include "players.h" #include "stars.h" #include "actions.h" #include "animations.h" @@ -13,19 +14,21 @@ #include "canvas.h" Universe::Universe() : currentSelectedPlanet(0) { + actionQueue = new ActionQueue(); + animationQueue = new AnimationQueue(); + stars = new Stars( 100 ); planets = new Planets( 15, 15 ); planets->setUniverse( this ); - actionQueue = new ActionQueue(); - animationQueue = new AnimationQueue(); } Universe::Universe( int nrPlanets ) : currentSelectedPlanet(0) { + actionQueue = new ActionQueue(); + animationQueue = new AnimationQueue(); + stars = new Stars( 100 ); planets = new Planets( nrPlanets, nrPlanets ); planets->setUniverse( this ); - actionQueue = new ActionQueue(); - animationQueue = new AnimationQueue(); } Universe::~Universe() { @@ -36,9 +39,11 @@ } void -Universe::update() { - actionQueue->executeEventsBefore( timer.getTime() ); - animationQueue->executeEventsBefore( timer.getTime() ); +Universe::update(Uint32 time) { + actionQueue->executeEventsBefore( time ); + animationQueue->executeEventsBefore( time ); + + planets->update(time); } void @@ -59,19 +64,78 @@ } void -Universe::renderBackground() { +Universe::renderBackground(Uint32 time) { stars->render( ); Canvas::drawRadar(); - animationQueue->render(); + animationQueue->render(time); Canvas::drawSun(); } void -Universe::renderForeground( ) { - planets->updateShipLocations(); - planets->render( ); +Universe::renderForeground(Uint32 time) { + planets->render(time); } + +/* Assigns unclaimed planets and moons to players. + * + * The algorithm tries to claim as many planets as + * given by planetCount. However if there are not + * enough unclaimed planets to fullfil the request + * a lower number of planets will be claimed. + * + * Each planet is given shipCount ships. + * + * Planets are claimed even if no ship is placed on + * it! + */ +void +Universe::claim(Uint32 time, Player *player, int planetCount, int shipCount) +{ + Planets::iterator i = planets->begin(); + + while (i != planets->end()) + { + if (!((*i)->getMoon() || (*i)->getOwner())) + { + Planet *p = (*i); + + p->setOwner(player); + + for (int s = 0; s < shipCount; s++) + player->addShip(time, p); + + if (--planetCount == 0) + return; + } + + i++; + } + +} + +void +Universe::claimRemaining(Uint32 time, Player *player, int maxPlanetShipCount, int maxMoonShipCount) +{ + Planets::iterator i = planets->begin(); + + while (i != planets->end()) + { + if (!(*i)->getOwner()) + { + Planet *p = (*i); + + p->setOwner(player); + + int ships = 1 + rand() % (p->getMoon() ? maxMoonShipCount : maxPlanetShipCount); + + for (; ships > 0; ships--) + player->addShip(time, p); + + } + i++; + } +} Modified: trunk/src/universe.h =================================================================== --- trunk/src/universe.h 2007-07-28 10:33:09 UTC (rev 92) +++ trunk/src/universe.h 2007-07-28 21:25:43 UTC (rev 93) @@ -6,6 +6,7 @@ class Stars; class Planet; class Planets; +class Player; class ActionQueue; class AnimationQueue; @@ -24,10 +25,13 @@ void highlightNearestPlanet(int x, int y); - void update(); + void update(Uint32); - void renderBackground(); - void renderForeground(); + void renderBackground(Uint32); + void renderForeground(Uint32); + + void claim(Uint32, Player *, int, int); + void claimRemaining(Uint32, Player *, int, int); }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-09-09 13:48:18
|
Revision: 94 http://qonk.svn.sourceforge.net/qonk/?rev=94&view=rev Author: thebohemian Date: 2007-09-09 06:48:13 -0700 (Sun, 09 Sep 2007) Log Message: ----------- - added THANKYOU file Modified Paths: -------------- trunk/HISTORY trunk/configure.ac Added Paths: ----------- trunk/THANKYOU Modified: trunk/HISTORY =================================================================== --- trunk/HISTORY 2007-07-28 21:25:43 UTC (rev 93) +++ trunk/HISTORY 2007-09-09 13:48:13 UTC (rev 94) @@ -2,7 +2,7 @@ Features: - new project page: http//qonk.sf.net - public SVN repository: https://qonk.svn.sf.net/svnroot/qonk - - freely chosable input (mouse, keyboard, gamepad, ...) + - freely choosable input (mouse, keyboard, gamepad, ...) - config file - advance to next level without leaving game - upgraded ship and universe painting @@ -10,7 +10,7 @@ - autotools build system - single ship mode Bugs fixed: - - do not call SDL functions in Timere before SDL_Init because of static + - do not call SDL functions in Timer before SDL_Init because of static initialization - properly update screen size changes - allow removing input mappings Added: trunk/THANKYOU =================================================================== --- trunk/THANKYOU (rev 0) +++ trunk/THANKYOU 2007-09-09 13:48:13 UTC (rev 94) @@ -0,0 +1,6 @@ +The following people have contributed to Qonk: + +Anthony Liekens +Jens Fursund +Robert Schuster +Troels Kofoed Jacobsen Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-07-28 21:25:43 UTC (rev 93) +++ trunk/configure.ac 2007-09-09 13:48:13 UTC (rev 94) @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([qonk], [0.0.3+svn], [qon...@li...]) +AC_INIT([qonk], [0.0.3-pre], [qon...@li...]) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-09-09 14:31:29
|
Revision: 95 http://qonk.svn.sourceforge.net/qonk/?rev=95&view=rev Author: thebohemian Date: 2007-09-09 07:31:27 -0700 (Sun, 09 Sep 2007) Log Message: ----------- - fixed some makefiles to proper allow dist targets - added more gameplay infos Modified Paths: -------------- trunk/HISTORY trunk/Makefile.am trunk/README trunk/configure.ac trunk/guichan/guichan/Makefile.am trunk/src/Makefile.am trunk/src/lisp/Makefile.am Modified: trunk/HISTORY =================================================================== --- trunk/HISTORY 2007-09-09 13:48:13 UTC (rev 94) +++ trunk/HISTORY 2007-09-09 14:31:27 UTC (rev 95) @@ -1,4 +1,4 @@ -0.0.3 - NOT_RELEASED_YET - +0.3.0 - released on 2007/09/09 Features: - new project page: http//qonk.sf.net - public SVN repository: https://qonk.svn.sf.net/svnroot/qonk @@ -17,6 +17,7 @@ other: - simplified initial planet claiming - remove need for static Timer variable + - switch to traditional MAJOR.MINOR.MICRO version number scheme rs-2007-02-17 - 2007-02-17 A modificated version Modificated qonk based on 0.0.2beta1 by Robert Schuster: Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2007-09-09 13:48:13 UTC (rev 94) +++ trunk/Makefile.am 2007-09-09 14:31:27 UTC (rev 95) @@ -1,4 +1,4 @@ SUBDIRS = guichan src data -EXTRA_DIST = README COPYING missing Makefile.manual TODO +EXTRA_DIST = autogen.sh README COPYING missing TODO HISTORY THANKYOU Modified: trunk/README =================================================================== --- trunk/README 2007-09-09 13:48:13 UTC (rev 94) +++ trunk/README 2007-09-09 14:31:27 UTC (rev 95) @@ -13,8 +13,7 @@ (from http://anthony.liekens.net/index.php/Computers/Qonk) -The game is currently very much in beta and was written and published by -Anthony Liekens. +The game is currently very much in beta. Dependencies ------------ @@ -33,19 +32,21 @@ How to play ------------- +The goal is wipe out all enemies from the solar system. Select a group of planets to put their ships into your selection for the next move. Now do a right-click near the planet where you want to send you fleet to. You can attack neutral (grey), enemy (some color) and reinforce your own planets (the white ones). -The number of ships starting from a planets depends on the number of ships being +The number of ships starting from a planet depends on the number of ships being stationed there and the current fleet strength setting. In the beginning the -strength is set to 50%. That means that half of the ships on each planets will -take off when you order them to move. You can choose other strength settings by -pressing the number keys (1 -> 10%, 9 -> 90%, 0->100%). If you press the 's' key -you are in single ship mode. This means that on each move order one ship leaves -from the selected planets (there has to be at least one stationed, though). +strength is set to 50%. That means that half of the ships on each selected +planet will take off when you order them to move. You can choose other +strength settings by pressing the number keys (1 -> 10%, 9 -> 90%, 0->100%). +If you press the 's' key you are in single ship mode. This means that on each +move order one ship leaves from the selected planets (there has to be at least +one stationed, though). Besides setting the strength to certain values you can lower or higher the strength by using the mouse wheel. Below 10% comes the single ship mode, @@ -55,6 +56,11 @@ New ships are continuisly built on the planets (and moons) you own. Bigger planets usually built ships faster than smaller ones. +Ships stationing at a planet or moon are automatically defending it. The rule +is simple: One defending ship destroys one attacking ships and vice versa. A +planet or moon defended by N ships can only be conquered by at least N + 1 +ships. + Other options ------------- @@ -67,8 +73,8 @@ need to make sure that the mouse cannot leave the game's window. Press 'g' to activate input grabbing and press it again if you want to release the input. -Last but not least 'p' can be used to pause and unpause the game and 'ESC' quits -it. +To pause the game just press ESC to open the menus. Pressing ESC again puts you +back into the action. Command line options -------------------- @@ -82,21 +88,13 @@ On GNU/Linux and other POSIX-like systems a config file is written in your home directory at .qonk/qonk.config. -The format is LISP-like (you remember it from SuperTuxKart probably :) ). At the -moment editing the config file is the only possibility to switch the various -of the game except for the fullscreen mode state and the game's progress which -are saved on exit. +The format is LISP-like (you remember it from SuperTuxKart probably :) ). -If you feel sufficiently experienced you can change the input configuration of -the game. Don't use escape or g in any of your mappings, because those are -hardcoded to quitting and toggling the input grab. - Development ----------- -Plans are there to add a menu system, some GUI components and perhaps -a single-computer multiplayer mode. Feel free to contact the development team -via the mailing-list. +Plans are there to add a single-computer multiplayer mode. Feel free to +contact the development team via the mailing-list. Issues ------ @@ -105,9 +103,34 @@ Homepage -------- -http://qonk.sf.net +http://qonk.sourceforge.net Project page ------------- -http://sf.net/projects/qonk +http://sourceforge.net/projects/qonk + +License +------- + +This game is free software released under the GNU General Public License 2 +or, at your option, any later version. See the file COPYING for details. + +Acknowledgements +---------------- +Qonk uses a number of free software components (libraries) for which we thank +their authors: + +Simple Direct Media Library: http://libsdl.org + * This library is truly a gem! + +Guichan: http://guichan.sf.net + * Provides us some user interface components and made the menu system + implementation easier. + +GNU Autotools: http://gnu.org/software/autoconf + http://gnu.org/software/automake + * These make lifes for packagers and people who cross-compile so much easier. + Unfortunately many people do not understand all the issues around compiling, + linking and installing on different platforms and coping with compatibility + and blame the Autotools for being the root of all evil. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-09-09 13:48:13 UTC (rev 94) +++ trunk/configure.ac 2007-09-09 14:31:27 UTC (rev 95) @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([qonk], [0.0.3-pre], [qon...@li...]) +AC_INIT([qonk], [0.3.0], [qon...@li...]) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE Modified: trunk/guichan/guichan/Makefile.am =================================================================== --- trunk/guichan/guichan/Makefile.am 2007-09-09 13:48:13 UTC (rev 94) +++ trunk/guichan/guichan/Makefile.am 2007-09-09 14:31:27 UTC (rev 95) @@ -62,5 +62,4 @@ mouselistener.hpp \ platform.hpp \ rectangle.hpp \ - widget.hpp \ - x.hpp + widget.hpp Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-09-09 13:48:13 UTC (rev 94) +++ trunk/src/Makefile.am 2007-09-09 14:31:27 UTC (rev 95) @@ -7,11 +7,11 @@ bin_PROGRAMS = qonk qonk_LDADD = lisp/liblisp.a\ - $(top_builddir)/guichan/guichan/sdl/libguichan_sdl.a\ - $(top_builddir)/guichan/guichan/widgets/libguichan_widgets.a\ - $(top_builddir)/guichan/guichan/libguichan.a + $(top_builddir)/guichan/guichan/sdl/libguichan_sdl.a\ + $(top_builddir)/guichan/guichan/widgets/libguichan_widgets.a\ + $(top_builddir)/guichan/guichan/libguichan.a -qonk_SOURCES = " \ +qonk_SOURCES = \ actions.cpp \ actions.h \ animations.cpp \ @@ -20,22 +20,22 @@ canvas.h \ coordinate.cpp \ coordinate.h \ - controloptions.cpp \ - controloptions.h \ + controloptions.cpp \ + controloptions.h \ extensions.cpp \ extensions.h \ fonts.cpp \ fonts.h \ - menu.cpp \ - menu.h \ - menuaction.cpp \ - menuaction.h \ - menuentry.cpp \ - menuentry.h \ - menumanager.cpp \ - menumanager.h \ - menusystem.cpp \ - menusystem.h \ + menu.cpp \ + menu.h \ + menuaction.cpp \ + menuaction.h \ + menuentry.cpp \ + menuentry.h \ + menumanager.cpp \ + menumanager.h \ + menusystem.cpp \ + menusystem.h \ game.cpp \ game.h \ gameoptions.cpp \ @@ -63,5 +63,5 @@ timer.h \ universe.cpp \ universe.h \ - videooptions.cpp \ - videooptions.h " + videooptions.cpp \ + videooptions.h Modified: trunk/src/lisp/Makefile.am =================================================================== --- trunk/src/lisp/Makefile.am 2007-09-09 13:48:13 UTC (rev 94) +++ trunk/src/lisp/Makefile.am 2007-09-09 14:31:27 UTC (rev 95) @@ -1,13 +1,13 @@ noinst_LIBRARIES = liblisp.a -liblisp_a_SOURCES = " \ - lexer.cpp \ - lexer.hpp \ - lisp.cpp \ - lisp.hpp \ - translation.hpp \ - parser.cpp \ - parser.hpp \ - writer.cpp \ - writer.hpp" +liblisp_a_SOURCES = \ + lexer.cpp \ + lexer.hpp \ + lisp.cpp \ + lisp.hpp \ + translation.hpp \ + parser.cpp \ + parser.hpp \ + writer.cpp \ + writer.hpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-09-09 14:53:00
|
Revision: 99 http://qonk.svn.sourceforge.net/qonk/?rev=99&view=rev Author: thebohemian Date: 2007-09-09 07:52:59 -0700 (Sun, 09 Sep 2007) Log Message: ----------- - more infos Modified Paths: -------------- trunk/INSTALL trunk/TODO Modified: trunk/INSTALL =================================================================== --- trunk/INSTALL 2007-09-09 14:44:25 UTC (rev 98) +++ trunk/INSTALL 2007-09-09 14:52:59 UTC (rev 99) @@ -1,3 +1,6 @@ +General compilation: +----------------- + Qonk uses GNU Autoconf to manage the compilation. Call ./configure --help @@ -7,3 +10,20 @@ Like all good applications Qonk is able to be run without installation. It tries to find its data files in ./data first and uses $(pkgdatadir)/data in a second attempt. + +Dependencies: +------------- +Qonk tries to only use components available in free software operating systems. + +Install the development version of the following packages in order to compile +from source: + + SDL (>= 1.2) + SDL_ttf (>= 2.0) + SDL_gfx (>= 1.2) + SDL_image (>= 1.2) + +Qonk includes a modified version of guichan 0.6.1 in its sources and statically +links that into the executable. The build system was not tested to use a +system-wide installation of guichan 0.6.1. Furthermore since guichan is not +extensively used in Qonk it is planned to remove it in further releases. Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-09-09 14:44:25 UTC (rev 98) +++ trunk/TODO 2007-09-09 14:52:59 UTC (rev 99) @@ -11,4 +11,7 @@ Add network multiplayer -Add menu system +Add single-machine multiplayer + +Replace guichan. It is not used that much. + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2007-10-02 06:21:52
|
Revision: 114 http://qonk.svn.sourceforge.net/qonk/?rev=114&view=rev Author: thebohemian Date: 2007-10-01 23:21:50 -0700 (Mon, 01 Oct 2007) Log Message: ----------- - restructed code to several subdirs - adjusted autoconfigury - moved gameWidth/gameHeight code from Settings to Canvas - adjusted all places using the old gameWidth/gameHeight code - made all Coordinate instance use game coordinates instead of screen coordinates Modified Paths: -------------- trunk/configure.ac trunk/src/Makefile.am trunk/src/fonts.cpp trunk/src/fonts.h trunk/src/main.cpp trunk/src/sdl_driver.cpp trunk/src/settings.cpp trunk/src/settings.h Added Paths: ----------- trunk/src/engine/ trunk/src/engine/Makefile trunk/src/engine/Makefile.am trunk/src/engine/actions.cpp trunk/src/engine/animations.cpp trunk/src/engine/canvas.cpp trunk/src/engine/coordinate.h trunk/src/engine/game.h trunk/src/engine/messages.h trunk/src/engine/planets.cpp trunk/src/engine/players.h trunk/src/engine/selection.h trunk/src/engine/ships.h trunk/src/engine/stars.cpp trunk/src/engine/timer.h trunk/src/engine/universe.cpp trunk/src/ui/ Removed Paths: ------------- trunk/src/actions.cpp trunk/src/actions.h trunk/src/animations.cpp trunk/src/animations.h trunk/src/canvas.cpp trunk/src/canvas.h trunk/src/coordinate.cpp trunk/src/coordinate.h trunk/src/extensions.cpp trunk/src/extensions.h trunk/src/game.cpp trunk/src/game.h trunk/src/menumanager.cpp trunk/src/menumanager.h trunk/src/messages.cpp trunk/src/messages.h trunk/src/planets.cpp trunk/src/planets.h trunk/src/players.cpp trunk/src/players.h trunk/src/selection.cpp trunk/src/selection.h trunk/src/ships.cpp trunk/src/ships.h trunk/src/stars.cpp trunk/src/stars.h trunk/src/timer.cpp trunk/src/timer.h trunk/src/ui/ trunk/src/universe.cpp trunk/src/universe.h Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-10-01 15:15:39 UTC (rev 113) +++ trunk/configure.ac 2007-10-02 06:21:50 UTC (rev 114) @@ -6,7 +6,7 @@ AC_CANONICAL_TARGET AM_INIT_AUTOMAKE -AC_CONFIG_SRCDIR([src/animations.h]) +AC_CONFIG_SRCDIR([src/main.cpp]) AC_CONFIG_HEADER([config.h]) # Checks for programs. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-10-01 15:15:39 UTC (rev 113) +++ trunk/src/Makefile.am 2007-10-02 06:21:50 UTC (rev 114) @@ -1,4 +1,4 @@ -SUBDIRS = lisp ui +SUBDIRS = lisp ui engine INCLUDES = -I$(top_srcdir)/guichan @@ -8,53 +8,26 @@ qonk_LDADD = lisp/liblisp.a \ ui/libui.a \ + engine/libengine.a \ $(top_builddir)/guichan/guichan/sdl/libguichan_sdl.a \ $(top_builddir)/guichan/guichan/widgets/libguichan_widgets.a \ $(top_builddir)/guichan/guichan/libguichan.a qonk_SOURCES = \ - actions.cpp \ - actions.h \ - animations.cpp \ - animations.h \ - canvas.cpp \ - canvas.h \ - coordinate.cpp \ - coordinate.h \ controloptions.cpp \ controloptions.h \ - extensions.cpp \ - extensions.h \ fonts.cpp \ fonts.h \ menumanager.cpp \ menumanager.h \ - game.cpp \ - game.h \ gameoptions.cpp \ gameoptions.h \ input.h \ main.cpp \ main.h \ - messages.cpp \ - messages.h \ - planets.cpp \ - planets.h \ - players.cpp \ - players.h \ sdl_driver.cpp \ sdl_driver.h \ - selection.cpp \ - selection.h \ settings.cpp \ settings.h \ - ships.cpp \ - ships.h \ - stars.cpp \ - stars.h \ - timer.cpp \ - timer.h \ - universe.cpp \ - universe.h \ videooptions.cpp \ videooptions.h Deleted: trunk/src/actions.cpp =================================================================== --- trunk/src/actions.cpp 2007-10-01 15:15:39 UTC (rev 113) +++ trunk/src/actions.cpp 2007-10-02 06:21:50 UTC (rev 114) @@ -1,70 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "actions.h" - -#include "settings.h" -#include <iostream> - -// ##### ACTION ##### -using namespace std; - -Action::Action() { - actionID = 0; -} - -void -Action::setActionQueue( ActionQueue* actionQueue ) { - this->actionQueue = actionQueue; -} - -ActionQueue* -Action::getActionQueue() const { - return actionQueue; -} - -// ##### ACTIONQUEUE ##### - -ActionQueue::ActionQueue() { - clear(); - time = 0; -} - -void -ActionQueue::scheduleAction( Uint32 time, Action* action ) { - if( this->time > time ) { - std::cerr << "Action was inserted before action that has already been executed" << endl; - } - action->setActionQueue( this ); - insert( pair< Uint32, Action* >( time, action ) ); -} - -Uint32 -ActionQueue::timeOfNextEvent() { - return this->begin()->first; -} - -void -ActionQueue::executeNextEvent() { - time = this->begin()->first; - Action* a = this->begin()->second; -// if( time > timer.getTime() ) { -// SDL_Delay( time - timer.getTime() ); -// } - a->execute( time ); - erase( this->begin() ); - delete a; -} - -void -ActionQueue::executeAllEvents() { - while( size() > 0 ) { - executeNextEvent(); - } -} - -void ActionQueue::executeEventsBefore( Uint32 time ) { - while( ( size() > 0 ) && ( timeOfNextEvent() < time ) ) { - executeNextEvent(); - } -} - Deleted: trunk/src/actions.h =================================================================== --- trunk/src/actions.h 2007-10-01 15:15:39 UTC (rev 113) +++ trunk/src/actions.h 2007-10-02 06:21:50 UTC (rev 114) @@ -1,39 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef ACTIONS_H -#define ACTIONS_H - -#include <SDL/SDL.h> -#include <map> - -class ActionQueue; - -class Action { -private: - ActionQueue* actionQueue; -protected: - int actionID; -public: - Action(); - virtual void execute( const Uint32& time ) = 0; - virtual ~Action() {} - void setActionQueue( ActionQueue* actionQueue ); - ActionQueue* getActionQueue() const; - int getActionID() { return actionID; } -}; - -class ActionQueue : public std::multimap< Uint32, Action* > { -private: - Uint32 time; -public: - ActionQueue(); - void scheduleAction( Uint32 time, Action* action ); - - Uint32 timeOfNextEvent(); - - void executeNextEvent(); - void executeAllEvents(); - void executeEventsBefore( Uint32 time ); -}; - -#endif Deleted: trunk/src/animations.cpp =================================================================== --- trunk/src/animations.cpp 2007-10-01 15:15:39 UTC (rev 113) +++ trunk/src/animations.cpp 2007-10-02 06:21:50 UTC (rev 114) @@ -1,38 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#include "animations.h" -#include "timer.h" -#include "planets.h" -#include "coordinate.h" -#include "canvas.h" - -void -AnimationQueue::render(Uint32 time) { - for( iterator i = begin(); i != end(); i++ ) { - Animation* animation = (Animation*)( i->second ); - animation->render(time); - } -} - -SonarAnimation::SonarAnimation() { -} - -SonarAnimation::SonarAnimation( Planet* planet, const Uint32& color, const int& size, const Uint32& startTime, const Uint32& endTime, bool circle ) { - this->circle = circle; - this->planet = planet; - r = ( color & 0xFF0000 ) >> 16; - g = ( color & 0x00FF00 ) >> 8; - b = ( color & 0x0000FF ); -// this->color = color; - this->size = size; - this->startTime = startTime; - this->endTime = endTime; -} - -void -SonarAnimation::render(Uint32 time) { - if( ( time > startTime ) && ( time < endTime ) ) { - double percentage = (double)( time - startTime ) / ( endTime - startTime ); - Canvas::drawSonar(planet->getLocation(), size, percentage, r, g, b, circle); - } -} Deleted: trunk/src/animations.h =================================================================== --- trunk/src/animations.h 2007-10-01 15:15:39 UTC (rev 113) +++ trunk/src/animations.h 2007-10-02 06:21:50 UTC (rev 114) @@ -1,34 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef ANIMATIONS_H -#define ANIMATIONS_H - -#include "actions.h" - -class Planet; - -class Animation : public Action { -public: - void execute( const Uint32& time ) {} - virtual void render(Uint32) = 0; -}; - -class AnimationQueue : public ActionQueue { -public: - void render(Uint32); -}; - -class SonarAnimation : public Animation { -private: - bool circle; - Planet* planet; - Uint32 startTime, endTime; - Uint8 r, g, b; - int size; -public: - SonarAnimation(); - SonarAnimation( Planet* planet, const Uint32& color, const int& size, const Uint32& startTime, const Uint32& endTime, bool circle = false ); - void render(Uint32); -}; - -#endif Deleted: trunk/src/canvas.cpp =================================================================== --- trunk/src/canvas.cpp 2007-10-01 15:15:39 UTC (rev 113) +++ trunk/src/canvas.cpp 2007-10-02 06:21:50 UTC (rev 114) @@ -1,308 +0,0 @@ -// Copyright 2005 by Anthony Liekens <an...@li...> -// Copyright 2007 by Robert Schuster <rob...@fs...> - -#include <SDL/SDL_gfxPrimitives.h> - -#include "canvas.h" - -#include "extensions.h" -#include "coordinate.h" -#include "settings.h" -#include "fonts.h" - -SDL_Surface* Canvas::main = 0; - -gcn::SDLGraphics *Canvas::sdlGraphics = 0; - -Font* Canvas::font = 0; - -void -Canvas::alphaBlend( SDL_Surface* surface, Uint8 alpha ) { - if( alpha == 0 ) { - for( int x = 0; x < surface->w; x++ ) - for( int y = 0; y < surface->h; y++ ) { - Uint32 *bufp; - bufp = (Uint32 *)surface->pixels + y*surface->pitch/4 + x; - if( *bufp != 0 ) - *bufp &= 0x00ffffff; - } - } if( alpha != 255 ) { - for( int x = 0; x < surface->w; x++ ) - for( int y = 0; y < surface->h; y++ ) { - Uint32 *bufp; - bufp = (Uint32 *)surface->pixels + y*surface->pitch/4 + x; - if( *bufp != 0 ) { - // seperate RGB from A, update A for new value, OR them together again - Uint32 color = ( *bufp & 0x00ffffff ) | ( ( *bufp >> 24 ) * alpha >> 8 ) << 24; - *bufp = color; - } - } - } -} - -void -Canvas::drawSelector(Coordinate &c, Sint16 offset, - Sint16 width, Sint16 height, Uint8 R, Uint8 G, Uint8 B) -{ - int x1 = c.getXMapped() + offset; - int y1 = c.getYMapped() + offset; - - hlineRGBA( main, x1, x1 + 2, y1, R, G, B, 255 ); - hlineRGBA( main, x1 + width - 2, x1 + width, y1, R, G, B, 255 ); - hlineRGBA( main, x1, x1 + 2, y1 + height, R, G, B, 255 ); - hlineRGBA( main, x1 + width - 2, x1 + width, y1 + height, R, G, B, 255 ); - vlineRGBA( main, x1, y1, y1 + 2, R, G, B, 255 ); - vlineRGBA( main, x1, y1 + height, y1 + height - 2, R, G, B, 255 ); - vlineRGBA( main, x1 + width, y1, y1 + 2, R, G, B, 255 ); - vlineRGBA( main, x1 + width, y1 + height, y1 + height - 2, R, G, B, 255 ); -} - -void -Canvas::drawNearestPlanetSelector(Coordinate &c, int size) -{ - size *= 3; - int offset = -size/2; - - drawSelector(c, offset, size, size, 255, 0, 0); -} - -void -Canvas::drawPlanet( Coordinate &loc, int size, Uint32 color ) { - drawPlanetMapped(loc.getXMapped(), loc.getYMapped(), size, color); -} - -void -Canvas::drawPlanetMapped(int x, int y, int size, Uint32 color ) { - int R = getRed(color); - int G = getGreen(color); - int B = getBlue(color); - - filledCircleRGBA( main, x, y, size + 2, 0, 0, 0, 128 ); - filledCircleRGBA( main, x, y, size, R, G, B, 255 ); - aacircleRGBA( main, x, y, size, R, G, B, 255 ); - filledEllipseRGBA( main, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); - aaellipseRGBA( main, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); -} - -void -Canvas::drawResidentShip(Coordinate& shipLocation, Coordinate& planetLocation, - int color) { - int sx = shipLocation.getXMapped(); - int sy = shipLocation.getYMapped(); - - int px = planetLocation.getXMapped(); - int py = planetLocation.getYMapped(); - - int r = getRed(color); - int g = getGreen(color); - int b = getBlue(color); - - aalineRGBA(main, sx, sy, px, py, r, g, b, 64); - filledCircleRGBA(main, sx, sy, 1, r, g, b, 255); -} - -void -Canvas::drawFlyingShip(Coordinate& shipLocation, double direction, int color) -{ - int sx = shipLocation.getXMapped(); - int sy = shipLocation.getYMapped(); - - int r = getRed(color); - int g = getGreen(color); - int b = getBlue(color); - - int headX, headY; - int leftTipX, leftTipY; - int rightTipX, rightTipY; - - headX = (int) (sx + 5.0 * cos( direction)); - headY = (int) (sy + 5.0 * sin( direction)); - leftTipX = (int) (sx + 2.0 * cos( direction + M_PI / 3.0)); - leftTipY = (int) (sy + 2.0 * sin( direction + M_PI / 3.0)); - rightTipX = (int) (sx + 2.0 * cos( direction - M_PI / 3.0)); - rightTipY = (int) (sy + 2.0 * sin( direction - M_PI / 3.0)); - - aalineRGBA(main, leftTipX, leftTipY, headX, headY, r, g, b, 255); - aalineRGBA(main, rightTipX, rightTipY, headX, headY, r, g, b, 255); - aalineRGBA(main, rightTipX, rightTipY, leftTipX, leftTipY, r, g, b, 255); -} - -void -Canvas::drawSelection(Coordinate& location) -{ - aacircleRGBA(main, location.getXMapped(), location.getYMapped(), 3, 255, 192, 0, 255 ); -} - -void -Canvas::drawOrbit(Coordinate ¢er, double rotationDistance, int color) -{ - int r = getRed(color); - int g = getGreen(color); - int b = getBlue(color); - - aaellipseRGBA(main, center.getXMapped(), center.getYMapped(), - (int) (rotationDistance * Settings::getGameWidth()), - (int) (rotationDistance * Settings::getGameHeight()), - r, g, b, 64); -} - -void -Canvas::drawBuildProgress(Coordinate& location, int size, double percentage) -{ - aacircleRGBA( main, location.getXMapped(), location.getYMapped(), - (int) (size + 102.5 - percentage), - 0xff, 0xff, 0xff, - (int)( 0.2 * percentage )); -} - -void -Canvas::drawText(int x, int y, const char *msg, int r, int g, int b, int a) -{ - font->render(main, x, y, msg, r, g, b, a); -} - -void -Canvas::drawBox(int x, int y, int w, int h, int r, int g, int b) -{ - boxRGBA( main, x, y, w, h, r, g, b, 255 ); -} - -int -Canvas::getFontHeight() -{ - return font->getHeight(); -} - -void -Canvas::drawRadar() -{ - int radarSteps = 4; - Uint32 radarColor = 0xfee190; - - double s = 1.0 / radarSteps; - for( int i = 1; i <= radarSteps; i++ ) { - aaellipseRGBA( main, Settings::getGameOffsetX() + Settings::getGameWidth() / 2, - Settings::getGameHeight() / 2, (int) (i * s * Settings::getGameWidth() / 2), - (int)( i * s * Settings::getGameHeight() / 2 ), 144, 225, 144, 64 ); - } - lineRGBA( main, - Settings::getGameOffsetX() + Settings::getGameWidth() / 2, 0, - Settings::getGameOffsetX() + Settings::getGameWidth() / 2, - Settings::getGameHeight(), 255, 225, 144, 64 ); - lineRGBA( main, - Settings::getGameOffsetX(), - Settings::getGameHeight() / 2, - Settings::getGameOffsetX() + Settings::getGameWidth(), - Settings::getGameHeight() / 2, 255, 225, 144, 64 ); -} - -void -Canvas::drawSun() -{ - // Sun in the middle - Sint16 x0 = Settings::getGameOffsetX() + Settings::getGameWidth() / 2; - Sint16 y0 = Settings::getGameHeight() / 2; - - filledTrigonRGBA( main, x0+5, y0, x0-5,y0, x0, y0+15, 255, 205, 0, 255); - filledTrigonRGBA( main, x0+5, y0, x0-5,y0, x0, y0-15, 255, 205, 0, 255); - filledTrigonRGBA( main, x0+15, y0, x0,y0+5, x0, y0-5, 255, 205, 0, 255); - filledTrigonRGBA( main, x0-15, y0, x0,y0+5, x0, y0-5, 255, 205, 0, 255); - - filledTrigonRGBA( main, x0+10, y0-10, x0+5,y0, x0, y0-5, 255, 205, 0, 255); - filledTrigonRGBA( main, x0-10, y0-10, x0-5,y0, x0, y0-5, 255, 205, 0, 255); - filledTrigonRGBA( main, x0+10, y0+10, x0+5,y0, x0, y0+5, 255, 205, 0, 255); - filledTrigonRGBA( main, x0-10, y0+10, x0-5,y0, x0, y0+5, 255, 205, 0, 255); - - filledCircleRGBA( main, x0,y0, 7, 255, 255, 0, 255 ); - filledCircleRGBA( main, x0,y0, 6, 255, 245, 0, 255 ); - filledCircleRGBA( main, x0,y0, 5, 255, 225, 0, 255 ); - filledCircleRGBA( main, x0,y0, 4, 255, 205, 0, 255 ); -} - -/** Little star drawn in the background. - * - */ -void -Canvas::drawStar(int x, int y, int brightness) -{ - pixelRGBA( main, x, y, - brightness + rand() % 64, - brightness + rand() % 64, - brightness + rand() % 64, - 255 ); - -} - -void -Canvas::drawSonar(Coordinate coord, int size, double percentage, int r, int g, int b, bool circle) -{ - int x = coord.getXMapped(); - int y = coord.getYMapped(); - - filledCircleRGBA( main, x, y, (int)( size * sin( percentage * M_PI ) ), r, g, b, (int)( ( 255 - 255 * percentage ) * 0.05 ) ); - - if( circle ) - aacircleRGBA( main, x, y, (int)( size * sin( percentage * M_PI ) ), r, g, b, 255 - (int)( 255 * percentage ) ); - -} - -void -Canvas::drawPlayerStat(int size, int index, int previousValue, int currentValue, int r, int g, int b) -{ - int w = Settings::getScreenWidth(); - int h = Settings::getScreenHeight(); - - aalineRGBA( main, w - size + index - 1, h - previousValue, - w - size + index, h - currentValue, - r, g, b, index * 2 ); -} - -void -Canvas::drawMouseSelection(Coordinate &c1, Coordinate &c2) -{ - rectangleColor( main, c1.getXMapped(), c1.getYMapped(), - c2.getXMapped(), c2.getYMapped(), 0xfee19080 ); -} - -void -Canvas::drawCursor(int x, int y) -{ - aacircleRGBA( main, x,y, 4, 255, 255, 255, 255 ); -} - -void -Canvas::initScreen() -{ - if (!sdlGraphics) - sdlGraphics = new gcn::SDLGraphics(); - - if (!font) - font = new Font("font.ttf", 18); - - long flags = SDL_SWSURFACE | SDL_HWSURFACE; - if (Settings::getFullscreen()) - flags |= SDL_FULLSCREEN; - - main = SDL_SetVideoMode( Settings::getScreenWidth(), Settings::getScreenHeight(), 0, flags); - sdlGraphics->setTarget(main); -} - -void -Canvas::shutdown() -{ - delete sdlGraphics; - SDL_FreeSurface(main); - main = NULL; -} - -void -Canvas::updateScreen() -{ - SDL_Flip(main); -} - -gcn::SDLGraphics * -Canvas::getSDLGraphics() -{ - return sdlGraphics; -} Deleted: trunk/src/canvas.h =================================================================== --- trunk/src/canvas.h 2007-10-01 15:15:39 UTC (rev 113) +++ trunk/src/canvas.h 2007-10-02 06:21:50 UTC (rev 114) @@ -1,82 +0,0 @@ -// Copyright 2007 by Robert Schuster <rob...@fs...> - -// Basic drawing and converting operations for Qonk - -// If not explicitly told otherwise coordinate values are -// in game units. - -#ifndef CANVAS_H -#define CANVAS_H - -#include <SDL/SDL.h> - -#include "guichan/guichan/sdl.hpp" - -class Coordinate; -class Font; - -class Canvas -{ - public: - static void alphaBlend( SDL_Surface* surface, Uint8 alpha ); - - static void drawSelector( Coordinate&, Sint16 offset, - Sint16 width, Sint16 height, - Uint8 R, Uint8 G, Uint8 B ); - - static void drawNearestPlanetSelector(Coordinate&, int); - - static void drawPlanet(Coordinate&, int size, Uint32 color); - - static void drawPlanetMapped(int x, int y, int size, Uint32 color); - - static void drawResidentShip(Coordinate& shipLocation, Coordinate& planetLocation, - int color); - - static void drawFlyingShip(Coordinate&, double direction, int color); - - static void drawSelection(Coordinate&); - - static void drawOrbit(Coordinate&, double rotationDistance, int color); - - static void drawBuildProgress(Coordinate&, int, double); - - static void drawText(int, int, const char *, int, int, int, int a=255); - - static int getFontHeight(); - - static void drawBox(int x, int y, int w, int h, int r, int g, int b); - - static void drawRadar(); - - static void drawSun(); - - static void drawStar(int x, int y, int brightness); - - static void drawSonar(Coordinate coord, int size, double percentage, int r, int g, int b, bool circle); - - static void drawPlayerStat(int size, int index, int previousValue, int currentValue, int r, int g, int b); - - static void drawMouseSelection(Coordinate &c1, Coordinate &c2); - - static void drawCursor(int, int); - - static void updateScreen(); - - static void initScreen(); - - static void shutdown(); - - static gcn::SDLGraphics *getSDLGraphics(); - - private: - - static gcn::SDLGraphics *sdlGraphics; - - static SDL_Surface* main; - - static Font *font; - -}; - -#endif /* CANVAS_H */ Deleted: trunk/src/coordinate.cpp =================================================================== --- trunk/src/coordinate.cpp 2007-10-01 15:15:39 UTC (rev 113) +++ trunk/src/coordinate.cpp 2007-10-02 06:21:50 UTC (rev 114) @@ -1,68 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... -#include <math.h> - -#include "coordinate.h" - -#include "settings.h" - -Coordinate::Coordinate() { - x = y = 0; -} - -Coordinate::Coordinate( double x, double y ) { - this->x = x; - this->y = y; -} - -void -Coordinate::setX( double x ) { - this->x = x; -} - -void -Coordinate::setY( double y ) { - this->y = y; -} - -void -Coordinate::setXMapped( int x ) { - this->x = ( (double)x - Settings::getGameOffsetX() ) / Settings::getGameWidth(); -} - -void -Coordinate::setYMapped( int y ) { - this->y = (double)y / Settings::getGameHeight(); -} - -double -Coordinate::getX() const { - return x; -} - -double -Coordinate::getY() const { - return y; -} - -int -Coordinate::getXMapped() const { - return Settings::getGameOffsetX() + ( int )( Settings::getGameWidth() * x ); -} - -int -Coordinate::getYMapped() const { - return ( int )( Settings::getGameHeight() * y ); -} - -double -Coordinate::distance( const Coordinate& c ) const { - double dx = c.getX() - getX(); - double dy = c.getY() - getY(); - return sqrt( dx * dx + dy * dy ); -} - -bool -Coordinate::operator==( const Coordinate &that) const -{ - return x == that.x && y == that.y; -} Deleted: trunk/src/coordinate.h =================================================================== --- trunk/src/coordinate.h 2007-10-01 15:15:39 UTC (rev 113) +++ trunk/src/coordinate.h 2007-10-02 06:21:50 UTC (rev 114) @@ -1,28 +0,0 @@ -// Copyright 2005 by Anthony Liekens an...@li... - -#ifndef COORDINATE_H -#define COORDINATE_H - -class Coordinate { -private: - double x, y; -public: - Coordinate(); - Coordinate( double x, double y ); - - void setX( double x ); - void setY( double y ); - void setXMapped( int x ); - void setYMapped( int y ); - - double getX() const; - double getY() const; - int getXMapped() const; - int getYMapped() const; - - double distance( const Coordinate& c ) const; - - bool operator==( const Coordinate &that) const; -}; - -#endif Added: trunk/src/engine/Makefile =================================================================== --- trunk/src/engine/Makefile (rev 0) +++ trunk/src/engine/Makefile 2007-10-02 06:21:50 UTC (rev 114) @@ -0,0 +1,452 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# src/engine/Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + + +srcdir = . +top_srcdir = ../.. + +pkgdatadir = $(datadir)/qonk +pkglibdir = $(libdir)/qonk +pkgincludedir = $(includedir)/qonk +top_builddir = ../.. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = /usr/bin/install -c +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = i686-pc-linux-gnu +host_triplet = i686-pc-linux-gnu +target_triplet = i686-pc-linux-gnu +subdir = src/engine +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +libengine_a_AR = $(AR) $(ARFLAGS) +libengine_a_LIBADD = +am_libengine_a_OBJECTS = actions.$(OBJEXT) animations.$(OBJEXT) \ + canvas.$(OBJEXT) coordinate.$(OBJEXT) extensions.$(OBJEXT) \ + game.$(OBJEXT) messages.$(OBJEXT) planets.$(OBJEXT) \ + players.$(OBJEXT) selection.$(OBJEXT) ships.$(OBJEXT) \ + stars.$(OBJEXT) universe.$(OBJEXT) timer.$(OBJEXT) +libengine_a_OBJECTS = $(am_libengine_a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libengine_a_SOURCES) +DIST_SOURCES = $(libengine_a_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = ${SHELL} /home/rob/devel/games/qonk/qonk-svn/trunk/missing --run aclocal-1.9 +AMDEP_FALSE = # +AMDEP_TRUE = +AMTAR = ${SHELL} /home/rob/devel/games/qonk/qonk-svn/trunk/missing --run tar +AUTOCONF = ${SHELL} /home/rob/devel/games/qonk/qonk-svn/trunk/missing --run autoconf +AUTOHEADER = ${SHELL} /home/rob/devel/games/qonk/qonk-svn/trunk/missing --run autoheader +AUTOMAKE = ${SHELL} /home/rob/devel/games/qonk/qonk-svn/trunk/missing --run automake-1.9 +AWK = gawk +CC = gcc +CCDEPMODE = depmode=gcc3 +CFLAGS = -g -O2 +CPP = gcc -E +CPPFLAGS = +CXX = g++ +CXXDEPMODE = depmode=gcc3 +CXXFLAGS = -g -O2 +CYGPATH_W = echo +DEFS = -DHAVE_CONFIG_H +DEPDIR = .deps +ECHO_C = +ECHO_N = -n +ECHO_T = +EGREP = /bin/grep -E +EXEEXT = +GREP = /bin/grep +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s +LDFLAGS = +LIBOBJS = +LIBS = -lSDL_image -lSDL_gfx -lSDL_ttf -lSDL +LTLIBOBJS = +MAKEINFO = ${SHELL} /home/rob/devel/games/qonk/qonk-svn/trunk/missing --run makeinfo +OBJEXT = o +PACKAGE = qonk +PACKAGE_BUGREPORT = qon...@li... +PACKAGE_NAME = qonk +PACKAGE_STRING = qonk 0.3.1+svn +PACKAGE_TARNAME = qonk +PACKAGE_VERSION = 0.3.1+svn +PATH_SEPARATOR = : +RANLIB = ranlib +SDL_CFLAGS = -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT +SDL_CONFIG = /usr/bin/sdl-config +SDL_LIBS = -L/usr/lib -lSDL +SET_MAKE = +SHELL = /bin/sh +STRIP = +VERSION = 0.3.1+svn +ac_ct_CC = gcc +ac_ct_CXX = g++ +am__fastdepCC_FALSE = # +am__fastdepCC_TRUE = +am__fastdepCXX_FALSE = # +am__fastdepCXX_TRUE = +am__include = include +am__leading_dot = . +am__quote = +am__tar = ${AMTAR} chof - "$$tardir" +am__untar = ${AMTAR} xf - +bindir = ${exec_prefix}/bin +build = i686-pc-linux-gnu +build_alias = +build_cpu = i686 +build_os = linux-gnu +build_vendor = pc +datadir = ${datarootdir} +datarootdir = ${prefix}/share +docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} +dvidir = ${docdir} +exec_prefix = ${prefix} +host = i686-pc-linux-gnu +host_alias = +host_cpu = i686 +host_os = linux-gnu +host_vendor = pc +htmldir = ${docdir} +includedir = ${prefix}/include +infodir = ${datarootdir}/info +install_sh = /home/rob/devel/games/qonk/qonk-svn/trunk/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localedir = ${datarootdir}/locale +localstatedir = ${prefix}/var +mandir = ${datarootdir}/man +mkdir_p = mkdir -p -- +oldincludedir = /usr/include +pdfdir = ${docdir} +prefix = /usr/local +program_transform_name = s,x,x, +psdir = ${docdir} +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +sysconfdir = ${prefix}/etc +target = i686-pc-linux-gnu +target_alias = +target_cpu = i686 +target_os = linux-gnu +target_vendor = pc +AM_CPPFLAGS = -DPKG_DATA_DIR="\"$(pkgdatadir)/\"" +INCLUDES = -I$(top_srcdir)/guichan +noinst_LIBRARIES = libengine.a +libengine_a_SOURCES = \ + actions.cpp \ + actions.h \ + animations.cpp \ + animations.h \ + canvas.cpp \ + canvas.h \ + coordinate.cpp \ + coordinate.h \ + extensions.cpp \ + extensions.h \ + game.cpp \ + game.h \ + messages.cpp \ + messages.h \ + planets.cpp \ + planets.h \ + players.cpp \ + players.h \ + selection.cpp \ + selection.h \ + ships.cpp \ + ships.h \ + stars.cpp \ + stars.h \ + universe.cpp \ + universe.h \ + timer.cpp \ + timer.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/engine/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/engine/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libengine.a: $(libengine_a_OBJECTS) $(libengine_a_DEPENDENCIES) + -rm -f libengine.a + $(libengine_a_AR) libengine.a $(libengine_a_OBJECTS) $(libengine_a_LIBADD) + $(RANLIB) libengine.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +include ./$(DEPDIR)/actions.Po +include ./$(DEPDIR)/animations.Po +include ./$(DEPDIR)/canvas.Po +include ./$(DEPDIR)/coordinate.Po +include ./$(DEPDIR)/extensions.Po +include ./$(DEPDIR)/game.Po +include ./$(DEPDIR)/messages.Po +include ./$(DEPDIR)/planets.Po +include ./$(DEPDIR)/players.Po +include ./$(DEPDIR)/selection.Po +include ./$(DEPDIR)/ships.Po +include ./$(DEPDIR)/stars.Po +include ./$(DEPDIR)/timer.Po +include ./$(DEPDIR)/universe.Po + +.cpp.o: + if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ + then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: + if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ + then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \ +# $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-noinstLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: Added: trunk/src/engine/Makefile.am =================================================================== --- trunk/src/engine/Makefile.am (rev 0) +++ trunk/src/engine/Makefile.am 2007-10-02 06:21:50 UTC (rev 114) @@ -0,0 +1,36 @@ +AM_CPPFLAGS=-DPKG_DATA_DIR="\"$(pkgdatadir)/\"" + +INCLUDES = -I$(top_srcdir)/guichan + +noinst_LIBRARIES = libengine.a + +libengine_a_SOURCES = \ + actions.cpp \ + actions.h \ + animations.cpp \ + animations.h \ + canvas.cpp \ + canvas.h \ + coordinate.cpp \ + coordinate.h \ + extensions.cpp \ + extensions.h \ + game.cpp \ + game.h \ + messages.cpp \ + messages.h \ + planets.cpp \ + planets.h \ + players.cpp \ + players.h \ + selection.cpp \ + selection.h \ + ships.cpp \ + ships.h \ + stars.cpp \ + stars.h \ + universe.cpp \ + universe.h \ + timer.cpp \ + timer.h + \ No newline at end of file Added: trunk/src/engine/actions.cpp =================================================================== --- trunk/src/engine/actions.cpp (rev 0) +++ trunk/src/engine/actions.cpp 2007-10-02 06:21:50 UTC (rev 114) @@ -0,0 +1,69 @@ +// Copyright 2005 by Anthony Liekens an...@li... + +#include "actions.h" + +#include <iostream> + +// ##### ACTION ##### +using namespace std; + +Action::Action() { + actionID = 0; +} + +void +Action::setActionQueue( ActionQueue* actionQueue ) { + this->actionQueue = actionQueue; +} + +ActionQueue* +Action::getActionQueue() const { + return actionQueue; +} + +// ##### ACTIONQUEUE ##### + +ActionQueue::ActionQueue() { + clear(); + time = 0; +} + +void +ActionQueue::scheduleAction( Uint32 time, Action* action ) { + if( this->time > time ) { + std::cerr << "Action was inserted before action that has already been executed" << endl; + } + action->setActionQueue( this ); + insert( pair< Uint32, Action* >( time, action ) ); +} + +Uint32 +ActionQueue::timeOfNextEvent() { + return this->begin()->first; +} + +void +ActionQueue::executeNextEvent() { + time = this->begin()->first; + Action* a = this->begin()->second; +// if( time > timer.getTime() ) { +// SDL_Delay( time - timer.getTime() ); +// } + a->execute( time ); + erase( this->begin() ); + delete a; +} + +void +ActionQueue::executeAllEvents() { + while( size() > 0 ) { + executeNextEvent(); + } +} + +void ActionQueue::executeEventsBefore( Uint32 time ) { + while( ( size() > 0 ) && ( timeOfNextEvent() < time ) ) { + executeNextEvent(); + } +} + Added: trunk/src/engine/animations.cpp =================================================================== --- trunk/src/engine/animations.cpp (rev 0) +++ trunk/src/engine/animations.cpp 2007-10-02 06:21:50 UTC (rev 114) @@ -0,0 +1,39 @@ +// Copyright 2005 by Anthony Liekens an...@li... + +#include "animations.h" +#include "timer.h" +#include "planets.h" +#include "coordinate.h" + +#include "canvas.h" + +void +AnimationQueue::render(Uint32 time) { + for( iterator i = begin(); i != end(); i++ ) { + Animation* animation = (Animation*)( i->second ); + animation->render(time); + } +} + +SonarAnimation::SonarAnimation() { +} + +SonarAnimation::SonarAnimation( Planet* planet, const Uint32& color, const int& size, const Uint32& startTime, const Uint32& endTime, bool circle ) { + this->circle = circle; + this->planet = planet; + r = ( color & 0xFF0000 ) >> 16; + g = ( color & 0x00FF00 ) >> 8; + b = ( color & 0x0000FF ); +// this->color = color; + this->size = size; + this->startTime = startTime; + this->endTime = endTime; +} + +void +SonarAnimation::render(Uint32 time) { + if( ( time > startTime ) && ( time < endTime ) ) { + double percentage = (double)( time - startTime ) / ( endTime - startTime ); + Canvas::drawSonar(planet->getLocation(), size, percentage, r, g, b, circle); + } +} Added: trunk/src/engine/canvas.cpp =================================================================== --- trunk/src/engine/canvas.cpp (rev 0) +++ trunk/src/engine/canvas.cpp 2007-10-02 06:21:50 UTC (rev 114) @@ -0,0 +1,326 @@ +// Copyright 2005 by Anthony Liekens <an...@li...> +// Copyright 2007 by Robert Schuster <rob...@fs...> + +#include <SDL/SDL_gfxPrimitives.h> + +#include "canvas.h" +#include "coordinate.h" +#include "extensions.h" + +#include "../fonts.h" + +SDL_Surface* Canvas::main = 0; + +gcn::SDLGraphics *Canvas::sdlGraphics = 0; +int Canvas::width = 0; +int Canvas::height = 0; +int Canvas::gameOffsetX = 0; + +Font* Canvas::font = 0; + +void +Canvas::alphaBlend( SDL_Surface* surface, Uint8 alpha ) { + if( alpha == 0 ) { + for( int x = 0; x < surface->w; x++ ) + for( int y = 0; y < surface->h; y++ ) { + Uint32 *bufp; + bufp = (Uint32 *)surface->pixels + y*surface->pitch/4 + x; + if( *bufp != 0 ) + *bufp &= 0x00ffffff; + } + } if( alpha != 255 ) { + for( int x = 0; x < surface->w; x++ ) + for( int y = 0; y < surface->h; y++ ) { + Uint32 *bufp; + bufp = (Uint32 *)surface->pixels + y*surface->pitch/4 + x; + if( *bufp != 0 ) { + // seperate RGB from A, update A for new value, OR them together again + Uint32 color = ( *bufp & 0x00ffffff ) | ( ( *bufp >> 24 ) * alpha >> 8 ) << 24; + *bufp = color; + } + } + } +} + +void +Canvas::drawSelector(Coordinate &c, Sint16 offset, + Sint16 width, Sint16 height, Uint8 R, Uint8 G, Uint8 B) +{ + int x1 = c.getXMapped() + offset; + int y1 = c.getYMapped() + offset; + + hlineRGBA( main, x1, x1 + 2, y1, R, G, B, 255 ); + hlineRGBA( main, x1 + width - 2, x1 + width, y1, R, G, B, 255 ); + hlineRGBA( main, x1, x1 + 2, y1 + height, R, G, B, 255 ); + hlineRGBA( main, x1 + width - 2, x1 + width, y1 + height, R, G, B, 255 ); + vlineRGBA( main, x1, y1, y1 + 2, R, G, B, 255 ); + vlineRGBA( main, x1, y1 + height, y1 + height - 2, R, G, B, 255 ); + vlineRGBA( main, x1 + width, y1, y1 + 2, R, G, B, 255 ); + vlineRGBA( main, x1 + width, y1 + height, y1 + height - 2, R, G, B, 255 ); +} + +void +Canvas::drawNearestPlanetSelector(Coordinate &c, int size) +{ + size *= 3; + int offset = -size/2; + + drawSelector(c, offset, size, size, 255, 0, 0); +} + +void +Canvas::drawPlanet( Coordinate &loc, int size, Uint32 color ) +{ + drawPlanetMapped(loc.getXMapped(), loc.getYMapped(), size, color); +} + +void +Canvas::drawPlanetMapped(int x, int y, int size, Uint32 color ) +{ + int R = getRed(color); + int G = getGreen(color); + int B = getBlue(color); + + filledCircleRGBA( main, x, y, size + 2, 0, 0, 0, 128 ); + filledCircleRGBA( main, x, y, size, R, G, B, 255 ); + aacircleRGBA( main, x, y, size, R, G, B, 255 ); + filledEllipseRGBA( main, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); + aaellipseRGBA( main, x, y - size / 2, size, size / 2, 255 - 4 * ( 255 - R ) / 5, 255 - 4 * ( 255 - G ) / 5, 255 - 4 * ( 255 - B ) / 5, 255 ); +} + +void +Canvas::drawResidentShip(Coordinate& shipLocation, Coordinate& planetLocation, + int color) { + int sx = shipLocation.getXMapped(); + int sy = shipLocation.getYMapped(); + + int px = planetLocation.getXMapped(); + int py = planetLocation.getYMapped(); + + int r = getRed(color); + int g = getGreen(color); + int b = getBlue(color); + + aalineRGBA(main, sx, sy, px, py, r, g, b, 64); + filledCircleRGBA(main, sx, sy, 1, r, g, b, 255); +} + +void +Canvas::drawFlyingShip(Coordinate& shipLocation, double direction, int color) +{ + int sx = shipLocation.getXMapped(); + int sy = shipLocation.getYMapped(); + + int r = getRed(color); + int g = getGreen(color); + int b = getBlue(color); + + int headX, headY; + int leftTipX, leftTipY; + int rightTipX, rightTipY; + + headX = (int) (sx + 5.0 * cos( direction)); + headY = (int) (sy + 5.0 * sin( direction)); + leftTipX = (int) (sx + 2.0 * cos( direction + M_PI / 3.0)); + leftTipY = (int) (sy + 2.0 * sin( direction + M_PI / 3.0)); + rightTipX = (int) (sx + 2.0 * cos( direction - M_PI / 3.0)); + rightTipY = (int) (sy + 2.0 * sin( direction - M_PI / 3.0)); + + aalineRGBA(main, leftTipX, leftTipY, headX, headY, r, g, b, 255); + aalineRGBA(main, rightTipX, rightTipY, headX, headY, r, g, b, 255); + aalineRGBA(main, rightTipX, rightTipY, leftTipX, leftTipY, r, g, b, 255); +} + +void +Canvas::drawSelection(Coordinate& location) +{ + aacircleRGBA(main, location.getXMapped(), location.getYMapped(), 3, 255, 192, 0, 255 ); +} + +void +Canvas::drawOrbit(Coordinate ¢er, double rotationDistance, int color) +{ + int r = getRed(color); + int g = getGreen(color); + int b = getBlue(color); + + aaellipseRGBA(main, center.getXMapped(), center.getYMapped(), + (int) (rotationDistance * height), + (int) (rotationDistance * height), + r, g, b, 64); +} + +void +Canvas::drawBuildProgress(Coordinate& location, int size, double percentage) +{ + aacircleRGBA( main, location.getXMapped(), location.getYMapped(), + (int) (size + 102.5 - percentage), + 0xff, 0xff, 0xff, + (int)( 0.2 * percentage )); +} + +void +Canvas::drawText(int x, int y, const char *msg, int r, int g, int b, int a) +{ + font->render(main, x, y, msg, r, g, b, a); +} + +void +Canvas::drawBox(int x, int y, int w, int h, int r, int g, int b) +{ + boxRGBA( main, x, y, w, h, r, g, b, 255 ); +} + +int +Canvas::getFontHeight() +{ + return font->getHeight(); +} + +void +Canvas::drawRadar() +{ + int radarSteps = 4; + Uint32 radarColor = 0xfee190; + + double s = 1.0 / radarSteps; + for( int i = 1; i <= radarSteps; i++ ) { + aaellipseRGBA( main, gameOffsetX + height / 2, + height / 2, (int) (i * s * height / 2), + (int)( i * s * height / 2 ), 144, 225, 144, 64 ); + } + lineRGBA( main, + gameOffsetX + height / 2, 0, + gameOffsetX + height / 2, + height, 255, 225, 144, 64 ); + lineRGBA( main, + gameOffsetX, + height / 2, + gameOffsetX + height, + height / 2, 255, 225, 144, 64 ); +} + +void +Canvas::drawSun() +{ + // Sun in the middle + Sint16 x0 = gameOffsetX + height / 2; + Sint16 y0 = height / 2; + + filledTrigonRGBA( main, x0+5, y0, x0-5,y0, x0, y0+15, 255, 205, 0, 255); + filledTrigonRGBA( main, x0+5, y0, x0-5,y0, x0, y0-15, 255, 205, 0, 255); + filledTrigonRGBA( main, x0+15, y0, x0,y0+5, x0, y0-5, 255, 205, 0, 255); + filledTrigonRGBA( main, x0-15, y0, x0,y0+5, x0, y0-5, 255, 205, 0, 255); + + filledTrigonRGBA( main, x0+10, y0-10, x0+5,y0, x0, y0-5, 255, 205, 0, 255); + filledTrigonRGBA( main, x0-10, y0-10, x0-5,y0, x0, y0-5, 255, 205, 0, 255); + filledTrigonRGBA( main, x0+10, y0+10, x0+5,y0, x0, y0+5, 255, 205, 0, 255); + filledTrigonRGBA( main, x0-10, y0+10, x0-5,y0, x0, y0+5, 255, 205, 0, 255); + + filledCircleRGBA( main, x0,y0, 7, 255, 255, 0, 255 ); + filledCircleRGBA( main, x0,y0, 6, 255, 245, 0, 255 ); + filledCircleRGBA( main, x0,y0, 5, 255, 225, 0, 255 ); + filledCircleRGBA( main, x0,y0, 4, 255, 205, 0, 255 ); +} + +/** Little star drawn in the background. + * + */ +void +Canvas::drawStar(int x, int y, int brightness) +{ + pixelRGBA( main, x, y, + brightness + rand() % 64, + brightness + rand() % 64, + brightness + rand() % 64, + 255 ); + +} + +void +Canvas::drawSonar(Coordinate coord, int size, double percentage, int r, int g, int b, bool circle) +{ + int x = coord.getXMapped(); + int y = coord.getYMapped(); + + filledCircleRGBA( main, x, y, (int)( size * sin( percentage * M_PI ) ), r, g, b, (int)( ( 255 - 255 * percentage ) * 0.05 ) ); + + if( circle ) + aacircleRGBA( main, x, y, (int)( size * sin( percentage * M_PI ) ), r, g, b, 255 - (int)( 255 * percentage ) ); + +} + +void +Canvas::drawPlayerStat(int size, int index, int previousValue, int currentValue, int r, int g, int b) +{ + aalineRGBA( main, width - size + index - 1, height - previousValue, + width - size + index, height - currentValue, + r, g, b, index * 2 ); +} + +void +Canvas::drawMouseSelection(Coordinate &c1, Coordinate &c2) +{ + rectangleColor( main, c1.getXMapped(), c1.getYMapped(), + c2.getXMapped(), c2.getYMapped(), 0xfee19080 ); +} + +void +Canvas::drawCursor(Coordinate &c) +{ + aacircleRGBA( main, c.getXMapped(), c.getYMapped(), 4, 255, 255, 255, 255 ); +} + +void +Canvas::initScreen(int w, int h, bool fullscreen) +{ + if (!sdlGraphics) + sdlGraphics = new gcn::SDLGraphics(); + + if (!font) + font = new Font("font.ttf", 18); + + long flags = SDL_SWSURFACE | SDL_HWSURFACE; + + if (fullscreen) + flags |= SDL_FULLSCREEN; + + width = w; + height = h; + gameOffsetX = ( w - h ) / 2; + + main = SDL_SetVideoMode( w, h, 0, flags); + sdlGraphics->setTarget(main); +} + +int +Canvas::getWidth() +{ + return width; +} + +int +Canvas::getHeight() +{ + return height; +} + +void +Canvas::shutdown() +{ + delete sdlGraphics; + SDL_FreeSurface(main); + main = NULL; +} + +void +Canvas::updateScreen() +{ + SDL_Flip(main); +} + +gcn::SDLGraphics * +Canvas::getSDLGraphics() +{ + return sdlGraphics; +} Added: trunk/src/engine/coordinate.h =================================================================== --- trunk/src/engine/coordinate.h (rev 0) +++ trunk/src/engine/coordinate.h 2007-10-02 06:21:50 UTC (rev 114) @@ -0,0 +1,29 @@ +// Copyright 2005 by Anthony Liekens an...@li... + +#ifndef COORDINATE_H +#define COORDINATE_H + +class Coordinate { +private: + double x, y; +public: + Coordinate(); + Coordinate( double x, double y ); + + void setX( double x ); + void setY( double y ); + + void setXMapped( int x ); + void setYMapped( int y ); + + double getX() const; + double getY() const; + int getXMapped() const; + int getYMapped() const; + + double distance( const Coordinate& c ) const; + + bool operator==( const Coordinate &that) const; +}; + +#endif Added: trunk/src/engine/game.h =================================================================== --- trunk/src/engine/game.h (rev 0) +++ trunk/src/engine/game.h 2007-10-02 06:21:50 UTC (rev 114) @@ -0,0 +1,91 @@ +// game.h +// Class which resembles a game and the events which can be triggered +// within it from a player's perspective. +// +// (c) Robert Schuster, 2007 +// +// Licensed under GNU GPL version 2 or, at your option, any later version. + +#ifndef GAME_H +#define GAME_H + +#include <SDL/SDL.h> +#include "../input.h" + +class Universe; +class Players; +class HumanPlayer; +class Message; +class Messages; +class Selection; +class GameOptions; +class Timer; +class Coordinate; + +class Game { + +public: + Game(GameOptions &); + + ~Game(); + + bool run(bool); + + bool checkWin(); + + bool checkLost(); + + void handle(GameAction, int); + + void addMessage(int, Message); + + void render(); + + void setPaused(bool); + + Uint32 getTime() const; + +private: + void moveCursor(int, int); + + void fleetStrengthUp(); + + void fleetStrengthDown(); + + void setFleetStrength(int); + + void selectAllPlanets(); + + void setEnemyVisibility(bool); + + void selectNearestPlanet(int, int); + + void moveToNearestPlanet(int, int); + + /** Location of the soft cursor. */ + Coordinate *cursor; + + /** Current cursor movement forces: x positive, x negative and the same for y. */ + int xp, xn, yp, yn; + + Universe *universe; + HumanPlayer *humanPlayer; + Messages *messages; + Timer *timer; + Players *players; + Selection *selection; + + enum States { PLAYING, LOST, WON }; + States state; + + bool quit; + bool nextRound; + + GameOptions &gameOptions; + + int nextNumberOfPlanets; + int nextNumberOfComputerPlayers; + +}; + +#endif Added: trunk/src/engine/messages.h =================================================================== --- trunk/src/engine/messages.h (rev 0) +++ trunk/src/engine/messages.h 2007-10-02 06:21:50 UTC (rev 114) @@ -0,0 +1,48 @@ +// Copyright 2005 by Anthony Liekens an...@li... + +#ifndef MESSAGES_H +#define MESSAGES_H + +#include <string> +#include <map> + +#include <SDL/SDL.h> + +class Universe; +class Game; + +class Message { +private: + Uint8 r, g, b; + Uint32 displayTime; + std::string message; +public: + Message( Uint32, std::string message, Uint32 displayTime, Uint8 r, Uint8 g, Uint8 b ); + Message( Uint32, std::string message, Uint32 displayTime, Uint32 color ); + Message( Uint32, std::string message, Uint8 r, Uint8 g, Uint8 b ); + Message( Uint32, std::string message, Uint32 color ); + void render(int &x, int &y, int time ); + Uint32 getDisplayTime(); +}; + +class Messages : std::multimap< Uint32, Message > { +//Begin Jacobsen +private: + Message fleetStrengthMessage; +//End Jacobsen +public: + Messages(); + ~Messages(); + void addMessage( Uint32 time, Message m ); + void cleanup(Uint32); + void render(Uint32); + + //Begin Jacobsen + void setFleetStrengthMessage( Message m ); + //End Jacobsen +}; + +void MSGwon(Game *, int, int); +void MSGlost(Game *); +void MSGstart(Game *); +#endif Added: trunk/src/engine/planets.cpp =================================================================== --- trunk/src/engine/planets.cpp (rev 0) +++ trunk/src/engine/planets.cpp 2007-10-02 06:21:50 UTC (rev 114) @@ -0,0 +1,466 @@ +// Copyright 2005 by Anthony Liekens an...@li... + +#include <math.h> + +#include "planets.h" +#include "timer.h" +#include "ships.h" +#include "animations.h" +#include "coordinate.h" +#include "selection.h" +#include "players.h" +#include "universe.h" +#include "messages.h" +#include "canvas.h" + +using namespace std; + +// ##### PLANET ##### + +Planet::Planet() : nearestPlanet(false), owner(), mother() +{ +// rotationSpeed = ( ( rand() % 2 ) * 2 - 1 ) * ( rand() % 60000 + 20000 ); + rotationSpeed = 1000; +// rotationDistance = 0.05 + 0.4 * ( double )rand() / RAND_MAX; + rotationDistance = 0.1; + rotationOffset = rand() % 10000000; + size = 4 + rand() % 4; // [4 ... 8) + isAMoon = false; + selected = false; + sourceSelected = false; + shipCreationSpeed = 12500 - size*1000; + + double angle = rotationOffset / rotationSpeed; + locationVector.setX(cos(angle)); + locationVector.setY(sin(angle)); + + buildStartTime = 0; + buildEndTime = shipCreationSpeed; +} + +void +Planet::makeMoon( Planet* mother ) { + rotationSpeed = ( ( rand() % 2 ) * 2 - 1 ) * ( rand() % 2000 + 2000 ); + rotationDistance = 0.01 + 0.03 * ( double )rand() / RAND_MAX; + rotationOffset = rand() % 100000; + size = 2 + rand() % 2; // [2 ... 4) + isAMoon = true; + this->mother = mother; + shipCreationSpeed = 15000 - size*1000; +} + +void +Planet::update(Uint32 time) +{ + double angle = (double)(rotationOffset + time) / rotationSpeed; + locationVector.setX(cos(angle)); + locationVector.setY(sin(angle)); + + if (buildEndTime <= time) + { + createShip(time); + buildStartTime = time; + buildEndTime = time + shipCreationSpeed; + } + + if( residentShips.size() > 0 ) { + Coordinate location = getLocation(); + int counter = 0; + double offset = 500 * rotationDistance + (double) time / 10000; + for( list< Ship* >::iterator i = residentShips.begin(); i != residentShips.end(); i++ ) { + double shipX = location.getX() + 0.02 * cos( offset + counter * 2 * M_PI / residentShips.size() ); + double shipY = location.getY() + 0.02 * sin( offset + counter * 2 * M_PI / residentShips.size() ); + (*i)->setLocation( shipX, shipY ); + counter++; + } + } + +} + +Coordinate +Planet::getLocation() const { + Coordinate motherLocation; + if( isAMoon ) { + motherLocation = mother->getLocation(); + } else { + motherLocation.setX( 0.5 ); + motherLocation.setY( 0.5 ); + } + + double x = motherLocation.getX() + rotationDistance * locationVector.getX(); + double y = motherLocation.getY() + rotationDistance * locationVector.getY(); + return Coordinate( x, y ); +} + +void +Planet::addResident( Ship* ship, Uint32 time ) +{ + if (owner != ship->getOwner()) + { + // Planet is conquered. + if (residentShips.size() == 0) + { + setOwner(ship->getOwner()); + + // Plays correspoing animation. + // TODO: This should be triggered through player->removePlanet()/addPlanet() + Uint32 color = owner->getColor(); + universe->animationQueue->scheduleAction(time + 1200, + new SonarAnimation(this, + color, + isAMoon ? 50 : 100, + time, + time + 1000, + true)); + + residentShips.push_back( ship ); + } + else + { + ship->die(); + Ship* resident = *( residentShips.begin() ); + removeResident( resident ); + resident->die(); + + // show an animation of die'ing ships that are of our interest + if( ( ship->getOwner()->getPlayerType() == Player::HUMAN ) || ( owner->getPlayerType() == Player::HUMAN ) ) + universe->animationQueue->scheduleAction( time + 1000, new SonarAnimation( this, ship->getOwner()->getColor(), 20, time, time + 1000, true ) ); + } + + } + else + { + residentShips.push_back( ship ); + } + +} + +void +Planet::setOwner(Player *newOwner) +{ + if (owner == newOwner) + return; + + if (owner != NULL) + owner->removePlanet(this); + + newOwner->addPlanet(this); + owner = newOwner; + +} + +void +Planet::removeResident( Ship* ship ) { + residentShips.remove( ship ); +} + +void +Planet::render(Uint32 time) const { + if( owner->getPlayerType() == Player::HUMAN ) + renderBuildProgress(time); + Coordinate location = getLocation(); + + Canvas::drawPlanet(location, size, owner->getColor() ); + if( selected ) + { + Canvas::drawSelector(location, -4, 10, 10, 0, 0, 0); + Canvas::drawSelector(location, -5, 10, 10, 255, 192, 0); + } + + if( sourceSelected ) + { + Canvas::drawSelector(location, -4, 10, 10, 0, 0, 0); + Canvas::drawSelector(location, -5, 10, 10, 255, 255, 0); + } + + if (nearestPlanet) + { + Canvas::drawNearestPlanetSelector(location, size); + } +} + +void +Planet::renderOrbit( ) const { + Coordinate centerLocation; + if( isAMoon ) { + centerLocation = mother->getLocation(); + } else { + centerLocation.setX( 0.5 ); + centerLocation.setY( 0.5 ); + } + if( owner != NULL ) + Canvas::drawOrbit(centerLocation, rotationDistance, owner->getColor()); + if( getMoon() ) { + mother->renderOrbit( ); + } +} + +void +Planet::renderBuildProgress(Uint32 time) const { + + Coordinate location = getLocation(); + double percentage = 100.0 * ( time - buildStartTime ) / ( buildEndTime - buildStartTime ); + + Canvas::drawBuildProgress(location, size, percentage); +} + +double +Planet::distance( Planet* planet ) { + return planet->getLocation().distance( getLocation() ); +} + +void +Planet::setNearestPlanet(bool b) { + nearestPlanet = b; +} + +void +Planet::setSourceSelected( bool selected ) { + sourceSelected = selected; +} + +void +Planet::setSelected( bool selected ) { + this->selected = selected; +} + +void +Planet::setUniverse( Universe* universe ) { + this->universe = universe; +} + +void +Planet::createShip(const Uint32& time) { + if( owner && owner->getPlayerType() != Player::NEUTRAL ) + owner->addShip(time, this); +} + +void +Planet::moveResidentsTo(Uint32 time, Planet *destination, int fleetSelection) { + // Save same fuel ... :) + if (destination == this || !residentShips.size()) { + return; + } + + // fleetSelection of 1 means "send one ship". Otherwise it means + // "send fleetSelection percen... [truncated message content] |
From: <the...@us...> - 2008-06-01 21:56:52
|
Revision: 140 http://qonk.svn.sourceforge.net/qonk/?rev=140&view=rev Author: thebohemian Date: 2008-06-01 14:56:50 -0700 (Sun, 01 Jun 2008) Log Message: ----------- - simplified autotools files Modified Paths: -------------- trunk/Makefile.am trunk/autogen.sh Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2008-06-01 21:49:34 UTC (rev 139) +++ trunk/Makefile.am 2008-06-01 21:56:50 UTC (rev 140) @@ -1,3 +1,5 @@ +AUTOMAKE_OPTIONS = foreign + SUBDIRS = guichan src data EXTRA_DIST = autogen.sh README COPYING missing TODO HISTORY THANKYOU Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2008-06-01 21:49:34 UTC (rev 139) +++ trunk/autogen.sh 2008-06-01 21:56:50 UTC (rev 140) @@ -1,3 +1,4 @@ #!/bin/sh +# [Re]generate autoconf files. -aclocal && automake --foreign --add-missing --copy && autoheader && autoconf +autoreconf --install "$@" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |