diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | c90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch) | |
tree | 6d8391395bce9eaea4ad78958617edb20c6a7573 /kasteroids | |
download | tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kasteroids')
236 files changed, 2749 insertions, 0 deletions
diff --git a/kasteroids/ChangeLog b/kasteroids/ChangeLog new file mode 100644 index 00000000..ccccd0c2 --- /dev/null +++ b/kasteroids/ChangeLog @@ -0,0 +1,35 @@ +Version 2.2 + * [Martin Jones] Show "Game Over" and stats in the game window instead + of displaying many annoying dialogs at the end of the + game. + +Version 2.1 + * [Martin Jones] + Shooting uses energy too. + Added firepower powerup. + Adjusted speed of asteroids to make game playable again. + +Version 1.90 + * [Martin Jones] KDE 2.0 and QCanvas port + Introduce ship's energy supply. Thrusting, shields, + etc. use power, and when you run out you're basically + screwed. Fortunately some asteroids release fuel + when you destroy them. + Make brakes, etc. permanent features once you catch them. + Made ship much cooler. + +Version 0.3.1 + * [Kristof <krzygod@kki.net.pl>] + Add brakes, shield, teleport, configureable keys, + highscores. + Also the cool shield graphics. + +Verison 0.2.0 + * [Martin Jones] Use QwSpriteField-1.4 from kdesupport + * [Martin Jones] Preliminary sound support + +Version 0.1.0 + * [Robert Williams] Added version.h and ChangeLog + * [Robert Williams] Renamed Kasteroids.kdelnk to kasteroids.kdelnk + * [Robert Williams] Added -caption "%c" to kasteroids.kdelnk + * [Robert Williams] Added getCaption() diff --git a/kasteroids/Makefile.am b/kasteroids/Makefile.am new file mode 100644 index 00000000..3ac5f46a --- /dev/null +++ b/kasteroids/Makefile.am @@ -0,0 +1,26 @@ +SUBDIRS = . sprites sounds + +INCLUDES = -I$(top_srcdir)/libkdegames -I$(top_srcdir)/libkdegames/highscore $(all_includes) +METASOURCES = AUTO + +bin_PROGRAMS = kasteroids +kasteroids_SOURCES = main.cpp view.cpp ledmeter.cpp toplevel.cpp settings.kcfgc +kasteroids_LDFLAGS = $(all_libraries) $(KDE_RPATH) +kasteroids_LDADD = $(LIB_KDEGAMES) -lsoundserver_idl -lqtmcop +kasteroids_DEPENDENCIES = $(LIB_KDEGAMES_DEP) + +picsdir = $(kde_datadir)/kasteroids/sprites +pics_DATA = bg.png + +xdg_apps_DATA = kasteroids.desktop +kde_kcfg_DATA = kasteroids.kcfg + +EXTRA_DIST = $(pics_DATA) +KDE_ICON = kasteroids + +rcdir = $(kde_datadir)/kasteroids +rc_DATA = kasteroidsui.rc + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kasteroids.pot + diff --git a/kasteroids/bg.png b/kasteroids/bg.png Binary files differnew file mode 100644 index 00000000..e4c5adc0 --- /dev/null +++ b/kasteroids/bg.png diff --git a/kasteroids/configure.in.in b/kasteroids/configure.in.in new file mode 100644 index 00000000..17ee6ce2 --- /dev/null +++ b/kasteroids/configure.in.in @@ -0,0 +1,5 @@ +dnl KDE_CHECK_QWSPRITEFIELD(DO_NOT_COMPILE="$DO_NOT_COMPILE kasteroids") + +if test "x$build_arts" = "xno"; then + DO_NOT_COMPILE="$DO_NOT_COMPILE kasteroids" +fi diff --git a/kasteroids/hi128-app-kasteroids.png b/kasteroids/hi128-app-kasteroids.png Binary files differnew file mode 100644 index 00000000..9f5307ff --- /dev/null +++ b/kasteroids/hi128-app-kasteroids.png diff --git a/kasteroids/hi16-app-kasteroids.png b/kasteroids/hi16-app-kasteroids.png Binary files differnew file mode 100644 index 00000000..8fca3e8f --- /dev/null +++ b/kasteroids/hi16-app-kasteroids.png diff --git a/kasteroids/hi22-app-kasteroids.png b/kasteroids/hi22-app-kasteroids.png Binary files differnew file mode 100644 index 00000000..207327a6 --- /dev/null +++ b/kasteroids/hi22-app-kasteroids.png diff --git a/kasteroids/hi32-app-kasteroids.png b/kasteroids/hi32-app-kasteroids.png Binary files differnew file mode 100644 index 00000000..7416e7fb --- /dev/null +++ b/kasteroids/hi32-app-kasteroids.png diff --git a/kasteroids/hi48-app-kasteroids.png b/kasteroids/hi48-app-kasteroids.png Binary files differnew file mode 100644 index 00000000..1ce848f8 --- /dev/null +++ b/kasteroids/hi48-app-kasteroids.png diff --git a/kasteroids/hi64-app-kasteroids.png b/kasteroids/hi64-app-kasteroids.png Binary files differnew file mode 100644 index 00000000..f879c3ae --- /dev/null +++ b/kasteroids/hi64-app-kasteroids.png diff --git a/kasteroids/kasteroids.desktop b/kasteroids/kasteroids.desktop new file mode 100644 index 00000000..caa94e9e --- /dev/null +++ b/kasteroids/kasteroids.desktop @@ -0,0 +1,79 @@ +[Desktop Entry] +Name=KAsteroids +Name[af]=Kasteroids +Name[ar]=لعبة الكويكبات (KAsteroids) +Name[be]=Астэроіды +Name[bn]=কে-অ্যাস্টেরয়েড +Name[eo]=Asteroidoj +Name[hi]=के-एस्टरॉइड्स +Name[nb]=KAsteroider +Name[ne]=केडीई एस्टेरोइड +Name[pa]=ਕੇ-ਉਲਕਾ +Name[pl]=Asteroidy +Name[pt_BR]=KAsteróides +Name[sv]=Kasteroids +Name[ta]=கேஅஸ்டராய்ட்ஸ் +Name[tg]=KАстероидҳо +Name[th]=ยิงอุกาบาต - K +Name[tr]=Göktaşları +Name[uz]=Asteroidlar +Name[uz@cyrillic]=Астероидлар +Name[wa]=KAsteroyides +Name[zh_TW]=KAsteroids 小行星 +MimeType= +Exec=kasteroids %i %m -caption "%c" +GenericName=Space Game +GenericName[be]=Касмічная гульня +GenericName[bg]=Космическа игра +GenericName[bn]=মহাশূন্যের খেলা +GenericName[bs]=Svemirska igra +GenericName[ca]=Joc de l'espai +GenericName[cs]=Vesmírná hra +GenericName[cy]=Gêm Ofod +GenericName[da]=Rumspil +GenericName[de]=Weltraumspiel +GenericName[el]=Διαστημικό παιχνίδι +GenericName[eo]=Kosmoludo +GenericName[es]=Juego espacial +GenericName[et]=Kosmoselahing +GenericName[eu]=Espazio-jokoa +GenericName[fa]=بازی فضایی +GenericName[fi]=Avaruuspeli +GenericName[fr]=Jeu dans l'espace +GenericName[he]=משחק חלל +GenericName[hr]=Igra u Svemiru +GenericName[hu]=Űrhajós +GenericName[is]=Geimleikur +GenericName[it]=Gioco spaziale +GenericName[ja]=宇宙ゲーム +GenericName[km]=ល្បែងអាវកាស +GenericName[lt]=Kosminis žaidimas +GenericName[lv]=Kosmiska spēle +GenericName[mk]=Вселенска игра +GenericName[nb]=Romspill +GenericName[nds]=Weltruumspeel +GenericName[ne]=खाली स्थान खेल +GenericName[nl]=Ruimtespel +GenericName[nn]=Romspel +GenericName[pa]=ਪੁਲਾੜ ਖੇਡ +GenericName[pl]=Gra kosmiczna +GenericName[pt]=Jogo Espacial +GenericName[pt_BR]=Jogo espacial +GenericName[ru]=Астероиды +GenericName[sk]=Vesmírna hra +GenericName[sl]=Vesoljska igra +GenericName[sr]=Свемирска игра +GenericName[sr@Latn]=Svemirska igra +GenericName[sv]=Rymdspel +GenericName[ta]=விண்வெளி விளையாட்டு +GenericName[uk]=Космічна гра +GenericName[zh_CN]=空间游戏 +GenericName[zh_TW]=太空遊戲 +Icon=kasteroids +Path= +DocPath=kasteroids/index.html +Type=Application +Terminal=false +X-KDE-StartupNotify=true +X-DCOP-ServiceType=Multi +Categories=Qt;KDE;Game;ArcadeGame; diff --git a/kasteroids/kasteroids.kcfg b/kasteroids/kasteroids.kcfg new file mode 100644 index 00000000..03451e75 --- /dev/null +++ b/kasteroids/kasteroids.kcfg @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 + http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > + <kcfgfile name="kasteroidsrc"/> + <group name="Preferences"> + <entry name="canDestroyPowerups" type="Bool"> + <label>Whether power upgrades can be shot.</label> + <default>true</default> + </entry> + <entry name="showHiscores" type="Bool"> + <label>Whether power upgrades can be shot.</label> + <default>false</default> + </entry> + <entry name="numShips" type="Int"> + <label>The number of ships per game.</label> + <default>3</default> + </entry> + </group> + <group name="Sounds"> + <entry name="PlaySounds" type="Bool"> + <label>Whether to play sounds.</label> + <default>true</default> + </entry> + <entry name="SoundShipDestroyed" type="Path" key="ShipDestroyed"> + <label>Sound to play when a ship gets destroyed.</label> + <default>Explosion.wav</default> + </entry> + <entry name="SoundRockDestroyed" type="Path" key="RockDestroyed"> + <label>Sound to play when a rock gets destroyed.</label> + <default>ploop.wav</default> + </entry> + </group> +</kcfg> diff --git a/kasteroids/kasteroidsui.rc b/kasteroids/kasteroidsui.rc new file mode 100644 index 00000000..8305e3d6 --- /dev/null +++ b/kasteroids/kasteroidsui.rc @@ -0,0 +1,6 @@ +<!DOCTYPE kpartgui> +<kpartgui name="kasteroids" version="2"> + +<MenuBar/> + +</kpartgui> diff --git a/kasteroids/ledmeter.cpp b/kasteroids/ledmeter.cpp new file mode 100644 index 00000000..3df87b8f --- /dev/null +++ b/kasteroids/ledmeter.cpp @@ -0,0 +1,118 @@ +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#include <qpainter.h> +#include "ledmeter.h" +#include "ledmeter.moc" + +KALedMeter::KALedMeter( QWidget *parent ) : QFrame( parent ) +{ + mCRanges.setAutoDelete( true ); + mRange = 100; + mCount = 20; + mCurrentCount = 0; + mValue = 0; + setMinimumWidth( mCount * 2 + frameWidth() ); +} + +void KALedMeter::setRange( int r ) +{ + mRange = r; + if ( mRange < 1 ) + mRange = 1; + setValue( mValue ); + update(); +} + +void KALedMeter::setCount( int c ) +{ + mCount = c; + if ( mCount < 1 ) + mCount = 1; + setMinimumWidth( mCount * 2 + frameWidth() ); + calcColorRanges(); + setValue( mValue ); + update(); +} + +void KALedMeter::setValue( int v ) +{ + mValue = v; + if ( mValue > mRange ) + mValue = mRange; + else if ( mValue < 0 ) + mValue = 0; + int c = ( mValue + mRange / mCount - 1 ) * mCount / mRange; + if ( c != mCurrentCount ) + { + mCurrentCount = c; + update(); + } +} + +void KALedMeter::addColorRange( int pc, const QColor &c ) +{ + ColorRange *cr = new ColorRange; + cr->mPc = pc; + cr->mColor = c; + mCRanges.append( cr ); + calcColorRanges(); +} + +void KALedMeter::resizeEvent( QResizeEvent *e ) +{ + QFrame::resizeEvent( e ); + int w = ( width() - frameWidth() - 2 ) / mCount * mCount; + w += frameWidth() + 2; + setFrameRect( QRect( 0, 0, w, height() ) ); +} + +void KALedMeter::drawContents( QPainter *p ) +{ + QRect b = contentsRect(); + + unsigned cidx = 0; + int ncol = mCount; + QColor col = colorGroup().foreground(); + + if ( !mCRanges.isEmpty() ) + { + col = mCRanges.at( cidx )->mColor; + ncol = mCRanges.at( cidx )->mValue; + } + p->setBrush( col ); + p->setPen( col ); + + int lw = b.width() / mCount; + int lx = b.left() + 1; + for ( int i = 0; i < mCurrentCount; i++, lx += lw ) + { + if ( i > ncol ) + { + if ( ++cidx < mCRanges.count() ) + { + col = mCRanges.at( cidx )->mColor; + ncol = mCRanges.at( cidx )->mValue; + p->setBrush( col ); + p->setPen( col ); + } + } + + p->drawRect( lx, b.top() + 1, lw - 1, b.height() - 2 ); + } +} + +void KALedMeter::calcColorRanges() +{ + int prev = 0; + ColorRange *cr; + for ( cr = mCRanges.first(); cr; cr = mCRanges.next() ) + { + cr->mValue = prev + cr->mPc * mCount / 100; + prev = cr->mValue; + } +} + diff --git a/kasteroids/ledmeter.h b/kasteroids/ledmeter.h new file mode 100644 index 00000000..ea9b7e96 --- /dev/null +++ b/kasteroids/ledmeter.h @@ -0,0 +1,54 @@ +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#ifndef __LEDMETER_H__ +#define __LEDMETER_H__ + +#include <qframe.h> +#include <qptrlist.h> + + +class KALedMeter : public QFrame +{ + Q_OBJECT +public: + KALedMeter( QWidget *parent ); + + int range() const { return mRange; } + void setRange( int r ); + + int count() const { return mCount; } + void setCount( int c ); + + int value () const { return mValue; } + + void addColorRange( int pc, const QColor &c ); + +public slots: + void setValue( int v ); + +protected: + virtual void resizeEvent( QResizeEvent * ); + virtual void drawContents( QPainter * ); + void calcColorRanges(); + +protected: + struct ColorRange + { + int mPc; + int mValue; + QColor mColor; + }; + + int mRange; + int mCount; + int mCurrentCount; + int mValue; + QPtrList<ColorRange> mCRanges; +}; + +#endif + diff --git a/kasteroids/main.cpp b/kasteroids/main.cpp new file mode 100644 index 00000000..361c9c77 --- /dev/null +++ b/kasteroids/main.cpp @@ -0,0 +1,51 @@ +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ +#include <config.h> + +#include <kstandarddirs.h> +#include <kcmdlineargs.h> +#include <kapplication.h> +#include <kaboutdata.h> + +#include "version.h" +#include "toplevel.h" + +#ifdef KA_ENABLE_SOUND +#include <arts/dispatcher.h> +#endif + + +static const char description[] = + I18N_NOOP("KDE Space Game"); + +int main( int argc, char *argv[] ) +{ + KAboutData aboutData( "kasteroids", I18N_NOOP("KAsteroids"), + KASTEROIDS_VERSION, description, KAboutData::License_GPL, + "(c) 1997, Martin R. Jones"); + aboutData.addAuthor("Martin R. Jones",0, "mjones@kde.org"); + KCmdLineArgs::init( argc, argv, &aboutData ); + + KApplication app; + KGlobal::locale()->insertCatalogue("libkdegames"); + KGlobal::dirs()->addResourceType("sprite", KStandardDirs::kde_default("data") + "kasteroids/sprites/"); + KGlobal::dirs()->addResourceType("sounds", KStandardDirs::kde_default("data") + "kasteroids/sounds/"); + +#ifdef KA_ENABLE_SOUND + // setup mcop communication + Arts::Dispatcher dispatcher; +#endif + + if( app.isRestored() ) + RESTORE(KAstTopLevel) + else { + KAstTopLevel *w = new KAstTopLevel; + app.setMainWidget(w); + w->show(); + } + return app.exec(); +} + diff --git a/kasteroids/settings.kcfgc b/kasteroids/settings.kcfgc new file mode 100644 index 00000000..f8d9e21d --- /dev/null +++ b/kasteroids/settings.kcfgc @@ -0,0 +1,5 @@ +# Code generation options for kconfig_compiler +File=kasteroids.kcfg +ClassName=Settings +Singleton=true +Mutators=false diff --git a/kasteroids/sounds/Explosion.wav b/kasteroids/sounds/Explosion.wav Binary files differnew file mode 100644 index 00000000..7b140b1c --- /dev/null +++ b/kasteroids/sounds/Explosion.wav diff --git a/kasteroids/sounds/Makefile.am b/kasteroids/sounds/Makefile.am new file mode 100644 index 00000000..9bdf7b99 --- /dev/null +++ b/kasteroids/sounds/Makefile.am @@ -0,0 +1,5 @@ +sound_DATA = Explosion.wav +sounddir = $(kde_datadir)/kasteroids/sounds + +EXTRA_DIST = $(sound_DATA) + diff --git a/kasteroids/sprites.h b/kasteroids/sprites.h new file mode 100644 index 00000000..0b0a718a --- /dev/null +++ b/kasteroids/sprites.h @@ -0,0 +1,129 @@ +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#ifndef __SPRITES_H__ +#define __SPRITES_H__ + +#include <qcanvas.h> + +#define ID_ROCK_LARGE 1024 +#define ID_ROCK_MEDIUM 1025 +#define ID_ROCK_SMALL 1026 + +#define ID_MISSILE 1030 + +#define ID_BIT 1040 +#define ID_EXHAUST 1041 + +#define ID_ENERGY_POWERUP 1310 +#define ID_TELEPORT_POWERUP 1311 +#define ID_BRAKE_POWERUP 1312 +#define ID_SHIELD_POWERUP 1313 +#define ID_SHOOT_POWERUP 1314 + +#define ID_SHIP 1350 +#define ID_SHIELD 1351 + +#define MAX_SHIELD_AGE 350 +#define MAX_POWERUP_AGE 500 +#define MAX_MISSILE_AGE 40 + +class KMissile : public QCanvasSprite +{ +public: + KMissile( QCanvasPixmapArray *s, QCanvas *c ) : QCanvasSprite( s, c ) + { myAge = 0; } + + virtual int rtti() const { return ID_MISSILE; } + + void growOlder() { myAge++; } + bool expired() { return myAge > MAX_MISSILE_AGE; } + +private: + int myAge; +}; + +class KBit : public QCanvasSprite +{ +public: + KBit( QCanvasPixmapArray *s, QCanvas *c ) : QCanvasSprite( s, c ) + { death = 7; } + + virtual int rtti() const { return ID_BIT; } + + void setDeath( int d ) { death = d; } + void growOlder() { death--; } + bool expired() { return death <= 0; } + +private: + int death; +}; + +class KExhaust : public QCanvasSprite +{ +public: + KExhaust( QCanvasPixmapArray *s, QCanvas *c ) : QCanvasSprite( s, c ) + { death = 1; } + + virtual int rtti() const { return ID_EXHAUST; } + + void setDeath( int d ) { death = d; } + void growOlder() { death--; } + bool expired() { return death <= 0; } + +private: + int death; +}; + +class KPowerup : public QCanvasSprite +{ +public: + KPowerup( QCanvasPixmapArray *s, QCanvas *c, int t ) : QCanvasSprite( s, c ), + myAge( 0 ), type(t) { } + + virtual int rtti() const { return type; } + + void growOlder() { myAge++; } + bool expired() const { return myAge > MAX_POWERUP_AGE; } + +protected: + int myAge; + int type; +}; + +class KRock : public QCanvasSprite +{ +public: + KRock (QCanvasPixmapArray *s, QCanvas *c, int t, int sk, int st) : QCanvasSprite( s, c ) + { type = t; skip = cskip = sk; step = st; } + + void nextFrame() + { + if (cskip-- <= 0) { + setFrame( (frame()+step+frameCount())%frameCount() ); + cskip = QABS(skip); + } + } + + virtual int rtti() const { return type; } + +private: + int type; + int skip; + int cskip; + int step; +}; + +class KShield : public QCanvasSprite +{ +public: + KShield( QCanvasPixmapArray *s, QCanvas *c ) + : QCanvasSprite( s, c ) {} + + virtual int rtti() const { return ID_SHIELD; } +}; + +#endif diff --git a/kasteroids/sprites/.pbm b/kasteroids/sprites/.pbm new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/kasteroids/sprites/.pbm diff --git a/kasteroids/sprites/Makefile.am b/kasteroids/sprites/Makefile.am new file mode 100644 index 00000000..f11d78f9 --- /dev/null +++ b/kasteroids/sprites/Makefile.am @@ -0,0 +1,36 @@ + +SUBDIRS = bits missile rock1 rock2 rock3 ship powerups exhaust + +POVRAY=x-povray # Must be Povray 3.0 + +#all: pngtoppmpgm + +#clean: +# rm -f *~ pngtoppmpgm + +#distclean: clean +# rm -f Makefile + +FILES = `cd $(srcdir) && find . \( -name "*.png" \) -print` +spritesdir = $(kde_datadir)/kasteroids/sprites + +install-data-local: + $(mkinstalldirs) $(DESTDIR)$(spritesdir)/rock1 + $(mkinstalldirs) $(DESTDIR)$(spritesdir)/rock2 + $(mkinstalldirs) $(DESTDIR)$(spritesdir)/rock3 + $(mkinstalldirs) $(DESTDIR)$(spritesdir)/ship + $(mkinstalldirs) $(DESTDIR)$(spritesdir)/bits + $(mkinstalldirs) $(DESTDIR)$(spritesdir)/missile + $(mkinstalldirs) $(DESTDIR)$(spritesdir)/powerups + $(mkinstalldirs) $(DESTDIR)$(spritesdir)/shield + $(mkinstalldirs) $(DESTDIR)$(spritesdir)/exhaust + @for file in $(FILES); do \ + echo $(INSTALL_DATA) $(srcdir)/$$file $(DESTDIR)$(spritesdir)/$$file ;\ + $(INSTALL_DATA) $(srcdir)/$$file $(DESTDIR)$(spritesdir)/$$file ;\ + done + +uninstall-local: + for file in $(FILES); do \ + rm -f $(DESTDIR)$(spritesdir)/$$file ;\ + done + diff --git a/kasteroids/sprites/bits/Makefile.am b/kasteroids/sprites/bits/Makefile.am new file mode 100644 index 00000000..21484518 --- /dev/null +++ b/kasteroids/sprites/bits/Makefile.am @@ -0,0 +1,17 @@ +#POVRAY=x-povray # Must be Povray 3.0 + +#bits: bits.pov +# $(POVRAY) +L/usr/lib/povray3/include bits.ini + +#clean: +# rm -f *~ *.pgm + +#realclean: clean +# rm -f *.ppm *.pbm + +EXTRA_DIST = bits0000.png bits0001.png bits0002.png bits0003.png \ + bits0004.png bits0005.png bits0006.png bits0007.png \ + bits0008.png bits0009.png bits0010.png bits0011.png \ + bits0012.png bits0013.png bits0014.png bits0015.png \ + bits.ini bits.pov + diff --git a/kasteroids/sprites/bits/bits.ini b/kasteroids/sprites/bits/bits.ini new file mode 100644 index 00000000..cb2976f8 --- /dev/null +++ b/kasteroids/sprites/bits/bits.ini @@ -0,0 +1,9 @@ +Cyclic_Animation=On +Width=12 +Height=12 +Final_frame=16 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Input_File_Name=bits.pov diff --git a/kasteroids/sprites/bits/bits.pov b/kasteroids/sprites/bits/bits.pov new file mode 100644 index 00000000..9be7ccb6 --- /dev/null +++ b/kasteroids/sprites/bits/bits.pov @@ -0,0 +1,31 @@ + +#version 3.0 +global_settings { assumed_gamma 2.0 } + +#include "colors.inc" +#include "textures.inc" +#include "metals.inc" + +camera { + location <15, -15, -100> + look_at <0, 0, 0> +} + +light_source { <50, 50, -50> colour White } +light_source { <0, 0, -50> colour White } + +prism { + linear_sweep + linear_spline + 0, + 0.2, + 5, + <2, 0>, <0, 2>, <-1, 1>, <0, -3>, <2, 0> + texture { T_Silver_2A } + + rotate <360*clock, 50, 30> + scale <20, 20, 20> +} + + + diff --git a/kasteroids/sprites/bits/bits0000.png b/kasteroids/sprites/bits/bits0000.png Binary files differnew file mode 100644 index 00000000..04c6482b --- /dev/null +++ b/kasteroids/sprites/bits/bits0000.png diff --git a/kasteroids/sprites/bits/bits0001.png b/kasteroids/sprites/bits/bits0001.png Binary files differnew file mode 100644 index 00000000..b4aa04f3 --- /dev/null +++ b/kasteroids/sprites/bits/bits0001.png diff --git a/kasteroids/sprites/bits/bits0002.png b/kasteroids/sprites/bits/bits0002.png Binary files differnew file mode 100644 index 00000000..3a654cd8 --- /dev/null +++ b/kasteroids/sprites/bits/bits0002.png diff --git a/kasteroids/sprites/bits/bits0003.png b/kasteroids/sprites/bits/bits0003.png Binary files differnew file mode 100644 index 00000000..483ecb78 --- /dev/null +++ b/kasteroids/sprites/bits/bits0003.png diff --git a/kasteroids/sprites/bits/bits0004.png b/kasteroids/sprites/bits/bits0004.png Binary files differnew file mode 100644 index 00000000..fc4f681a --- /dev/null +++ b/kasteroids/sprites/bits/bits0004.png diff --git a/kasteroids/sprites/bits/bits0005.png b/kasteroids/sprites/bits/bits0005.png Binary files differnew file mode 100644 index 00000000..ffbdcf00 --- /dev/null +++ b/kasteroids/sprites/bits/bits0005.png diff --git a/kasteroids/sprites/bits/bits0006.png b/kasteroids/sprites/bits/bits0006.png Binary files differnew file mode 100644 index 00000000..0c6b0752 --- /dev/null +++ b/kasteroids/sprites/bits/bits0006.png diff --git a/kasteroids/sprites/bits/bits0007.png b/kasteroids/sprites/bits/bits0007.png Binary files differnew file mode 100644 index 00000000..302a9535 --- /dev/null +++ b/kasteroids/sprites/bits/bits0007.png diff --git a/kasteroids/sprites/bits/bits0008.png b/kasteroids/sprites/bits/bits0008.png Binary files differnew file mode 100644 index 00000000..aae11420 --- /dev/null +++ b/kasteroids/sprites/bits/bits0008.png diff --git a/kasteroids/sprites/bits/bits0009.png b/kasteroids/sprites/bits/bits0009.png Binary files differnew file mode 100644 index 00000000..5aed2027 --- /dev/null +++ b/kasteroids/sprites/bits/bits0009.png diff --git a/kasteroids/sprites/bits/bits0010.png b/kasteroids/sprites/bits/bits0010.png Binary files differnew file mode 100644 index 00000000..13069992 --- /dev/null +++ b/kasteroids/sprites/bits/bits0010.png diff --git a/kasteroids/sprites/bits/bits0011.png b/kasteroids/sprites/bits/bits0011.png Binary files differnew file mode 100644 index 00000000..742ae1b6 --- /dev/null +++ b/kasteroids/sprites/bits/bits0011.png diff --git a/kasteroids/sprites/bits/bits0012.png b/kasteroids/sprites/bits/bits0012.png Binary files differnew file mode 100644 index 00000000..d10fdba5 --- /dev/null +++ b/kasteroids/sprites/bits/bits0012.png diff --git a/kasteroids/sprites/bits/bits0013.png b/kasteroids/sprites/bits/bits0013.png Binary files differnew file mode 100644 index 00000000..6ee0aaac --- /dev/null +++ b/kasteroids/sprites/bits/bits0013.png diff --git a/kasteroids/sprites/bits/bits0014.png b/kasteroids/sprites/bits/bits0014.png Binary files differnew file mode 100644 index 00000000..167ebe4a --- /dev/null +++ b/kasteroids/sprites/bits/bits0014.png diff --git a/kasteroids/sprites/bits/bits0015.png b/kasteroids/sprites/bits/bits0015.png Binary files differnew file mode 100644 index 00000000..15a287e3 --- /dev/null +++ b/kasteroids/sprites/bits/bits0015.png diff --git a/kasteroids/sprites/exhaust/Makefile.am b/kasteroids/sprites/exhaust/Makefile.am new file mode 100644 index 00000000..4493dbd7 --- /dev/null +++ b/kasteroids/sprites/exhaust/Makefile.am @@ -0,0 +1 @@ +EXTRA_DIST = exhaust.png diff --git a/kasteroids/sprites/exhaust/exhaust.png b/kasteroids/sprites/exhaust/exhaust.png Binary files differnew file mode 100644 index 00000000..78f987e3 --- /dev/null +++ b/kasteroids/sprites/exhaust/exhaust.png diff --git a/kasteroids/sprites/missile/Makefile.am b/kasteroids/sprites/missile/Makefile.am new file mode 100644 index 00000000..cc06088f --- /dev/null +++ b/kasteroids/sprites/missile/Makefile.am @@ -0,0 +1 @@ +EXTRA_DIST = missile.png diff --git a/kasteroids/sprites/missile/missile.png b/kasteroids/sprites/missile/missile.png Binary files differnew file mode 100644 index 00000000..e78a0ac0 --- /dev/null +++ b/kasteroids/sprites/missile/missile.png diff --git a/kasteroids/sprites/powerups/Makefile.am b/kasteroids/sprites/powerups/Makefile.am new file mode 100644 index 00000000..4431ae3c --- /dev/null +++ b/kasteroids/sprites/powerups/Makefile.am @@ -0,0 +1,2 @@ + +EXTRA_DIST = brake.png energy.png shield.png shoot.png diff --git a/kasteroids/sprites/powerups/brake.png b/kasteroids/sprites/powerups/brake.png Binary files differnew file mode 100644 index 00000000..fe12dfa8 --- /dev/null +++ b/kasteroids/sprites/powerups/brake.png diff --git a/kasteroids/sprites/powerups/energy.png b/kasteroids/sprites/powerups/energy.png Binary files differnew file mode 100644 index 00000000..f8df39f9 --- /dev/null +++ b/kasteroids/sprites/powerups/energy.png diff --git a/kasteroids/sprites/powerups/shield.png b/kasteroids/sprites/powerups/shield.png Binary files differnew file mode 100644 index 00000000..f8a6d0c5 --- /dev/null +++ b/kasteroids/sprites/powerups/shield.png diff --git a/kasteroids/sprites/powerups/shoot.png b/kasteroids/sprites/powerups/shoot.png Binary files differnew file mode 100644 index 00000000..bebdb5ef --- /dev/null +++ b/kasteroids/sprites/powerups/shoot.png diff --git a/kasteroids/sprites/powerups/teleport.png b/kasteroids/sprites/powerups/teleport.png Binary files differnew file mode 100644 index 00000000..4ffde863 --- /dev/null +++ b/kasteroids/sprites/powerups/teleport.png diff --git a/kasteroids/sprites/rock1/Makefile.am b/kasteroids/sprites/rock1/Makefile.am new file mode 100644 index 00000000..c8d5c04b --- /dev/null +++ b/kasteroids/sprites/rock1/Makefile.am @@ -0,0 +1,24 @@ +#POVRAY=x-povray # Must be Povray 3.0 + +#rocks: rock1.pov +# gforge -s 0 -m 256 -crat 1.9 1.5 -type mat -na rock.mat +# orb rock.mat rock.inc 0.7 6 +# rm rock.mat +# $(POVRAY) +L/usr/lib/povray3/include rock1.ini + +#clean: +# rm -f *~ *.pgm + +#realclean: clean +# rm -f *.ppm *.pbm + +EXTRA_DIST = rock10000.png rock10001.png rock10002.png rock10003.png \ + rock10004.png rock10005.png rock10006.png rock10007.png \ + rock10008.png rock10009.png rock10010.png rock10011.png \ + rock10012.png rock10013.png rock10014.png rock10015.png \ + rock10016.png rock10017.png rock10018.png rock10019.png \ + rock10020.png rock10021.png rock10022.png rock10023.png \ + rock10024.png rock10025.png rock10026.png rock10027.png \ + rock10028.png rock10029.png rock10030.png rock10031.png \ + rock1.ini rock1.pov + diff --git a/kasteroids/sprites/rock1/rock1.ini b/kasteroids/sprites/rock1/rock1.ini new file mode 100644 index 00000000..e42fc766 --- /dev/null +++ b/kasteroids/sprites/rock1/rock1.ini @@ -0,0 +1,9 @@ +Cyclic_Animation=On +Width=48 +Height=48 +Final_frame=32 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Input_File_Name=rock1.pov diff --git a/kasteroids/sprites/rock1/rock1.pov b/kasteroids/sprites/rock1/rock1.pov new file mode 100644 index 00000000..58298c05 --- /dev/null +++ b/kasteroids/sprites/rock1/rock1.pov @@ -0,0 +1,26 @@ +#include "colors.inc" +#include "shapes.inc" +#include "textures.inc" +// #include "stones.inc" + +camera { + location <2,2,-6> + up <0, 1, 0> +// right <4/3, 0, 0> + look_at <0,0,0> +} + +object { light_source { <10, 5, -5> color red 1.1 green 1.1 blue 1.0 } } + +#declare Rock = +mesh { + #include "rock.inc" /* collection of triangle or smooth_triangle data */ +} + +object { + Rock + texture { pigment {White} } + scale 1.9 + rotate <60, 45, 360*clock> +} + diff --git a/kasteroids/sprites/rock1/rock10000.png b/kasteroids/sprites/rock1/rock10000.png Binary files differnew file mode 100644 index 00000000..ddcc7c37 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10000.png diff --git a/kasteroids/sprites/rock1/rock10001.png b/kasteroids/sprites/rock1/rock10001.png Binary files differnew file mode 100644 index 00000000..41ab94ee --- /dev/null +++ b/kasteroids/sprites/rock1/rock10001.png diff --git a/kasteroids/sprites/rock1/rock10002.png b/kasteroids/sprites/rock1/rock10002.png Binary files differnew file mode 100644 index 00000000..f96a3c51 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10002.png diff --git a/kasteroids/sprites/rock1/rock10003.png b/kasteroids/sprites/rock1/rock10003.png Binary files differnew file mode 100644 index 00000000..6d6abce3 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10003.png diff --git a/kasteroids/sprites/rock1/rock10004.png b/kasteroids/sprites/rock1/rock10004.png Binary files differnew file mode 100644 index 00000000..94d2e34d --- /dev/null +++ b/kasteroids/sprites/rock1/rock10004.png diff --git a/kasteroids/sprites/rock1/rock10005.png b/kasteroids/sprites/rock1/rock10005.png Binary files differnew file mode 100644 index 00000000..163c4f0f --- /dev/null +++ b/kasteroids/sprites/rock1/rock10005.png diff --git a/kasteroids/sprites/rock1/rock10006.png b/kasteroids/sprites/rock1/rock10006.png Binary files differnew file mode 100644 index 00000000..3d1fb0ed --- /dev/null +++ b/kasteroids/sprites/rock1/rock10006.png diff --git a/kasteroids/sprites/rock1/rock10007.png b/kasteroids/sprites/rock1/rock10007.png Binary files differnew file mode 100644 index 00000000..c172d03e --- /dev/null +++ b/kasteroids/sprites/rock1/rock10007.png diff --git a/kasteroids/sprites/rock1/rock10008.png b/kasteroids/sprites/rock1/rock10008.png Binary files differnew file mode 100644 index 00000000..3e8e33fa --- /dev/null +++ b/kasteroids/sprites/rock1/rock10008.png diff --git a/kasteroids/sprites/rock1/rock10009.png b/kasteroids/sprites/rock1/rock10009.png Binary files differnew file mode 100644 index 00000000..b97c42b0 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10009.png diff --git a/kasteroids/sprites/rock1/rock10010.png b/kasteroids/sprites/rock1/rock10010.png Binary files differnew file mode 100644 index 00000000..227c822b --- /dev/null +++ b/kasteroids/sprites/rock1/rock10010.png diff --git a/kasteroids/sprites/rock1/rock10011.png b/kasteroids/sprites/rock1/rock10011.png Binary files differnew file mode 100644 index 00000000..7ac34a2e --- /dev/null +++ b/kasteroids/sprites/rock1/rock10011.png diff --git a/kasteroids/sprites/rock1/rock10012.png b/kasteroids/sprites/rock1/rock10012.png Binary files differnew file mode 100644 index 00000000..5607651b --- /dev/null +++ b/kasteroids/sprites/rock1/rock10012.png diff --git a/kasteroids/sprites/rock1/rock10013.png b/kasteroids/sprites/rock1/rock10013.png Binary files differnew file mode 100644 index 00000000..e5ce1f28 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10013.png diff --git a/kasteroids/sprites/rock1/rock10014.png b/kasteroids/sprites/rock1/rock10014.png Binary files differnew file mode 100644 index 00000000..527dff57 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10014.png diff --git a/kasteroids/sprites/rock1/rock10015.png b/kasteroids/sprites/rock1/rock10015.png Binary files differnew file mode 100644 index 00000000..6199740f --- /dev/null +++ b/kasteroids/sprites/rock1/rock10015.png diff --git a/kasteroids/sprites/rock1/rock10016.png b/kasteroids/sprites/rock1/rock10016.png Binary files differnew file mode 100644 index 00000000..fcef0110 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10016.png diff --git a/kasteroids/sprites/rock1/rock10017.png b/kasteroids/sprites/rock1/rock10017.png Binary files differnew file mode 100644 index 00000000..e58d712a --- /dev/null +++ b/kasteroids/sprites/rock1/rock10017.png diff --git a/kasteroids/sprites/rock1/rock10018.png b/kasteroids/sprites/rock1/rock10018.png Binary files differnew file mode 100644 index 00000000..607ec96e --- /dev/null +++ b/kasteroids/sprites/rock1/rock10018.png diff --git a/kasteroids/sprites/rock1/rock10019.png b/kasteroids/sprites/rock1/rock10019.png Binary files differnew file mode 100644 index 00000000..8694376a --- /dev/null +++ b/kasteroids/sprites/rock1/rock10019.png diff --git a/kasteroids/sprites/rock1/rock10020.png b/kasteroids/sprites/rock1/rock10020.png Binary files differnew file mode 100644 index 00000000..44560d5e --- /dev/null +++ b/kasteroids/sprites/rock1/rock10020.png diff --git a/kasteroids/sprites/rock1/rock10021.png b/kasteroids/sprites/rock1/rock10021.png Binary files differnew file mode 100644 index 00000000..6746b712 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10021.png diff --git a/kasteroids/sprites/rock1/rock10022.png b/kasteroids/sprites/rock1/rock10022.png Binary files differnew file mode 100644 index 00000000..ccb7d8e6 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10022.png diff --git a/kasteroids/sprites/rock1/rock10023.png b/kasteroids/sprites/rock1/rock10023.png Binary files differnew file mode 100644 index 00000000..22322356 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10023.png diff --git a/kasteroids/sprites/rock1/rock10024.png b/kasteroids/sprites/rock1/rock10024.png Binary files differnew file mode 100644 index 00000000..a8b9e034 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10024.png diff --git a/kasteroids/sprites/rock1/rock10025.png b/kasteroids/sprites/rock1/rock10025.png Binary files differnew file mode 100644 index 00000000..ba806f64 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10025.png diff --git a/kasteroids/sprites/rock1/rock10026.png b/kasteroids/sprites/rock1/rock10026.png Binary files differnew file mode 100644 index 00000000..6eb57dd8 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10026.png diff --git a/kasteroids/sprites/rock1/rock10027.png b/kasteroids/sprites/rock1/rock10027.png Binary files differnew file mode 100644 index 00000000..56d7a090 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10027.png diff --git a/kasteroids/sprites/rock1/rock10028.png b/kasteroids/sprites/rock1/rock10028.png Binary files differnew file mode 100644 index 00000000..fc7e8681 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10028.png diff --git a/kasteroids/sprites/rock1/rock10029.png b/kasteroids/sprites/rock1/rock10029.png Binary files differnew file mode 100644 index 00000000..18eb8aea --- /dev/null +++ b/kasteroids/sprites/rock1/rock10029.png diff --git a/kasteroids/sprites/rock1/rock10030.png b/kasteroids/sprites/rock1/rock10030.png Binary files differnew file mode 100644 index 00000000..955307d9 --- /dev/null +++ b/kasteroids/sprites/rock1/rock10030.png diff --git a/kasteroids/sprites/rock1/rock10031.png b/kasteroids/sprites/rock1/rock10031.png Binary files differnew file mode 100644 index 00000000..902b86fc --- /dev/null +++ b/kasteroids/sprites/rock1/rock10031.png diff --git a/kasteroids/sprites/rock2/Makefile.am b/kasteroids/sprites/rock2/Makefile.am new file mode 100644 index 00000000..05db3bf6 --- /dev/null +++ b/kasteroids/sprites/rock2/Makefile.am @@ -0,0 +1,24 @@ +#POVRAY=x-povray # Must be Povray 3.0 + +#rocks: rock2.pov +# gforge -s 1 -m 128 -dim 2.6 -type mat -na rock.mat +# orb rock.mat rock.inc 0.7 5 +# rm rock.mat +# $(POVRAY) +L/usr/lib/povray3/include rock2.ini + +#clean: +# rm -f *~ *.pgm + +#realclean: clean +# rm -f *.ppm *.pbm + +EXTRA_DIST = rock20000.png rock20001.png rock20002.png rock20003.png \ + rock20004.png rock20005.png rock20006.png rock20007.png \ + rock20008.png rock20009.png rock20010.png rock20011.png \ + rock20012.png rock20013.png rock20014.png rock20015.png \ + rock20016.png rock20017.png rock20018.png rock20019.png \ + rock20020.png rock20021.png rock20022.png rock20023.png \ + rock20024.png rock20025.png rock20026.png rock20027.png \ + rock20028.png rock20029.png rock20030.png rock20031.png \ + rock2.ini rock2.pov + diff --git a/kasteroids/sprites/rock2/rock2.ini b/kasteroids/sprites/rock2/rock2.ini new file mode 100644 index 00000000..d50e6fad --- /dev/null +++ b/kasteroids/sprites/rock2/rock2.ini @@ -0,0 +1,9 @@ +Cyclic_Animation=On +Width=32 +Height=32 +Final_frame=32 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Input_File_Name=rock2.pov diff --git a/kasteroids/sprites/rock2/rock2.pov b/kasteroids/sprites/rock2/rock2.pov new file mode 100644 index 00000000..2f37a206 --- /dev/null +++ b/kasteroids/sprites/rock2/rock2.pov @@ -0,0 +1,26 @@ +#include "colors.inc" +#include "shapes.inc" +#include "textures.inc" +// #include "stones.inc" + +camera { + location <2,2,-6> + up <0, 1, 0> +// right <4/3, 0, 0> + look_at <0,0,0> +} + +object { light_source { <10, 5, -5> color red 1.1 green 1.1 blue 1.0 } } + +#declare Rock = +mesh { + #include "rock.inc" /* collection of triangle or smooth_triangle data */ +} + +object { + Rock + texture { pigment {White} } + scale 1.9 + rotate <60, 30, 360*clock> +} + diff --git a/kasteroids/sprites/rock2/rock20000.png b/kasteroids/sprites/rock2/rock20000.png Binary files differnew file mode 100644 index 00000000..4c483116 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20000.png diff --git a/kasteroids/sprites/rock2/rock20001.png b/kasteroids/sprites/rock2/rock20001.png Binary files differnew file mode 100644 index 00000000..8041395a --- /dev/null +++ b/kasteroids/sprites/rock2/rock20001.png diff --git a/kasteroids/sprites/rock2/rock20002.png b/kasteroids/sprites/rock2/rock20002.png Binary files differnew file mode 100644 index 00000000..83b412f4 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20002.png diff --git a/kasteroids/sprites/rock2/rock20003.png b/kasteroids/sprites/rock2/rock20003.png Binary files differnew file mode 100644 index 00000000..31f41b16 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20003.png diff --git a/kasteroids/sprites/rock2/rock20004.png b/kasteroids/sprites/rock2/rock20004.png Binary files differnew file mode 100644 index 00000000..47d359fe --- /dev/null +++ b/kasteroids/sprites/rock2/rock20004.png diff --git a/kasteroids/sprites/rock2/rock20005.png b/kasteroids/sprites/rock2/rock20005.png Binary files differnew file mode 100644 index 00000000..565dfe39 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20005.png diff --git a/kasteroids/sprites/rock2/rock20006.png b/kasteroids/sprites/rock2/rock20006.png Binary files differnew file mode 100644 index 00000000..ebf10c42 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20006.png diff --git a/kasteroids/sprites/rock2/rock20007.png b/kasteroids/sprites/rock2/rock20007.png Binary files differnew file mode 100644 index 00000000..44425780 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20007.png diff --git a/kasteroids/sprites/rock2/rock20008.png b/kasteroids/sprites/rock2/rock20008.png Binary files differnew file mode 100644 index 00000000..2601a824 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20008.png diff --git a/kasteroids/sprites/rock2/rock20009.png b/kasteroids/sprites/rock2/rock20009.png Binary files differnew file mode 100644 index 00000000..8987fdc8 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20009.png diff --git a/kasteroids/sprites/rock2/rock20010.png b/kasteroids/sprites/rock2/rock20010.png Binary files differnew file mode 100644 index 00000000..a3d19851 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20010.png diff --git a/kasteroids/sprites/rock2/rock20011.png b/kasteroids/sprites/rock2/rock20011.png Binary files differnew file mode 100644 index 00000000..0bea56f4 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20011.png diff --git a/kasteroids/sprites/rock2/rock20012.png b/kasteroids/sprites/rock2/rock20012.png Binary files differnew file mode 100644 index 00000000..22712591 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20012.png diff --git a/kasteroids/sprites/rock2/rock20013.png b/kasteroids/sprites/rock2/rock20013.png Binary files differnew file mode 100644 index 00000000..de91a877 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20013.png diff --git a/kasteroids/sprites/rock2/rock20014.png b/kasteroids/sprites/rock2/rock20014.png Binary files differnew file mode 100644 index 00000000..b76af51d --- /dev/null +++ b/kasteroids/sprites/rock2/rock20014.png diff --git a/kasteroids/sprites/rock2/rock20015.png b/kasteroids/sprites/rock2/rock20015.png Binary files differnew file mode 100644 index 00000000..01283e6c --- /dev/null +++ b/kasteroids/sprites/rock2/rock20015.png diff --git a/kasteroids/sprites/rock2/rock20016.png b/kasteroids/sprites/rock2/rock20016.png Binary files differnew file mode 100644 index 00000000..f220642d --- /dev/null +++ b/kasteroids/sprites/rock2/rock20016.png diff --git a/kasteroids/sprites/rock2/rock20017.png b/kasteroids/sprites/rock2/rock20017.png Binary files differnew file mode 100644 index 00000000..cca6ccfe --- /dev/null +++ b/kasteroids/sprites/rock2/rock20017.png diff --git a/kasteroids/sprites/rock2/rock20018.png b/kasteroids/sprites/rock2/rock20018.png Binary files differnew file mode 100644 index 00000000..6adac3fe --- /dev/null +++ b/kasteroids/sprites/rock2/rock20018.png diff --git a/kasteroids/sprites/rock2/rock20019.png b/kasteroids/sprites/rock2/rock20019.png Binary files differnew file mode 100644 index 00000000..fbb54c95 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20019.png diff --git a/kasteroids/sprites/rock2/rock20020.png b/kasteroids/sprites/rock2/rock20020.png Binary files differnew file mode 100644 index 00000000..e8bfd2d4 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20020.png diff --git a/kasteroids/sprites/rock2/rock20021.png b/kasteroids/sprites/rock2/rock20021.png Binary files differnew file mode 100644 index 00000000..33e313d7 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20021.png diff --git a/kasteroids/sprites/rock2/rock20022.png b/kasteroids/sprites/rock2/rock20022.png Binary files differnew file mode 100644 index 00000000..cf94837a --- /dev/null +++ b/kasteroids/sprites/rock2/rock20022.png diff --git a/kasteroids/sprites/rock2/rock20023.png b/kasteroids/sprites/rock2/rock20023.png Binary files differnew file mode 100644 index 00000000..2ef4c458 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20023.png diff --git a/kasteroids/sprites/rock2/rock20024.png b/kasteroids/sprites/rock2/rock20024.png Binary files differnew file mode 100644 index 00000000..1fe628fa --- /dev/null +++ b/kasteroids/sprites/rock2/rock20024.png diff --git a/kasteroids/sprites/rock2/rock20025.png b/kasteroids/sprites/rock2/rock20025.png Binary files differnew file mode 100644 index 00000000..3403c2e0 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20025.png diff --git a/kasteroids/sprites/rock2/rock20026.png b/kasteroids/sprites/rock2/rock20026.png Binary files differnew file mode 100644 index 00000000..b71629b9 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20026.png diff --git a/kasteroids/sprites/rock2/rock20027.png b/kasteroids/sprites/rock2/rock20027.png Binary files differnew file mode 100644 index 00000000..0b1301ae --- /dev/null +++ b/kasteroids/sprites/rock2/rock20027.png diff --git a/kasteroids/sprites/rock2/rock20028.png b/kasteroids/sprites/rock2/rock20028.png Binary files differnew file mode 100644 index 00000000..ff9514da --- /dev/null +++ b/kasteroids/sprites/rock2/rock20028.png diff --git a/kasteroids/sprites/rock2/rock20029.png b/kasteroids/sprites/rock2/rock20029.png Binary files differnew file mode 100644 index 00000000..996efaca --- /dev/null +++ b/kasteroids/sprites/rock2/rock20029.png diff --git a/kasteroids/sprites/rock2/rock20030.png b/kasteroids/sprites/rock2/rock20030.png Binary files differnew file mode 100644 index 00000000..db406978 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20030.png diff --git a/kasteroids/sprites/rock2/rock20031.png b/kasteroids/sprites/rock2/rock20031.png Binary files differnew file mode 100644 index 00000000..9079d195 --- /dev/null +++ b/kasteroids/sprites/rock2/rock20031.png diff --git a/kasteroids/sprites/rock3/Makefile.am b/kasteroids/sprites/rock3/Makefile.am new file mode 100644 index 00000000..8b63bef8 --- /dev/null +++ b/kasteroids/sprites/rock3/Makefile.am @@ -0,0 +1,24 @@ +#POVRAY=x-povray # Must be Povray 3.0 + +#rocks: rock3.pov +# gforge -s 2 -m 128 -dim 2.6 -type mat -na rock.mat +# orb rock.mat rock.inc 0.7 5 +# rm rock.mat +# $(POVRAY) +L/usr/lib/povray3/include rock3.ini + +#clean: +# rm -f *~ *.pgm + +#realclean: clean +# rm -f *.ppm *.pbm + +EXTRA_DIST = rock30000.png rock30001.png rock30002.png rock30003.png \ + rock30004.png rock30005.png rock30006.png rock30007.png \ + rock30008.png rock30009.png rock30010.png rock30011.png \ + rock30012.png rock30013.png rock30014.png rock30015.png \ + rock30016.png rock30017.png rock30018.png rock30019.png \ + rock30020.png rock30021.png rock30022.png rock30023.png \ + rock30024.png rock30025.png rock30026.png rock30027.png \ + rock30028.png rock30029.png rock30030.png rock30031.png \ + rock3.ini rock3.pov + diff --git a/kasteroids/sprites/rock3/rock3.ini b/kasteroids/sprites/rock3/rock3.ini new file mode 100644 index 00000000..26a3cf96 --- /dev/null +++ b/kasteroids/sprites/rock3/rock3.ini @@ -0,0 +1,9 @@ +Cyclic_Animation=On +Width=20 +Height=20 +Final_frame=32 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Input_File_Name=rock3.pov diff --git a/kasteroids/sprites/rock3/rock3.pov b/kasteroids/sprites/rock3/rock3.pov new file mode 100644 index 00000000..2f37a206 --- /dev/null +++ b/kasteroids/sprites/rock3/rock3.pov @@ -0,0 +1,26 @@ +#include "colors.inc" +#include "shapes.inc" +#include "textures.inc" +// #include "stones.inc" + +camera { + location <2,2,-6> + up <0, 1, 0> +// right <4/3, 0, 0> + look_at <0,0,0> +} + +object { light_source { <10, 5, -5> color red 1.1 green 1.1 blue 1.0 } } + +#declare Rock = +mesh { + #include "rock.inc" /* collection of triangle or smooth_triangle data */ +} + +object { + Rock + texture { pigment {White} } + scale 1.9 + rotate <60, 30, 360*clock> +} + diff --git a/kasteroids/sprites/rock3/rock30000.png b/kasteroids/sprites/rock3/rock30000.png Binary files differnew file mode 100644 index 00000000..e16c5fa5 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30000.png diff --git a/kasteroids/sprites/rock3/rock30001.png b/kasteroids/sprites/rock3/rock30001.png Binary files differnew file mode 100644 index 00000000..46148262 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30001.png diff --git a/kasteroids/sprites/rock3/rock30002.png b/kasteroids/sprites/rock3/rock30002.png Binary files differnew file mode 100644 index 00000000..0417648d --- /dev/null +++ b/kasteroids/sprites/rock3/rock30002.png diff --git a/kasteroids/sprites/rock3/rock30003.png b/kasteroids/sprites/rock3/rock30003.png Binary files differnew file mode 100644 index 00000000..a8ef0bf7 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30003.png diff --git a/kasteroids/sprites/rock3/rock30004.png b/kasteroids/sprites/rock3/rock30004.png Binary files differnew file mode 100644 index 00000000..95c55c73 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30004.png diff --git a/kasteroids/sprites/rock3/rock30005.png b/kasteroids/sprites/rock3/rock30005.png Binary files differnew file mode 100644 index 00000000..a061fb7f --- /dev/null +++ b/kasteroids/sprites/rock3/rock30005.png diff --git a/kasteroids/sprites/rock3/rock30006.png b/kasteroids/sprites/rock3/rock30006.png Binary files differnew file mode 100644 index 00000000..58b79dff --- /dev/null +++ b/kasteroids/sprites/rock3/rock30006.png diff --git a/kasteroids/sprites/rock3/rock30007.png b/kasteroids/sprites/rock3/rock30007.png Binary files differnew file mode 100644 index 00000000..727dd538 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30007.png diff --git a/kasteroids/sprites/rock3/rock30008.png b/kasteroids/sprites/rock3/rock30008.png Binary files differnew file mode 100644 index 00000000..fffc1444 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30008.png diff --git a/kasteroids/sprites/rock3/rock30009.png b/kasteroids/sprites/rock3/rock30009.png Binary files differnew file mode 100644 index 00000000..c8de18bd --- /dev/null +++ b/kasteroids/sprites/rock3/rock30009.png diff --git a/kasteroids/sprites/rock3/rock30010.png b/kasteroids/sprites/rock3/rock30010.png Binary files differnew file mode 100644 index 00000000..23085284 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30010.png diff --git a/kasteroids/sprites/rock3/rock30011.png b/kasteroids/sprites/rock3/rock30011.png Binary files differnew file mode 100644 index 00000000..c2eda4cd --- /dev/null +++ b/kasteroids/sprites/rock3/rock30011.png diff --git a/kasteroids/sprites/rock3/rock30012.png b/kasteroids/sprites/rock3/rock30012.png Binary files differnew file mode 100644 index 00000000..2bf02230 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30012.png diff --git a/kasteroids/sprites/rock3/rock30013.png b/kasteroids/sprites/rock3/rock30013.png Binary files differnew file mode 100644 index 00000000..1e12d554 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30013.png diff --git a/kasteroids/sprites/rock3/rock30014.png b/kasteroids/sprites/rock3/rock30014.png Binary files differnew file mode 100644 index 00000000..4e2dd198 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30014.png diff --git a/kasteroids/sprites/rock3/rock30015.png b/kasteroids/sprites/rock3/rock30015.png Binary files differnew file mode 100644 index 00000000..ea905e22 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30015.png diff --git a/kasteroids/sprites/rock3/rock30016.png b/kasteroids/sprites/rock3/rock30016.png Binary files differnew file mode 100644 index 00000000..650b9af4 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30016.png diff --git a/kasteroids/sprites/rock3/rock30017.png b/kasteroids/sprites/rock3/rock30017.png Binary files differnew file mode 100644 index 00000000..1ef30eb2 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30017.png diff --git a/kasteroids/sprites/rock3/rock30018.png b/kasteroids/sprites/rock3/rock30018.png Binary files differnew file mode 100644 index 00000000..40bddae3 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30018.png diff --git a/kasteroids/sprites/rock3/rock30019.png b/kasteroids/sprites/rock3/rock30019.png Binary files differnew file mode 100644 index 00000000..0d2637c8 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30019.png diff --git a/kasteroids/sprites/rock3/rock30020.png b/kasteroids/sprites/rock3/rock30020.png Binary files differnew file mode 100644 index 00000000..8eebba63 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30020.png diff --git a/kasteroids/sprites/rock3/rock30021.png b/kasteroids/sprites/rock3/rock30021.png Binary files differnew file mode 100644 index 00000000..2fa50efe --- /dev/null +++ b/kasteroids/sprites/rock3/rock30021.png diff --git a/kasteroids/sprites/rock3/rock30022.png b/kasteroids/sprites/rock3/rock30022.png Binary files differnew file mode 100644 index 00000000..a1184f77 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30022.png diff --git a/kasteroids/sprites/rock3/rock30023.png b/kasteroids/sprites/rock3/rock30023.png Binary files differnew file mode 100644 index 00000000..92d35979 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30023.png diff --git a/kasteroids/sprites/rock3/rock30024.png b/kasteroids/sprites/rock3/rock30024.png Binary files differnew file mode 100644 index 00000000..2749bc94 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30024.png diff --git a/kasteroids/sprites/rock3/rock30025.png b/kasteroids/sprites/rock3/rock30025.png Binary files differnew file mode 100644 index 00000000..1afa737f --- /dev/null +++ b/kasteroids/sprites/rock3/rock30025.png diff --git a/kasteroids/sprites/rock3/rock30026.png b/kasteroids/sprites/rock3/rock30026.png Binary files differnew file mode 100644 index 00000000..e6af352f --- /dev/null +++ b/kasteroids/sprites/rock3/rock30026.png diff --git a/kasteroids/sprites/rock3/rock30027.png b/kasteroids/sprites/rock3/rock30027.png Binary files differnew file mode 100644 index 00000000..1ac52764 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30027.png diff --git a/kasteroids/sprites/rock3/rock30028.png b/kasteroids/sprites/rock3/rock30028.png Binary files differnew file mode 100644 index 00000000..7395a37a --- /dev/null +++ b/kasteroids/sprites/rock3/rock30028.png diff --git a/kasteroids/sprites/rock3/rock30029.png b/kasteroids/sprites/rock3/rock30029.png Binary files differnew file mode 100644 index 00000000..b0b56200 --- /dev/null +++ b/kasteroids/sprites/rock3/rock30029.png diff --git a/kasteroids/sprites/rock3/rock30030.png b/kasteroids/sprites/rock3/rock30030.png Binary files differnew file mode 100644 index 00000000..2bddf8ee --- /dev/null +++ b/kasteroids/sprites/rock3/rock30030.png diff --git a/kasteroids/sprites/rock3/rock30031.png b/kasteroids/sprites/rock3/rock30031.png Binary files differnew file mode 100644 index 00000000..f5cce0fc --- /dev/null +++ b/kasteroids/sprites/rock3/rock30031.png diff --git a/kasteroids/sprites/shield/Makefile.am b/kasteroids/sprites/shield/Makefile.am new file mode 100644 index 00000000..4f86837c --- /dev/null +++ b/kasteroids/sprites/shield/Makefile.am @@ -0,0 +1,3 @@ + +EXTRA_DIST = shield0000.png shield0001.png shield0002.png shield0003.png \ + shield0004.png shield0005.png shield0006.png diff --git a/kasteroids/sprites/shield/shield0000.png b/kasteroids/sprites/shield/shield0000.png Binary files differnew file mode 100644 index 00000000..90f25718 --- /dev/null +++ b/kasteroids/sprites/shield/shield0000.png diff --git a/kasteroids/sprites/shield/shield0001.png b/kasteroids/sprites/shield/shield0001.png Binary files differnew file mode 100644 index 00000000..342d40aa --- /dev/null +++ b/kasteroids/sprites/shield/shield0001.png diff --git a/kasteroids/sprites/shield/shield0002.png b/kasteroids/sprites/shield/shield0002.png Binary files differnew file mode 100644 index 00000000..d00f4ab1 --- /dev/null +++ b/kasteroids/sprites/shield/shield0002.png diff --git a/kasteroids/sprites/shield/shield0003.png b/kasteroids/sprites/shield/shield0003.png Binary files differnew file mode 100644 index 00000000..2ae53d45 --- /dev/null +++ b/kasteroids/sprites/shield/shield0003.png diff --git a/kasteroids/sprites/shield/shield0004.png b/kasteroids/sprites/shield/shield0004.png Binary files differnew file mode 100644 index 00000000..72d0847b --- /dev/null +++ b/kasteroids/sprites/shield/shield0004.png diff --git a/kasteroids/sprites/shield/shield0005.png b/kasteroids/sprites/shield/shield0005.png Binary files differnew file mode 100644 index 00000000..7efa4f14 --- /dev/null +++ b/kasteroids/sprites/shield/shield0005.png diff --git a/kasteroids/sprites/shield/shield0006.png b/kasteroids/sprites/shield/shield0006.png Binary files differnew file mode 100644 index 00000000..18eff6c6 --- /dev/null +++ b/kasteroids/sprites/shield/shield0006.png diff --git a/kasteroids/sprites/ship/Makefile.am b/kasteroids/sprites/ship/Makefile.am new file mode 100644 index 00000000..4679332c --- /dev/null +++ b/kasteroids/sprites/ship/Makefile.am @@ -0,0 +1,22 @@ +#POVRAY=x-povray # Must be Povray 3.0 + +#ship: ship.pov +# $(POVRAY) +L/usr/lib/povray3/include ship.ini + +#clean: +# rm -f *~ *.png *.pgm + +#realclean: clean +# rm -f *.ppm *.pbm + + +EXTRA_DIST = ship0000.png ship0001.png ship0002.png ship0003.png \ + ship0004.png ship0005.png ship0006.png ship0007.png \ + ship0008.png ship0009.png ship0010.png ship0011.png \ + ship0012.png ship0013.png ship0014.png ship0015.png \ + ship0016.png ship0017.png ship0018.png ship0019.png \ + ship0020.png ship0021.png ship0022.png ship0023.png \ + ship0024.png ship0025.png ship0026.png ship0027.png \ + ship0028.png ship0029.png ship0030.png ship0031.png \ + ship.ini ship.pov + diff --git a/kasteroids/sprites/ship/ship.ini b/kasteroids/sprites/ship/ship.ini new file mode 100644 index 00000000..ceca85d8 --- /dev/null +++ b/kasteroids/sprites/ship/ship.ini @@ -0,0 +1,11 @@ +Cyclic_Animation=On +Width=42 +Height=42 +Initial_Frame=0 +Final_frame=63 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Output_File_Name=ship00 +Input_File_Name=ship.pov diff --git a/kasteroids/sprites/ship/ship.pov b/kasteroids/sprites/ship/ship.pov new file mode 100644 index 00000000..8f185cd7 --- /dev/null +++ b/kasteroids/sprites/ship/ship.pov @@ -0,0 +1,128 @@ + +#version 3.0 +global_settings { assumed_gamma 2.0 } + +#include "colors.inc" +#include "textures.inc" +#include "metals.inc" + +camera { + orthographic + up <0, 130, 0> + right <130, 0, 0> + location <0, 0, -130> + look_at <0, 0, 0> +} + +light_source { <50, 25, -25> colour White } +light_source { <0, 0, -100> colour Gray80 } + +#declare ShipColor = color red 1.0 green 1.0 blue 0.9 + +#declare BaseTexture = +texture { + pigment { ShipColor } +} + +#declare Grubby = +texture { + pigment { + bozo + color_map { + [0.0 color rgbt <1, 1, 1, 1>] + [0.8 color rgbt <0.9, 0.9, 0.9, 0.5>] + [1.0 color rgbt <0.8, 0.8, 0.8, 0.5>] + } + turbulence 2.0 + scale 3 + } +} + +#declare ShipTexture = +texture { BaseTexture } +texture { Grubby } + +union { + cone { + <12, 0, 0>, 0.5 + <11, 0, 0>, 1.0 + texture { ShipTexture } + } + cone { + <11, 0, 0>, 1.0 + <8, 0, 0>, 2.0 + texture { ShipTexture } + } + cone { + <8, 0, 0>, 2.0 + <3.5, 0, 0>, 3.8 + texture { ShipTexture } + } + difference { + cone { + <8, 0, -0.01>, 2.0 + <3.5, 0, -0.01>, 3.8 + pigment { color Gray20 } + } + box { + <9, -4.0, -3.7>, + <2, 4.0, 10> + rotate <0, -18, 0> + } + box { + <6.5, -4.0, -8>, + <10, 4.0, 8> + } + box { + <2, -4.0, -8>, + <4.5, 4.0, 8> + } + } + cone { + <3.5, 0, 0>, 3.8 + <2, 0, 0>, 4.0 + texture { ShipTexture } + } + cylinder { + <2, 0, 0>, + <-9, 0, 0>, + 4.0 + texture { ShipTexture } + } + cone { + <-9, 0, 0>, 4.0 + <-10, 0, 0>, 3.5 + texture { ShipTexture } + } + prism { + linear_sweep + linear_spline + 0, + 0.5, + 4, + <7.5, 0>, <-7.5, 10>, <-7.5, -10>, <7.5, 0> + rotate <90, 0, 0> + texture { T_Silver_2A } + texture { ShipTexture } + } + prism { + linear_sweep + linear_spline + -0.5, + 0.5, + 4, + <4, 0>, <-7.5, 5>, <-7.5, -5>, <4, 0> + pigment { color White } + } + cone { + <-12, 0, 0>, 3.0 + <-10, 0, 0>, 2.0 + texture { T_Silver_2A } + pigment { color Gray60 } + } + + rotate <0, 0,-360*clock> + scale <5, 5, 5> +} + + diff --git a/kasteroids/sprites/ship/ship0000.png b/kasteroids/sprites/ship/ship0000.png Binary files differnew file mode 100644 index 00000000..817fe1b4 --- /dev/null +++ b/kasteroids/sprites/ship/ship0000.png diff --git a/kasteroids/sprites/ship/ship0001.png b/kasteroids/sprites/ship/ship0001.png Binary files differnew file mode 100644 index 00000000..50cafa14 --- /dev/null +++ b/kasteroids/sprites/ship/ship0001.png diff --git a/kasteroids/sprites/ship/ship0002.png b/kasteroids/sprites/ship/ship0002.png Binary files differnew file mode 100644 index 00000000..161fee51 --- /dev/null +++ b/kasteroids/sprites/ship/ship0002.png diff --git a/kasteroids/sprites/ship/ship0003.png b/kasteroids/sprites/ship/ship0003.png Binary files differnew file mode 100644 index 00000000..7eb65c78 --- /dev/null +++ b/kasteroids/sprites/ship/ship0003.png diff --git a/kasteroids/sprites/ship/ship0004.png b/kasteroids/sprites/ship/ship0004.png Binary files differnew file mode 100644 index 00000000..fd71f2f2 --- /dev/null +++ b/kasteroids/sprites/ship/ship0004.png diff --git a/kasteroids/sprites/ship/ship0005.png b/kasteroids/sprites/ship/ship0005.png Binary files differnew file mode 100644 index 00000000..e6df9605 --- /dev/null +++ b/kasteroids/sprites/ship/ship0005.png diff --git a/kasteroids/sprites/ship/ship0006.png b/kasteroids/sprites/ship/ship0006.png Binary files differnew file mode 100644 index 00000000..3d1b0f70 --- /dev/null +++ b/kasteroids/sprites/ship/ship0006.png diff --git a/kasteroids/sprites/ship/ship0007.png b/kasteroids/sprites/ship/ship0007.png Binary files differnew file mode 100644 index 00000000..1ec6ce4e --- /dev/null +++ b/kasteroids/sprites/ship/ship0007.png diff --git a/kasteroids/sprites/ship/ship0008.png b/kasteroids/sprites/ship/ship0008.png Binary files differnew file mode 100644 index 00000000..f2632745 --- /dev/null +++ b/kasteroids/sprites/ship/ship0008.png diff --git a/kasteroids/sprites/ship/ship0009.png b/kasteroids/sprites/ship/ship0009.png Binary files differnew file mode 100644 index 00000000..e7188fd1 --- /dev/null +++ b/kasteroids/sprites/ship/ship0009.png diff --git a/kasteroids/sprites/ship/ship0010.png b/kasteroids/sprites/ship/ship0010.png Binary files differnew file mode 100644 index 00000000..20c5aa72 --- /dev/null +++ b/kasteroids/sprites/ship/ship0010.png diff --git a/kasteroids/sprites/ship/ship0011.png b/kasteroids/sprites/ship/ship0011.png Binary files differnew file mode 100644 index 00000000..1d21e59c --- /dev/null +++ b/kasteroids/sprites/ship/ship0011.png diff --git a/kasteroids/sprites/ship/ship0012.png b/kasteroids/sprites/ship/ship0012.png Binary files differnew file mode 100644 index 00000000..1d5c51c3 --- /dev/null +++ b/kasteroids/sprites/ship/ship0012.png diff --git a/kasteroids/sprites/ship/ship0013.png b/kasteroids/sprites/ship/ship0013.png Binary files differnew file mode 100644 index 00000000..37e1a68d --- /dev/null +++ b/kasteroids/sprites/ship/ship0013.png diff --git a/kasteroids/sprites/ship/ship0014.png b/kasteroids/sprites/ship/ship0014.png Binary files differnew file mode 100644 index 00000000..49e2d6da --- /dev/null +++ b/kasteroids/sprites/ship/ship0014.png diff --git a/kasteroids/sprites/ship/ship0015.png b/kasteroids/sprites/ship/ship0015.png Binary files differnew file mode 100644 index 00000000..e65bdf2b --- /dev/null +++ b/kasteroids/sprites/ship/ship0015.png diff --git a/kasteroids/sprites/ship/ship0016.png b/kasteroids/sprites/ship/ship0016.png Binary files differnew file mode 100644 index 00000000..bab602e9 --- /dev/null +++ b/kasteroids/sprites/ship/ship0016.png diff --git a/kasteroids/sprites/ship/ship0017.png b/kasteroids/sprites/ship/ship0017.png Binary files differnew file mode 100644 index 00000000..c6bede44 --- /dev/null +++ b/kasteroids/sprites/ship/ship0017.png diff --git a/kasteroids/sprites/ship/ship0018.png b/kasteroids/sprites/ship/ship0018.png Binary files differnew file mode 100644 index 00000000..50e74c92 --- /dev/null +++ b/kasteroids/sprites/ship/ship0018.png diff --git a/kasteroids/sprites/ship/ship0019.png b/kasteroids/sprites/ship/ship0019.png Binary files differnew file mode 100644 index 00000000..6621046d --- /dev/null +++ b/kasteroids/sprites/ship/ship0019.png diff --git a/kasteroids/sprites/ship/ship0020.png b/kasteroids/sprites/ship/ship0020.png Binary files differnew file mode 100644 index 00000000..da5d8839 --- /dev/null +++ b/kasteroids/sprites/ship/ship0020.png diff --git a/kasteroids/sprites/ship/ship0021.png b/kasteroids/sprites/ship/ship0021.png Binary files differnew file mode 100644 index 00000000..5f4fee20 --- /dev/null +++ b/kasteroids/sprites/ship/ship0021.png diff --git a/kasteroids/sprites/ship/ship0022.png b/kasteroids/sprites/ship/ship0022.png Binary files differnew file mode 100644 index 00000000..6828ccec --- /dev/null +++ b/kasteroids/sprites/ship/ship0022.png diff --git a/kasteroids/sprites/ship/ship0023.png b/kasteroids/sprites/ship/ship0023.png Binary files differnew file mode 100644 index 00000000..34d81a05 --- /dev/null +++ b/kasteroids/sprites/ship/ship0023.png diff --git a/kasteroids/sprites/ship/ship0024.png b/kasteroids/sprites/ship/ship0024.png Binary files differnew file mode 100644 index 00000000..3ecce1a3 --- /dev/null +++ b/kasteroids/sprites/ship/ship0024.png diff --git a/kasteroids/sprites/ship/ship0025.png b/kasteroids/sprites/ship/ship0025.png Binary files differnew file mode 100644 index 00000000..de28312d --- /dev/null +++ b/kasteroids/sprites/ship/ship0025.png diff --git a/kasteroids/sprites/ship/ship0026.png b/kasteroids/sprites/ship/ship0026.png Binary files differnew file mode 100644 index 00000000..da7d5e3a --- /dev/null +++ b/kasteroids/sprites/ship/ship0026.png diff --git a/kasteroids/sprites/ship/ship0027.png b/kasteroids/sprites/ship/ship0027.png Binary files differnew file mode 100644 index 00000000..d11bb640 --- /dev/null +++ b/kasteroids/sprites/ship/ship0027.png diff --git a/kasteroids/sprites/ship/ship0028.png b/kasteroids/sprites/ship/ship0028.png Binary files differnew file mode 100644 index 00000000..e0524641 --- /dev/null +++ b/kasteroids/sprites/ship/ship0028.png diff --git a/kasteroids/sprites/ship/ship0029.png b/kasteroids/sprites/ship/ship0029.png Binary files differnew file mode 100644 index 00000000..db5497db --- /dev/null +++ b/kasteroids/sprites/ship/ship0029.png diff --git a/kasteroids/sprites/ship/ship0030.png b/kasteroids/sprites/ship/ship0030.png Binary files differnew file mode 100644 index 00000000..ee734fa6 --- /dev/null +++ b/kasteroids/sprites/ship/ship0030.png diff --git a/kasteroids/sprites/ship/ship0031.png b/kasteroids/sprites/ship/ship0031.png Binary files differnew file mode 100644 index 00000000..8234d015 --- /dev/null +++ b/kasteroids/sprites/ship/ship0031.png diff --git a/kasteroids/sprites/ship/ship0032.png b/kasteroids/sprites/ship/ship0032.png Binary files differnew file mode 100644 index 00000000..f438621c --- /dev/null +++ b/kasteroids/sprites/ship/ship0032.png diff --git a/kasteroids/sprites/ship/ship0033.png b/kasteroids/sprites/ship/ship0033.png Binary files differnew file mode 100644 index 00000000..35a7c94a --- /dev/null +++ b/kasteroids/sprites/ship/ship0033.png diff --git a/kasteroids/sprites/ship/ship0034.png b/kasteroids/sprites/ship/ship0034.png Binary files differnew file mode 100644 index 00000000..ae436b66 --- /dev/null +++ b/kasteroids/sprites/ship/ship0034.png diff --git a/kasteroids/sprites/ship/ship0035.png b/kasteroids/sprites/ship/ship0035.png Binary files differnew file mode 100644 index 00000000..ccae1f4a --- /dev/null +++ b/kasteroids/sprites/ship/ship0035.png diff --git a/kasteroids/sprites/ship/ship0036.png b/kasteroids/sprites/ship/ship0036.png Binary files differnew file mode 100644 index 00000000..ba1e0f37 --- /dev/null +++ b/kasteroids/sprites/ship/ship0036.png diff --git a/kasteroids/sprites/ship/ship0037.png b/kasteroids/sprites/ship/ship0037.png Binary files differnew file mode 100644 index 00000000..66ab96ca --- /dev/null +++ b/kasteroids/sprites/ship/ship0037.png diff --git a/kasteroids/sprites/ship/ship0038.png b/kasteroids/sprites/ship/ship0038.png Binary files differnew file mode 100644 index 00000000..f2efab14 --- /dev/null +++ b/kasteroids/sprites/ship/ship0038.png diff --git a/kasteroids/sprites/ship/ship0039.png b/kasteroids/sprites/ship/ship0039.png Binary files differnew file mode 100644 index 00000000..1998e6f5 --- /dev/null +++ b/kasteroids/sprites/ship/ship0039.png diff --git a/kasteroids/sprites/ship/ship0040.png b/kasteroids/sprites/ship/ship0040.png Binary files differnew file mode 100644 index 00000000..005dc49d --- /dev/null +++ b/kasteroids/sprites/ship/ship0040.png diff --git a/kasteroids/sprites/ship/ship0041.png b/kasteroids/sprites/ship/ship0041.png Binary files differnew file mode 100644 index 00000000..a2cd13e6 --- /dev/null +++ b/kasteroids/sprites/ship/ship0041.png diff --git a/kasteroids/sprites/ship/ship0042.png b/kasteroids/sprites/ship/ship0042.png Binary files differnew file mode 100644 index 00000000..788f0abd --- /dev/null +++ b/kasteroids/sprites/ship/ship0042.png diff --git a/kasteroids/sprites/ship/ship0043.png b/kasteroids/sprites/ship/ship0043.png Binary files differnew file mode 100644 index 00000000..222c63a4 --- /dev/null +++ b/kasteroids/sprites/ship/ship0043.png diff --git a/kasteroids/sprites/ship/ship0044.png b/kasteroids/sprites/ship/ship0044.png Binary files differnew file mode 100644 index 00000000..20606f6c --- /dev/null +++ b/kasteroids/sprites/ship/ship0044.png diff --git a/kasteroids/sprites/ship/ship0045.png b/kasteroids/sprites/ship/ship0045.png Binary files differnew file mode 100644 index 00000000..dd5d195a --- /dev/null +++ b/kasteroids/sprites/ship/ship0045.png diff --git a/kasteroids/sprites/ship/ship0046.png b/kasteroids/sprites/ship/ship0046.png Binary files differnew file mode 100644 index 00000000..53564007 --- /dev/null +++ b/kasteroids/sprites/ship/ship0046.png diff --git a/kasteroids/sprites/ship/ship0047.png b/kasteroids/sprites/ship/ship0047.png Binary files differnew file mode 100644 index 00000000..60b0bac3 --- /dev/null +++ b/kasteroids/sprites/ship/ship0047.png diff --git a/kasteroids/sprites/ship/ship0048.png b/kasteroids/sprites/ship/ship0048.png Binary files differnew file mode 100644 index 00000000..c3b7a57d --- /dev/null +++ b/kasteroids/sprites/ship/ship0048.png diff --git a/kasteroids/sprites/ship/ship0049.png b/kasteroids/sprites/ship/ship0049.png Binary files differnew file mode 100644 index 00000000..a9a1228f --- /dev/null +++ b/kasteroids/sprites/ship/ship0049.png diff --git a/kasteroids/sprites/ship/ship0050.png b/kasteroids/sprites/ship/ship0050.png Binary files differnew file mode 100644 index 00000000..89fd0b25 --- /dev/null +++ b/kasteroids/sprites/ship/ship0050.png diff --git a/kasteroids/sprites/ship/ship0051.png b/kasteroids/sprites/ship/ship0051.png Binary files differnew file mode 100644 index 00000000..a1039a08 --- /dev/null +++ b/kasteroids/sprites/ship/ship0051.png diff --git a/kasteroids/sprites/ship/ship0052.png b/kasteroids/sprites/ship/ship0052.png Binary files differnew file mode 100644 index 00000000..85eadc8a --- /dev/null +++ b/kasteroids/sprites/ship/ship0052.png diff --git a/kasteroids/sprites/ship/ship0053.png b/kasteroids/sprites/ship/ship0053.png Binary files differnew file mode 100644 index 00000000..e6e204e0 --- /dev/null +++ b/kasteroids/sprites/ship/ship0053.png diff --git a/kasteroids/sprites/ship/ship0054.png b/kasteroids/sprites/ship/ship0054.png Binary files differnew file mode 100644 index 00000000..950b5021 --- /dev/null +++ b/kasteroids/sprites/ship/ship0054.png diff --git a/kasteroids/sprites/ship/ship0055.png b/kasteroids/sprites/ship/ship0055.png Binary files differnew file mode 100644 index 00000000..d26dbbff --- /dev/null +++ b/kasteroids/sprites/ship/ship0055.png diff --git a/kasteroids/sprites/ship/ship0056.png b/kasteroids/sprites/ship/ship0056.png Binary files differnew file mode 100644 index 00000000..c26fae98 --- /dev/null +++ b/kasteroids/sprites/ship/ship0056.png diff --git a/kasteroids/sprites/ship/ship0057.png b/kasteroids/sprites/ship/ship0057.png Binary files differnew file mode 100644 index 00000000..7d2733a4 --- /dev/null +++ b/kasteroids/sprites/ship/ship0057.png diff --git a/kasteroids/sprites/ship/ship0058.png b/kasteroids/sprites/ship/ship0058.png Binary files differnew file mode 100644 index 00000000..86e233ea --- /dev/null +++ b/kasteroids/sprites/ship/ship0058.png diff --git a/kasteroids/sprites/ship/ship0059.png b/kasteroids/sprites/ship/ship0059.png Binary files differnew file mode 100644 index 00000000..6745551d --- /dev/null +++ b/kasteroids/sprites/ship/ship0059.png diff --git a/kasteroids/sprites/ship/ship0060.png b/kasteroids/sprites/ship/ship0060.png Binary files differnew file mode 100644 index 00000000..b227019c --- /dev/null +++ b/kasteroids/sprites/ship/ship0060.png diff --git a/kasteroids/sprites/ship/ship0061.png b/kasteroids/sprites/ship/ship0061.png Binary files differnew file mode 100644 index 00000000..c0302e20 --- /dev/null +++ b/kasteroids/sprites/ship/ship0061.png diff --git a/kasteroids/sprites/ship/ship0062.png b/kasteroids/sprites/ship/ship0062.png Binary files differnew file mode 100644 index 00000000..41d98263 --- /dev/null +++ b/kasteroids/sprites/ship/ship0062.png diff --git a/kasteroids/sprites/ship/ship0063.png b/kasteroids/sprites/ship/ship0063.png Binary files differnew file mode 100644 index 00000000..3f2ac102 --- /dev/null +++ b/kasteroids/sprites/ship/ship0063.png diff --git a/kasteroids/toplevel.cpp b/kasteroids/toplevel.cpp new file mode 100644 index 00000000..a4286d2f --- /dev/null +++ b/kasteroids/toplevel.cpp @@ -0,0 +1,678 @@ +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#include <qlabel.h> +#include <qlayout.h> +#include <qlcdnumber.h> +#include <qspinbox.h> +#include <qcheckbox.h> + +#include <kdebug.h> +#include <kapplication.h> +#include <kstandarddirs.h> +#include <kglobalsettings.h> +#include <kmessagebox.h> +#include <klocale.h> +#include <kkeydialog.h> +#include <kaction.h> +#include <kstdgameaction.h> +#include <kaudioplayer.h> +#include <kscoredialog.h> +#include <kconfigdialog.h> + +#include "settings.h" +#include "toplevel.h" +#include "ledmeter.h" + +#include "toplevel.moc" + +#if defined Q_WS_X11 && ! defined K_WS_QTONLY +#include <X11/Xlib.h> +#endif +#include <fixx11h.h> + +#define SB_SCORE 1 +#define SB_LEVEL 2 +#define SB_SHIPS 3 + +struct SLevel +{ + int nrocks; + double rockSpeed; +}; + +#define MAX_LEVELS 16 + +SLevel levels[MAX_LEVELS] = +{ + { 1, 0.4 }, + { 1, 0.6 }, + { 2, 0.5 }, + { 2, 0.7 }, + { 2, 0.8 }, + { 3, 0.6 }, + { 3, 0.7 }, + { 3, 0.8 }, + { 4, 0.6 }, + { 4, 0.7 }, + { 4, 0.8 }, + { 5, 0.7 }, + { 5, 0.8 }, + { 5, 0.9 }, + { 5, 1.0 } +}; + +#ifdef KA_ENABLE_SOUND +#include <arts/dispatcher.h> +#include <arts/soundserver.h> + +Arts::SimpleSoundServer *soundServer = 0; +#endif + + +KAstTopLevel::KAstTopLevel() +{ + QWidget *mainWin = new QWidget( this ); + mainWin->setFixedSize(640, 480); + + view = new KAsteroidsView( mainWin ); + connect( view, SIGNAL( shipKilled() ), SLOT( slotShipKilled() ) ); + connect( view, SIGNAL( rockHit(int) ), SLOT( slotRockHit(int) ) ); + connect( view, SIGNAL( rocksRemoved() ), SLOT( slotRocksRemoved() ) ); + connect( view, SIGNAL( updateVitals() ), SLOT( slotUpdateVitals() ) ); + + QVBoxLayout *vb = new QVBoxLayout( mainWin ); + QHBoxLayout *hb = new QHBoxLayout; + QHBoxLayout *hbd = new QHBoxLayout; + vb->addLayout( hb ); + + QFont labelFont( KGlobalSettings::generalFont().family(), 24 ); + QColorGroup grp( darkGreen, black, QColor( 128, 128, 128 ), + QColor( 64, 64, 64 ), black, darkGreen, black ); + QPalette pal( grp, grp, grp ); + + mainWin->setPalette( pal ); + + hb->addSpacing( 10 ); + + QLabel *label; + label = new QLabel( i18n("Score"), mainWin ); + label->setFont( labelFont ); + label->setPalette( pal ); + label->setFixedWidth( label->sizeHint().width() ); + hb->addWidget( label ); + + scoreLCD = new QLCDNumber( 6, mainWin ); + scoreLCD->setFrameStyle( QFrame::NoFrame ); + scoreLCD->setSegmentStyle( QLCDNumber::Flat ); + scoreLCD->setFixedWidth( 150 ); + scoreLCD->setPalette( pal ); + hb->addWidget( scoreLCD ); + hb->addStretch( 10 ); + + label = new QLabel( i18n("Level"), mainWin ); + label->setFont( labelFont ); + label->setPalette( pal ); + label->setFixedWidth( label->sizeHint().width() ); + hb->addWidget( label ); + + levelLCD = new QLCDNumber( 2, mainWin ); + levelLCD->setFrameStyle( QFrame::NoFrame ); + levelLCD->setSegmentStyle( QLCDNumber::Flat ); + levelLCD->setFixedWidth( 70 ); + levelLCD->setPalette( pal ); + hb->addWidget( levelLCD ); + hb->addStretch( 10 ); + + label = new QLabel( i18n("Ships"), mainWin ); + label->setFont( labelFont ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hb->addWidget( label ); + + shipsLCD = new QLCDNumber( 1, mainWin ); + shipsLCD->setFrameStyle( QFrame::NoFrame ); + shipsLCD->setSegmentStyle( QLCDNumber::Flat ); + shipsLCD->setFixedWidth( 40 ); + shipsLCD->setPalette( pal ); + hb->addWidget( shipsLCD ); + + hb->addStrut( 30 ); + + QFrame *sep = new QFrame( mainWin ); + sep->setMaximumHeight( 5 ); + sep->setFrameStyle( QFrame::HLine | QFrame::Raised ); + sep->setPalette( pal ); + + vb->addWidget( sep ); + + vb->addWidget( view, 10 ); + +// -- bottom layout: + QFrame *sep2 = new QFrame( mainWin ); + sep2->setMaximumHeight( 1 ); + sep2->setFrameStyle( QFrame::HLine | QFrame::Raised ); + sep2->setPalette( pal ); + vb->addWidget( sep2, 1 ); + + vb->addLayout( hbd ); + + QFont smallFont( KGlobalSettings::generalFont().family(), 14 ); + hbd->addSpacing( 10 ); + + QString sprites_prefix = + KGlobal::dirs()->findResourceDir("sprite", "rock1/rock10000.png"); +/* + label = new QLabel( i18n( "T" ), mainWin ); + label->setFont( smallFont ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hbd->addWidget( label ); + + teleportsLCD = new QLCDNumber( 1, mainWin ); + teleportsLCD->setFrameStyle( QFrame::NoFrame ); + teleportsLCD->setSegmentStyle( QLCDNumber::Flat ); + teleportsLCD->setPalette( pal ); + teleportsLCD->setFixedHeight( 20 ); + hbd->addWidget( teleportsLCD ); + + hbd->addSpacing( 10 ); +*/ + QPixmap pm( sprites_prefix + "powerups/brake.png" ); + label = new QLabel( mainWin ); + label->setPixmap( pm ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hbd->addWidget( label ); + + brakesLCD = new QLCDNumber( 1, mainWin ); + brakesLCD->setFrameStyle( QFrame::NoFrame ); + brakesLCD->setSegmentStyle( QLCDNumber::Flat ); + brakesLCD->setPalette( pal ); + brakesLCD->setFixedHeight( 20 ); + hbd->addWidget( brakesLCD ); + + hbd->addSpacing( 10 ); + + pm.load( sprites_prefix + "powerups/shield.png" ); + label = new QLabel( mainWin ); + label->setPixmap( pm ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hbd->addWidget( label ); + + shieldLCD = new QLCDNumber( 1, mainWin ); + shieldLCD->setFrameStyle( QFrame::NoFrame ); + shieldLCD->setSegmentStyle( QLCDNumber::Flat ); + shieldLCD->setPalette( pal ); + shieldLCD->setFixedHeight( 20 ); + hbd->addWidget( shieldLCD ); + + hbd->addSpacing( 10 ); + + pm.load( sprites_prefix + "powerups/shoot.png" ); + label = new QLabel( mainWin ); + label->setPixmap( pm ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hbd->addWidget( label ); + + shootLCD = new QLCDNumber( 1, mainWin ); + shootLCD->setFrameStyle( QFrame::NoFrame ); + shootLCD->setSegmentStyle( QLCDNumber::Flat ); + shootLCD->setPalette( pal ); + shootLCD->setFixedHeight( 20 ); + hbd->addWidget( shootLCD ); + + hbd->addStretch( 1 ); + + label = new QLabel( i18n( "Fuel" ), mainWin ); + label->setFont( smallFont ); + label->setFixedWidth( label->sizeHint().width() + 10 ); + label->setPalette( pal ); + hbd->addWidget( label ); + + powerMeter = new KALedMeter( mainWin ); + powerMeter->setFrameStyle( QFrame::Box | QFrame::Plain ); + powerMeter->setRange( MAX_POWER_LEVEL ); + powerMeter->addColorRange( 10, darkRed ); + powerMeter->addColorRange( 20, QColor(160, 96, 0) ); + powerMeter->addColorRange( 70, darkGreen ); + powerMeter->setCount( 40 ); + powerMeter->setPalette( pal ); + powerMeter->setFixedSize( 200, 12 ); + hbd->addWidget( powerMeter ); + + initKAction(); + + setCentralWidget( mainWin ); + + setupGUI( KMainWindow::Save | Create ); + + setFocusPolicy( StrongFocus ); + setFocus(); + +#ifdef KA_ENABLE_SOUND + soundServer = new Arts::SimpleSoundServer( + Arts::Reference("global:Arts_SimpleSoundServer") ); +#endif + + loadSettings(); + slotNewGame(); + installEventFilter(this); +} + +KAstTopLevel::~KAstTopLevel() +{ +#if defined Q_WS_X11 && ! defined K_WS_QTONLY + XAutoRepeatOn( qt_xdisplay() ); +#endif + soundDict.setAutoDelete(true); + soundDict.clear(); +#ifdef KA_ENABLE_SOUND + delete soundServer; +#endif +} + +void KAstTopLevel::initKAction() +{ +// game + KStdGameAction::gameNew( this, SLOT( slotNewGame() ), actionCollection() ); + KStdGameAction::highscores( this, SLOT( slotShowHighscores() ), actionCollection() ); + KStdGameAction::pause( this, SLOT( slotPause() ), actionCollection() ); + KStdGameAction::quit(this, SLOT( close() ), actionCollection()); + +// settings + KStdAction::keyBindings(this, SLOT( slotKeyConfig() ), actionCollection()); + KStdAction::preferences(this, SLOT( slotPref() ), actionCollection()); + +// keyboard-only actions + keycodes.insert(Thrust, new KAction(i18n("Thrust"), Qt::Key_Up, 0, 0, actionCollection(), "Thrust")); + keycodes.insert(RotateLeft, new KAction(i18n("Rotate Left"), Qt::Key_Left, 0, 0, actionCollection(), "RotateLeft")); + keycodes.insert(RotateRight, new KAction(i18n("Rotate Right"), Qt::Key_Right, 0, 0, actionCollection(), "RotateRight")); + keycodes.insert(Shoot, new KAction(i18n("Shoot"), Qt::Key_Space, 0, 0, actionCollection(), "Shoot")); +// keycodes.insert(Teleport, new KAction(i18n("Teleport"), Qt::Key_Z, 0, 0, actionCollection(), "Teleport")); + keycodes.insert(Brake, new KAction(i18n("Brake"), Qt::Key_X, 0, 0, actionCollection(), "Brake")); + keycodes.insert(Shield, new KAction(i18n("Shield"), Qt::Key_S, 0, 0, actionCollection(), "Shield")); + launchAction = new KAction(i18n("Launch"), Qt::Key_L, this, SLOT(slotLaunch()), actionCollection(), "Launch"); +} + + +void KAstTopLevel::loadSettings() +{ + soundDict.insert("ShipDestroyed", + new QString( locate("sounds", Settings::soundShipDestroyed())) ); + soundDict.insert("RockDestroyed", + new QString( locate("sounds", Settings::soundRockDestroyed())) ); + + shipsRemain = Settings::numShips(); +} + +void KAstTopLevel::playSound( const char *snd ) +{ +// KAudioPlayer sometimes seem to be a little bit...slow +// it takes a moment until the sound is played - maybe an arts problem +// but it's a good temporary solution + if (!Settings::playSounds()) + return; + + QString *filename = soundDict[ snd ]; + if (filename) { + KAudioPlayer::play(*filename); + } + +return; // remove this and the above when the sound below is working correctly +#ifdef KA_ENABLE_SOUND + QString *filename = soundDict[ snd ]; + if (filename) { + kdDebug(12012)<< "playing " << *filename << endl; + if(!soundServer->isNull()) soundServer->play(filename->latin1()); + } +#endif +} + +bool KAstTopLevel::eventFilter( QObject* /* object */, QEvent *event ) +{ + QKeyEvent *e = static_cast<QKeyEvent*>(event); + if (event->type() == QEvent::AccelOverride) + { + if (processKeyPress(e)) return true; + else return false; + } + else if (event->type() == QEvent::KeyRelease) + { + if (processKeyRelease(e)) return true; + else return false; + } + return false; +} + +bool KAstTopLevel::processKeyPress( QKeyEvent *event ) +{ + KKey key(event); + Action a = Invalid; + QMap<Action, KAction*>::Iterator it = keycodes.begin(); + for (; it != keycodes.end(); ++it) + { + if ( (*it)->shortcut().contains(key) ) + { + a = it.key(); + break; + } + } + switch ( a ) + { + case RotateLeft: + view->rotateLeft( true ); + break; + + case RotateRight: + view->rotateRight( true ); + break; + + case Thrust: + view->thrust( true ); + break; + + case Shoot: + if (gameOver) + slotNewGame(); + else + view->shoot( true ); + break; + + case Shield: + view->setShield( true ); + break; + +/* case Teleport: + view->teleport( true ); + break;*/ + + case Brake: + view->brake( true ); + break; + + case Invalid: + default: + return false; + } + return true; +} + +bool KAstTopLevel::processKeyRelease( QKeyEvent *event ) +{ + KKey key(event); + Action a = Invalid; + QMap<Action, KAction*>::Iterator it = keycodes.begin(); + for (; it != keycodes.end(); ++it) + { + if ( (*it)->shortcut().contains(key) ) + { + a = it.key(); + break; + } + } + switch ( a ) + { + case RotateLeft: + view->rotateLeft( false ); + break; + + case RotateRight: + view->rotateRight( false ); + break; + + case Thrust: + view->thrust( false ); + break; + + case Shoot: + view->shoot( false ); + break; + + case Brake: + view->brake( false ); + break; + + case Shield: + view->setShield( false ); + break; + +/* case Teleport: + view->teleport( false ); + break;*/ + + case Invalid: + default: + return false; + } + + return true; +} + +void KAstTopLevel::focusInEvent( QFocusEvent *e ) +{ + view->pause( false ); +#if defined Q_WS_X11 && ! defined K_WS_QTONLY + XAutoRepeatOff( qt_xdisplay() ); +#endif + KMainWindow::focusInEvent(e); +} + +void KAstTopLevel::focusOutEvent( QFocusEvent *e ) +{ + view->pause( true ); +#if defined Q_WS_X11 && ! defined K_WS_QTONLY + XAutoRepeatOn( qt_xdisplay() ); +#endif + KMainWindow::focusOutEvent(e); +} + +void KAstTopLevel::slotNewGame() +{ + loadSettings(); + score = 0; + scoreLCD->display( 0 ); + level = 0; + levelLCD->display( level ); + shipsLCD->display( shipsRemain-1 ); + view->newGame(); + view->setRockSpeed( levels[0].rockSpeed ); + view->addRocks( levels[0].nrocks ); + view->showText( i18n( "Press %1 to launch." ) + .arg(launchAction->shortcut().seq(0).toString()), + yellow ); + waitShip = true; + gameOver = false; +} + +bool KAstTopLevel::queryExit() +{ +#if defined Q_WS_X11 && ! defined K_WS_QTONLY + XAutoRepeatOn( qt_xdisplay() ); +#endif + return true; +} + +void KAstTopLevel::slotShipKilled() +{ + shipsRemain--; + shipsLCD->display( shipsRemain-1 ); + + playSound( "ShipDestroyed" ); + + if ( shipsRemain ) + { + waitShip = true; + view->showText( i18n( "Ship Destroyed. Press %1 to launch.") + .arg(launchAction->shortcut().seq(0).toString()), + yellow ); + } + else + { + view->showText( i18n("Game Over!"), red ); + view->endGame(); + doStats(); + KScoreDialog d(KScoreDialog::Name | KScoreDialog::Level | KScoreDialog::Score, this); + KScoreDialog::FieldInfo scoreInfo; + scoreInfo[KScoreDialog::Level].setNum(level); + + if (d.addScore(score, scoreInfo) || Settings::showHiscores()) + { + // Show highscore and ask for name. + d.exec(); + slotGameOver(); + } + else + { + QTimer::singleShot(1000, this, SLOT(slotGameOver())); + } + } +} + +void KAstTopLevel::slotGameOver() +{ + gameOver = true; +} + +void KAstTopLevel::slotRockHit( int size ) +{ + switch ( size ) + { + case 0: + score += 10; + break; + + case 1: + score += 20; + break; + + default: + score += 40; + } + + playSound( "RockDestroyed" ); + + scoreLCD->display( score ); +} + +void KAstTopLevel::slotRocksRemoved() +{ + level++; + + if ( level >= MAX_LEVELS ) + level = MAX_LEVELS - 1; + + view->setRockSpeed( levels[level-1].rockSpeed ); + view->addRocks( levels[level-1].nrocks ); + + levelLCD->display( level ); +} + +void KAstTopLevel::slotKeyConfig() +{ + KKeyDialog::configure( actionCollection(), this ); + if ( waitShip ) view->showText( i18n( "Press %1 to launch." ) + .arg(launchAction->shortcut().seq(0).toString()), + yellow, false ); +} + +void KAstTopLevel::slotPref() +{ + if(KConfigDialog::showDialog("settings")) + return; + + KConfigDialog *dialog = new KConfigDialog(this, "settings", Settings::self(), KDialogBase::Swallow); + + /* Make widget */ + QWidget *w = new QWidget(0, "Settings"); + QVBoxLayout *page = new QVBoxLayout( w, 11 ); + + QHBoxLayout *hb = new QHBoxLayout( page, 11 ); + QLabel *label = new QLabel( i18n("Start new game with"), w ); + QSpinBox* sb = new QSpinBox( 1, 5, 1, w, "kcfg_numShips" ); + sb->setValue(3); + QLabel *lb = new QLabel( i18n(" ships."), w ); + QSpacerItem* hspacer = new QSpacerItem( 16, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + hb->addWidget(label); + hb->addWidget(sb); + hb->addWidget(lb); + hb->addItem(hspacer); + + QCheckBox *f1 = new QCheckBox(i18n("Show highscores on Game Over"), w, "kcfg_showHiscores"); + QCheckBox *f2 = new QCheckBox(i18n("Player can destroy Powerups"), w, "kcfg_canDestroyPowerups"); + f2->setChecked(true); + page->addWidget(f1); + page->addWidget(f2); + QSpacerItem* spacer = new QSpacerItem( 20, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + page->addItem( spacer ); + /* Done */ + + dialog->addPage(w, i18n("General"), "package_settings"); + connect(dialog, SIGNAL(settingsChanged()), this, SLOT(loadSettings())); + dialog->show(); +} + +void KAstTopLevel::slotShowHighscores() +{ + KScoreDialog d(KScoreDialog::Name | KScoreDialog::Level | KScoreDialog::Score, this); + d.exec(); +} + +void KAstTopLevel::doStats() +{ + QString r; + if ( view->shots() ) + r = KGlobal::locale()->formatNumber(( (float)view->hits() / + (float)view->shots() ) * 100, 2 ); + else + r = KGlobal::locale()->formatNumber( 0.0, 2 ); + + QString s = i18n( "Game Over\n\n" + "Shots fired:\t%1\n" + " Hit:\t%2\n" + " Missed:\t%3\n" + "Hit ratio:\t%4 %\t\t") + .arg(view->shots()).arg(view->hits()) + .arg(view->shots() - view->hits()) + .arg(r); + + view->showText( s, green, FALSE ); +} + +void KAstTopLevel::slotUpdateVitals() +{ + brakesLCD->display( view->brakeCount() ); + shieldLCD->display( view->shieldCount() ); + shootLCD->display( view->shootCount() ); +// teleportsLCD->display( view->teleportCount() ); + powerMeter->setValue( view->power() ); +} + +void KAstTopLevel::slotPause() +{ + KMessageBox::information( this, + i18n("KAsteroids is paused."), + i18n("Paused") ); + //Hack (montel@kde.org) + //To create "pause" action we display a messagebox + //and we "play" when we close this messagebox + //so before this action was 'checked/uncheched' + //so I force to unchecked it when we close messagebox. + KToggleAction * act = (KToggleAction *)(sender()); + act->setChecked(false); +} + +void KAstTopLevel::slotLaunch() +{ + if ( waitShip ) + { + view->newShip(); + waitShip = false; + view->hideText(); + } +} diff --git a/kasteroids/toplevel.h b/kasteroids/toplevel.h new file mode 100644 index 00000000..70545f71 --- /dev/null +++ b/kasteroids/toplevel.h @@ -0,0 +1,94 @@ +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#ifndef __KAST_TOPLEVEL_H__ +#define __KAST_TOPLEVEL_H__ + +#include <kmainwindow.h> +#include <kaccel.h> +#include <qdict.h> +#include <qmap.h> + +#include "view.h" + +//#define KA_ENABLE_SOUND + +class KALedMeter; +class QLCDNumber; +class KDialogBase; + +class KAstTopLevel : public KMainWindow +{ + Q_OBJECT +public: + KAstTopLevel(); + virtual ~KAstTopLevel(); + +private: + void initKAction(); + void playSound( const char *snd ); + void readSoundMapping(); + void doStats(); + bool queryExit(); + bool processKeyPress( QKeyEvent *event ); + bool processKeyRelease( QKeyEvent *event ); + +protected: + virtual bool eventFilter( QObject *object, QEvent *event ); + virtual void focusInEvent( QFocusEvent *event ); + virtual void focusOutEvent( QFocusEvent *event ); + +private slots: + void loadSettings(); + void slotNewGame(); + void slotGameOver(); + + void slotShipKilled(); + void slotRockHit( int size ); + void slotRocksRemoved(); + + void slotUpdateVitals(); + + void slotKeyConfig(); + void slotPref(); + void slotShowHighscores(); + + void slotPause(); + void slotLaunch(); + +private: + KAsteroidsView *view; + QLCDNumber *scoreLCD; + QLCDNumber *levelLCD; + QLCDNumber *shipsLCD; + + QLCDNumber *teleportsLCD; +// QLCDNumber *bombsLCD; + QLCDNumber *brakesLCD; + QLCDNumber *shieldLCD; + QLCDNumber *shootLCD; + KALedMeter *powerMeter; + + QDict<QString> soundDict; + + // waiting for user to press Enter to launch a ship + bool waitShip; + bool gameOver; + + int shipsRemain; + int score; + int level; + + enum Action { Invalid, Launch, Thrust, RotateLeft, RotateRight, Shoot, + Teleport, Brake, Shield }; + + QMap<Action, KAction*> keycodes; + + KAction *launchAction; +}; + +#endif + diff --git a/kasteroids/version.h b/kasteroids/version.h new file mode 100644 index 00000000..5ab917a4 --- /dev/null +++ b/kasteroids/version.h @@ -0,0 +1 @@ +#define KASTEROIDS_VERSION "2.3" diff --git a/kasteroids/view.cpp b/kasteroids/view.cpp new file mode 100644 index 00000000..8ca358fd --- /dev/null +++ b/kasteroids/view.cpp @@ -0,0 +1,857 @@ +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#include <stdlib.h> +#include <math.h> +#include <kapplication.h> +#include <kstandarddirs.h> +#include <kglobalsettings.h> + +#include "settings.h" +#include "view.h" +#include "view.moc" + +#define IMG_BACKGROUND "bg.png" +#define SPRITES_PREFIX kapp->kde_datadir() + "/kasteroids/" + +#define REFRESH_DELAY 33 +#define SHIP_SPEED 0.3 +#define MISSILE_SPEED 10.0 +#define SHIP_STEPS 64 +#define ROTATE_RATE 2 +#define SHIELD_ON_COST 1 +#define SHIELD_HIT_COST 30 +#define BRAKE_ON_COST 4 + +#define MAX_ROCK_SPEED 2.5 +#define MAX_POWERUP_SPEED 1.5 +#define MAX_SHIP_SPEED 12 +#define MAX_BRAKES 5 +#define MAX_SHIELDS 5 +#define MAX_FIREPOWER 5 + +#define TEXT_SPEED 4 + +#define PI_X_2 6.283185307 + +static struct +{ + int id; + const char *path; + int frames; +} +kas_animations [] = +{ + { ID_ROCK_LARGE, "rock1/rock1%1.png", 32 }, + { ID_ROCK_MEDIUM, "rock2/rock2%1.png", 32 }, + { ID_ROCK_SMALL, "rock3/rock3%1.png", 32 }, + { ID_SHIP, "ship/ship%1.png", 64 }, + { ID_MISSILE, "missile/missile.png", 1 }, + { ID_BIT, "bits/bits%1.png", 16 }, + { ID_EXHAUST, "exhaust/exhaust.png", 1 }, + { ID_ENERGY_POWERUP, "powerups/energy.png", 1 }, +// { ID_TELEPORT_POWERUP, "powerups/teleport%1.png", 12 }, + { ID_BRAKE_POWERUP, "powerups/brake.png", 1 }, + { ID_SHIELD_POWERUP, "powerups/shield.png", 1 }, + { ID_SHOOT_POWERUP, "powerups/shoot.png", 1 }, + { ID_SHIELD, "shield/shield%1.png", 6 }, + { 0, 0, 0 } +}; + + + +KAsteroidsView::KAsteroidsView( QWidget *parent, const char *name ) + : QWidget( parent, name ), + field(640, 440), + view(&field,this) +{ + view.setVScrollBarMode( QScrollView::AlwaysOff ); + view.setHScrollBarMode( QScrollView::AlwaysOff ); + rocks.setAutoDelete( true ); + missiles.setAutoDelete( true ); + bits.setAutoDelete( true ); + powerups.setAutoDelete( true ); + exhaust.setAutoDelete( true ); + + field.setBackgroundColor(black); + QPixmap pm( locate("sprite", IMG_BACKGROUND) ); + field.setBackgroundPixmap( pm ); + + textSprite = new QCanvasText( &field ); + QFont font( KGlobalSettings::generalFont().family(), 18 ); + textSprite->setFont( font ); + + shield = 0; + shieldOn = false; + refreshRate = REFRESH_DELAY; + + readSprites(); + + shieldTimer = new QTimer( this ); + connect( shieldTimer, SIGNAL(timeout()), this, SLOT(hideShield()) ); + mTimerId = -1; + + shipPower = MAX_POWER_LEVEL; + vitalsChanged = true; + mBrakeCount = 0; + mShootCount = 0; + mShieldCount = 0; +} + +// - - - + +KAsteroidsView::~KAsteroidsView() +{ +} + +// - - - + +void KAsteroidsView::reset() +{ + rocks.clear(); + missiles.clear(); + bits.clear(); + powerups.clear(); + exhaust.clear(); + + shotsFired = 0; + shotsHit = 0; + + rockSpeed = 1.0; + powerupSpeed = 1.0; + mFrameNum = 0; + mPaused = false; + + ship->hide(); + shield->hide(); + + if ( mTimerId >= 0 ) { + killTimer( mTimerId ); + mTimerId = -1; + } +} + +// - -- + +void KAsteroidsView::newGame() +{ + if ( shieldOn ) + { + shield->hide(); + shieldOn = false; + } + reset(); + if ( mTimerId < 0 ) + mTimerId = startTimer( REFRESH_DELAY ); + emit updateVitals(); +} + +// - - - + +void KAsteroidsView::endGame() +{ +} + +void KAsteroidsView::pause( bool p ) +{ + if ( !mPaused && p ) { + if ( mTimerId >= 0 ) { + killTimer( mTimerId ); + mTimerId = -1; + } + } else if ( mPaused && !p ) + mTimerId = startTimer( REFRESH_DELAY ); + mPaused = p; +} + +// - - - + +void KAsteroidsView::newShip() +{ + ship->move( field.width()/2, field.height()/2, 0 ); + shield->move( field.width()/2, field.height()/2, 0 ); + ship->setVelocity( 0.0, 0.0 ); + shipDx = 0; + shipDy = 0; + shipAngle = 0; + rotateL = false; + rotateR = false; + thrustShip = false; + shootShip = false; + brakeShip = false; + teleportShip = false; + shieldOn = true; + shootDelay = 0; + shipPower = MAX_POWER_LEVEL; + rotateRate = ROTATE_RATE; + rotateSlow = 0; + + mBrakeCount = 0; + mTeleportCount = 0; + mShootCount = 0; + + ship->show(); + shield->show(); + mShieldCount = 1; // just in case the ship appears on a rock. + shieldTimer->start( 1000, true ); +} + +void KAsteroidsView::setShield( bool s ) +{ + if ( shieldTimer->isActive() && !s ) { + shieldTimer->stop(); + hideShield(); + } else { + shieldOn = s && mShieldCount; + } +} + +void KAsteroidsView::brake( bool b ) +{ + if ( mBrakeCount ) + { + if ( brakeShip && !b ) + { + rotateL = false; + rotateR = false; + thrustShip = false; + rotateRate = ROTATE_RATE; + } + + brakeShip = b; + } +} + +// - - - + +void KAsteroidsView::readSprites() +{ + QString sprites_prefix = + KGlobal::dirs()->findResourceDir("sprite", "rock1/rock10000.png"); + + int i = 0; + while ( kas_animations[i].id ) + { + animation.insert( kas_animations[i].id, + new QCanvasPixmapArray( sprites_prefix + kas_animations[i].path, + kas_animations[i].frames ) ); + i++; + } + + ship = new QCanvasSprite( animation[ID_SHIP], &field ); + ship->hide(); + + shield = new KShield( animation[ID_SHIELD], &field ); + shield->hide(); +} + +// - - - + +void KAsteroidsView::addRocks( int num ) +{ + for ( int i = 0; i < num; i++ ) + { + KRock *rock = new KRock( animation[ID_ROCK_LARGE], &field, + ID_ROCK_LARGE, krandom.getLong(2), + krandom.getLong(2) ? -1 : 1 ); + double dx = (2.0 - krandom.getDouble()*4.0) * rockSpeed; + double dy = (2.0 - krandom.getDouble()*4.0) * rockSpeed; + rock->setVelocity( dx, dy ); + rock->setFrame( krandom.getLong( rock->frameCount() ) ); + if ( dx > 0 ) + { + if ( dy > 0 ) + rock->move( 5, 5, 0 ); + else + rock->move( 5, field.height() - 25, 0 ); + } + else + { + if ( dy > 0 ) + rock->move( field.width() - 25, 5, 0 ); + else + rock->move( field.width() - 25, field.height() - 25, 0 ); + } + rock->show( ); + rocks.append( rock ); + } +} + +// - - - + +void KAsteroidsView::showText( const QString &text, const QColor &color, bool scroll ) +{ +// textSprite->setTextFlags( AlignHCenter | AlignVCenter ); + textSprite->setText( text ); + textSprite->setColor( color ); + + if ( scroll ) { + textSprite->move( (field.width()-textSprite->boundingRect().width()) / 2, + -textSprite->boundingRect().height() ); + textDy = TEXT_SPEED; + } else { + textSprite->move( (field.width()-textSprite->boundingRect().width()) / 2, + (field.height()-textSprite->boundingRect().height()) / 2 ); + textDy = 0; + } + textSprite->show(); +} + +// - - - + +void KAsteroidsView::hideText() +{ + textDy = -TEXT_SPEED; +} + +// - - - + +void KAsteroidsView::resizeEvent(QResizeEvent* event) +{ + QWidget::resizeEvent(event); + field.resize(width()-4, height()-4); + view.resize(width(),height()); +} + +// - - - + +void KAsteroidsView::timerEvent( QTimerEvent * ) +{ + field.advance(); + + QCanvasSprite *rock; + + // move rocks forward + for ( rock = rocks.first(); rock; rock = rocks.next() ) { + ((KRock *)rock)->nextFrame(); + wrapSprite( rock ); + } + + wrapSprite( ship ); + + // check for missile collision with rocks. + processMissiles(); + + // these are generated when a ship explodes + for ( KBit *bit = bits.first(); bit; bit = bits.next() ) + { + if ( bit->expired() ) + { + bits.removeRef( bit ); + } + else + { + bit->growOlder(); + bit->setFrame( ( bit->frame()+1 ) % bit->frameCount() ); + } + } + + for ( KExhaust *e = exhaust.first(); e; e = exhaust.next() ) + exhaust.removeRef( e ); + + // move / rotate ship. + // check for collision with a rock. + processShip(); + + // move powerups and check for collision with player and missiles + processPowerups(); + + if ( textSprite->isVisible() ) + { + if ( textDy < 0 && + textSprite->boundingRect().y() <= -textSprite->boundingRect().height() ) + textSprite->hide(); + else + { + textSprite->moveBy( 0, textDy ); + } + if ( textSprite->boundingRect().y() > (field.height()-textSprite->boundingRect().height())/2 ) + textDy = 0; + } + + if ( vitalsChanged && !(mFrameNum % 10) ) { + emit updateVitals(); + vitalsChanged = false; + } + + mFrameNum++; +} + +void KAsteroidsView::wrapSprite( QCanvasItem *s ) +{ + int x = int(s->x() + s->boundingRect().width() / 2); + int y = int(s->y() + s->boundingRect().height() / 2); + + if ( x > field.width() ) + s->move( s->x() - field.width(), s->y() ); + else if ( x < 0 ) + s->move( field.width() + s->x(), s->y() ); + + if ( y > field.height() ) + s->move( s->x(), s->y() - field.height() ); + else if ( y < 0 ) + s->move( s->x(), field.height() + s->y() ); +} + +// - - - + +void KAsteroidsView::rockHit( QCanvasItem *hit ) +{ + KPowerup *nPup = 0; + int rnd = static_cast<int>(krandom.getDouble()*30.0) % 30; + switch( rnd ) + { + case 4: + case 5: + nPup = new KPowerup( animation[ID_ENERGY_POWERUP], &field, + ID_ENERGY_POWERUP ); + break; + case 10: +// nPup = new KPowerup( animation[ID_TELEPORT_POWERUP], &field, +// ID_TELEPORT_POWERUP ); + break; + case 15: + nPup = new KPowerup( animation[ID_BRAKE_POWERUP], &field, + ID_BRAKE_POWERUP ); + break; + case 20: + nPup = new KPowerup( animation[ID_SHIELD_POWERUP], &field, + ID_SHIELD_POWERUP ); + break; + case 24: + case 25: + nPup = new KPowerup( animation[ID_SHOOT_POWERUP], &field, + ID_SHOOT_POWERUP ); + break; + } + if ( nPup ) + { + double r = 0.5 - krandom.getDouble(); + nPup->move( hit->x(), hit->y(), 0 ); + nPup->setVelocity( hit->xVelocity() + r, hit->yVelocity() + r ); + nPup->show( ); + powerups.append( nPup ); + } + + if ( hit->rtti() == ID_ROCK_LARGE || hit->rtti() == ID_ROCK_MEDIUM ) + { + // break into smaller rocks + double addx[4] = { 1.0, 1.0, -1.0, -1.0 }; + double addy[4] = { -1.0, 1.0, -1.0, 1.0 }; + + double dx = hit->xVelocity(); + double dy = hit->yVelocity(); + + double maxRockSpeed = MAX_ROCK_SPEED * rockSpeed; + if ( dx > maxRockSpeed ) + dx = maxRockSpeed; + else if ( dx < -maxRockSpeed ) + dx = -maxRockSpeed; + if ( dy > maxRockSpeed ) + dy = maxRockSpeed; + else if ( dy < -maxRockSpeed ) + dy = -maxRockSpeed; + + QCanvasSprite *nrock; + + for ( int i = 0; i < 4; i++ ) + { + double r = rockSpeed/2 - krandom.getDouble()*rockSpeed; + if ( hit->rtti() == ID_ROCK_LARGE ) + { + nrock = new KRock( animation[ID_ROCK_MEDIUM], &field, + ID_ROCK_MEDIUM, krandom.getLong(2), + krandom.getLong(2) ? -1 : 1 ); + emit rockHit( 0 ); + } + else + { + nrock = new KRock( animation[ID_ROCK_SMALL], &field, + ID_ROCK_SMALL, krandom.getLong(2), + krandom.getLong(2) ? -1 : 1 ); + emit rockHit( 1 ); + } + + nrock->move( hit->x(), hit->y(), 0 ); + nrock->setVelocity( dx+addx[i]*rockSpeed+r, dy+addy[i]*rockSpeed+r ); + nrock->setFrame( krandom.getLong( nrock->frameCount() ) ); + nrock->show( ); + rocks.append( nrock ); + } + } + else if ( hit->rtti() == ID_ROCK_SMALL ) + emit rockHit( 2 ); + rocks.removeRef( (QCanvasSprite *)hit ); + if ( rocks.count() == 0 ) + emit rocksRemoved(); +} + +void KAsteroidsView::reducePower( int val ) +{ + shipPower -= val; + if ( shipPower <= 0 ) + { + shipPower = 0; + thrustShip = false; + if ( shieldOn ) + { + shieldOn = false; + shield->hide(); + } + } + vitalsChanged = true; +} + +void KAsteroidsView::addExhaust( double x, double y, double dx, + double dy, int count ) +{ + for ( int i = 0; i < count; i++ ) + { + KExhaust *e = new KExhaust( animation[ID_EXHAUST], &field ); + e->move( x + 2 - krandom.getDouble()*4, y + 2 - krandom.getDouble()*4 ); + e->setVelocity( dx, dy ); + e->show( ); + exhaust.append( e ); + } +} + +void KAsteroidsView::processMissiles() +{ + KMissile *missile; + + // if a missile has hit a rock, remove missile and break rock into smaller + // rocks or remove completely. + QPtrListIterator<KMissile> it(missiles); + + for ( ; it.current(); ++it ) + { + missile = it.current(); + missile->growOlder(); + + if ( missile->expired() ) + { + missiles.removeRef( missile ); + continue; + } + + wrapSprite( missile ); + + QCanvasItemList hits = missile->collisions( true ); + QCanvasItemList::Iterator hit; + for ( hit = hits.begin(); hit != hits.end(); ++hit ) + { + if ( (*hit)->rtti() >= ID_ROCK_LARGE && + (*hit)->rtti() <= ID_ROCK_SMALL ) + { + shotsHit++; + rockHit( *hit ); + missiles.removeRef( missile ); + break; + } + } + } +} + +// - - - + +void KAsteroidsView::processShip() +{ + if ( ship->isVisible() ) + { + if ( shieldOn ) + { + shield->show(); + reducePower( SHIELD_ON_COST ); + static int sf = 0; + sf++; + + if ( sf % 2 ) + shield->setFrame( (shield->frame()+1) % shield->frameCount() ); + shield->move( ship->x() - 9, ship->y() - 9 ); + + QCanvasItemList hits = shield->collisions( true ); + QCanvasItemList::Iterator it; + for ( it = hits.begin(); it != hits.end(); ++it ) + { + if ( (*it)->rtti() >= ID_ROCK_LARGE && + (*it)->rtti() <= ID_ROCK_SMALL ) + { + int factor; + switch ( (*it)->rtti() ) + { + case ID_ROCK_LARGE: + factor = 3; + break; + + case ID_ROCK_MEDIUM: + factor = 2; + break; + + default: + factor = 1; + } + + if ( factor > mShieldCount ) + { + // shield not strong enough + shieldOn = false; + break; + } + rockHit( *it ); + // the more shields we have the less costly + reducePower( factor * (SHIELD_HIT_COST - mShieldCount*2) ); + } + } + } + + if ( !shieldOn ) + { + shield->hide(); + QCanvasItemList hits = ship->collisions( true ); + QCanvasItemList::Iterator it; + for ( it = hits.begin(); it != hits.end(); ++it ) + { + if ( (*it)->rtti() >= ID_ROCK_LARGE && + (*it)->rtti() <= ID_ROCK_SMALL ) + { + KBit *bit; + for ( int i = 0; i < 12; i++ ) + { + bit = new KBit( animation[ID_BIT], &field ); + bit->move( ship->x() + 5 - krandom.getDouble() * 10, + ship->y() + 5 - krandom.getDouble() * 10, + krandom.getLong(bit->frameCount()) ); + bit->setVelocity( 1-krandom.getDouble()*2, + 1-krandom.getDouble()*2 ); + bit->setDeath( 60 + krandom.getLong(60) ); + bit->show( ); + bits.append( bit ); + } + ship->hide(); + shield->hide(); + emit shipKilled(); + break; + } + } + } + + + if ( rotateSlow ) + rotateSlow--; + + if ( rotateL ) + { + shipAngle -= rotateSlow ? 1 : rotateRate; + if ( shipAngle < 0 ) + shipAngle += SHIP_STEPS; + } + + if ( rotateR ) + { + shipAngle += rotateSlow ? 1 : rotateRate; + if ( shipAngle >= SHIP_STEPS ) + shipAngle -= SHIP_STEPS; + } + + double angle = shipAngle * PI_X_2 / SHIP_STEPS; + double cosangle = cos( angle ); + double sinangle = sin( angle ); + + if ( brakeShip ) + { + thrustShip = false; + rotateL = false; + rotateR = false; + rotateRate = ROTATE_RATE; + if ( fabs(shipDx) < 2.5 && fabs(shipDy) < 2.5 ) + { + shipDx = 0.0; + shipDy = 0.0; + ship->setVelocity( shipDx, shipDy ); + brakeShip = false; + } + else + { + double motionAngle = atan2( -shipDy, -shipDx ); + if ( angle > M_PI ) + angle -= PI_X_2; + double angleDiff = angle - motionAngle; + if ( angleDiff > M_PI ) + angleDiff = PI_X_2 - angleDiff; + else if ( angleDiff < -M_PI ) + angleDiff = PI_X_2 + angleDiff; + double fdiff = fabs( angleDiff ); + if ( fdiff > 0.08 ) + { + if ( angleDiff > 0 ) + rotateL = true; + else if ( angleDiff < 0 ) + rotateR = true; + if ( fdiff > 0.6 ) + rotateRate = mBrakeCount + 1; + else if ( fdiff > 0.4 ) + rotateRate = 2; + else + rotateRate = 1; + + if ( rotateRate > 5 ) + rotateRate = 5; + } + else if ( fabs(shipDx) > 1 || fabs(shipDy) > 1 ) + { + thrustShip = true; + // we'll make braking a bit faster + shipDx += cosangle/6 * (mBrakeCount - 1); + shipDy += sinangle/6 * (mBrakeCount - 1); + reducePower( BRAKE_ON_COST ); + addExhaust( ship->x() + 20 - cosangle*22, + ship->y() + 20 - sinangle*22, + shipDx-cosangle, shipDy-sinangle, + mBrakeCount+1 ); + } + } + } + + if ( thrustShip ) + { + // The ship has a terminal velocity, but trying to go faster + // still uses fuel (can go faster diagonally - don't care). + double thrustx = cosangle/4; + double thrusty = sinangle/4; + if ( fabs(shipDx + thrustx) < MAX_SHIP_SPEED ) + shipDx += thrustx; + if ( fabs(shipDy + thrusty) < MAX_SHIP_SPEED ) + shipDy += thrusty; + ship->setVelocity( shipDx, shipDy ); + reducePower( 1 ); + addExhaust( ship->x() + 20 - cosangle*20, + ship->y() + 20 - sinangle*20, + shipDx-cosangle, shipDy-sinangle, 3 ); + } + + ship->setFrame( shipAngle ); + + if ( shootShip ) + { + if ( !shootDelay && (int)missiles.count() < mShootCount + 2 ) + { + KMissile *missile = new KMissile( animation[ID_MISSILE], &field ); + missile->move( 21+ship->x()+cosangle*10, + 21+ship->y()+sinangle*10, 0 ); + missile->setVelocity( shipDx + cosangle*MISSILE_SPEED, + shipDy + sinangle*MISSILE_SPEED ); + missile->show( ); + missiles.append( missile ); + shotsFired++; + reducePower( 1 ); + + shootDelay = 5; + } + + if ( shootDelay ) + shootDelay--; + } + + if ( teleportShip ) + { + int ra = rand() % 10; + if( ra == 0 ) + ra += rand() % 20; + int xra = ra * 60 + ( (rand() % 20) * (rand() % 20) ); + int yra = ra * 50 - ( (rand() % 20) * (rand() % 20) ); + ship->move( xra, yra ); + } + + vitalsChanged = true; + } +} + +// - - - + +void KAsteroidsView::processPowerups() +{ + if ( !powerups.isEmpty() ) + { + // if player gets the powerup remove it from the screen, if option + // "Can destroy powerups" is enabled and a missile hits the powerup + // destroy it + + KPowerup *pup; + QPtrListIterator<KPowerup> it( powerups ); + + for( ; (pup = it.current()); ) + { + ++it; // We have to increase here, because pup may get deleted. + pup->growOlder(); + + if( pup->expired() ) + { + powerups.removeRef( pup ); + continue; + } + + wrapSprite( pup ); + + QCanvasItemList hits = pup->collisions( true ); + QCanvasItemList::Iterator it; + for ( it = hits.begin(); it != hits.end(); ++it ) + { + if ( (*it) == ship || (*it) == shield ) + { + switch( pup->rtti() ) + { + case ID_ENERGY_POWERUP: + shipPower += 150; + if ( shipPower > MAX_POWER_LEVEL ) + shipPower = MAX_POWER_LEVEL; + break; + case ID_TELEPORT_POWERUP: + mTeleportCount++; + break; + case ID_BRAKE_POWERUP: + if ( mBrakeCount < MAX_BRAKES ) + mBrakeCount++; + break; + case ID_SHIELD_POWERUP: + if ( mShieldCount < MAX_SHIELDS ) + mShieldCount++; + break; + case ID_SHOOT_POWERUP: + if ( mShootCount < MAX_FIREPOWER ) + mShootCount++; + break; + } + + powerups.removeRef( pup ); + vitalsChanged = true; + break; + } + + if ( (*it)->rtti() == ID_MISSILE ) + { + if ( Settings::canDestroyPowerups() ) + { + powerups.removeRef( pup ); + break; + } + } + } + } + } // -- if( powerups.isEmpty() ) +} + +// - - - + +void KAsteroidsView::hideShield() +{ + shield->hide(); + mShieldCount = 0; + shieldOn = false; +} + + +// - - - + diff --git a/kasteroids/view.h b/kasteroids/view.h new file mode 100644 index 00000000..6807037a --- /dev/null +++ b/kasteroids/view.h @@ -0,0 +1,133 @@ +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#ifndef __AST_VIEW_H__ +#define __AST_VIEW_H__ + +#include <qwidget.h> +#include <qptrlist.h> +#include <qtimer.h> +#include <qcanvas.h> +#include <qintdict.h> +#include "sprites.h" +#include <krandomsequence.h> + +#define MAX_POWER_LEVEL 1000 + +class KAsteroidsView : public QWidget +{ + Q_OBJECT +public: + KAsteroidsView( QWidget *parent = 0, const char *name = 0 ); + virtual ~KAsteroidsView(); + + int refreshRate; + + void reset(); + void setRockSpeed( double rs ) { rockSpeed = rs; } + void addRocks( int num ); + void newGame(); + void endGame(); + void newShip(); + + void rotateLeft( bool r ) { rotateL = r; rotateSlow = 5; } + void rotateRight( bool r ) { rotateR = r; rotateSlow = 5; } + void thrust( bool t ) { thrustShip = t && shipPower > 0; } + void shoot( bool s ) { shootShip = s; shootDelay = 0; } + void setShield( bool s ); + void teleport( bool te) { teleportShip = te && mTeleportCount; } + void brake( bool b ); + void pause( bool p); + + void showText( const QString &text, const QColor &color, bool scroll=TRUE ); + void hideText(); + + int shots() const { return shotsFired; } + int hits() const { return shotsHit; } + int power() const { return shipPower; } + + int teleportCount() const { return mTeleportCount; } + int brakeCount() const { return mBrakeCount; } + int shieldCount() const { return mShieldCount; } + int shootCount() const { return mShootCount; } + +signals: + void shipKilled(); + void rockHit( int size ); + void rocksRemoved(); + void updateVitals(); + +private slots: + void hideShield(); + +protected: + void readSprites(); + void wrapSprite( QCanvasItem * ); + void rockHit( QCanvasItem * ); + void reducePower( int val ); + void addExhaust( double x, double y, double dx, double dy, int count ); + void processMissiles(); + void processShip(); + void processPowerups(); + void processShield(); + + virtual void resizeEvent( QResizeEvent *event ); + virtual void timerEvent( QTimerEvent * ); + +private: + QCanvas field; + QCanvasView view; + QIntDict<QCanvasPixmapArray> animation; + QPtrList<QCanvasSprite> rocks; + QPtrList<KMissile> missiles; + QPtrList<KBit> bits; + QPtrList<KExhaust> exhaust; + QPtrList<KPowerup> powerups; + KShield *shield; + QCanvasSprite *ship; + QCanvasText *textSprite; + + bool rotateL; + bool rotateR; + bool thrustShip; + bool shootShip; + bool teleportShip; + bool brakeShip; + bool pauseShip; + bool shieldOn; + + bool vitalsChanged; + + int shipAngle; + int rotateSlow; + int rotateRate; + int shipPower; + + int shotsFired; + int shotsHit; + int shootDelay; + + int mBrakeCount; + int mShieldCount; + int mTeleportCount; + int mShootCount; + + double shipDx; + double shipDy; + + int textDy; + int mFrameNum; + bool mPaused; + int mTimerId; + + double rockSpeed; + double powerupSpeed; + + KRandomSequence krandom; + QTimer *shieldTimer; +}; + +#endif |