| 1 |
Description: a mousepress is also an anykey |
| 2 |
When the use is asked to "press any key", accept a mousepress to, |
| 3 |
so the user does not have touse the keyboard in a mouse-driven game. |
| 4 |
Forwarded: no |
| 5 |
Author: Evgeni Golov <[email protected]> |
| 6 |
Last-Update: 2008-10-26 |
| 7 |
|
| 8 |
Index: blocks-of-the-undead-1.0/TetrisAttack/src/CTetrisGame.cpp |
| 9 |
=================================================================== |
| 10 |
--- blocks-of-the-undead-1.0.orig/TetrisAttack/src/CTetrisGame.cpp 2012-05-01 20:13:20.321936666 +0200 |
| 11 |
+++ blocks-of-the-undead-1.0/TetrisAttack/src/CTetrisGame.cpp 2012-05-01 20:13:26.317980862 +0200 |
| 12 |
@@ -363,42 +363,7 @@ |
| 13 |
|
| 14 |
case Splash: |
| 15 |
{ |
| 16 |
- state = SinglePlayerPuzzle; |
| 17 |
- int a = 1, b = 1; |
| 18 |
- |
| 19 |
- string file; |
| 20 |
-#if defined(WIN32) || defined(_WIN32) |
| 21 |
- file = CImgLoader::getPath() + "/progress.txt"; |
| 22 |
-#else |
| 23 |
- char *homedir = getenv("HOME"); |
| 24 |
- if (homedir != NULL) |
| 25 |
- { |
| 26 |
- file = string(homedir) + "/.blocks-progress"; |
| 27 |
- } |
| 28 |
- else |
| 29 |
- { |
| 30 |
- file = "blocks-progress"; |
| 31 |
- } |
| 32 |
-#endif |
| 33 |
- |
| 34 |
- ifstream data( file.c_str() ); |
| 35 |
- if (data) |
| 36 |
- { |
| 37 |
- data >> a; |
| 38 |
- data >> b; |
| 39 |
- } |
| 40 |
- |
| 41 |
- if (a != 1) |
| 42 |
- { |
| 43 |
- CTetrisTheme* tmptheme = new CTetrisTheme( stringify(a) ); |
| 44 |
- CVector pos = fields[0]->getPos(); |
| 45 |
- delete fields[0]; |
| 46 |
- fields.clear(); |
| 47 |
- fields.push_back(new CPlayingField(pos, *(tmptheme->getBlockSet()), tmptheme, 100) ); |
| 48 |
- delete theme; |
| 49 |
- theme = tmptheme; |
| 50 |
- } |
| 51 |
- fields[0]->load(a,b); |
| 52 |
+ startGame(); |
| 53 |
}break; |
| 54 |
|
| 55 |
default: |
| 56 |
@@ -440,12 +405,68 @@ |
| 57 |
case SinglePlayerPuzzle: |
| 58 |
case SinglePlayer: |
| 59 |
{ |
| 60 |
+ if (fields[0]->isGameOver()) |
| 61 |
+ { |
| 62 |
+ fields[0]->reLoadLevel(); |
| 63 |
+ break; |
| 64 |
+ } |
| 65 |
+ |
| 66 |
int x, y; |
| 67 |
bool cords; |
| 68 |
/*if ( (cords = fields[0]->boardCords(mouseloc, x, y)) && (fields[0]->blockExists(x, y) || fields[0]->blockExists(x+1, y))) |
| 69 |
{*/ |
| 70 |
fields[0]->swap(); |
| 71 |
//} |
| 72 |
- } |
| 73 |
+ } break; |
| 74 |
+ |
| 75 |
+ case Loading: |
| 76 |
+ { |
| 77 |
+ state = SinglePlayerPuzzle; |
| 78 |
+ } break; |
| 79 |
+ |
| 80 |
+ case Splash: |
| 81 |
+ { |
| 82 |
+ startGame(); |
| 83 |
+ }break; |
| 84 |
} |
| 85 |
} |
| 86 |
+ |
| 87 |
+void CTetrisGame::startGame() |
| 88 |
+{ |
| 89 |
+ state = SinglePlayerPuzzle; |
| 90 |
+ int a = 1, b = 1; |
| 91 |
+ |
| 92 |
+ string file; |
| 93 |
+#if defined(WIN32) || defined(_WIN32) |
| 94 |
+ file = CImgLoader::getPath() + "/progress.txt"; |
| 95 |
+#else |
| 96 |
+ char *homedir = getenv("HOME"); |
| 97 |
+ if (homedir != NULL) |
| 98 |
+ { |
| 99 |
+ file = string(homedir) + "/.blocks-progress"; |
| 100 |
+ } |
| 101 |
+ else |
| 102 |
+ { |
| 103 |
+ file = "blocks-progress"; |
| 104 |
+ } |
| 105 |
+#endif |
| 106 |
+ |
| 107 |
+ ifstream data( file.c_str() ); |
| 108 |
+ if (data) |
| 109 |
+ { |
| 110 |
+ data >> a; |
| 111 |
+ data >> b; |
| 112 |
+ } |
| 113 |
+ |
| 114 |
+ if (a != 1) |
| 115 |
+ { |
| 116 |
+ CTetrisTheme* tmptheme = new CTetrisTheme( stringify(a) ); |
| 117 |
+ CVector pos = fields[0]->getPos(); |
| 118 |
+ delete fields[0]; |
| 119 |
+ fields.clear(); |
| 120 |
+ fields.push_back(new CPlayingField(pos, *(tmptheme->getBlockSet()), tmptheme, 100) ); |
| 121 |
+ delete theme; |
| 122 |
+ theme = tmptheme; |
| 123 |
+ } |
| 124 |
+ fields[0]->load(a,b); |
| 125 |
+} |
| 126 |
Index: blocks-of-the-undead-1.0/TetrisAttack/src/CTetrisGame.h |
| 127 |
=================================================================== |
| 128 |
--- blocks-of-the-undead-1.0.orig/TetrisAttack/src/CTetrisGame.h 2005-01-17 05:49:02.000000000 +0100 |
| 129 |
+++ blocks-of-the-undead-1.0/TetrisAttack/src/CTetrisGame.h 2012-05-01 20:13:26.317980862 +0200 |
| 130 |
@@ -37,6 +37,7 @@ |
| 131 |
void handleKeypress(const SDL_KeyboardEvent &e); |
| 132 |
void handleMouseMotion(const SDL_MouseMotionEvent &e); |
| 133 |
void handleMouseButton(const SDL_MouseButtonEvent &e); |
| 134 |
+ void startGame(); |
| 135 |
|
| 136 |
vector<CPlayingField*> fields; |
| 137 |
list<CSprite*> sprites; |