summaryrefslogtreecommitdiff
authorandyq <andyq>2002-12-20 22:57:16 (UTC)
committer andyq <andyq>2002-12-20 22:57:16 (UTC)
commit12a964a2f8837ee981284f3ee902baae0c7b1f77 (patch) (unidiff)
treec89f1e29e40f8aa1d0b1f2940b7227ce6c75bf01
parent48efd0d81aad0c3d0a64baabbc46fde593eb086c (diff)
downloadopie-12a964a2f8837ee981284f3ee902baae0c7b1f77.zip
opie-12a964a2f8837ee981284f3ee902baae0c7b1f77.tar.gz
opie-12a964a2f8837ee981284f3ee902baae0c7b1f77.tar.bz2
Fixed small bugette with cursor keys
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/sfcave/sfcave.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/noncore/games/sfcave/sfcave.cpp b/noncore/games/sfcave/sfcave.cpp
index 5633a8f..c1e4532 100644
--- a/noncore/games/sfcave/sfcave.cpp
+++ b/noncore/games/sfcave/sfcave.cpp
@@ -206,64 +206,61 @@ void SFCave :: setSeed( int seed )
206{ 206{
207 if ( seed == -1 ) 207 if ( seed == -1 )
208 currentSeed = ((unsigned long) time((time_t *) NULL)); 208 currentSeed = ((unsigned long) time((time_t *) NULL));
209 else 209 else
210 currentSeed = seed; 210 currentSeed = seed;
211 PutSeed( currentSeed ); 211 PutSeed( currentSeed );
212} 212}
213 213
214int SFCave :: nextInt( int range ) 214int SFCave :: nextInt( int range )
215{ 215{
216 int val = (int)(Random( ) * range); 216 int val = (int)(Random( ) * range);
217 217
218 return val; 218 return val;
219 219
220} 220}
221 221
222void SFCave :: setUp() 222void SFCave :: setUp()
223{ 223{
224 score = 0; 224 score = 0;
225 offset = 0; 225 offset = 0;
226 nrFrames = 0; 226 nrFrames = 0;
227 dir = 1; 227 dir = 1;
228 thrust = 0; 228 thrust = 0;
229 229
230 int dist[] = { 100, 60, 40 };
231 if ( CURRENT_GAME_TYPE == SFCAVE_GAME ) 230 if ( CURRENT_GAME_TYPE == SFCAVE_GAME )
232 { 231 {
233 thrustUp = UpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; 232 thrustUp = UpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];;
234 noThrust = DownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; 233 noThrust = DownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];;
235 maxUpThrust = MaxUpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; 234 maxUpThrust = MaxUpThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];;
236 maxDownThrust = MaxDownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];; 235 maxDownThrust = MaxDownThrustVals[SFCAVE_GAME_TYPE][currentGameDifficulty];;
237 236
238 if ( currentCameDifficulty == DIFICULTY_EASY ) 237 if ( currentGameDifficulty == DIFICULTY_EASY )
239 gateDistance = 100; 238 gateDistance = 100;
240 else if ( currentCameDifficulty == DIFICULTY_EASY ) 239 else if ( currentGameDifficulty == DIFICULTY_EASY )
241 gateDistance = 60; 240 gateDistance = 60;
242 else 241 else
243 gateDistance = 40; 242 gateDistance = 40;
244
245 printf( "GD = %d\n", gateDistance );
246 } 243 }
247 else if ( CURRENT_GAME_TYPE == GATES_GAME ) 244 else if ( CURRENT_GAME_TYPE == GATES_GAME )
248 { 245 {
249 thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; 246 thrustUp = UpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];;
250 noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; 247 noThrust = DownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];;
251 maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; 248 maxUpThrust = MaxUpThrustVals[GATES_GAME_TYPE][currentGameDifficulty];;
252 maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];; 249 maxDownThrust = MaxDownThrustVals[GATES_GAME_TYPE][currentGameDifficulty];;
253 gateDistance = 75; 250 gateDistance = 75;
254 nextGate = nextInt( 50 ) + gateDistance; 251 nextGate = nextInt( 50 ) + gateDistance;
255 } 252 }
256 else 253 else
257 { 254 {
258 thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; 255 thrustUp = UpThrustVals[FLY_GAME_TYPE][currentGameDifficulty];
259 noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; 256 noThrust = DownThrustVals[FLY_GAME_TYPE][currentGameDifficulty];
260 maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; 257 maxUpThrust = MaxUpThrustVals[FLY_GAME_TYPE][currentGameDifficulty];
261 maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty]; 258 maxDownThrust = MaxDownThrustVals[FLY_GAME_TYPE][currentGameDifficulty];
262 } 259 }
263 260
264 crashLineLength = 0; 261 crashLineLength = 0;
265 lastGateBottomY = 0; 262 lastGateBottomY = 0;
266 263
267 user.setRect( 50, sWidth/2, 4, 4 ); 264 user.setRect( 50, sWidth/2, 4, 4 );
268 265
269 blockWidth = 20; 266 blockWidth = 20;
@@ -770,94 +767,94 @@ void SFCave :: handleKeys()
770 if ( press ) 767 if ( press )
771 thrust -= 0.5; 768 thrust -= 0.5;
772 else 769 else
773 thrust += 0.8; 770 thrust += 0.8;
774 771
775 if ( thrust > 5.0 ) 772 if ( thrust > 5.0 )
776 thrust = 5.0; 773 thrust = 5.0;
777 else if ( thrust < -3.5 ) 774 else if ( thrust < -3.5 )
778 thrust = -3.5; 775 thrust = -3.5;
779 } 776 }
780 user.moveBy( 0, (int)thrust ); 777 user.moveBy( 0, (int)thrust );
781} 778}
782 779
783void SFCave :: keyPressEvent( QKeyEvent *e ) 780void SFCave :: keyPressEvent( QKeyEvent *e )
784{ 781{
785 if ( state == STATE_MENU ) 782 if ( state == STATE_MENU )
786 handleMenuKeys( e ); 783 handleMenuKeys( e );
787 else 784 else
788 { 785 {
789 switch( e->key() ) 786 switch( e->key() )
790 { 787 {
791 case Qt::Key_Up: 788 case Qt::Key_Up:
792 case Qt::Key_F9: 789 case Qt::Key_F9:
793 case Qt::Key_Space: 790 case Qt::Key_Space:
794 if ( !replay && !press ) 791 if ( state == STATE_RUNNING && !replay && !press )
795 { 792 {
796 press = true; 793 press = true;
797 replayList.append( new int( nrFrames ) ); 794 replayList.append( new int( nrFrames ) );
798 } 795 }
796 else if ( state == STATE_CRASHED && e->key() == Key_Up )
797 state = STATE_NEWGAME;
799 break; 798 break;
800 case Qt::Key_M: 799 case Qt::Key_M:
801 case Qt::Key_Return: 800 case Qt::Key_Return:
802 case Qt::Key_Enter: 801 case Qt::Key_Enter:
803 if ( state == STATE_CRASHED ) 802 if ( state == STATE_CRASHED )
804 { 803 {
805 state = STATE_MENU; 804 state = STATE_MENU;
806 currentMenuNr = 0; 805 currentMenuNr = 0;
807 currentMenuOption[currentMenuNr] = 0; 806 currentMenuOption[currentMenuNr] = 0;
808 } 807 }
809 break; 808 break;
810 809
811 case Qt::Key_Z: 810 case Qt::Key_Z:
812 showScoreZones = !showScoreZones; 811 showScoreZones = !showScoreZones;
813 break; 812 break;
814 813
815 default: 814 default:
816 e->ignore(); 815 e->ignore();
817 break; 816 break;
818 } 817 }
819 } 818 }
820} 819}
821 820
822void SFCave :: keyReleaseEvent( QKeyEvent *e ) 821void SFCave :: keyReleaseEvent( QKeyEvent *e )
823{ 822{
824 if ( state == STATE_MENU ) 823 if ( state == STATE_MENU )
825 { 824 {
826 } 825 }
827 else 826 else
828 { 827 {
829 switch( e->key() ) 828 switch( e->key() )
830 { 829 {
831 case Qt::Key_F9: 830 case Qt::Key_F9:
832 case Qt::Key_Space: 831 case Qt::Key_Space:
833 case Qt::Key_Up: 832 case Qt::Key_Up:
834 if ( !replay && press ) 833 press = false;
835 { 834 if ( state == STATE_RUNNING && !replay && press )
836 press = false;
837
838 replayList.append( new int( nrFrames ) ); 835 replayList.append( new int( nrFrames ) );
839 } 836
840 break; 837 break;
841 838
842 case Qt::Key_R: 839 case Qt::Key_R:
843 if ( state == STATE_CRASHED ) 840 if ( state == STATE_CRASHED )
844 { 841 {
845 state = STATE_REPLAY; 842 state = STATE_REPLAY;
846 } 843 }
847 break; 844 break;
848 845
849 case Qt::Key_Down: 846 case Qt::Key_Down:
850 if ( state == STATE_CRASHED ) 847 if ( state == STATE_CRASHED )
851 state = STATE_NEWGAME; 848 state = STATE_NEWGAME;
852 break; 849 break;
853 850
854 case Qt::Key_S: 851 case Qt::Key_S:
855 if ( state == STATE_CRASHED ) 852 if ( state == STATE_CRASHED )
856 saveReplay(); 853 saveReplay();
857 break; 854 break;
858 855
859 case Qt::Key_L: 856 case Qt::Key_L:
860 if ( state == STATE_CRASHED ) 857 if ( state == STATE_CRASHED )
861 loadReplay(); 858 loadReplay();
862 break; 859 break;
863 default: 860 default: