| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1 |
/* |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2 |
Block Attack - Rise of the Blocks, SDL game, besed on Nintendo's Tetris Attack |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3 |
Copyright (C) 2008 Poul Sander |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
5 |
This program is free software; you can redistribute it and/or modify |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
6 |
it under the terms of the GNU General Public License as published by |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
7 |
the Free Software Foundation; either version 2 of the License, or |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
8 |
(at your option) any later version. |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
9 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
10 |
This program is distributed in the hope that it will be useful, |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
13 |
GNU General Public License for more details. |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
14 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
15 |
You should have received a copy of the GNU General Public License |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
16 |
along with this program; if not, write to the Free Software |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
17 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
18 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
19 |
Poul Sander |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
20 |
R�vehjvej 36, V. 1111 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
21 |
2800 Kgs. Lyngby |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
22 |
DENMARK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
23 |
blockattack@poulsander.com |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
24 |
http://blockattack.sf.net |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
25 |
*/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
26 |
|
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
27 |
#include "common.h" |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
28 |
|
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
29 |
|
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
30 |
#include <string.h> |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
31 |
|
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
32 |
|
| 91886cae |
sago007 |
2008-09-12 16:28 |
33 |
|
| 1572de2b |
sago007 |
2008-09-11 18:15 |
34 |
|
| 1572de2b |
sago007 |
2008-09-11 18:15 |
35 |
|
| 1572de2b |
sago007 |
2008-09-11 18:15 |
36 |
#ifndef VERSION_NUMBER |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
37 |
#define VERSION_NUMBER "version 1.4.1 BETA" |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
38 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
39 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
40 |
//If DEBUG is defined: AI info and FPS will be written to screen |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
41 |
#ifndef DEBUG |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
42 |
#define DEBUG 0 |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
43 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
44 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
45 |
//If NETWORK id defined: enet will be used |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
46 |
#ifndef NETWORK |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
47 |
#define NETWORK 1 |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
48 |
#endif |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
49 |
|
| 1572de2b |
sago007 |
2008-09-11 18:15 |
50 |
//Build-in level editor is still experimental! |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
51 |
#ifndef LEVELEDITOR |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
52 |
#define LEVELEDITOR 0 |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
53 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
54 |
|
| aca2f4b0 |
sago007 |
2009-05-10 18:11 |
55 |
//Macros to convert surfaces (ffor faster drawing) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
56 |
#define CONVERT(n) tmp = SDL_DisplayFormat(n); SDL_FreeSurface(n); n = tmp |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
57 |
#define CONVERTA(n) tmp = SDL_DisplayFormatAlpha(n); SDL_FreeSurface(n); n = tmp |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
58 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
59 |
#include <iostream> |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
60 |
#include <stdlib.h> |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
61 |
#include <time.h> //Used for srand() |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
62 |
#include <sstream> //Still used by itoa2 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
63 |
#include <string> |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
64 |
#include "SDL.h" //The SDL libary, used for most things |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
65 |
#include <SDL_mixer.h> //Used for sound & music |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
66 |
#include <SDL_image.h> //To load PNG images! |
| 41f02ab2 |
sago007 |
2009-05-10 21:40 |
67 |
#include <physfs.h> //Abstract file system. To use containers |
| 41f02ab2 |
sago007 |
2009-05-10 21:40 |
68 |
#include "physfs_stream.hpp" //To use C++ style file streams |
| 47529580 |
sago007 |
2008-12-09 02:34 |
69 |
//#include "ttfont.h" //To use True Type Fonts in SDL |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
70 |
//#include "config.h" |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
71 |
#include <vector> |
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
72 |
#include <SDL/SDL_timer.h> |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
73 |
//#include "MenuSystem.h" |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
74 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
75 |
//if SHAREDIR is not used we look in current directory |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
76 |
#ifndef SHAREDIR |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
77 |
#define SHAREDIR "." |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
78 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
79 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
80 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
81 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
82 |
//enet things |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
83 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
84 |
#include "enet/enet.h" |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
85 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
86 |
//enet things end |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
87 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
88 |
#include "SFont.h" //Used to write on screen |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
89 |
#include "highscore.h" //Stores highscores |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
90 |
#include "ReadKeyboard.h" //Reads text from keyboard |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
91 |
#include "joypad.h" //Used for joypads |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
92 |
#include "listFiles.h" //Used to show files on screen |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
93 |
#include "replay.h" //Used for replays |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
94 |
#include "stats.h" //Saves general stats |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
95 |
#if LEVELEDITOR |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
96 |
#include "editor/editorMain.hpp" //The level editor |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
97 |
#endif |
| bc9ea011 |
sago007 |
2009-04-12 17:43 |
98 |
//#include "uploadReplay.h" //Takes care of everything libcurl related |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
99 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
100 |
#include "common.h" |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
101 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
102 |
/******************************************************************************* |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
103 |
* All variables and constant has been moved to mainVars.hpp for the overview. * |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
104 |
*******************************************************************************/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
105 |
#include "mainVars.hpp" |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
106 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
107 |
void MakeBackground(int,int); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
108 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
109 |
void closeAllMenus() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
110 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
111 |
bNewGameOpen=false; //show sub menues |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
112 |
bOptionsOpen=false; //Show OptionsMenu (Configure and Select Puzzle) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
113 |
b1playerOpen=false; //show submenu |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
114 |
b2playersOpen=false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
115 |
bReplayOpen = false; |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
116 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
117 |
bNetworkOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
118 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
119 |
showOptions = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
120 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
121 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
122 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
123 |
|
| 64ea862c |
sago007 |
2009-05-05 02:45 |
124 |
SDL_Surface * IMG_Load2(char* path) |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
125 |
{ |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
126 |
if (!PHYSFS_exists(path)) |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
127 |
{ |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
128 |
cout << "File not in blockattack.data: " << path << endl; |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
129 |
return NULL; //file doesn't exist |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
130 |
} |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
131 |
|
| 64ea862c |
sago007 |
2009-05-05 02:45 |
132 |
PHYSFS_file* myfile = PHYSFS_openRead(path); |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
133 |
|
| 64ea862c |
sago007 |
2009-05-05 02:45 |
134 |
// Get the lenght of the file |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
135 |
unsigned int m_size = PHYSFS_fileLength(myfile); |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
136 |
|
| 64ea862c |
sago007 |
2009-05-05 02:45 |
137 |
// Get the file data. |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
138 |
char *m_data = new char[m_size]; |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
139 |
|
| 64ea862c |
sago007 |
2009-05-05 02:45 |
140 |
int length_read = PHYSFS_read (myfile, m_data, 1, m_size); |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
141 |
|
| 64ea862c |
sago007 |
2009-05-05 02:45 |
142 |
if (length_read != (int)m_size) |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
143 |
{ |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
144 |
delete [] m_data; |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
145 |
m_data = 0; |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
146 |
PHYSFS_close(myfile); |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
147 |
cout << "Error. Curropt data file!" << endl; |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
148 |
return NULL; |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
149 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
150 |
|
| 64ea862c |
sago007 |
2009-05-05 02:45 |
151 |
PHYSFS_close(myfile); |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
152 |
|
| 64ea862c |
sago007 |
2009-05-05 02:45 |
153 |
// And this is how you load an image from a memory buffer with SDL |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
154 |
SDL_RWops *rw = SDL_RWFromMem (m_data, m_size); |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
155 |
|
| 64ea862c |
sago007 |
2009-05-05 02:45 |
156 |
//The above might fail an return null. |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
157 |
if(!rw) |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
158 |
{ |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
159 |
delete [] m_data; |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
160 |
m_data = 0; |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
161 |
PHYSFS_close(myfile); |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
162 |
cout << "Error. Curropt data file!" << endl; |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
163 |
return NULL; |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
164 |
} |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
165 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
166 |
SDL_Surface* surface = IMG_Load_RW(rw,true); //the second argument tells the function to three RWops |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
167 |
|
| 64ea862c |
sago007 |
2009-05-05 02:45 |
168 |
return surface; |
| 64ea862c |
sago007 |
2009-05-05 02:45 |
169 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
170 |
|
| 866417ca |
sago007 |
2009-05-10 21:35 |
171 |
void UnloadImages(); |
| 866417ca |
sago007 |
2009-05-10 21:35 |
172 |
int InitImages(); |
| 866417ca |
sago007 |
2009-05-10 21:35 |
173 |
|
| 866417ca |
sago007 |
2009-05-10 21:35 |
174 |
static string oldThemePath = "default"; |
| 41f02ab2 |
sago007 |
2009-05-10 21:40 |
175 |
static bool loaded = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
176 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
177 |
void loadTheme(string themeName) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
178 |
{ |
| 41f02ab2 |
sago007 |
2009-05-10 21:40 |
179 |
if(loaded) |
| 866417ca |
sago007 |
2009-05-10 21:35 |
180 |
UnloadImages(); |
| 866417ca |
sago007 |
2009-05-10 21:35 |
181 |
#if defined(__unix__) |
| 866417ca |
sago007 |
2009-05-10 21:35 |
182 |
string home = (string)getenv("HOME")+(string)"/.gamesaves/blockattack"; |
| 866417ca |
sago007 |
2009-05-10 21:35 |
183 |
#elif defined(_WIN32) |
| 866417ca |
sago007 |
2009-05-10 21:35 |
184 |
string home = (string)getMyDocumentsPath()+(string)"/My Games/blockattack"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
185 |
#endif |
| 866417ca |
sago007 |
2009-05-10 21:35 |
186 |
//Remove old theme |
| 866417ca |
sago007 |
2009-05-10 21:35 |
187 |
PHYSFS_removeFromSearchPath(oldThemePath.c_str()); |
| 866417ca |
sago007 |
2009-05-10 21:35 |
188 |
//Look in blockattack.data |
| 866417ca |
sago007 |
2009-05-10 21:35 |
189 |
PHYSFS_addToSearchPath(((string)SHAREDIR+"/blockattack.data").c_str(), 1); |
| 866417ca |
sago007 |
2009-05-10 21:35 |
190 |
//Look in folder |
| 866417ca |
sago007 |
2009-05-10 21:35 |
191 |
PHYSFS_addToSearchPath(SHAREDIR, 1); |
| 866417ca |
sago007 |
2009-05-10 21:35 |
192 |
//Look in home folder |
| 866417ca |
sago007 |
2009-05-10 21:35 |
193 |
#if defined(__unix__) || defined(_WIN32) |
| 866417ca |
sago007 |
2009-05-10 21:35 |
194 |
PHYSFS_addToSearchPath(home.c_str(), 1); |
| 866417ca |
sago007 |
2009-05-10 21:35 |
195 |
#endif |
| 866417ca |
sago007 |
2009-05-10 21:35 |
196 |
if(themeName.compare("default")==0 || (themeName.compare("start")==0)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
197 |
{ |
| 866417ca |
sago007 |
2009-05-10 21:35 |
198 |
InitImages(); |
| 41f02ab2 |
sago007 |
2009-05-10 21:40 |
199 |
loaded =true; |
| 866417ca |
sago007 |
2009-05-10 21:35 |
200 |
return; //Nothing more to do |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
201 |
} |
| 866417ca |
sago007 |
2009-05-10 21:35 |
202 |
oldThemePath = "themes/"+themeName; |
| 866417ca |
sago007 |
2009-05-10 21:35 |
203 |
PHYSFS_addToSearchPath(oldThemePath.c_str(),0); |
| 866417ca |
sago007 |
2009-05-10 21:35 |
204 |
#if defined(__unix__) || defined(_WIN32) |
| 866417ca |
sago007 |
2009-05-10 21:35 |
205 |
PHYSFS_addToSearchPath((home+(string)"/"+oldThemePath).c_str(), 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
206 |
#endif |
| 866417ca |
sago007 |
2009-05-10 21:35 |
207 |
InitImages(); |
| 41f02ab2 |
sago007 |
2009-05-10 21:40 |
208 |
loaded = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
209 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
210 |
|
| 47529580 |
sago007 |
2008-12-09 02:34 |
211 |
/*TTF_Font * TTF_OpenFont2(char* path, int ptsize) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
212 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
213 |
char * tmp; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
214 |
TTF_Font * ret=NULL; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
215 |
tmp = (char*)malloc (sizeof(char)*(strlen(path)+strlen(sharedir)+2)); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
216 |
strcpy(tmp, sharedir); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
217 |
strcat(tmp, "/"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
218 |
strcat(tmp, path); |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
219 |
#if DEBUG |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
220 |
printf("loading %s\n",tmp); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
221 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
222 |
if(!(TTF_WasInit())) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
223 |
TTF_Init(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
224 |
if (!(ret = TTF_OpenFont(tmp, ptsize))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
225 |
ret = TTF_OpenFont(path, ptsize); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
226 |
if(!ret) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
227 |
cout << "failed to load font: " << TTF_GetError() << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
228 |
free(tmp); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
229 |
return ret; |
| 47529580 |
sago007 |
2008-12-09 02:34 |
230 |
}*/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
231 |
|
| 41f02ab2 |
sago007 |
2009-05-10 21:40 |
232 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
233 |
Mix_Music * Mix_LoadMUS2(char* path) |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
234 |
{ |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
235 |
if (!PHYSFS_exists(path)) |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
236 |
{ |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
237 |
cout << "File not in blockattack.data: " << path << endl; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
238 |
return NULL; //file doesn't exist |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
239 |
} |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
240 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
241 |
PHYSFS_file* myfile = PHYSFS_openRead(path); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
242 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
243 |
// Get the lenght of the file |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
244 |
unsigned int m_size = PHYSFS_fileLength(myfile); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
245 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
246 |
// Get the file data. |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
247 |
char *m_data = new char[m_size]; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
248 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
249 |
int length_read = PHYSFS_read (myfile, m_data, 1, m_size); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
250 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
251 |
if (length_read != (int)m_size) |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
252 |
{ |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
253 |
delete [] m_data; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
254 |
m_data = 0; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
255 |
PHYSFS_close(myfile); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
256 |
cout << "Error. Curropt data file!" << endl; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
257 |
return NULL; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
258 |
} |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
259 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
260 |
PHYSFS_close(myfile); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
261 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
262 |
// And this is how you load from a memory buffer with SDL |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
263 |
SDL_RWops *rw = SDL_RWFromMem (m_data, m_size); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
264 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
265 |
//The above might fail an return null. |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
266 |
if(!rw) |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
267 |
{ |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
268 |
delete [] m_data; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
269 |
m_data = 0; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
270 |
PHYSFS_close(myfile); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
271 |
cout << "Error. Curropt data file!" << endl; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
272 |
return NULL; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
273 |
} |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
274 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
275 |
Mix_Music* ret = Mix_LoadMUS_RW(rw); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
276 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
277 |
return ret; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
278 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
279 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
280 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
281 |
Mix_Chunk * Mix_LoadWAV2(char* path) |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
282 |
{ |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
283 |
if (!PHYSFS_exists(path)) |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
284 |
{ |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
285 |
cout << "File not in blockattack.data: " << path << endl; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
286 |
return NULL; //file doesn't exist |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
287 |
} |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
288 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
289 |
PHYSFS_file* myfile = PHYSFS_openRead(path); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
290 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
291 |
// Get the lenght of the file |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
292 |
unsigned int m_size = PHYSFS_fileLength(myfile); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
293 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
294 |
// Get the file data. |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
295 |
char *m_data = new char[m_size]; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
296 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
297 |
int length_read = PHYSFS_read (myfile, m_data, 1, m_size); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
298 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
299 |
if (length_read != (int)m_size) |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
300 |
{ |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
301 |
delete [] m_data; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
302 |
m_data = 0; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
303 |
PHYSFS_close(myfile); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
304 |
cout << "Error. Curropt data file!" << endl; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
305 |
return NULL; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
306 |
} |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
307 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
308 |
PHYSFS_close(myfile); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
309 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
310 |
// And this is how you load from a memory buffer with SDL |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
311 |
SDL_RWops *rw = SDL_RWFromMem (m_data, m_size); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
312 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
313 |
//The above might fail an return null. |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
314 |
if(!rw) |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
315 |
{ |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
316 |
delete [] m_data; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
317 |
m_data = 0; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
318 |
PHYSFS_close(myfile); |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
319 |
cout << "Error. Curropt data file!" << endl; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
320 |
return NULL; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
321 |
} |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
322 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
323 |
Mix_Chunk* ret = Mix_LoadWAV_RW(rw,true); //the second argument tells the function to three RWops |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
324 |
|
| adaf31bf |
sago007 |
2009-05-05 16:01 |
325 |
return ret; |
| adaf31bf |
sago007 |
2009-05-05 16:01 |
326 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
327 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
328 |
//Load all image files to memory |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
329 |
int InitImages() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
330 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
331 |
if (!((backgroundImage = IMG_Load2((char*)"gfx/background.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
332 |
&& (background = IMG_Load2((char*)"gfx/blackBackGround.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
333 |
&& (bNewGame = IMG_Load2((char*)"gfx/bNewGame.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
334 |
&& (b1player = IMG_Load2((char*)"gfx/bOnePlayer.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
335 |
&& (b2players = IMG_Load2((char*)"gfx/bTwoPlayers.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
336 |
&& (bVsMode = IMG_Load2((char*)"gfx/bVsGame.png")) |
| e3e0644e |
sago007 |
2008-09-25 14:00 |
337 |
&& (bVsModeConfig = IMG_Load2((char*)"gfx/bVsGameConfig.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
338 |
&& (bPuzzle = IMG_Load2((char*)"gfx/bPuzzle.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
339 |
&& (bStageClear = IMG_Load2((char*)"gfx/bStageClear.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
340 |
&& (bTimeTrial = IMG_Load2((char*)"gfx/bTimeTrial.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
341 |
&& (bEndless = IMG_Load2((char*)"gfx/bEndless.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
342 |
&& (bOptions = IMG_Load2((char*)"gfx/bOptions.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
343 |
&& (bConfigure = IMG_Load2((char*)"gfx/bConfigure.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
344 |
&& (bSelectPuzzle = IMG_Load2((char*)"gfx/bSelectPuzzle.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
345 |
&& (bHighScore = IMG_Load2((char*)"gfx/bHighScore.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
346 |
&& (bExit = IMG_Load2((char*)"gfx/bExit.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
347 |
&& (bBack = IMG_Load2((char*)"gfx/bBack.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
348 |
&& (bForward = IMG_Load2((char*)"gfx/bForward.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
349 |
&& (bReplay = IMG_Load2((char*)"gfx/bReplays.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
350 |
&& (bSave = IMG_Load2((char*)"gfx/bSave.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
351 |
&& (bLoad = IMG_Load2((char*)"gfx/bLoad.png")) |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
352 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
353 |
&& (bNetwork = IMG_Load2((char*)"gfx/bNetwork.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
354 |
&& (bHost = IMG_Load2((char*)"gfx/bHost.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
355 |
&& (bConnect = IMG_Load2((char*)"gfx/bConnect.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
356 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
357 |
&& (blackLine = IMG_Load2((char*)"gfx/blackLine.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
358 |
&& (stageBobble = IMG_Load2((char*)"gfx/iStageClearLimit.png")) |
| a039f5c4 |
sago007 |
2008-09-19 23:12 |
359 |
&& (bricks[0] = IMG_Load2((char*)"gfx/bricks/blue.png")) |
| a039f5c4 |
sago007 |
2008-09-19 23:12 |
360 |
&& (bricks[1] = IMG_Load2((char*)"gfx/bricks/green.png")) |
| a039f5c4 |
sago007 |
2008-09-19 23:12 |
361 |
&& (bricks[2] = IMG_Load2((char*)"gfx/bricks/purple.png")) |
| a039f5c4 |
sago007 |
2008-09-19 23:12 |
362 |
&& (bricks[3] = IMG_Load2((char*)"gfx/bricks/red.png")) |
| a039f5c4 |
sago007 |
2008-09-19 23:12 |
363 |
&& (bricks[4] = IMG_Load2((char*)"gfx/bricks/turkish.png")) |
| a039f5c4 |
sago007 |
2008-09-19 23:12 |
364 |
&& (bricks[5] = IMG_Load2((char*)"gfx/bricks/yellow.png")) |
| a039f5c4 |
sago007 |
2008-09-19 23:12 |
365 |
&& (bricks[6] = IMG_Load2((char*)"gfx/bricks/grey.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
366 |
&& (crossover = IMG_Load2((char*)"gfx/crossover.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
367 |
&& (balls[0] = IMG_Load2((char*)"gfx/balls/ballBlue.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
368 |
&& (balls[1] = IMG_Load2((char*)"gfx/balls/ballGreen.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
369 |
&& (balls[2] = IMG_Load2((char*)"gfx/balls/ballPurple.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
370 |
&& (balls[3] = IMG_Load2((char*)"gfx/balls/ballRed.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
371 |
&& (balls[4] = IMG_Load2((char*)"gfx/balls/ballTurkish.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
372 |
&& (balls[5] = IMG_Load2((char*)"gfx/balls/ballYellow.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
373 |
&& (balls[6] = IMG_Load2((char*)"gfx/balls/ballGray.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
374 |
&& (cursor[0] = IMG_Load2((char*)"gfx/animations/cursor/1.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
375 |
&& (cursor[1] = IMG_Load2((char*)"gfx/animations/cursor/2.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
376 |
&& (bomb[0] = IMG_Load2((char*)"gfx/animations/bomb/bomb_1.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
377 |
&& (bomb[1] = IMG_Load2((char*)"gfx/animations/bomb/bomb_2.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
378 |
&& (ready[0] = IMG_Load2((char*)"gfx/animations/ready/ready_1.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
379 |
&& (ready[1] = IMG_Load2((char*)"gfx/animations/ready/ready_2.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
380 |
&& (explosion[0] = IMG_Load2((char*)"gfx/animations/explosion/0.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
381 |
&& (explosion[1] = IMG_Load2((char*)"gfx/animations/explosion/1.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
382 |
&& (explosion[2] = IMG_Load2((char*)"gfx/animations/explosion/2.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
383 |
&& (explosion[3] = IMG_Load2((char*)"gfx/animations/explosion/3.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
384 |
&& (counter[0] = IMG_Load2((char*)"gfx/counter/1.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
385 |
&& (counter[1] = IMG_Load2((char*)"gfx/counter/2.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
386 |
&& (counter[2] = IMG_Load2((char*)"gfx/counter/3.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
387 |
&& (backBoard = IMG_Load2((char*)"gfx/BackBoard.png")) //not used, we just test if it exists :) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
388 |
&& (iGameOver = IMG_Load2((char*)"gfx/iGameOver.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
389 |
&& (iWinner = IMG_Load2((char*)"gfx/iWinner.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
390 |
&& (iDraw = IMG_Load2((char*)"gfx/iDraw.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
391 |
&& (iLoser = IMG_Load2((char*)"gfx/iLoser.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
392 |
&& (iChainBack = IMG_Load2((char*)"gfx/chainFrame.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
393 |
&& (iBlueFont = IMG_Load2((char*)"gfx/24P_Arial_Blue.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
394 |
&& (iSmallFont = IMG_Load2((char*)"gfx/14P_Arial_Angle_Red.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
395 |
&& (optionsBack = IMG_Load2((char*)"gfx/options.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
396 |
&& (bOn = IMG_Load2((char*)"gfx/bOn.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
397 |
&& (bOff = IMG_Load2((char*)"gfx/bOff.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
398 |
&& (bChange = IMG_Load2((char*)"gfx/bChange.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
399 |
&& (b1024 = IMG_Load2((char*)"gfx/b1024.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
400 |
&& (dialogBox = IMG_Load2((char*)"gfx/dialogbox.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
401 |
// && (fileDialogBox = IMG_Load2("gfx/fileDialogbox.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
402 |
&& (iLevelCheck = IMG_Load2((char*)"gfx/iLevelCheck.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
403 |
&& (iLevelCheckBox = IMG_Load2((char*)"gfx/iLevelCheckBox.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
404 |
&& (iCheckBoxArea = IMG_Load2((char*)"gfx/iCheckBoxArea.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
405 |
&& (boardBackBack = IMG_Load2((char*)"gfx/boardBackBack.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
406 |
&& (changeButtonsBack = IMG_Load2((char*)"gfx/changeButtonsBack.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
407 |
&& (garbageTL = IMG_Load2((char*)"gfx/garbage/garbageTL.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
408 |
&& (garbageT = IMG_Load2((char*)"gfx/garbage/garbageT.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
409 |
&& (garbageTR = IMG_Load2((char*)"gfx/garbage/garbageTR.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
410 |
&& (garbageR = IMG_Load2((char*)"gfx/garbage/garbageR.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
411 |
&& (garbageBR = IMG_Load2((char*)"gfx/garbage/garbageBR.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
412 |
&& (garbageB = IMG_Load2((char*)"gfx/garbage/garbageB.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
413 |
&& (garbageBL = IMG_Load2((char*)"gfx/garbage/garbageBL.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
414 |
&& (garbageL = IMG_Load2((char*)"gfx/garbage/garbageL.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
415 |
&& (garbageFill = IMG_Load2((char*)"gfx/garbage/garbageFill.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
416 |
&& (garbageML = IMG_Load2((char*)"gfx/garbage/garbageML.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
417 |
&& (garbageM = IMG_Load2((char*)"gfx/garbage/garbageM.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
418 |
&& (garbageMR = IMG_Load2((char*)"gfx/garbage/garbageMR.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
419 |
&& (garbageGM = IMG_Load2((char*)"gfx/garbage/garbageGM.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
420 |
&& (garbageGML = IMG_Load2((char*)"gfx/garbage/garbageGML.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
421 |
&& (garbageGMR = IMG_Load2((char*)"gfx/garbage/garbageGMR.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
422 |
&& (smiley[0] = IMG_Load2((char*)"gfx/smileys/0.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
423 |
&& (smiley[1] = IMG_Load2((char*)"gfx/smileys/1.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
424 |
&& (smiley[2] = IMG_Load2((char*)"gfx/smileys/2.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
425 |
&& (smiley[3] = IMG_Load2((char*)"gfx/smileys/3.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
426 |
//new in 1.3.2 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
427 |
&& (transCover = IMG_Load2((char*)"gfx/transCover.png")) |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
428 |
#if LEVELEDITOR |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
429 |
&& (bCreateFile = IMG_Load2((char*)"gfx/editor/bCreateFile.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
430 |
&& (bDeletePuzzle = IMG_Load2((char*)"gfx/editor/bDeletePuzzle.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
431 |
&& (bLoadFile = IMG_Load2((char*)"gfx/editor/bLoadFile.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
432 |
&& (bMoveBack = IMG_Load2((char*)"gfx/editor/bMoveBack.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
433 |
&& (bMoveDown = IMG_Load2((char*)"gfx/editor/bMoveDown.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
434 |
&& (bMoveForward = IMG_Load2((char*)"gfx/editor/bMoveForward.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
435 |
&& (bMoveLeft = IMG_Load2((char*)"gfx/editor/bMoveLeft.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
436 |
&& (bMoveRight = IMG_Load2((char*)"gfx/editor/bMoveRight.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
437 |
&& (bMoveUp = IMG_Load2((char*)"gfx/editor/bMoveUp.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
438 |
&& (bNewPuzzle = IMG_Load2((char*)"gfx/editor/bNewPuzzle.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
439 |
&& (bSaveFileAs = IMG_Load2((char*)"gfx/editor/bSaveFileAs.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
440 |
&& (bSavePuzzle = IMG_Load2((char*)"gfx/editor/bSavePuzzle.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
441 |
&& (bSaveToFile = IMG_Load2((char*)"gfx/editor/bSaveToFile.png")) |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
442 |
&& (bTestPuzzle = IMG_Load2((char*)"gfx/editor/bTestPuzzle.png")) |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
443 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
444 |
//end new in 1.3.2 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
445 |
//new in 1.4.0 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
446 |
&& (bTheme = IMG_Load2((char*)"gfx/bTheme.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
447 |
&& (bSkip = IMG_Load2((char*)"gfx/bSkip.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
448 |
&& (bNext = IMG_Load2((char*)"gfx/bNext.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
449 |
&& (bRetry = IMG_Load2((char*)"gfx/bRetry.png")) |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
450 |
//&& (menuMarked = IMG_Load2((char*)"gfx/menu/marked.png")) |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
451 |
//&& (menuUnmarked = IMG_Load2((char*)"gfx/menu/unmarked.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
452 |
//end new in 1.4.0 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
453 |
&& (mouse = IMG_Load2((char*)"gfx/mouse.png")) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
454 |
)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
455 |
//if there was a problem ie. "File not found" |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
456 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
457 |
cout << "Error loading image file: " << SDL_GetError() << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
458 |
exit(1); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
459 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
460 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
461 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
462 |
//Prepare for fast blittering! |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
463 |
CONVERT(background); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
464 |
CONVERT(bNewGame); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
465 |
CONVERT(backgroundImage); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
466 |
CONVERT(b1player); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
467 |
CONVERT(b2players); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
468 |
CONVERT(bVsMode); |
| e3e0644e |
sago007 |
2008-09-25 14:00 |
469 |
CONVERT(bVsModeConfig); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
470 |
CONVERT(bPuzzle); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
471 |
CONVERT(bStageClear); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
472 |
CONVERT(bTimeTrial); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
473 |
CONVERT(bEndless); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
474 |
CONVERT(bOptions); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
475 |
CONVERTA(bConfigure); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
476 |
CONVERTA(bSelectPuzzle); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
477 |
CONVERTA(bReplay); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
478 |
CONVERTA(bSave); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
479 |
CONVERTA(bLoad); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
480 |
CONVERTA(bTheme); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
481 |
CONVERTA(bSkip); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
482 |
CONVERTA(bRetry); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
483 |
CONVERTA(bNext); |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
484 |
//CONVERTA(menuMarked); |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
485 |
//CONVERTA(menuUnmarked); |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
486 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
487 |
CONVERTA(bNetwork); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
488 |
CONVERTA(bHost); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
489 |
CONVERTA(bConnect); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
490 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
491 |
CONVERT(bHighScore); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
492 |
CONVERTA(boardBackBack); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
493 |
CONVERT(backBoard); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
494 |
CONVERT(blackLine); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
495 |
CONVERTA(changeButtonsBack); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
496 |
CONVERTA(cursor[0]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
497 |
CONVERTA(cursor[1]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
498 |
CONVERTA(counter[0]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
499 |
CONVERTA(counter[1]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
500 |
CONVERTA(counter[2]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
501 |
CONVERTA(optionsBack); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
502 |
CONVERT(bExit); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
503 |
CONVERT(bOn); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
504 |
CONVERT(bOff); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
505 |
CONVERT(bChange); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
506 |
CONVERT(b1024); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
507 |
CONVERTA(dialogBox); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
508 |
// CONVERTA(fileDialogBox); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
509 |
CONVERTA(iLevelCheck); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
510 |
CONVERT(iLevelCheckBox); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
511 |
CONVERTA(iCheckBoxArea); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
512 |
for (int i = 0;i<4;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
513 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
514 |
CONVERTA(explosion[i]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
515 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
516 |
for (int i = 0; i<7; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
517 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
518 |
CONVERTA(bricks[i]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
519 |
CONVERTA(balls[i]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
520 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
521 |
CONVERTA(crossover); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
522 |
CONVERTA(garbageTL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
523 |
CONVERTA(garbageT); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
524 |
CONVERTA(garbageTR); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
525 |
CONVERTA(garbageR); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
526 |
CONVERTA(garbageBR); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
527 |
CONVERTA(garbageB); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
528 |
CONVERTA(garbageBL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
529 |
CONVERTA(garbageL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
530 |
CONVERTA(garbageFill); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
531 |
CONVERTA(garbageML); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
532 |
CONVERTA(garbageMR); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
533 |
CONVERTA(garbageM); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
534 |
CONVERTA(garbageGML); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
535 |
CONVERTA(garbageGMR); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
536 |
CONVERTA(garbageGM); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
537 |
CONVERTA(smiley[0]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
538 |
CONVERTA(smiley[1]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
539 |
CONVERTA(smiley[2]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
540 |
CONVERTA(smiley[3]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
541 |
CONVERTA(iWinner); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
542 |
CONVERTA(iDraw); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
543 |
CONVERTA(iLoser); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
544 |
CONVERTA(iChainBack); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
545 |
CONVERTA(iBlueFont); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
546 |
CONVERTA(iSmallFont); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
547 |
CONVERTA(iGameOver); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
548 |
CONVERTA(mouse); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
549 |
CONVERTA(stageBobble); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
550 |
CONVERTA(transCover); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
551 |
//Editor: |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
552 |
#if LEVELEDITOR |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
553 |
CONVERTA(bCreateFile); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
554 |
CONVERTA(bDeletePuzzle); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
555 |
CONVERTA(bLoadFile); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
556 |
CONVERTA(bMoveBack); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
557 |
CONVERTA(bMoveDown); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
558 |
CONVERTA(bMoveForward); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
559 |
CONVERTA(bMoveLeft); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
560 |
CONVERTA(bMoveRight); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
561 |
CONVERTA(bMoveUp); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
562 |
CONVERTA(bNewPuzzle); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
563 |
CONVERTA(bSaveFileAs); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
564 |
CONVERTA(bSavePuzzle); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
565 |
CONVERTA(bSaveToFile); |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
566 |
CONVERTA(bTestPuzzle); |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
567 |
#endif |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
568 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
569 |
//Here comes the fonts: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
570 |
fBlueFont = SFont_InitFont(iBlueFont); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
571 |
fSmallFont = SFont_InitFont(iSmallFont); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
572 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
573 |
//And the ttf font: |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
574 |
/*TTF_Font *ttFont1 = TTF_OpenFont2((char*)"fonts/FreeSerif.ttf", 24); |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
575 |
TTF_SetFontStyle(ttFont1,TTF_STYLE_BOLD); |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
576 |
ttfont = TTFont(ttFont1);*/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
577 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
578 |
//Loads the sound if sound present |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
579 |
if (!NoSound) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
580 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
581 |
//And here the music: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
582 |
bgMusic = Mix_LoadMUS2((char*)"music/bgMusic.ogg"); |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
583 |
highbeatMusic = Mix_LoadMUS2((char*)"music/highbeat.ogg"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
584 |
//the music... we just hope it exists, else the user won't hear anything |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
585 |
//Same goes for the sounds |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
586 |
boing = Mix_LoadWAV2((char*)"sound/pop.ogg"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
587 |
applause = Mix_LoadWAV2((char*)"sound/applause.ogg"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
588 |
photoClick = Mix_LoadWAV2((char*)"sound/cameraclick.ogg"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
589 |
typingChunk = Mix_LoadWAV2((char*)"sound/typing.ogg"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
590 |
counterChunk = Mix_LoadWAV2((char*)"sound/counter.ogg"); |
| 24a6ea5f |
sago007 |
2008-11-13 22:28 |
591 |
counterFinalChunk = Mix_LoadWAV2((char*)"sound/counterFinal.ogg"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
592 |
} //All sound has been loaded or not |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
593 |
return 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
594 |
} //InitImages() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
595 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
596 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
597 |
//Unload images and fonts and sounds |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
598 |
void UnloadImages() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
599 |
{ |
| 866417ca |
sago007 |
2009-05-10 21:35 |
600 |
cout << "Unloading data..." << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
601 |
//Fonts and Sounds needs to be freed |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
602 |
SFont_FreeFont(fBlueFont); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
603 |
SFont_FreeFont(fSmallFont); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
604 |
if (!NoSound) //Only unload then it has been loaded! |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
605 |
{ |
| 866417ca |
sago007 |
2009-05-10 21:35 |
606 |
Mix_HaltMusic(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
607 |
Mix_FreeMusic(bgMusic); |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
608 |
Mix_FreeMusic(highbeatMusic); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
609 |
Mix_FreeChunk(boing); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
610 |
Mix_FreeChunk(applause); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
611 |
Mix_FreeChunk(photoClick); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
612 |
Mix_FreeChunk(counterChunk); |
| 24a6ea5f |
sago007 |
2008-11-13 22:28 |
613 |
Mix_FreeChunk(counterFinalChunk); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
614 |
Mix_FreeChunk(typingChunk); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
615 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
616 |
//Free surfaces: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
617 |
//I think this will crash, at least it happend to me... |
| 866417ca |
sago007 |
2009-05-10 21:35 |
618 |
//Chrashes no more. Caused by an undocumented double free |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
619 |
SDL_FreeSurface(backgroundImage); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
620 |
SDL_FreeSurface(background); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
621 |
SDL_FreeSurface(bNewGame); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
622 |
SDL_FreeSurface(b1player); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
623 |
SDL_FreeSurface(b2players); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
624 |
SDL_FreeSurface(bVsMode); |
| e3e0644e |
sago007 |
2008-09-25 14:00 |
625 |
SDL_FreeSurface(bVsModeConfig); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
626 |
SDL_FreeSurface(bPuzzle); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
627 |
SDL_FreeSurface(bStageClear); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
628 |
SDL_FreeSurface(bTimeTrial); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
629 |
SDL_FreeSurface(bEndless); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
630 |
SDL_FreeSurface(bOptions); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
631 |
SDL_FreeSurface(bConfigure); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
632 |
SDL_FreeSurface(bSelectPuzzle); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
633 |
SDL_FreeSurface(bHighScore); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
634 |
SDL_FreeSurface(bReplay); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
635 |
SDL_FreeSurface(bSave); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
636 |
SDL_FreeSurface(bLoad); |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
637 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
638 |
SDL_FreeSurface(bNetwork); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
639 |
SDL_FreeSurface(bHost); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
640 |
SDL_FreeSurface(bConnect); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
641 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
642 |
SDL_FreeSurface(bExit); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
643 |
SDL_FreeSurface(blackLine); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
644 |
SDL_FreeSurface(stageBobble); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
645 |
SDL_FreeSurface(bricks[0]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
646 |
SDL_FreeSurface(bricks[1]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
647 |
SDL_FreeSurface(bricks[2]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
648 |
SDL_FreeSurface(bricks[3]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
649 |
SDL_FreeSurface(bricks[4]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
650 |
SDL_FreeSurface(bricks[5]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
651 |
SDL_FreeSurface(bricks[6]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
652 |
SDL_FreeSurface(crossover); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
653 |
SDL_FreeSurface(balls[0]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
654 |
SDL_FreeSurface(balls[1]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
655 |
SDL_FreeSurface(balls[2]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
656 |
SDL_FreeSurface(balls[3]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
657 |
SDL_FreeSurface(balls[4]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
658 |
SDL_FreeSurface(balls[5]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
659 |
SDL_FreeSurface(balls[6]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
660 |
SDL_FreeSurface(cursor[0]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
661 |
SDL_FreeSurface(cursor[1]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
662 |
SDL_FreeSurface(backBoard); //not used, we just test if it exists :) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
663 |
SDL_FreeSurface(iGameOver); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
664 |
SDL_FreeSurface(iWinner); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
665 |
SDL_FreeSurface(iDraw); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
666 |
SDL_FreeSurface(iLoser); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
667 |
SDL_FreeSurface(iChainBack); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
668 |
//SDL_FreeSurface(iBlueFont); //Segfault |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
669 |
//SDL_FreeSurface(iSmallFont); //Segfault |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
670 |
SDL_FreeSurface(optionsBack); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
671 |
SDL_FreeSurface(bOn); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
672 |
SDL_FreeSurface(bOff); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
673 |
SDL_FreeSurface(bChange); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
674 |
SDL_FreeSurface(b1024); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
675 |
SDL_FreeSurface(dialogBox); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
676 |
//SDL_FreeSurface(fileDialogBox); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
677 |
SDL_FreeSurface(iLevelCheck); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
678 |
SDL_FreeSurface(iLevelCheckBox); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
679 |
SDL_FreeSurface(iCheckBoxArea); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
680 |
SDL_FreeSurface(boardBackBack); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
681 |
SDL_FreeSurface(changeButtonsBack); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
682 |
SDL_FreeSurface(garbageTL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
683 |
SDL_FreeSurface(garbageT); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
684 |
SDL_FreeSurface(garbageTR); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
685 |
SDL_FreeSurface(garbageR); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
686 |
SDL_FreeSurface(garbageBR); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
687 |
SDL_FreeSurface(garbageB); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
688 |
SDL_FreeSurface(garbageBL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
689 |
SDL_FreeSurface(garbageL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
690 |
SDL_FreeSurface(garbageFill); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
691 |
SDL_FreeSurface(garbageML); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
692 |
SDL_FreeSurface(garbageM); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
693 |
SDL_FreeSurface(garbageMR); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
694 |
SDL_FreeSurface(garbageGML); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
695 |
SDL_FreeSurface(garbageGM); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
696 |
SDL_FreeSurface(garbageGMR); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
697 |
SDL_FreeSurface(smiley[0]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
698 |
SDL_FreeSurface(smiley[1]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
699 |
SDL_FreeSurface(smiley[2]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
700 |
SDL_FreeSurface(smiley[3]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
701 |
SDL_FreeSurface(transCover); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
702 |
SDL_FreeSurface(mouse); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
703 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
704 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
705 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
706 |
//Function to convert numbers to string |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
707 |
/*string itoa(int num) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
708 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
709 |
stringstream converter; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
710 |
converter << num; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
711 |
return converter.str(); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
712 |
}*/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
713 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
714 |
//Function to convert numbers to string (2 diget) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
715 |
string itoa2(int num) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
716 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
717 |
stringstream converter; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
718 |
if(num<10) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
719 |
converter << "0"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
720 |
converter << num; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
721 |
return converter.str(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
722 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
723 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
724 |
/*Loads all the puzzle levels*/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
725 |
int LoadPuzzleStages() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
726 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
727 |
//if(puzzleLoaded) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
728 |
// return 1; |
| aca2f4b0 |
sago007 |
2009-05-10 18:11 |
729 |
if (!PHYSFS_exists(("puzzles/"+puzzleName).c_str())) |
| aca2f4b0 |
sago007 |
2009-05-10 18:11 |
730 |
{ |
| aca2f4b0 |
sago007 |
2009-05-10 18:11 |
731 |
cout << "File not in blockattack.data: " << ("puzzles/"+puzzleName) << endl; |
| aca2f4b0 |
sago007 |
2009-05-10 18:11 |
732 |
return -1; //file doesn't exist |
| aca2f4b0 |
sago007 |
2009-05-10 18:11 |
733 |
} |
| aca2f4b0 |
sago007 |
2009-05-10 18:11 |
734 |
PhysFS::ifstream inFile(("puzzles/"+puzzleName).c_str()); |
| aca2f4b0 |
sago007 |
2009-05-10 18:11 |
735 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
736 |
inFile >> nrOfPuzzles; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
737 |
if (nrOfPuzzles>maxNrOfPuzzleStages) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
738 |
nrOfPuzzles=maxNrOfPuzzleStages; |
| aca2f4b0 |
sago007 |
2009-05-10 18:11 |
739 |
for (int k=0; (k<nrOfPuzzles) /*&&(!inFile.eof())*/ ; k++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
740 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
741 |
inFile >> nrOfMovesAllowed[k]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
742 |
for (int i=11;i>=0;i--) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
743 |
for (int j=0;j<6;j++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
744 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
745 |
inFile >> puzzleLevels[k][j][i]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
746 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
747 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
748 |
puzzleLoaded = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
749 |
return 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
750 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
751 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
752 |
/*Draws a image from on a given Surface. Takes source image, destination surface and coordinates*/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
753 |
inline void DrawIMG(SDL_Surface *img, SDL_Surface *target, int x, int y) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
754 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
755 |
SDL_Rect dest; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
756 |
dest.x = x; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
757 |
dest.y = y; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
758 |
SDL_BlitSurface(img, NULL, target, &dest); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
759 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
760 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
761 |
/*Draws a part of an image on a surface of choice*/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
762 |
void DrawIMG(SDL_Surface *img, SDL_Surface * target, int x, int y, int w, int h, int x2, int y2) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
763 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
764 |
SDL_Rect dest; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
765 |
dest.x = x; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
766 |
dest.y = y; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
767 |
SDL_Rect dest2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
768 |
dest2.x = x2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
769 |
dest2.y = y2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
770 |
dest2.w = w; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
771 |
dest2.h = h; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
772 |
SDL_BlitSurface(img, &dest2, target, &dest); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
773 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
774 |
|
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
775 |
//Menu |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
776 |
/*void PrintHi() |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
777 |
{ |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
778 |
cout << "Hi" <<endl; |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
779 |
} |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
780 |
|
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
781 |
void InitMenues() |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
782 |
{ |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
783 |
ButtonGfx::setSurfaces(&menuMarked,&menuUnmarked); |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
784 |
ButtonGfx::ttf = &ttfont; |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
785 |
} |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
786 |
|
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
787 |
void MainMenu() |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
788 |
{ |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
789 |
Menu m(&screen,true); |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
790 |
Button bHi; |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
791 |
bHi.setLabel("Write hi"); |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
792 |
bHi.setAction(PrintHi); |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
793 |
m.addButton(bHi); |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
794 |
m.run(); |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
795 |
}*/ |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
796 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
797 |
//The small things that are faaling when you clear something |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
798 |
class aBall |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
799 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
800 |
private: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
801 |
double x; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
802 |
double y; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
803 |
double velocityY; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
804 |
double velocityX; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
805 |
int color; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
806 |
unsigned long int lastTime; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
807 |
public: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
808 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
809 |
aBall() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
810 |
{} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
811 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
812 |
//constructor: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
813 |
aBall(int X, int Y, bool right, int coulor) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
814 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
815 |
double tal = 1.0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
816 |
velocityY = -tal*startVelocityY; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
817 |
lastTime = currentTime; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
818 |
x = (double)X; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
819 |
y = (double)Y; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
820 |
color = coulor; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
821 |
if (right) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
822 |
velocityX = tal*VelocityX; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
823 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
824 |
velocityX = -tal*VelocityX; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
825 |
} //constructor |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
826 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
827 |
//Deconstructor |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
828 |
~aBall() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
829 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
830 |
} //Deconstructor |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
831 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
832 |
void update() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
833 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
834 |
double timePassed = (((double)(currentTime-lastTime))/1000.0); //time passed in seconds |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
835 |
x = x+timePassed*velocityX; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
836 |
y = y+timePassed*velocityY; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
837 |
velocityY = velocityY + gravity*timePassed; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
838 |
if (y<1.0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
839 |
velocityY=10.0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
840 |
if ((velocityY>minVelocity) && (y>(double)(768-ballSize)) && (y<768.0)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
841 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
842 |
velocityY = -0.70*velocityY; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
843 |
y = 768.0-ballSize; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
844 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
845 |
lastTime = currentTime; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
846 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
847 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
848 |
int getX() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
849 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
850 |
return (int)x; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
851 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
852 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
853 |
int getY() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
854 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
855 |
return (int)y; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
856 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
857 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
858 |
int getColor() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
859 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
860 |
return color; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
861 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
862 |
}; //aBall |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
863 |
|
| 6d48320c |
sago007 |
2009-03-28 17:06 |
864 |
const int maxNumberOfBalls = 6*12*2*2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
865 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
866 |
class ballManeger |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
867 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
868 |
public: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
869 |
aBall ballArray[maxNumberOfBalls]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
870 |
bool ballUsed[maxNumberOfBalls]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
871 |
//The old ball information is also saved so balls can be deleted! |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
872 |
aBall oldBallArray[maxNumberOfBalls]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
873 |
bool oldBallUsed[maxNumberOfBalls]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
874 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
875 |
ballManeger() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
876 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
877 |
for (int i=0; i<maxNumberOfBalls; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
878 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
879 |
ballUsed[i] = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
880 |
oldBallUsed[i] = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
881 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
882 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
883 |
|
| 6d48320c |
sago007 |
2009-03-28 17:06 |
884 |
//Adds a ball to the screen at given coordiantes, traveling right or not with color |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
885 |
int addBall(int x, int y,bool right,int color) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
886 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
887 |
int ballNumber = 0; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
888 |
//Find a free ball |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
889 |
while ((ballUsed[ballNumber])&&(ballNumber<maxNumberOfBalls)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
890 |
ballNumber++; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
891 |
//Could not find a free ball, return -1 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
892 |
if (ballNumber==maxNumberOfBalls) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
893 |
return -1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
894 |
currentTime = SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
895 |
ballArray[ballNumber] = aBall(x,y,right,color); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
896 |
ballUsed[ballNumber] = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
897 |
return 1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
898 |
} //addBall |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
899 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
900 |
void update() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
901 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
902 |
currentTime = SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
903 |
for (int i = 0; i<maxNumberOfBalls; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
904 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
905 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
906 |
if (ballUsed[i]) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
907 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
908 |
oldBallUsed[i] = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
909 |
oldBallArray[i] = ballArray[i]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
910 |
ballArray[i].update(); |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
911 |
if (ballArray[i].getY()>800 || ballArray[i].getX()>xsize || ballArray[i].getX()<-ballSize) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
912 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
913 |
ballArray[i].~aBall(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
914 |
ballUsed[i] = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
915 |
//cout << "Ball removed" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
916 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
917 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
918 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
919 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
920 |
oldBallUsed[i] = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
921 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
922 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
923 |
} //update |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
924 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
925 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
926 |
}; //theBallManeger |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
927 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
928 |
ballManeger theBallManeger; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
929 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
930 |
//a explosions, non moving |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
931 |
class anExplosion |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
932 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
933 |
private: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
934 |
int x; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
935 |
int y; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
936 |
Uint8 frameNumber; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
937 |
#define frameLength 80 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
938 |
//How long an image in an animation should be showed |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
939 |
#define maxFrame 4 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
940 |
//How many images there are in the animation |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
941 |
unsigned long int placeTime; //Then the explosion occored |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
942 |
public: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
943 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
944 |
anExplosion() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
945 |
{} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
946 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
947 |
//constructor: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
948 |
anExplosion(int X, int Y) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
949 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
950 |
placeTime = currentTime; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
951 |
x = X; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
952 |
y = Y; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
953 |
frameNumber=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
954 |
} //constructor |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
955 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
956 |
//Deconstructor |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
957 |
~anExplosion() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
958 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
959 |
} //Deconstructor |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
960 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
961 |
//true if animation has played and object should be removed from the screen |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
962 |
bool removeMe() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
963 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
964 |
frameNumber = (currentTime-placeTime)/frameLength; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
965 |
return (!(frameNumber<maxFrame)); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
966 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
967 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
968 |
int getX() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
969 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
970 |
return (int)x; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
971 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
972 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
973 |
int getY() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
974 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
975 |
return (int)y; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
976 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
977 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
978 |
int getFrame() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
979 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
980 |
return frameNumber; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
981 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
982 |
}; //nExplosion |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
983 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
984 |
class explosionManeger |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
985 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
986 |
public: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
987 |
anExplosion explosionArray[maxNumberOfBalls]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
988 |
bool explosionUsed[maxNumberOfBalls]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
989 |
//The old explosion information is also saved so explosions can be deleted! |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
990 |
anExplosion oldExplosionArray[maxNumberOfBalls]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
991 |
bool oldExplosionUsed[maxNumberOfBalls]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
992 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
993 |
explosionManeger() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
994 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
995 |
for (int i=0; i<maxNumberOfBalls; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
996 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
997 |
explosionUsed[i] = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
998 |
oldExplosionUsed[i] = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
999 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1000 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1001 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1002 |
int addExplosion(int x, int y) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1003 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1004 |
//cout << "Tries to add an explosion" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1005 |
int explosionNumber = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1006 |
while ((explosionUsed[explosionNumber])&&(explosionNumber<maxNumberOfBalls)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1007 |
explosionNumber++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1008 |
if (explosionNumber==maxNumberOfBalls) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1009 |
return -1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1010 |
currentTime = SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1011 |
explosionArray[explosionNumber] = anExplosion(x,y); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1012 |
explosionUsed[explosionNumber] = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1013 |
//cout << "Explosion added" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1014 |
return 1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1015 |
} //addBall |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1016 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1017 |
void update() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1018 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1019 |
currentTime = SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1020 |
for (int i = 0; i<maxNumberOfBalls; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1021 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1022 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1023 |
if (explosionUsed[i]) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1024 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1025 |
oldExplosionUsed[i] = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1026 |
oldExplosionArray[i] = explosionArray[i]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1027 |
if (explosionArray[i].removeMe()) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1028 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1029 |
explosionArray[i].~anExplosion(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1030 |
explosionUsed[i] = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1031 |
//cout << "Explosion removed" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1032 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1033 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1034 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1035 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1036 |
oldExplosionUsed[i] = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1037 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1038 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1039 |
} //update |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1040 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1041 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1042 |
}; //explosionManeger |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1043 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1044 |
explosionManeger theExplosionManeger; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1045 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1046 |
//text pop-up |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1047 |
class textMessage |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1048 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1049 |
private: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1050 |
int x; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1051 |
int y; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1052 |
char textt[10]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1053 |
unsigned long int time; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1054 |
unsigned long int placeTime; //Then the text was placed |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1055 |
public: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1056 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1057 |
textMessage() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1058 |
{} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1059 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1060 |
//constructor: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1061 |
textMessage(int X, int Y,const char* Text,unsigned int Time) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1062 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1063 |
placeTime = currentTime; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1064 |
x = X; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1065 |
y = Y; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1066 |
strncpy(textt,Text,10); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1067 |
textt[9]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1068 |
time = Time; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1069 |
} //constructor |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1070 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1071 |
//true if the text has expired |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1072 |
bool removeMe() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1073 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1074 |
return currentTime-placeTime>time; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1075 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1076 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1077 |
int getX() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1078 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1079 |
return x; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1080 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1081 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1082 |
int getY() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1083 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1084 |
return y; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1085 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1086 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1087 |
char* getText() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1088 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1089 |
return textt; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1090 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1091 |
}; //text popup |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1092 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1093 |
class textManeger |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1094 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1095 |
public: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1096 |
textMessage textArray[maxNumberOfBalls]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1097 |
bool textUsed[maxNumberOfBalls]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1098 |
//The old text information is also saved so text can be deleted! |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1099 |
textMessage oldTextArray[maxNumberOfBalls]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1100 |
bool oldTextUsed[maxNumberOfBalls]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1101 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1102 |
textManeger() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1103 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1104 |
for (int i=0; i<maxNumberOfBalls; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1105 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1106 |
textUsed[i] = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1107 |
oldTextUsed[i] = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1108 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1109 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1110 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1111 |
int addText(int x, int y,string Text,unsigned int Time) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1112 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1113 |
//cout << "Tries to add text" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1114 |
int textNumber = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1115 |
while ((textNumber<maxNumberOfBalls)&&((textUsed[textNumber])||(oldTextUsed[textNumber]))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1116 |
textNumber++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1117 |
if (textNumber==maxNumberOfBalls) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1118 |
return -1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1119 |
//cout << "adding to: " << textNumber << ":" << textUsed[textNumber] << ":" << &textArray[textNumber] << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1120 |
currentTime = SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1121 |
textArray[textNumber] = textMessage(x,y,Text.c_str(),Time); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1122 |
textUsed[textNumber] = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1123 |
return 1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1124 |
} //addText |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1125 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1126 |
void update() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1127 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1128 |
//cout << "Running update" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1129 |
currentTime = SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1130 |
for (int i = 0; i<maxNumberOfBalls; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1131 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1132 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1133 |
if (textUsed[i]) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1134 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1135 |
if (!oldTextUsed[i]) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1136 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1137 |
oldTextUsed[i] = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1138 |
oldTextArray[i] = textMessage(textArray[i]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1139 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1140 |
if (textArray[i].removeMe()) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1141 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1142 |
textArray[i].~textMessage(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1143 |
textUsed[i] = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1144 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1145 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1146 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1147 |
if (oldTextUsed[i]) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1148 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1149 |
oldTextUsed[i] = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1150 |
oldTextArray[i].~textMessage(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1151 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1152 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1153 |
} //update |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1154 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1155 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1156 |
}; //textManeger |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1157 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1158 |
textManeger theTextManeger; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1159 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1160 |
//Here comes the Block Game object |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1161 |
#include "BlockGame.hpp" |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1162 |
#include "SFont.h" |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1163 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1164 |
//writeScreenShot saves the screen as a bmp file, it uses the time to get a unique filename |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1165 |
void writeScreenShot() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1166 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1167 |
cout << "Saving screenshot" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1168 |
int rightNow = (int)time(NULL); |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1169 |
/*#if defined(__unix__) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1170 |
char buf[514]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1171 |
sprintf( buf, "%s/.gamesaves/blockattack/screenshots/screenshot%i.bmp", getenv("HOME"), rightNow ); |
| 91886cae |
sago007 |
2008-09-12 16:28 |
1172 |
#elif defined(__win32__) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1173 |
char buf[MAX_PATH]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1174 |
sprintf( buf, "%s\\My Games\\blockattack\\screenshots\\screenshot%i.bmp", (getMyDocumentsPath()).c_str(), rightNow ); |
| 91886cae |
sago007 |
2008-09-12 16:28 |
1175 |
#else |
| 91886cae |
sago007 |
2008-09-12 16:28 |
1176 |
char buf[MAX_PATH]; |
| 91886cae |
sago007 |
2008-09-12 16:28 |
1177 |
sprintf( buf, "screenshot%i.bmp", rightNow ); |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1178 |
#endif*/ |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1179 |
#if defined(__unix__) |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1180 |
string buf = (string)getenv("HOME")+"/.gamesaves/blockattack/screenshots/screenshot"+itoa(rightNow)+".bmp"; |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1181 |
#elif defined(__win32__) |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1182 |
string buf = getMyDocumentsPath()+"\\My Games\\blockattack\\screenshots\\screenshot"+itoa(rightNow)+".bmp"; |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1183 |
#else |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1184 |
string buf = "screenshot"+itoa(rightNow)+".bmp"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1185 |
#endif |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1186 |
SDL_SaveBMP( screen, buf.c_str() ); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1187 |
if (!NoSound) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1188 |
if (SoundEnabled)Mix_PlayChannel(1,photoClick,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1189 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1190 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1191 |
//Function to return the name of a key, to be displayed... |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1192 |
string getKeyName(SDLKey key) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1193 |
{ |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1194 |
string keyname; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1195 |
char charToPut = '\0'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1196 |
switch (key) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1197 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1198 |
case SDLK_a: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1199 |
charToPut = 'A'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1200 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1201 |
case SDLK_b: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1202 |
charToPut = 'B'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1203 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1204 |
case SDLK_c: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1205 |
charToPut = 'C'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1206 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1207 |
case SDLK_d: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1208 |
charToPut = 'D'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1209 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1210 |
case SDLK_e: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1211 |
charToPut = 'E'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1212 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1213 |
case SDLK_f: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1214 |
charToPut = 'F'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1215 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1216 |
case SDLK_g: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1217 |
charToPut = 'G'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1218 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1219 |
case SDLK_h: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1220 |
charToPut = 'H'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1221 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1222 |
case SDLK_i: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1223 |
charToPut = 'I'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1224 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1225 |
case SDLK_j: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1226 |
charToPut = 'J'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1227 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1228 |
case SDLK_k: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1229 |
charToPut = 'K'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1230 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1231 |
case SDLK_l: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1232 |
charToPut = 'L'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1233 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1234 |
case SDLK_m: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1235 |
charToPut = 'M'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1236 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1237 |
case SDLK_n: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1238 |
charToPut = 'N'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1239 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1240 |
case SDLK_o: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1241 |
charToPut = 'O'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1242 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1243 |
case SDLK_p: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1244 |
charToPut = 'P'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1245 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1246 |
case SDLK_q: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1247 |
charToPut = 'Q'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1248 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1249 |
case SDLK_r: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1250 |
charToPut = 'R'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1251 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1252 |
case SDLK_s: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1253 |
charToPut = 'S'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1254 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1255 |
case SDLK_t: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1256 |
charToPut = 'T'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1257 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1258 |
case SDLK_u: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1259 |
charToPut = 'U'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1260 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1261 |
case SDLK_v: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1262 |
charToPut = 'V'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1263 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1264 |
case SDLK_w: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1265 |
charToPut = 'W'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1266 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1267 |
case SDLK_x: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1268 |
charToPut = 'X'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1269 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1270 |
case SDLK_y: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1271 |
charToPut = 'Y'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1272 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1273 |
case SDLK_z: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1274 |
charToPut = 'Z'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1275 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1276 |
case SDLK_0: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1277 |
charToPut = '0'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1278 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1279 |
case SDLK_1: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1280 |
charToPut = '1'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1281 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1282 |
case SDLK_2: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1283 |
charToPut = '2'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1284 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1285 |
case SDLK_3: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1286 |
charToPut = '3'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1287 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1288 |
case SDLK_4: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1289 |
charToPut = '4'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1290 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1291 |
case SDLK_5: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1292 |
charToPut = '5'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1293 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1294 |
case SDLK_6: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1295 |
charToPut = '6'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1296 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1297 |
case SDLK_7: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1298 |
charToPut = '7'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1299 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1300 |
case SDLK_8: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1301 |
charToPut = '8'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1302 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1303 |
case SDLK_9: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1304 |
charToPut = '9'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1305 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1306 |
case SDLK_KP0: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1307 |
keyname = "NP_0"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1308 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1309 |
case SDLK_KP1: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1310 |
keyname = "NP_1"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1311 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1312 |
case SDLK_KP2: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1313 |
keyname = "NP_2"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1314 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1315 |
case SDLK_KP3: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1316 |
keyname = "NP_3"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1317 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1318 |
case SDLK_KP4: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1319 |
keyname = "NP_4"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1320 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1321 |
case SDLK_KP5: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1322 |
keyname = "NP_5"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1323 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1324 |
case SDLK_KP6: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1325 |
keyname = "NP_6"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1326 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1327 |
case SDLK_KP7: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1328 |
keyname = "NP_7"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1329 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1330 |
case SDLK_KP8: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1331 |
keyname = "NP_8"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1332 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1333 |
case SDLK_KP9: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1334 |
keyname = "NP_9"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1335 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1336 |
case SDLK_BACKSPACE: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1337 |
keyname = "Backspace"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1338 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1339 |
case SDLK_TAB: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1340 |
keyname = "Tab"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1341 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1342 |
case SDLK_CLEAR: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1343 |
keyname = "Clear"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1344 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1345 |
case SDLK_RETURN: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1346 |
keyname = "Return"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1347 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1348 |
case SDLK_PAUSE: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1349 |
keyname = "Pause"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1350 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1351 |
case SDLK_SPACE: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1352 |
keyname = "Space"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1353 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1354 |
case SDLK_EXCLAIM: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1355 |
charToPut = '!'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1356 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1357 |
case SDLK_QUOTEDBL: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1358 |
keyname = "QuoteDBL"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1359 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1360 |
case SDLK_HASH: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1361 |
charToPut = '#'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1362 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1363 |
case SDLK_DOLLAR: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1364 |
keyname = "$"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1365 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1366 |
case SDLK_ASTERISK: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1367 |
keyname = "Asterisk"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1368 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1369 |
case SDLK_PLUS: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1370 |
keyname = "Plus"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1371 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1372 |
case SDLK_COMMA: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1373 |
keyname = "Comma"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1374 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1375 |
case SDLK_MINUS: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1376 |
keyname = "Minus"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1377 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1378 |
case SDLK_PERIOD: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1379 |
keyname = "Period"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1380 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1381 |
case SDLK_SLASH: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1382 |
charToPut ='/'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1383 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1384 |
case SDLK_COLON: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1385 |
keyname = "Colon"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1386 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1387 |
case SDLK_SEMICOLON: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1388 |
keyname = "SemiColon"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1389 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1390 |
case SDLK_LESS: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1391 |
charToPut = '<'; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1392 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1393 |
case SDLK_EQUALS: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1394 |
keyname = "Equals"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1395 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1396 |
case SDLK_DELETE: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1397 |
keyname = "Delete"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1398 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1399 |
case SDLK_KP_PERIOD: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1400 |
keyname = "NPperiod"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1401 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1402 |
case SDLK_KP_DIVIDE: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1403 |
keyname = "NPdivide"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1404 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1405 |
case SDLK_KP_MULTIPLY: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1406 |
keyname = "NPmultiply"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1407 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1408 |
case SDLK_KP_MINUS: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1409 |
keyname = "NPminus"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1410 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1411 |
case SDLK_KP_PLUS: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1412 |
keyname = "NPplus"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1413 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1414 |
case SDLK_KP_ENTER: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1415 |
keyname = "NP_Enter"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1416 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1417 |
case SDLK_KP_EQUALS: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1418 |
keyname = "NP="; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1419 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1420 |
case SDLK_UP: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1421 |
keyname = "UP"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1422 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1423 |
case SDLK_DOWN: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1424 |
keyname = "DOWN"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1425 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1426 |
case SDLK_RIGHT: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1427 |
keyname = "RIGHT"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1428 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1429 |
case SDLK_LEFT: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1430 |
keyname = "LEFT"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1431 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1432 |
case SDLK_INSERT: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1433 |
keyname = "Insert"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1434 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1435 |
case SDLK_HOME: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1436 |
keyname = "Home"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1437 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1438 |
case SDLK_END: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1439 |
keyname = "End"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1440 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1441 |
case SDLK_PAGEUP: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1442 |
keyname = "PageUp"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1443 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1444 |
case SDLK_PAGEDOWN: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1445 |
keyname = "PageDown"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1446 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1447 |
case SDLK_NUMLOCK: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1448 |
keyname = "NumLock"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1449 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1450 |
case SDLK_CAPSLOCK: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1451 |
keyname = "CapsLock"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1452 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1453 |
case SDLK_SCROLLOCK: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1454 |
keyname = "ScrolLock"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1455 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1456 |
case SDLK_RSHIFT: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1457 |
keyname = "Rshift"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1458 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1459 |
case SDLK_LSHIFT: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1460 |
keyname = "Lshift"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1461 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1462 |
case SDLK_RCTRL: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1463 |
keyname = "Rctrl"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1464 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1465 |
case SDLK_LCTRL: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1466 |
keyname = "Lctrl"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1467 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1468 |
case SDLK_RALT: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1469 |
keyname = "Ralt"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1470 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1471 |
case SDLK_LALT: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1472 |
keyname = "Lalt"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1473 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1474 |
case SDLK_RMETA: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1475 |
keyname = "Rmeta"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1476 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1477 |
case SDLK_LMETA: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1478 |
keyname = "Lmeta"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1479 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1480 |
case SDLK_LSUPER: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1481 |
keyname = "Lwin"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1482 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1483 |
case SDLK_RSUPER: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1484 |
keyname = "Rwin"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1485 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1486 |
case SDLK_MODE: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1487 |
keyname = "Mode"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1488 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1489 |
case SDLK_HELP: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1490 |
keyname = "Help"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1491 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1492 |
default: |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1493 |
keyname = "Unknown"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1494 |
break; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1495 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1496 |
if (charToPut != '\0') |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1497 |
{ |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1498 |
keyname.clear(); |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1499 |
keyname.append(1,charToPut); |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1500 |
} |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1501 |
return keyname; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1502 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1503 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1504 |
void MakeBackground(int xsize,int ysize,BlockGame &theGame, BlockGame &theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1505 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1506 |
int OpenControlsBox(int x, int y, int player) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1507 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1508 |
int mousex, mousey; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1509 |
Uint8 *keys; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1510 |
bool done =false; |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1511 |
string keyname; |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
1512 |
MakeBackground(xsize,ysize); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1513 |
while (!done) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1514 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1515 |
SDL_Delay(10); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1516 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1517 |
DrawIMG(changeButtonsBack,screen,x,y); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1518 |
if (player == 0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1519 |
SFont_Write(screen,fBlueFont,x+40,y+2,"Player 1 keys"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1520 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1521 |
SFont_Write(screen,fBlueFont,x+40,y+2,"Player 2 keys"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1522 |
SFont_Write(screen,fBlueFont,x+6,y+50,"Up"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1523 |
keyname = getKeyName(keySettings[player].up); |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1524 |
SFont_Write(screen,fBlueFont,x+200,y+50,keyname.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1525 |
SFont_Write(screen,fBlueFont,x+6,y+100,"Down"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1526 |
keyname = getKeyName(keySettings[player].down); |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1527 |
SFont_Write(screen,fBlueFont,x+200,y+100,keyname.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1528 |
SFont_Write(screen,fBlueFont,x+6,y+150,"Left"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1529 |
keyname = getKeyName(keySettings[player].left); |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1530 |
SFont_Write(screen,fBlueFont,x+200,y+150,keyname.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1531 |
SFont_Write(screen,fBlueFont,x+6,y+200,"Right"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1532 |
keyname = getKeyName(keySettings[player].right); |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1533 |
SFont_Write(screen,fBlueFont,x+200,y+200,keyname.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1534 |
SFont_Write(screen,fBlueFont,x+6,y+250,"Push"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1535 |
keyname = getKeyName(keySettings[player].push); |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1536 |
SFont_Write(screen,fBlueFont,x+200,y+250,keyname.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1537 |
SFont_Write(screen,fBlueFont,x+6,y+300,"Change"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1538 |
keyname = getKeyName(keySettings[player].change); |
| 215ca7b3 |
sago007 |
2009-03-06 16:37 |
1539 |
SFont_Write(screen,fBlueFont,x+200,y+300,keyname.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1540 |
//Ask for mouse play |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1541 |
SFont_Write(screen,fBlueFont,x+6,y+350,"Mouse play?"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1542 |
DrawIMG(iLevelCheckBox,screen,x+220,y+350); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1543 |
if (((player==0)&&(mouseplay1))||((player==2)&&(mouseplay2))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1544 |
DrawIMG(iLevelCheck,screen,x+220,y+350); //iLevelCheck witdh is 42 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1545 |
//Ask for joypad play |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1546 |
SFont_Write(screen,fBlueFont,x+300,y+350,"Joypad?"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1547 |
DrawIMG(iLevelCheckBox,screen,x+460,y+350); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1548 |
if (((player==0)&&(joyplay1))||((player==2)&&(joyplay2))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1549 |
DrawIMG(iLevelCheck,screen,x+460,y+350); //iLevelCheck witdh is 42 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1550 |
for (int i=1; i<7; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1551 |
DrawIMG(bChange,screen,x+420,y+50*i); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1552 |
SDL_Event event; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1553 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1554 |
while (SDL_PollEvent(&event)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1555 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1556 |
if ( event.type == SDL_QUIT ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1557 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1558 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1559 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1560 |
if (event.type == SDL_KEYDOWN) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1561 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1562 |
if (event.key.keysym.sym == SDLK_ESCAPE) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1563 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1564 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1565 |
} //PollEvent |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1566 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1567 |
keys = SDL_GetKeyState(NULL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1568 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1569 |
SDL_GetMouseState(&mousex,&mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1570 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1571 |
// If the mouse button is released, make bMouseUp equal true |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1572 |
if (!SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1573 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1574 |
bMouseUp=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1575 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1576 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1577 |
if (SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(1) && bMouseUp) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1578 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1579 |
bMouseUp = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1580 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1581 |
if ((mousex>(420+x)) && (mousex<(540+x)) && (mousey>(50+y)) && (mousey<(90+y))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1582 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1583 |
//up |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1584 |
bool finnish = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1585 |
while (!finnish) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1586 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1587 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1588 |
if (event.type == SDL_KEYDOWN) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1589 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1590 |
if (event.key.keysym.sym != SDLK_ESCAPE) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1591 |
keySettings[player].up = event.key.keysym.sym; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1592 |
finnish = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1593 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1594 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1595 |
} //up |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1596 |
if ((mousex>(420+x)) && (mousex<(540+x)) && (mousey>(100+y)) && (mousey<(140+y))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1597 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1598 |
//down |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1599 |
bool finnish = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1600 |
while (!finnish) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1601 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1602 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1603 |
if (event.type == SDL_KEYDOWN) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1604 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1605 |
if (event.key.keysym.sym != SDLK_ESCAPE) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1606 |
keySettings[player].down = event.key.keysym.sym; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1607 |
finnish = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1608 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1609 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1610 |
} //down |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1611 |
if ((mousex>(420+x)) && (mousex<(540+x)) && (mousey>(150+y)) && (mousey<(190+y))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1612 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1613 |
//left |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1614 |
bool finnish = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1615 |
while (!finnish) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1616 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1617 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1618 |
if (event.type == SDL_KEYDOWN) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1619 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1620 |
if (event.key.keysym.sym != SDLK_ESCAPE) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1621 |
keySettings[player].left = event.key.keysym.sym; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1622 |
finnish = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1623 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1624 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1625 |
} //left |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1626 |
if ((mousex>(420+x)) && (mousex<(540+x)) && (mousey>(200+y)) && (mousey<(240+y))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1627 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1628 |
//right |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1629 |
bool finnish = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1630 |
while (!finnish) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1631 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1632 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1633 |
if (event.type == SDL_KEYDOWN) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1634 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1635 |
if (event.key.keysym.sym != SDLK_ESCAPE) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1636 |
keySettings[player].right = event.key.keysym.sym; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1637 |
finnish = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1638 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1639 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1640 |
} //right |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1641 |
if ((mousex>(420+x)) && (mousex<(540+x)) && (mousey>(250+y)) && (mousey<(290+y))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1642 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1643 |
//push |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1644 |
bool finnish = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1645 |
while (!finnish) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1646 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1647 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1648 |
if (event.type == SDL_KEYDOWN) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1649 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1650 |
if (event.key.keysym.sym != SDLK_ESCAPE) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1651 |
keySettings[player].push = event.key.keysym.sym; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1652 |
finnish = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1653 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1654 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1655 |
} //push |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1656 |
if ((mousex>(420+x)) && (mousex<(540+x)) && (mousey>(300+y)) && (mousey<(340+y))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1657 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1658 |
//change |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1659 |
bool finnish = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1660 |
while (!finnish) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1661 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1662 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1663 |
if (event.type == SDL_KEYDOWN) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1664 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1665 |
if (event.key.keysym.sym != SDLK_ESCAPE) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1666 |
keySettings[player].change = event.key.keysym.sym; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1667 |
finnish = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1668 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1669 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1670 |
} //change |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1671 |
//mouseplay: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1672 |
if ((mousex>(220+x)) && (mousex<(262+x)) && (mousey>(350+y)) && (mousey<(392+y))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1673 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1674 |
if (player==0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1675 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1676 |
mouseplay1 = !mouseplay1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1677 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1678 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1679 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1680 |
mouseplay2 = !mouseplay2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1681 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1682 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1683 |
//Joyplay: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1684 |
if ((mousex>(460+x)) && (mousex<(502+x)) && (mousey>(350+y)) && (mousey<(392+y))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1685 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1686 |
if (player==0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1687 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1688 |
joyplay1 = !joyplay1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1689 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1690 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1691 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1692 |
joyplay2 = !joyplay2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1693 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1694 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1695 |
} //get mouse state |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1696 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1697 |
DrawIMG(mouse,screen,mousex,mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1698 |
SDL_Flip(screen); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1699 |
} //while !done |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1700 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1701 |
return 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1702 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1703 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1704 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1705 |
//Dialogbox |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1706 |
bool OpenDialogbox(int x, int y, char *name) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1707 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1708 |
bool done = false; //We are done! |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1709 |
bool accept = false; //New name is accepted! (not Cancelled) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1710 |
bool repeating = false; //The key is being held (BACKSPACE) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1711 |
const int repeatDelay = 200; //Repeating |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1712 |
unsigned long time = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1713 |
ReadKeyboard rk = ReadKeyboard(name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1714 |
Uint8* keys; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1715 |
string strHolder; |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
1716 |
MakeBackground(xsize,ysize); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1717 |
DrawIMG(background,screen,0,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1718 |
while (!done) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1719 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1720 |
DrawIMG(dialogBox,screen,x,y); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1721 |
SFont_Write(screen,fBlueFont,x+40,y+72,rk.GetString()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1722 |
strHolder = rk.GetString(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1723 |
strHolder.erase((int)rk.CharsBeforeCursor()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1724 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1725 |
if (((SDL_GetTicks()/600)%2)==1) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1726 |
SFont_Write(screen,fBlueFont,x+40+SFont_TextWidth(fBlueFont,strHolder.c_str()),y+69,"|"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1727 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1728 |
SDL_Event event; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1729 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1730 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1731 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1732 |
if ( event.type == SDL_QUIT ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1733 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1734 |
accept = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1735 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1736 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1737 |
if ( event.type == SDL_KEYDOWN ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1738 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1739 |
if ( (event.key.keysym.sym == SDLK_RETURN)||(event.key.keysym.sym == SDLK_KP_ENTER) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1740 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1741 |
accept = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1742 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1743 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1744 |
if ( (event.key.keysym.sym == SDLK_ESCAPE) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1745 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1746 |
accept = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1747 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1748 |
else if (!(event.key.keysym.sym == SDLK_BACKSPACE)){ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1749 |
if ((rk.ReadKey(event.key.keysym.sym))&&(SoundEnabled)&&(!NoSound))Mix_PlayChannel(1,typingChunk,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1750 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1751 |
else if ((event.key.keysym.sym == SDLK_BACKSPACE)&&(!repeating)){ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1752 |
if ((rk.ReadKey(event.key.keysym.sym))&&(SoundEnabled)&&(!NoSound))Mix_PlayChannel(1,typingChunk,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1753 |
repeating = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1754 |
time=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1755 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1756 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1757 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1758 |
} //while(event) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1759 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1760 |
if (SDL_GetTicks()>(time+repeatDelay)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1761 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1762 |
time = SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1763 |
keys = SDL_GetKeyState(NULL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1764 |
if ( (keys[SDLK_BACKSPACE])&&(repeating) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1765 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1766 |
if ((rk.ReadKey(SDLK_BACKSPACE))&&(SoundEnabled)&&(!NoSound))Mix_PlayChannel(1,typingChunk,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1767 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1768 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1769 |
repeating = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1770 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1771 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1772 |
SDL_Flip(screen); //Update screen |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1773 |
} //while(!done) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1774 |
strcpy(name,rk.GetString()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1775 |
bScreenLocked = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1776 |
showDialog = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1777 |
return accept; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1778 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1779 |
|
| 47529580 |
sago007 |
2008-12-09 02:34 |
1780 |
//Draws the highscores |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1781 |
void DrawHighscores(int x, int y, bool endless) |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1782 |
{ |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
1783 |
MakeBackground(xsize,ysize); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1784 |
DrawIMG(background,screen,0,0); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1785 |
if (endless) SFont_Write(screen,fBlueFont,x+100,y+100,"Endless:"); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1786 |
else SFont_Write(screen,fBlueFont,x+100,y+100,"Time Trial:"); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1787 |
for (int i =0;i<10;i++) |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1788 |
{ |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1789 |
char playerScore[32]; |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1790 |
char playerName[32]; |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1791 |
if (endless) |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1792 |
{ |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1793 |
sprintf(playerScore, "%i", theTopScoresEndless.getScoreNumber(i)); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1794 |
} |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1795 |
else |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1796 |
{ |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1797 |
sprintf(playerScore, "%i", theTopScoresTimeTrial.getScoreNumber(i)); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1798 |
} |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1799 |
if (endless) |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1800 |
{ |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1801 |
strcpy(playerName,theTopScoresEndless.getScoreName(i)); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1802 |
} |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1803 |
else |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1804 |
{ |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1805 |
strcpy(playerName,theTopScoresTimeTrial.getScoreName(i)); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1806 |
} |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1807 |
SFont_Write(screen,fBlueFont,x+420,y+150+i*35,playerScore); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1808 |
SFont_Write(screen,fBlueFont,x+60,y+150+i*35,playerName); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1809 |
} |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1810 |
} |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1811 |
|
| 47529580 |
sago007 |
2008-12-09 02:34 |
1812 |
void DrawStats() |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1813 |
{ |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
1814 |
MakeBackground(xsize,ysize); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1815 |
DrawIMG(background,screen,0,0); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1816 |
int y = 5; |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1817 |
const int y_spacing = 30; |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1818 |
SFont_Write(screen,fBlueFont,10,y,"Stats"); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1819 |
y+=y_spacing*2; |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1820 |
SFont_Write(screen,fBlueFont,10,y,"Chains"); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1821 |
for(int i=2;i<13;i++) |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1822 |
{ |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1823 |
y+=y_spacing; |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1824 |
SFont_Write(screen,fBlueFont,10,y,(itoa(i)+"X").c_str()); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1825 |
string numberAsString = itoa(Stats::getInstance()->getNumberOf("chainX"+itoa(i))); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1826 |
SFont_Write(screen,fBlueFont,300,y,numberAsString.c_str()); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1827 |
} |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1828 |
y+=y_spacing*2; |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1829 |
SFont_Write(screen,fBlueFont,10,y,"Lines Pushed: "); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1830 |
string numberAsString = itoa(Stats::getInstance()->getNumberOf("linesPushed")); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1831 |
SFont_Write(screen,fBlueFont,300,y,numberAsString.c_str()); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1832 |
|
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1833 |
y+=y_spacing; |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1834 |
SFont_Write(screen,fBlueFont,10,y,"Puzzles solved: "); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1835 |
numberAsString = itoa(Stats::getInstance()->getNumberOf("puzzlesSolved")); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1836 |
SFont_Write(screen,fBlueFont,300,y,numberAsString.c_str()); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1837 |
|
| d07b805e |
sago007 |
2009-01-27 13:15 |
1838 |
y+=y_spacing*2; |
| d07b805e |
sago007 |
2009-01-27 13:15 |
1839 |
SFont_Write(screen,fBlueFont,10,y,"Run time: "); |
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
1840 |
commonTime ct = TimeHandler::peekTime("totalTime",TimeHandler::ms2ct(SDL_GetTicks())); |
| d07b805e |
sago007 |
2009-01-27 13:15 |
1841 |
y+=y_spacing; |
| d07b805e |
sago007 |
2009-01-27 13:15 |
1842 |
SFont_Write(screen,fBlueFont,10,y,((string)("Days: "+itoa(ct.days))).c_str()); |
| d07b805e |
sago007 |
2009-01-27 13:15 |
1843 |
y+=y_spacing; |
| d07b805e |
sago007 |
2009-01-27 13:15 |
1844 |
SFont_Write(screen,fBlueFont,10,y,((string)("Hours: "+itoa(ct.hours))).c_str()); |
| d07b805e |
sago007 |
2009-01-27 13:15 |
1845 |
y+=y_spacing; |
| d07b805e |
sago007 |
2009-01-27 13:15 |
1846 |
SFont_Write(screen,fBlueFont,10,y,((string)("Minutes: "+itoa(ct.minutes))).c_str()); |
| d07b805e |
sago007 |
2009-01-27 13:15 |
1847 |
y+=y_spacing; |
| d07b805e |
sago007 |
2009-01-27 13:15 |
1848 |
SFont_Write(screen,fBlueFont,10,y,((string)("Seconds: "+itoa(ct.seconds))).c_str()); |
| d07b805e |
sago007 |
2009-01-27 13:15 |
1849 |
|
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
1850 |
y-=y_spacing*4; //Four rows back |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
1851 |
const int x_offset3 = xsize/3+10; //Ofset for three rows |
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
1852 |
SFont_Write(screen,fBlueFont,x_offset3,y,"Play time: "); |
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
1853 |
ct = TimeHandler::getTime("playTime"); |
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
1854 |
y+=y_spacing; |
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
1855 |
SFont_Write(screen,fBlueFont,x_offset3,y,((string)("Days: "+itoa(ct.days))).c_str()); |
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
1856 |
y+=y_spacing; |
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
1857 |
SFont_Write(screen,fBlueFont,x_offset3,y,((string)("Hours: "+itoa(ct.hours))).c_str()); |
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
1858 |
y+=y_spacing; |
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
1859 |
SFont_Write(screen,fBlueFont,x_offset3,y,((string)("Minutes: "+itoa(ct.minutes))).c_str()); |
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
1860 |
y+=y_spacing; |
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
1861 |
SFont_Write(screen,fBlueFont,x_offset3,y,((string)("Seconds: "+itoa(ct.seconds))).c_str()); |
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
1862 |
|
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
1863 |
const int x_offset = xsize/2+10; |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1864 |
y = 5+y_spacing*2; |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1865 |
SFont_Write(screen,fBlueFont,x_offset,y,"VS CPU (win/loss)"); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1866 |
for(int i=0;i<7;i++) |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1867 |
{ |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1868 |
y += y_spacing; |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1869 |
SFont_Write(screen,fBlueFont,x_offset,y,("AI "+itoa(i+1)).c_str()); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1870 |
numberAsString = itoa(Stats::getInstance()->getNumberOf("defeatedAI"+itoa(i))); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1871 |
string numberAsString2 = itoa(Stats::getInstance()->getNumberOf("defeatedByAI"+itoa(i))); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1872 |
string toPrint = numberAsString + "/" + numberAsString2; |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1873 |
SFont_Write(screen,fBlueFont,x_offset+230,y,toPrint.c_str()); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1874 |
} |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1875 |
} |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1876 |
|
| 47529580 |
sago007 |
2008-12-09 02:34 |
1877 |
void OpenScoresDisplay() |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1878 |
{ |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
1879 |
int mousex,mousey; |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1880 |
bool done = false; //We are done! |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1881 |
int page = 0; |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1882 |
const int numberOfPages = 3; |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1883 |
//button coodinates: |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1884 |
const int scoreX = buttonXsize*2; |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1885 |
const int scoreY = 0; |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1886 |
const int backX = 20; |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1887 |
const int backY = ysize-buttonYsize-20; |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1888 |
const int nextX = xsize-buttonXsize-20; |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1889 |
const int nextY = backY; |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1890 |
while (!done) |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1891 |
{ |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1892 |
switch(page) |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1893 |
{ |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1894 |
case 0: |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1895 |
//Highscores, endless |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1896 |
DrawHighscores(100,100,true); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1897 |
break; |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1898 |
case 1: |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1899 |
//Highscores, Time Trial |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1900 |
DrawHighscores(100,100,false); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1901 |
break; |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1902 |
case 2: |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1903 |
default: |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1904 |
DrawStats(); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1905 |
}; |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1906 |
|
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1907 |
//Draw buttons: |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1908 |
DrawIMG(bHighScore,screen,scoreX,scoreY); |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1909 |
DrawIMG(bBack,screen,backX,backY); |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1910 |
DrawIMG(bNext,screen,nextX,nextY); |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1911 |
|
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1912 |
//Draw page number |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1913 |
string pageXofY = ((string)"Page ")+itoa(page+1)+((string)" of ")+itoa(numberOfPages); |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1914 |
SFont_Write(screen,fBlueFont,xsize/2-SFont_TextWidth(fBlueFont,pageXofY.c_str())/2,ysize-60,pageXofY.c_str()); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
1915 |
|
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1916 |
SDL_Delay(10); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1917 |
SDL_Event event; |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
1918 |
|
| 9050a50a |
sago007 |
2008-12-09 13:35 |
1919 |
SDL_GetMouseState(&mousex,&mousey); |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1920 |
|
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1921 |
while ( SDL_PollEvent(&event) ) |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1922 |
{ |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
1923 |
|
| 9050a50a |
sago007 |
2008-12-09 13:35 |
1924 |
|
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1925 |
if ( event.type == SDL_QUIT ) { |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1926 |
done = true; |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1927 |
} |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1928 |
|
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1929 |
if ( event.type == SDL_KEYDOWN ) |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1930 |
{ |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1931 |
if( (event.key.keysym.sym == SDLK_RIGHT)) |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1932 |
{ |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1933 |
page++; |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1934 |
if(page>=numberOfPages) |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1935 |
page = 0; |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1936 |
} |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1937 |
else |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1938 |
if( (event.key.keysym.sym == SDLK_LEFT)) |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1939 |
{ |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1940 |
page--; |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1941 |
if(page<0) |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1942 |
page = numberOfPages-1; |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1943 |
} |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1944 |
else |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1945 |
done = true; |
| fcd5a134 |
sago007 |
2008-12-19 01:11 |
1946 |
|
| fcd5a134 |
sago007 |
2008-12-19 01:11 |
1947 |
if ( event.key.keysym.sym == SDLK_F9 ) { |
| fcd5a134 |
sago007 |
2008-12-19 01:11 |
1948 |
writeScreenShot(); |
| fcd5a134 |
sago007 |
2008-12-19 01:11 |
1949 |
} |
| 47529580 |
sago007 |
2008-12-09 02:34 |
1950 |
|
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1951 |
if ( (event.key.keysym.sym == SDLK_RETURN)||(event.key.keysym.sym == SDLK_KP_ENTER) ) { |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1952 |
done = true; |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1953 |
} |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1954 |
else |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1955 |
if ( (event.key.keysym.sym == SDLK_ESCAPE) ) { |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1956 |
done = true; |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1957 |
} |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1958 |
} |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1959 |
|
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1960 |
} //while(event) |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1961 |
|
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1962 |
// If the mouse button is released, make bMouseUp equal true |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1963 |
if (!SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1)) |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1964 |
{ |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1965 |
bMouseUp=true; |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1966 |
} |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1967 |
|
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1968 |
if (SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(1) && bMouseUp) |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1969 |
{ |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1970 |
bMouseUp = false; |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1971 |
|
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1972 |
//The Score button: |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1973 |
if((mousex>scoreX) && (mousex<scoreX+buttonXsize) && (mousey>scoreY) && (mousey<scoreY+buttonYsize)) |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1974 |
done =true; |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1975 |
|
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1976 |
//The back button: |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1977 |
if((mousex>backX) && (mousex<backX+buttonXsize) && (mousey>backY) && (mousey<backY+buttonYsize)) |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1978 |
{ |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1979 |
page--; |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1980 |
if(page<0) |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1981 |
page = numberOfPages-1; |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1982 |
} |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1983 |
|
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1984 |
//The next button: |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1985 |
if((mousex>nextX) && (mousex<nextX+buttonXsize) && (mousey>nextY) && (mousey<nextY+buttonYsize)) |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1986 |
{ |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1987 |
page++; |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1988 |
if(page>=numberOfPages) |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1989 |
page = 0; |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1990 |
} |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1991 |
} |
| 7ca669ac |
sago007 |
2008-12-09 16:30 |
1992 |
|
| 9050a50a |
sago007 |
2008-12-09 13:35 |
1993 |
DrawIMG(mouse,screen,mousex,mousey); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
1994 |
SDL_Flip(screen); //Update screen |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1995 |
} |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1996 |
} |
| 81d9c25d |
sago007 |
2008-11-24 09:50 |
1997 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1998 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1999 |
//Open a puzzle file |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2000 |
bool OpenFileDialogbox(int x, int y, char *name) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2001 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2002 |
bool done = false; //We are done! |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2003 |
int mousex, mousey; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2004 |
ListFiles lf = ListFiles(); |
| aca2f4b0 |
sago007 |
2009-05-10 18:11 |
2005 |
string folder = (string)SHAREDIR+(string)"/puzzles"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2006 |
cout << "Looking in " << folder << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2007 |
lf.setDirectory(folder.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2008 |
#ifdef __unix__ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2009 |
string homeFolder = (string)getenv("HOME")+(string)"/.gamesaves/blockattack/puzzles"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2010 |
lf.setDirectory2(homeFolder.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2011 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2012 |
Uint8* keys; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2013 |
string strHolder; |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2014 |
MakeBackground(xsize,ysize); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2015 |
DrawIMG(background,screen,0,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2016 |
DrawIMG(bForward,background,x+460,y+420); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2017 |
DrawIMG(bBack,background,x+20,y+420); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2018 |
while (!done) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2019 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2020 |
DrawIMG(background,screen,0,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2021 |
const int nrOfFiles = 10; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2022 |
DrawIMG(changeButtonsBack,screen,x,y); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2023 |
for (int i=0;i<nrOfFiles;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2024 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2025 |
SFont_Write(screen,fBlueFont,x+10,y+10+36*i,lf.getFileName(i).c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2026 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2027 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2028 |
SDL_Event event; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2029 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2030 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2031 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2032 |
if ( event.type == SDL_QUIT ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2033 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2034 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2035 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2036 |
if ( event.type == SDL_KEYDOWN ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2037 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2038 |
if ( (event.key.keysym.sym == SDLK_ESCAPE) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2039 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2040 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2041 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2042 |
if ( (event.key.keysym.sym == SDLK_RIGHT) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2043 |
lf.forward(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2044 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2045 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2046 |
if ( (event.key.keysym.sym == SDLK_LEFT) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2047 |
lf.back(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2048 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2049 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2050 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2051 |
} //while(event) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2052 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2053 |
SDL_GetMouseState(&mousex,&mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2054 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2055 |
// If the mouse button is released, make bMouseUp equal true |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2056 |
if (!SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2057 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2058 |
bMouseUp=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2059 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2060 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2061 |
if (SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(1) && bMouseUp) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2062 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2063 |
bMouseUp = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2064 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2065 |
//The Forward Button: |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2066 |
if ( (mousex>x+460) && (mousex<x+460+buttonXsize) && (mousey>y+420) && (mousey<y+420+40) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2067 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2068 |
lf.forward(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2069 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2070 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2071 |
//The back button: |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2072 |
if ( (mousex>x+20) && (mousex<x+20+buttonXsize) && (mousey>y+420) && (mousey<y+420+40) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2073 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2074 |
lf.back(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2075 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2076 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2077 |
for (int i=0;i<10;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2078 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2079 |
if ( (mousex>x+10) && (mousex<x+480) && (mousey>y+10+i*36) && (mousey<y+10+i*36+32) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2080 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2081 |
if (lf.fileExists(i)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2082 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2083 |
strncpy(name,lf.getFileName(i).c_str(),28); //Problems occurs then larger than 28 (maybe 29) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2084 |
done=true; //The user have, clicked the purpose of this function is now complete |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2085 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2086 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2087 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2088 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2089 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2090 |
DrawIMG(mouse,screen,mousex,mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2091 |
SDL_Flip(screen); //Update screen |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2092 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2093 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2094 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2095 |
//Slelect a theme |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2096 |
bool SelectThemeDialogbox(int x, int y, char *name) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2097 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2098 |
bool done = false; //We are done! |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2099 |
int mousex, mousey; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2100 |
ListFiles lf = ListFiles(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2101 |
string folder = (string)SHAREDIR+(string)"/themes"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2102 |
cout << "Looking in " << folder << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2103 |
lf.setDirectory(folder.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2104 |
#ifdef __unix__ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2105 |
string homeFolder = (string)getenv("HOME")+(string)"/.gamesaves/blockattack/themes"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2106 |
lf.setDirectory2(homeFolder.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2107 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2108 |
Uint8* keys; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2109 |
string strHolder; |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2110 |
MakeBackground(xsize,ysize); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2111 |
DrawIMG(background,screen,0,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2112 |
DrawIMG(bForward,background,x+460,y+420); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2113 |
DrawIMG(bBack,background,x+20,y+420); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2114 |
while (!done) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2115 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2116 |
DrawIMG(background,screen,0,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2117 |
const int nrOfFiles = 10; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2118 |
DrawIMG(changeButtonsBack,screen,x,y); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2119 |
for (int i=0;i<nrOfFiles;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2120 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2121 |
SFont_Write(screen,fBlueFont,x+10,y+10+36*i,lf.getFileName(i).c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2122 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2123 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2124 |
SDL_Event event; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2125 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2126 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2127 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2128 |
if ( event.type == SDL_QUIT ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2129 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2130 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2131 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2132 |
if ( event.type == SDL_KEYDOWN ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2133 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2134 |
if ( (event.key.keysym.sym == SDLK_ESCAPE) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2135 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2136 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2137 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2138 |
if ( (event.key.keysym.sym == SDLK_RIGHT) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2139 |
lf.forward(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2140 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2141 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2142 |
if ( (event.key.keysym.sym == SDLK_LEFT) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2143 |
lf.back(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2144 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2145 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2146 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2147 |
} //while(event) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2148 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2149 |
SDL_GetMouseState(&mousex,&mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2150 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2151 |
// If the mouse button is released, make bMouseUp equal true |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2152 |
if (!SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2153 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2154 |
bMouseUp=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2155 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2156 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2157 |
if (SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(1) && bMouseUp) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2158 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2159 |
bMouseUp = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2160 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2161 |
//The Forward Button: |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2162 |
if ( (mousex>x+460) && (mousex<x+460+buttonXsize) && (mousey>y+420) && (mousey<y+420+40) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2163 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2164 |
lf.forward(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2165 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2166 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2167 |
//The back button: |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2168 |
if ( (mousex>x+20) && (mousex<x+20+buttonXsize) && (mousey>y+420) && (mousey<y+420+40) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2169 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2170 |
lf.back(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2171 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2172 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2173 |
for (int i=0;i<10;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2174 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2175 |
if ( (mousex>x+10) && (mousex<x+480) && (mousey>y+10+i*36) && (mousey<y+10+i*36+32) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2176 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2177 |
if (lf.fileExists(i)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2178 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2179 |
strncpy(name,lf.getFileName(i).c_str(),28); //Problems occurs then larger than 28 (maybe 29) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2180 |
loadTheme(lf.getFileName(i)); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2181 |
done=true; //The user have, clicked the purpose of this function is now complete |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2182 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2183 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2184 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2185 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2186 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2187 |
DrawIMG(mouse,screen,mousex,mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2188 |
SDL_Flip(screen); //Update screen |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2189 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2190 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2191 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2192 |
//Open a saved replay |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2193 |
bool OpenReplayDialogbox(int x, int y, char *name) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2194 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2195 |
bool done = false; //We are done! |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2196 |
int mousex, mousey; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2197 |
ListFiles lf = ListFiles(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2198 |
cout << "Ready to set directory!" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2199 |
#ifdef __unix__ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2200 |
string directory = (string)getenv("HOME")+(string)"/.gamesaves/blockattack/replays"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2201 |
#elif WIN32 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2202 |
string directory = getMyDocumentsPath()+(string)"/My Games/blockattack/replays"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2203 |
#else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2204 |
string directory = "./replays"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2205 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2206 |
lf.setDirectory(directory); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2207 |
cout << "Directory sat" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2208 |
Uint8* keys; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2209 |
string strHolder; |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2210 |
MakeBackground(xsize,ysize); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2211 |
DrawIMG(background,screen,0,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2212 |
DrawIMG(bForward,background,x+460,y+420); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2213 |
DrawIMG(bBack,background,x+20,y+420); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2214 |
while (!done) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2215 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2216 |
DrawIMG(background,screen,0,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2217 |
const int nrOfFiles = 10; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2218 |
DrawIMG(changeButtonsBack,screen,x,y); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2219 |
for (int i=0;i<nrOfFiles;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2220 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2221 |
SFont_Write(screen,fBlueFont,x+10,y+10+36*i,lf.getFileName(i).c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2222 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2223 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2224 |
SDL_Event event; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2225 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2226 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2227 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2228 |
if ( event.type == SDL_QUIT ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2229 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2230 |
return false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2231 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2232 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2233 |
if ( event.type == SDL_KEYDOWN ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2234 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2235 |
if ( (event.key.keysym.sym == SDLK_ESCAPE) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2236 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2237 |
return false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2238 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2239 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2240 |
if ( (event.key.keysym.sym == SDLK_RIGHT) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2241 |
lf.forward(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2242 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2243 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2244 |
if ( (event.key.keysym.sym == SDLK_LEFT) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2245 |
lf.back(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2246 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2247 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2248 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2249 |
} //while(event) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2250 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2251 |
SDL_GetMouseState(&mousex,&mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2252 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2253 |
// If the mouse button is released, make bMouseUp equal true |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2254 |
if (!SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2255 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2256 |
bMouseUp=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2257 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2258 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2259 |
if (SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(1) && bMouseUp) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2260 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2261 |
bMouseUp = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2262 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2263 |
//The Forward Button: |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2264 |
if ( (mousex>x+460) && (mousex<x+460+buttonXsize) && (mousey>y+420) && (mousey<y+420+40) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2265 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2266 |
lf.forward(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2267 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2268 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2269 |
//The back button: |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2270 |
if ( (mousex>x+20) && (mousex<x+20+buttonXsize) && (mousey>y+420) && (mousey<y+420+40) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2271 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2272 |
lf.back(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2273 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2274 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2275 |
for (int i=0;i<10;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2276 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2277 |
if ( (mousex>x+10) && (mousex<x+480) && (mousey>y+10+i*36) && (mousey<y+10+i*36+32) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2278 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2279 |
if (lf.fileExists(i)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2280 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2281 |
strncpy(name,lf.getFileName(i).c_str(),28); //Problems occurs then larger than 28 (maybe 29) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2282 |
done=true; //The user have, clicked the purpose of this function is now complete |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2283 |
return true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2284 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2285 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2286 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2287 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2288 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2289 |
DrawIMG(mouse,screen,mousex,mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2290 |
SDL_Flip(screen); //Update screen |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2291 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2292 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2293 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2294 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2295 |
//draws options: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2296 |
inline void DrawOptions(int x, int y) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2297 |
{ |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2298 |
if (MusicEnabled) DrawIMG(bOn,optionsBack,400,buttonXsize); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2299 |
else DrawIMG(bOff,optionsBack,400,buttonXsize); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2300 |
if (SoundEnabled) DrawIMG(bOn,optionsBack,400,170); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2301 |
else DrawIMG(bOff,optionsBack,400,170); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2302 |
if (bFullscreen) DrawIMG(bOn,optionsBack,400,220); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2303 |
else DrawIMG(bOff,optionsBack,400,220); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2304 |
DrawIMG(bChange,optionsBack,230,435); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2305 |
DrawIMG(bChange,optionsBack,410,435); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2306 |
DrawIMG(bChange,optionsBack,230,500); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2307 |
DrawIMG(bChange,optionsBack,410,500); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2308 |
DrawIMG(optionsBack,screen,x,y); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2309 |
} //drawOptions |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2310 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2311 |
//Draws the balls and explosions |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2312 |
void DrawBalls() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2313 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2314 |
for (int i = 0; i< maxNumberOfBalls; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2315 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2316 |
if (theBallManeger.ballUsed[i]) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2317 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2318 |
DrawIMG(balls[theBallManeger.ballArray[i].getColor()],screen,theBallManeger.ballArray[i].getX(),theBallManeger.ballArray[i].getY()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2319 |
} //if used |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2320 |
if (theExplosionManeger.explosionUsed[i]) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2321 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2322 |
DrawIMG(explosion[theExplosionManeger.explosionArray[i].getFrame()],screen,theExplosionManeger.explosionArray[i].getX(),theExplosionManeger.explosionArray[i].getY()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2323 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2324 |
if (theTextManeger.textUsed[i]) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2325 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2326 |
//cout << "Printing text: " << theTextManeger.textArray[i].getText() << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2327 |
int x = theTextManeger.textArray[i].getX()-SFont_TextWidth(fSmallFont,theTextManeger.textArray[i].getText())/2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2328 |
int y = theTextManeger.textArray[i].getY()-SFont_TextHeight(fSmallFont)/2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2329 |
DrawIMG(iChainBack,screen,x,y); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2330 |
SFont_Write(screen,fSmallFont,x+(25-SFont_TextWidth(fSmallFont,theTextManeger.textArray[i].getText()))/2,y+(25-SFont_TextHeight(fSmallFont))/2,theTextManeger.textArray[i].getText()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2331 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2332 |
} //for |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2333 |
} //DrawBalls |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2334 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2335 |
//Removes the old balls |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2336 |
void UndrawBalls() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2337 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2338 |
for (int i = 0; i< maxNumberOfBalls; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2339 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2340 |
if (theBallManeger.oldBallUsed[i]) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2341 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2342 |
DrawIMG(background,screen,theBallManeger.oldBallArray[i].getX(),theBallManeger.oldBallArray[i].getY(),ballSize,ballSize,theBallManeger.oldBallArray[i].getX(),theBallManeger.oldBallArray[i].getY()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2343 |
} //if used |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2344 |
if (theExplosionManeger.oldExplosionUsed[i]) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2345 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2346 |
DrawIMG(background,screen,theExplosionManeger.oldExplosionArray[i].getX(),theExplosionManeger.oldExplosionArray[i].getY(),70,120,theExplosionManeger.oldExplosionArray[i].getX(),theExplosionManeger.oldExplosionArray[i].getY()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2347 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2348 |
if (theTextManeger.oldTextUsed[i]) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2349 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2350 |
int x = theTextManeger.oldTextArray[i].getX()-SFont_TextWidth(fSmallFont,theTextManeger.oldTextArray[i].getText())/2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2351 |
int y = theTextManeger.oldTextArray[i].getY()-SFont_TextHeight(fSmallFont)/2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2352 |
DrawIMG(background,screen,x,y,25,25,x,y); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2353 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2354 |
} //for |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2355 |
} //UndrawBalls |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2356 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2357 |
//draws everything |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2358 |
void DrawEverything(int xsize, int ysize,BlockGame &theGame, BlockGame &theGame2) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2359 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2360 |
SDL_ShowCursor(SDL_DISABLE); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2361 |
//draw background: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2362 |
if (forceredraw != 1) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2363 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2364 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2365 |
UndrawBalls(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2366 |
DrawIMG(background,screen,oldMousex,oldMousey,32,32,oldMousex,oldMousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2367 |
DrawIMG(background,screen,oldBubleX,oldBubleY,140,50,oldBubleX,oldBubleY); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2368 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2369 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2370 |
DrawIMG(background,screen,350,200,120,200,350,200); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2371 |
DrawIMG(background,screen,830,200,120,200,830,200); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2372 |
DrawIMG(background,screen,800,0,140,50,800,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2373 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2374 |
DrawIMG(background,screen,50,60,300,50,50,60); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2375 |
DrawIMG(background,screen,510,60,300,50,510,60); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2376 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2377 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2378 |
DrawIMG(background,screen,0,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2379 |
//draw bottons (should be moves and drawn directly to background once) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2380 |
if (!editorMode) |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
2381 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2382 |
if (!networkActive) //We don't show the menu while running server or connected to a server |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
2383 |
#else |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
2384 |
if(true) |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
2385 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2386 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2387 |
//Here we draw the menu |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2388 |
DrawIMG(bNewGame, screen, 0, 0); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2389 |
DrawIMG(bOptions, screen, buttonXsize,0); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2390 |
DrawIMG(bHighScore, screen, 2*buttonXsize,0); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2391 |
DrawIMG(bReplay,screen,3*buttonXsize,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2392 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2393 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2394 |
{ //If network is active |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2395 |
DrawIMG(bBack, screen, 0, 0); //Display a disconnect button |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2396 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2397 |
if (!editorMode) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2398 |
DrawIMG(bExit, screen, xsize-120,ysize-120); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2399 |
//DrawIMG(boardBackBack,screen,theGame.topx-60,theGame.topy-68); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2400 |
DrawIMG(theGame.sBoard,screen,theGame.topx,theGame.topy); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2401 |
string strHolder; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2402 |
strHolder = itoa(theGame.score+theGame.handicap); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2403 |
SFont_Write(screen,fBlueFont,theGame.topx+310,theGame.topy+100,strHolder.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2404 |
if (theGame.AI_Enabled) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2405 |
SFont_Write(screen,fBlueFont,theGame.topx+10,theGame.topy-40,"CPU"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2406 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2407 |
if (editorMode) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2408 |
SFont_Write(screen,fBlueFont,theGame.topx+10,theGame.topy-40,"Playing field"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2409 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2410 |
if (!singlePuzzle) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2411 |
SFont_Write(screen,fBlueFont,theGame.topx+10,theGame.topy-40,player1name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2412 |
if (theGame.timetrial) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2413 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2414 |
int tid = (int)SDL_GetTicks()-theGame.gameStartedAt; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2415 |
int minutes; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2416 |
int seconds; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2417 |
if (tid>=0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2418 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2419 |
minutes = (2*60*1000-(abs((int)SDL_GetTicks()-(int)theGame.gameStartedAt)))/60/1000; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2420 |
seconds = ((2*60*1000-(abs((int)SDL_GetTicks()-(int)theGame.gameStartedAt)))%(60*1000))/1000; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2421 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2422 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2423 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2424 |
minutes = ((abs((int)SDL_GetTicks()-(int)theGame.gameStartedAt)))/60/1000; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2425 |
seconds = (((abs((int)SDL_GetTicks()-(int)theGame.gameStartedAt)))%(60*1000))/1000; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2426 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2427 |
if (theGame.bGameOver) minutes=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2428 |
if (theGame.bGameOver) seconds=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2429 |
if (seconds>9) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2430 |
strHolder = itoa(minutes)+":"+itoa(seconds); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2431 |
else strHolder = itoa(minutes)+":0"+itoa(seconds); |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
2432 |
//if ((SoundEnabled)&&(!NoSound)&&(tid>0)&&(seconds<5)&&(minutes == 0)&&(seconds>1)&&(!(Mix_Playing(6)))) Mix_PlayChannel(6,heartBeat,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2433 |
SFont_Write(screen,fBlueFont,theGame.topx+310,theGame.topy+150,strHolder.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2434 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2435 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2436 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2437 |
int minutes = ((abs((int)SDL_GetTicks()-(int)theGame.gameStartedAt)))/60/1000; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2438 |
int seconds = (((abs((int)SDL_GetTicks()-(int)theGame.gameStartedAt)))%(60*1000))/1000; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2439 |
if (theGame.bGameOver) minutes=(theGame.gameEndedAfter/1000/60)%100; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2440 |
if (theGame.bGameOver) seconds=(theGame.gameEndedAfter/1000)%60; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2441 |
if (seconds>9) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2442 |
strHolder = itoa(minutes)+":"+itoa(seconds); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2443 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2444 |
strHolder = itoa(minutes)+":0"+itoa(seconds); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2445 |
SFont_Write(screen,fBlueFont,theGame.topx+310,theGame.topy+150,strHolder.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2446 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2447 |
strHolder = itoa(theGame.chain); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2448 |
SFont_Write(screen,fBlueFont,theGame.topx+310,theGame.topy+200,strHolder.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2449 |
//drawspeedLevel: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2450 |
strHolder = itoa(theGame.speedLevel); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2451 |
SFont_Write(screen,fBlueFont,theGame.topx+310,theGame.topy+250,strHolder.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2452 |
if ((theGame.stageClear) &&(theGame.topy+700+50*(theGame.stageClearLimit-theGame.linesCleared)-theGame.pixels-1<600+theGame.topy)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2453 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2454 |
oldBubleX = theGame.topx+280; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2455 |
oldBubleY = theGame.topy+650+50*(theGame.stageClearLimit-theGame.linesCleared)-theGame.pixels-1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2456 |
DrawIMG(stageBobble,screen,theGame.topx+280,theGame.topy+650+50*(theGame.stageClearLimit-theGame.linesCleared)-theGame.pixels-1); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2457 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2458 |
//player1 finnish, player2 start |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2459 |
//DrawIMG(boardBackBack,screen,theGame2.topx-60,theGame2.topy-68); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2460 |
if (!editorMode) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2461 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2462 |
DrawIMG(theGame2.sBoard,screen,theGame2.topx,theGame2.topy); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2463 |
strHolder = itoa(theGame2.score+theGame2.handicap); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2464 |
SFont_Write(screen,fBlueFont,theGame2.topx+310,theGame2.topy+100,strHolder.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2465 |
if (theGame2.AI_Enabled) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2466 |
SFont_Write(screen,fBlueFont,theGame2.topx+10,theGame2.topy-40,"CPU"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2467 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2468 |
SFont_Write(screen,fBlueFont,theGame2.topx+10,theGame2.topy-40,theGame2.name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2469 |
if (theGame2.timetrial) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2470 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2471 |
int tid = (int)SDL_GetTicks()-theGame2.gameStartedAt; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2472 |
int minutes; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2473 |
int seconds; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2474 |
if (tid>=0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2475 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2476 |
minutes = (2*60*1000-(abs((int)SDL_GetTicks()-(int)theGame2.gameStartedAt)))/60/1000; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2477 |
seconds = ((2*60*1000-(abs((int)SDL_GetTicks()-(int)theGame2.gameStartedAt)))%(60*1000))/1000; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2478 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2479 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2480 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2481 |
minutes = ((abs((int)SDL_GetTicks()-(int)theGame2.gameStartedAt)))/60/1000; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2482 |
seconds = (((abs((int)SDL_GetTicks()-(int)theGame2.gameStartedAt)))%(60*1000))/1000; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2483 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2484 |
if (theGame2.bGameOver) minutes=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2485 |
if (theGame2.bGameOver) seconds=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2486 |
if (seconds>9) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2487 |
strHolder = itoa(minutes)+":"+itoa(seconds); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2488 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2489 |
strHolder = itoa(minutes)+":0"+itoa(seconds); |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
2490 |
//if ((SoundEnabled)&&(!NoSound)&&(tid>0)&&(seconds<5)&&(minutes == 0)&&(seconds>1)&&(!(Mix_Playing(6)))) Mix_PlayChannel(6,heartBeat,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2491 |
SFont_Write(screen,fBlueFont,theGame2.topx+310,theGame2.topy+150,strHolder.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2492 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2493 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2494 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2495 |
int minutes = (abs((int)SDL_GetTicks()-(int)theGame2.gameStartedAt))/60/1000; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2496 |
int seconds = (abs((int)SDL_GetTicks()-(int)theGame2.gameStartedAt)%(60*1000))/1000; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2497 |
if (theGame2.bGameOver) minutes=(theGame2.gameEndedAfter/1000/60)%100; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2498 |
if (theGame2.bGameOver) seconds=(theGame2.gameEndedAfter/1000)%60; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2499 |
if (seconds>9) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2500 |
strHolder = itoa(minutes)+":"+itoa(seconds); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2501 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2502 |
strHolder = itoa(minutes)+":0"+itoa(seconds); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2503 |
SFont_Write(screen,fBlueFont,theGame2.topx+310,theGame2.topy+150,strHolder.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2504 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2505 |
strHolder = itoa(theGame2.chain); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2506 |
SFont_Write(screen,fBlueFont,theGame2.topx+310,theGame2.topy+200,strHolder.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2507 |
strHolder = itoa(theGame2.speedLevel); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2508 |
SFont_Write(screen,fBlueFont,theGame2.topx+310,theGame2.topy+250,strHolder.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2509 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2510 |
//player2 finnish |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2511 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2512 |
if (bNewGameOpen) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2513 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2514 |
DrawIMG(b1player,screen,0,40); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2515 |
DrawIMG(b2players,screen,0,80); |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
2516 |
#if NETWORK |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2517 |
DrawIMG(bNetwork,screen,0,buttonXsize); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2518 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2519 |
if (b1playerOpen) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2520 |
{ |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2521 |
DrawIMG(bEndless,screen,buttonXsize,40); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2522 |
DrawIMG(bTimeTrial,screen,buttonXsize,80); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2523 |
DrawIMG(bStageClear,screen,buttonXsize,buttonXsize); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2524 |
DrawIMG(bPuzzle,screen,buttonXsize,160); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2525 |
DrawIMG(bVsMode,screen,buttonXsize,200); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2526 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2527 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2528 |
if (b2playersOpen) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2529 |
{ |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2530 |
DrawIMG(bTimeTrial,screen,buttonXsize,80); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2531 |
DrawIMG(bVsMode,screen,buttonXsize,120); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2532 |
} |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
2533 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2534 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2535 |
if (bNetworkOpen) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2536 |
{ |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2537 |
DrawIMG(bHost,screen,buttonXsize,120); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2538 |
DrawIMG(bConnect,screen,buttonXsize,160); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2539 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2540 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2541 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2542 |
if (bOptionsOpen) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2543 |
{ |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2544 |
DrawIMG(bConfigure,screen,buttonXsize,40); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2545 |
DrawIMG(bSelectPuzzle,screen,buttonXsize,80); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2546 |
DrawIMG(bVsModeConfig,screen,buttonXsize,120); |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
2547 |
DrawIMG(bTheme,screen,buttonXsize,160); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2548 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2549 |
if (bReplayOpen) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2550 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2551 |
DrawIMG(bSave,screen,360,40); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2552 |
DrawIMG(bLoad,screen,360,80); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2553 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2554 |
if (showOptions) DrawOptions(100,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2555 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2556 |
DrawBalls(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2557 |
|
| 1572de2b |
sago007 |
2008-09-11 18:15 |
2558 |
#if DEBUG |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2559 |
Frames++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2560 |
if (SDL_GetTicks() >= Ticks + 1000) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2561 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2562 |
if (Frames > 999) Frames=999; |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
2563 |
sprintf(FPS, "%lu fps", Frames); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2564 |
Frames = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2565 |
Ticks = SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2566 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2567 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2568 |
SFont_Write(screen,fBlueFont,800,4,FPS); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2569 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2570 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2571 |
//SDL_Flip(screen); Update screen is now called outside DrawEvrything, bacause the mouse needs to be painted |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2572 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2573 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2574 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2575 |
//Generates the standard background |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2576 |
void MakeBackground(int xsize,int ysize) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2577 |
{ |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2578 |
int w = backgroundImage->w; |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2579 |
int h = backgroundImage->h; |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2580 |
for(int i=0;i*w<xsize;i++) |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2581 |
for(int j=0;j*h<ysize;j++) |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2582 |
DrawIMG(backgroundImage,background,i*w,j*h); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2583 |
standardBackground = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2584 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2585 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2586 |
//Generates the background with red board backs |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2587 |
void MakeBackground(int xsize,int ysize,BlockGame &theGame, BlockGame &theGame2) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2588 |
{ |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2589 |
MakeBackground(xsize,ysize); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2590 |
DrawIMG(boardBackBack,background,theGame.topx-60,theGame.topy-68); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2591 |
DrawIMG(boardBackBack,background,theGame2.topx-60,theGame2.topy-68); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2592 |
standardBackground = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2593 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2594 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2595 |
void MakeBackground(int xsize, int ysize, BlockGame &theGame) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2596 |
{ |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2597 |
MakeBackground(xsize,ysize); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2598 |
DrawIMG(boardBackBack,background,theGame.topx-60,theGame.topy-68); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2599 |
standardBackground = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2600 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2601 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2602 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2603 |
//The function that allows the player to choose PuzzleLevel |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2604 |
int PuzzleLevelSelect() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2605 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2606 |
const int xplace = 200; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2607 |
const int yplace = 300; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2608 |
Uint8 *keys; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2609 |
int levelNr, mousex, mousey; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2610 |
bool levelSelected = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2611 |
bool tempBool; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2612 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2613 |
//Loads the levels, if they havn't been loaded: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2614 |
LoadPuzzleStages(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2615 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2616 |
//Keeps track of background; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2617 |
int nowTime=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2618 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2619 |
ifstream puzzleFile(puzzleSavePath.c_str(),ios::binary); |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2620 |
MakeBackground(xsize,ysize); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2621 |
if (puzzleFile) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2622 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2623 |
for (int i=0;(i<nrOfPuzzles)&&(!puzzleFile.eof()); i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2624 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2625 |
puzzleFile.read(reinterpret_cast<char*>(&tempBool),sizeof(bool)); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2626 |
puzzleCleared[i] = tempBool; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2627 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2628 |
puzzleFile.close(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2629 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2630 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2631 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2632 |
tempBool = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2633 |
for (int i=0; i<nrOfPuzzles; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2634 |
puzzleCleared[i] = tempBool; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2635 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2636 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2637 |
do |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2638 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2639 |
nowTime=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2640 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2641 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2642 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2643 |
DrawIMG(iCheckBoxArea,screen,xplace,yplace); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2644 |
SFont_Write(screen,fBlueFont,xplace+12,yplace+2,"Select Puzzle"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2645 |
//Now drow the fields you click in (and a V if clicked): |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2646 |
for (int i = 0; i < nrOfPuzzles;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2647 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2648 |
DrawIMG(iLevelCheckBox,screen,xplace+10+(i%10)*50, yplace+60+(i/10)*50); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2649 |
if (puzzleCleared[i]==true) DrawIMG(iLevelCheck,screen,xplace+10+(i%10)*50, yplace+60+(i/10)*50); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2650 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2651 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2652 |
SDL_Event event; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2653 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2654 |
if ( event.type == SDL_KEYDOWN ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2655 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2656 |
if ( event.key.keysym.sym == SDLK_ESCAPE ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2657 |
levelNr = -1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2658 |
levelSelected = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2659 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2660 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2661 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2662 |
keys = SDL_GetKeyState(NULL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2663 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2664 |
SDL_GetMouseState(&mousex,&mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2665 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2666 |
// If the mouse button is released, make bMouseUp equal true |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2667 |
if (!SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2668 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2669 |
bMouseUp=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2670 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2671 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2672 |
if (SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(1) && bMouseUp) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2673 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2674 |
bMouseUp = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2675 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2676 |
int levelClicked = -1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2677 |
int i; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2678 |
for (i = 0; (i<nrOfPuzzles/10)||((i<nrOfPuzzles/10+1)&&(nrOfPuzzles%10 != 0)); i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2679 |
if ((60+i*50<mousey-yplace)&&(mousey-yplace<i*50+92)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2680 |
levelClicked = i*10; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2681 |
i++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2682 |
if (levelClicked != -1) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2683 |
for (int j = 0; ((j<nrOfStageLevels%(i*10))&&(j<10)); j++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2684 |
if ((10+j*50<mousex-xplace)&&(mousex-xplace<j*50+42)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2685 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2686 |
levelClicked +=j; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2687 |
levelSelected = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2688 |
levelNr = levelClicked; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2689 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2690 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2691 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2692 |
DrawIMG(mouse,screen,mousex,mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2693 |
SDL_Flip(screen); //draws it all to the screen |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2694 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2695 |
} while (!levelSelected); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2696 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2697 |
return levelNr; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2698 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2699 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2700 |
//The function that allows the player to choose Level number |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2701 |
int StageLevelSelect() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2702 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2703 |
const int xplace = 200; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2704 |
const int yplace = 300; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2705 |
Uint8 *keys; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2706 |
int levelNr, mousex, mousey; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2707 |
bool levelSelected = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2708 |
bool tempBool; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2709 |
Uint32 tempUInt32; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2710 |
Uint32 totalScore = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2711 |
Uint32 totalTime = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2712 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2713 |
//Keeps track of background; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2714 |
//int nowTime=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2715 |
|
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2716 |
MakeBackground(xsize,ysize); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2717 |
ifstream stageFile(stageClearSavePath.c_str(),ios::binary); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2718 |
if (stageFile) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2719 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2720 |
for (int i = 0; i<nrOfStageLevels; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2721 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2722 |
stageFile.read(reinterpret_cast<char*>(&tempBool),sizeof(bool)); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2723 |
stageCleared[i]=tempBool; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2724 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2725 |
if(!stageFile.eof()) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2726 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2727 |
for(int i=0; i<nrOfStageLevels; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2728 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2729 |
tempUInt32 = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2730 |
if(!stageFile.eof()) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2731 |
stageFile.read(reinterpret_cast<char*>(&tempUInt32),sizeof(Uint32)); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2732 |
stageScores[i]=tempUInt32; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2733 |
totalScore+=tempUInt32; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2734 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2735 |
for(int i=0; i<nrOfStageLevels; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2736 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2737 |
tempUInt32 = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2738 |
if(!stageFile.eof()) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2739 |
stageFile.read(reinterpret_cast<char*>(&tempUInt32),sizeof(Uint32)); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2740 |
stageTimes[i]=tempUInt32; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2741 |
totalTime += tempUInt32; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2742 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2743 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2744 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2745 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2746 |
for(int i=0; i<nrOfStageLevels; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2747 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2748 |
stageScores[i]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2749 |
stageTimes[i]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2750 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2751 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2752 |
stageFile.close(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2753 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2754 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2755 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2756 |
for (int i=0; i<nrOfStageLevels; i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2757 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2758 |
stageCleared[i]= false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2759 |
stageScores[i]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2760 |
stageTimes[i]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2761 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2762 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2763 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2764 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2765 |
do |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2766 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2767 |
//nowTime=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2768 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2769 |
DrawIMG(iCheckBoxArea,screen,xplace,yplace); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2770 |
SFont_Write(screen,fBlueFont,xplace+12,yplace+2,"Stage Clear Level Select"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2771 |
for (int i = 0; i < nrOfStageLevels;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2772 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2773 |
DrawIMG(iLevelCheckBox,screen,xplace+10+(i%10)*50, yplace+60+(i/10)*50); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2774 |
if (stageCleared[i]==true) DrawIMG(iLevelCheck,screen,xplace+10+(i%10)*50, yplace+60+(i/10)*50); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2775 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2776 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2777 |
SDL_Event event; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2778 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2779 |
if ( event.type == SDL_KEYDOWN ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2780 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2781 |
if ( event.key.keysym.sym == SDLK_ESCAPE ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2782 |
levelNr = -1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2783 |
levelSelected = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2784 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2785 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2786 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2787 |
keys = SDL_GetKeyState(NULL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2788 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2789 |
SDL_GetMouseState(&mousex,&mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2790 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2791 |
// If the mouse button is released, make bMouseUp equal true |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2792 |
if (!SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2793 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2794 |
bMouseUp=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2795 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2796 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2797 |
if (SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(1) && bMouseUp) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2798 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2799 |
bMouseUp = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2800 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2801 |
int levelClicked = -1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2802 |
int i; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2803 |
for (i = 0; (i<nrOfStageLevels/10)||((i<nrOfStageLevels/10+1)&&(nrOfStageLevels%10 != 0)); i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2804 |
if ((60+i*50<mousey-yplace)&&(mousey-yplace<i*50+92)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2805 |
levelClicked = i*10; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2806 |
i++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2807 |
if (levelClicked != -1) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2808 |
for (int j = 0; ((j<nrOfStageLevels%(i*10))&&(j<10)); j++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2809 |
if ((10+j*50<mousex-xplace)&&(mousex-xplace<j*50+42)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2810 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2811 |
levelClicked +=j; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2812 |
levelSelected = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2813 |
levelNr = levelClicked; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2814 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2815 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2816 |
//Find what we are over: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2817 |
int overLevel = -1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2818 |
int i; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2819 |
for (i = 0; (i<nrOfStageLevels/10)||((i<nrOfStageLevels/10+1)&&(nrOfStageLevels%10 != 0)); i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2820 |
if ((60+i*50<mousey-yplace)&&(mousey-yplace<i*50+92)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2821 |
overLevel = i*10; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2822 |
i++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2823 |
if (overLevel != -1) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2824 |
for (int j = 0; ((j<nrOfStageLevels%(i*10))&&(j<10)); j++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2825 |
if ((10+j*50<mousex-xplace)&&(mousex-xplace<j*50+42)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2826 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2827 |
overLevel +=j; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2828 |
string scoreString = "Best score: 0"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2829 |
string timeString = "Time used: -- : --"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2830 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2831 |
if(stageScores.at(overLevel)>0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2832 |
scoreString = "Best score: "+itoa(stageScores[overLevel]); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2833 |
if(stageTimes[overLevel]>0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2834 |
timeString = "Time used: "+itoa(stageTimes[overLevel]/1000/60)+" : "+itoa2((stageTimes[overLevel]/1000)%60); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2835 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2836 |
SFont_Write(screen,fBlueFont,200,200,scoreString.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2837 |
SFont_Write(screen,fBlueFont,200,250,timeString.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2838 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2839 |
overLevel; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2840 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2841 |
string totalString = "Total score: " +itoa(totalScore) + " in " + itoa(totalTime/1000/60) + " : " + itoa2((totalTime/1000)%60); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2842 |
SFont_Write(screen,fBlueFont,200,600,totalString.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2843 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2844 |
DrawIMG(mouse,screen,mousex,mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2845 |
SDL_Flip(screen); //draws it all to the screen |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2846 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2847 |
} while (!levelSelected); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2848 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2849 |
return levelNr; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2850 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2851 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2852 |
//Ask user for what AI level he will compete agains, return the number. Number must be 0..AIlevels |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2853 |
int startSingleVs() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2854 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2855 |
//Where to place the windows |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2856 |
const int xplace = 200; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2857 |
const int yplace = 100; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2858 |
Uint8 *keys; //To take keyboard input |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2859 |
int mousex, mousey; //To allow mouse |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2860 |
bool done = false; //When are we done? |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2861 |
|
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2862 |
MakeBackground(xsize,ysize); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2863 |
DrawIMG(changeButtonsBack,background,xplace,yplace); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2864 |
SFont_Write(background,fBlueFont,xplace+10,yplace+10,"1 : Very Easy"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2865 |
SFont_Write(background,fBlueFont,xplace+10,yplace+40,"2 : Easy"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2866 |
SFont_Write(background,fBlueFont,xplace+10,yplace+70,"3 : Below Normal"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2867 |
SFont_Write(background,fBlueFont,xplace+10,yplace+100,"4 : Normal"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2868 |
SFont_Write(background,fBlueFont,xplace+10,yplace+130,"5 : Above Normal"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2869 |
SFont_Write(background,fBlueFont,xplace+10,yplace+160,"6 : Hard"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2870 |
SFont_Write(background,fBlueFont,xplace+10,yplace+190,"7 : Hardest"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2871 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2872 |
SDL_Flip(screen); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2873 |
do |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2874 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2875 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2876 |
SDL_Delay(10); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2877 |
SDL_Event event; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2878 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2879 |
if ( event.type == SDL_KEYDOWN ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2880 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2881 |
if ( event.key.keysym.sym == SDLK_ESCAPE ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2882 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2883 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2884 |
if ( event.key.keysym.sym == SDLK_RETURN ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2885 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2886 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2887 |
if ( event.key.keysym.sym == SDLK_KP_ENTER ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2888 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2889 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2890 |
if ( event.key.keysym.sym == SDLK_1 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2891 |
return 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2892 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2893 |
if ( event.key.keysym.sym == SDLK_2 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2894 |
return 1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2895 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2896 |
if ( event.key.keysym.sym == SDLK_3 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2897 |
return 2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2898 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2899 |
if ( event.key.keysym.sym == SDLK_4 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2900 |
return 3; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2901 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2902 |
if ( event.key.keysym.sym == SDLK_5 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2903 |
return 4; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2904 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2905 |
if ( event.key.keysym.sym == SDLK_6 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2906 |
return 5; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2907 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2908 |
if ( event.key.keysym.sym == SDLK_7 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2909 |
return 6; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2910 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2911 |
if ( event.key.keysym.sym == SDLK_KP1 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2912 |
return 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2913 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2914 |
if ( event.key.keysym.sym == SDLK_KP2 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2915 |
return 1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2916 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2917 |
if ( event.key.keysym.sym == SDLK_KP3 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2918 |
return 2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2919 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2920 |
if ( event.key.keysym.sym == SDLK_KP4 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2921 |
return 3; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2922 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2923 |
if ( event.key.keysym.sym == SDLK_KP5 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2924 |
return 4; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2925 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2926 |
if ( event.key.keysym.sym == SDLK_KP6 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2927 |
return 5; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2928 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2929 |
if ( event.key.keysym.sym == SDLK_KP7 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2930 |
return 6; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2931 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2932 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2933 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2934 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2935 |
// If the mouse button is released, make bMouseUp equal true |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2936 |
if (!SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2937 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2938 |
bMouseUp=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2939 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2940 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2941 |
if (SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(1) && bMouseUp) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2942 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2943 |
bMouseUp = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2944 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2945 |
for (int i=0; i<7;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2946 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2947 |
if ((mousex>xplace+10)&&(mousex<xplace+410)&&(mousey>yplace+10+i*30)&&(mousey<yplace+38+i*30)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2948 |
return i; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2949 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2950 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2951 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2952 |
SDL_GetMouseState(&mousex,&mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2953 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2954 |
DrawIMG(mouse,screen,mousex,mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2955 |
SDL_Flip(screen); //draws it all to the screen |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2956 |
}while (!done); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2957 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2958 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2959 |
return 3; //Returns normal |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2960 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2961 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2962 |
//The function that allows the player to choose Level number |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2963 |
void startVsMenu() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2964 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2965 |
const int xplace = 200; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2966 |
const int yplace = 100; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2967 |
Uint8 *keys; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2968 |
int mousex, mousey; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2969 |
bool done = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2970 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2971 |
//Keeps track of background; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2972 |
//int nowTime=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2973 |
|
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2974 |
MakeBackground(xsize,ysize); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2975 |
SFont_Write(background,fBlueFont,360,650,"Press ESC to accept"); |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
2976 |
DrawIMG(bBack,background,xsize/2-120/2,600); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2977 |
do |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2978 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2979 |
//nowTime=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2980 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2981 |
DrawIMG(changeButtonsBack,screen,xplace,yplace); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2982 |
SFont_Write(screen,fBlueFont,xplace+50,yplace+20,"Player 1"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2983 |
SFont_Write(screen,fBlueFont,xplace+300+50,yplace+20,"Player 2"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2984 |
SFont_Write(screen,fBlueFont,xplace+50,yplace+70,"Speed:"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2985 |
SFont_Write(screen,fBlueFont,xplace+50+300,yplace+70,"Speed:"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2986 |
for (int i=0; i<5;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2987 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2988 |
char levelS[2]; //level string; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2989 |
levelS[0]='1'+i; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2990 |
levelS[1]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2991 |
SFont_Write(screen,fBlueFont,xplace+50+i*40,yplace+110,levelS); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2992 |
DrawIMG(iLevelCheckBox,screen,xplace+50+i*40,yplace+150); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2993 |
if (player1Speed==i) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2994 |
DrawIMG(iLevelCheck,screen,xplace+50+i*40,yplace+150); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2995 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2996 |
for (int i=0; i<5;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2997 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2998 |
char levelS[2]; //level string; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
2999 |
levelS[0]='1'+i; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3000 |
levelS[1]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3001 |
SFont_Write(screen,fBlueFont,xplace+300+50+i*40,yplace+110,levelS); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3002 |
DrawIMG(iLevelCheckBox,screen,xplace+300+50+i*40,yplace+150); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3003 |
if (player2Speed==i) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3004 |
DrawIMG(iLevelCheck,screen,xplace+300+50+i*40,yplace+150); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3005 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3006 |
SFont_Write(screen,fBlueFont,xplace+50,yplace+200,"AI: "); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3007 |
DrawIMG(iLevelCheckBox,screen,xplace+50+70,yplace+200); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3008 |
if (player1AI) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3009 |
DrawIMG(iLevelCheck,screen,xplace+50+70,yplace+200); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3010 |
SFont_Write(screen,fBlueFont,xplace+50,yplace+250,"TT Handicap: "); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3011 |
SFont_Write(screen,fBlueFont,xplace+50+300,yplace+200,"AI: "); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3012 |
DrawIMG(iLevelCheckBox,screen,xplace+50+70+300,yplace+200); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3013 |
if (player2AI) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3014 |
DrawIMG(iLevelCheck,screen,xplace+50+70+300,yplace+200); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3015 |
SFont_Write(screen,fBlueFont,xplace+50+300,yplace+250,"TT Handicap: "); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3016 |
for (int i=0; i<5;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3017 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3018 |
char levelS[2]; //level string; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3019 |
levelS[0]='1'+i; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3020 |
levelS[1]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3021 |
SFont_Write(screen,fBlueFont,xplace+50+i*40,yplace+290,levelS); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3022 |
DrawIMG(iLevelCheckBox,screen,xplace+50+i*40,yplace+330); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3023 |
if (player1handicap==i) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3024 |
DrawIMG(iLevelCheck,screen,xplace+50+i*40,yplace+330); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3025 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3026 |
for (int i=0; i<5;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3027 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3028 |
char levelS[2]; //level string; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3029 |
levelS[0]='1'+i; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3030 |
levelS[1]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3031 |
SFont_Write(screen,fBlueFont,xplace+50+i*40+300,yplace+290,levelS); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3032 |
DrawIMG(iLevelCheckBox,screen,xplace+50+i*40+300,yplace+330); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3033 |
if (player2handicap==i) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3034 |
DrawIMG(iLevelCheck,screen,xplace+50+i*40+300,yplace+330); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3035 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3036 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3037 |
SDL_Event event; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3038 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3039 |
if ( event.type == SDL_KEYDOWN ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3040 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3041 |
if ( event.key.keysym.sym == SDLK_ESCAPE ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3042 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3043 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3044 |
if ( event.key.keysym.sym == SDLK_RETURN ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3045 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3046 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3047 |
if ( event.key.keysym.sym == SDLK_KP_ENTER ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3048 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3049 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3050 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3051 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3052 |
keys = SDL_GetKeyState(NULL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3053 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3054 |
SDL_GetMouseState(&mousex,&mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3055 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3056 |
// If the mouse button is released, make bMouseUp equal true |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3057 |
if (!SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3058 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3059 |
bMouseUp=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3060 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3061 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3062 |
if (SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(1) && bMouseUp) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3063 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3064 |
bMouseUp = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3065 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3066 |
if ((mousex>xplace+50+70)&&(mousey>yplace+200)&&(mousex<xplace+50+70+30)&&(mousey<yplace+200+30)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3067 |
player1AI=!player1AI; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3068 |
if ((mousex>xplace+50+70+300)&&(mousey>yplace+200)&&(mousex<xplace+50+70+30+300)&&(mousey<yplace+200+30)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3069 |
player2AI=!player2AI; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3070 |
for (int i=0; i<5;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3071 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3072 |
if ((mousex>xplace+50+i*40)&&(mousex<xplace+50+i*40+30)&&(mousey>yplace+150)&&(mousey<yplace+150+30)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3073 |
player1Speed=i; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3074 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3075 |
for (int i=0; i<5;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3076 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3077 |
if ((mousex>xplace+50+i*40+300)&&(mousex<xplace+50+i*40+30+300)&&(mousey>yplace+150)&&(mousey<yplace+150+30)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3078 |
player2Speed=i; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3079 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3080 |
for (int i=0; i<5;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3081 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3082 |
if ((mousex>xplace+50+i*40)&&(mousex<xplace+50+i*40+30)&&(mousey>yplace+330)&&(mousey<yplace+330+30)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3083 |
player1handicap=i; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3084 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3085 |
for (int i=0; i<5;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3086 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3087 |
if ((mousex>xplace+50+i*40+300)&&(mousex<xplace+50+i*40+30+300)&&(mousey>yplace+330)&&(mousey<yplace+330+30)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3088 |
player2handicap=i; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3089 |
} |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
3090 |
if ((mousex>xsize/2-120/2)&&(mousex<xsize/2+120/2)&&(mousey>600)&&(mousey<640)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3091 |
done = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3092 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3093 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3094 |
DrawIMG(mouse,screen,mousex,mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3095 |
SDL_Flip(screen); //draws it all to the screen |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3096 |
SDL_Delay(10); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3097 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3098 |
} while (!done); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3099 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3100 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3101 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3102 |
//This function will promt for the user to select another file for puzzle mode |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3103 |
void changePuzzleLevels() |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3104 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3105 |
char theFileName[30]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3106 |
strcpy(theFileName,puzzleName.c_str()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3107 |
for (int i=puzzleName.length();i<30;i++) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3108 |
theFileName[i]=' '; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3109 |
theFileName[29]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3110 |
if (OpenFileDialogbox(200,100,theFileName)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3111 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3112 |
for (int i=28;((theFileName[i]==' ')&&(i>0));i--) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3113 |
theFileName[i]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3114 |
puzzleName = theFileName; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3115 |
#if defined(__unix__) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3116 |
string home = getenv("HOME"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3117 |
puzzleSavePath = home+"/.gamesaves/blockattack/"+puzzleName+".save"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3118 |
#elif defined(_WIN32) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3119 |
string home = getMyDocumentsPath(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3120 |
if (&home!=NULL) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3121 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3122 |
puzzleSavePath = home+"/My Games/blockattack/"+puzzleName+".save"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3123 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3124 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3125 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3126 |
puzzleSavePath = puzzleName+".save"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3127 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3128 |
#else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3129 |
puzzleSavePath = puzzleName+".save"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3130 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3131 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3132 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3133 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3134 |
|
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3135 |
class Keymenu { |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3136 |
static void setXY(int x, int y) |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3137 |
{ |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3138 |
keymenu.x = x; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3139 |
keymenu.y = y; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3140 |
} |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3141 |
|
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3142 |
static void startMenu() |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3143 |
{ |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3144 |
keymenu.activated = true; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3145 |
setXY(0,0); |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3146 |
} |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3147 |
|
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3148 |
static void stopMenu() |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3149 |
{ |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3150 |
keymenu.activated = false; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3151 |
} |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3152 |
}; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3153 |
|
| 1572de2b |
sago007 |
2008-09-11 18:15 |
3154 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3155 |
#include "NetworkThing.hpp" |
| eec83b7d |
sago007 |
2009-03-29 15:46 |
3156 |
//#include "MenuSystem.h" |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3157 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3158 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3159 |
//The main function, quite big... too big |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3160 |
int main(int argc, char *argv[]) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3161 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3162 |
//We first create the folder there we will save (only on UNIX systems) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3163 |
//we call the external command "mkdir"... the user might have renamed this, but we hope he hasn't |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3164 |
#if defined(__unix__) |
| 42f8ed5f |
sago007 |
2009-03-05 11:47 |
3165 |
//Compiler warns about unused result. The users envisonment should normally give the user all the information he needs |
| 42f8ed5f |
sago007 |
2009-03-05 11:47 |
3166 |
if(system("mkdir -p ~/.gamesaves/blockattack/screenshots")) |
| 42f8ed5f |
sago007 |
2009-03-05 11:47 |
3167 |
cout << "mkdir error creating ~/.gamesaves/blockattack/screenshots" << endl; |
| 42f8ed5f |
sago007 |
2009-03-05 11:47 |
3168 |
if(system("mkdir -p ~/.gamesaves/blockattack/replays")) |
| 42f8ed5f |
sago007 |
2009-03-05 11:47 |
3169 |
cout << "mkdir error creating ~/.gamesaves/blockattack/replays" << endl; |
| 42f8ed5f |
sago007 |
2009-03-05 11:47 |
3170 |
if(system("mkdir -p ~/.gamesaves/blockattack/puzzles")) |
| 42f8ed5f |
sago007 |
2009-03-05 11:47 |
3171 |
cout << "mkdir error creating ~/.gamesaves/blockattack/puzzles" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3172 |
#elif defined(_WIN32) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3173 |
//Now for Windows NT/2k/xp/2k3 etc. |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3174 |
string tempA = getMyDocumentsPath()+"\\My Games"; |
| c325f4fa |
sago007 |
2009-05-09 18:33 |
3175 |
CreateDirectory(tempA.c_str(),NULL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3176 |
tempA = getMyDocumentsPath()+"\\My Games\\blockattack"; |
| c325f4fa |
sago007 |
2009-05-09 18:33 |
3177 |
CreateDirectory(tempA.c_str(),NULL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3178 |
tempA = getMyDocumentsPath()+"\\My Games\\blockattack\\replays"; |
| c325f4fa |
sago007 |
2009-05-09 18:33 |
3179 |
CreateDirectory(tempA.c_str(),NULL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3180 |
tempA = getMyDocumentsPath()+"\\My Games\\blockattack\\screenshots"; |
| c325f4fa |
sago007 |
2009-05-09 18:33 |
3181 |
CreateDirectory(tempA.c_str(),NULL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3182 |
#endif |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
3183 |
highPriority = false; //if true the game will take most resources, but increase framerate. |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3184 |
bFullscreen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3185 |
if (argc > 1) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3186 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3187 |
int argumentNr = 1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3188 |
forceredraw = 2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3189 |
while (argc>argumentNr) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3190 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3191 |
char helpString[] = "--help"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3192 |
char priorityString[] = "-priority"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3193 |
char forceRedrawString[] = "-forceredraw"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3194 |
char forcepartdrawString[] = "-forcepartdraw"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3195 |
char singlePuzzleString[] = "-SP"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3196 |
char noSoundAtAll[] = "-nosound"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3197 |
char IntegratedEditor[] = "-editor"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3198 |
if (!(strncmp(argv[argumentNr],helpString,6))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3199 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3200 |
cout << "Block Attack Help" << endl << "--help Display this message" << |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3201 |
endl << "-priority Starts game in high priority" << endl << |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3202 |
"-forceredraw Redraw the whole screen every frame, prevents garbage" << endl << |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3203 |
"-forcepartdraw Only draw what is changed, sometimes cause garbage" << endl << |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3204 |
"-nosound No sound will be played at all, and sound hardware want be loaded (use this if game crashes because of sound)" << endl << |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3205 |
"-editor Starts the build-in editor (not yet integrated)" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3206 |
#ifdef WIN32 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3207 |
system("Pause"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3208 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3209 |
return 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3210 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3211 |
if (!(strncmp(argv[argumentNr],priorityString,9))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3212 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3213 |
cout << "Priority mode" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3214 |
highPriority = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3215 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3216 |
if (!(strncmp(argv[argumentNr],forceRedrawString,12))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3217 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3218 |
forceredraw = 1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3219 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3220 |
if (!(strncmp(argv[argumentNr],forcepartdrawString,14))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3221 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3222 |
forceredraw = 2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3223 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3224 |
if (!(strncmp(argv[argumentNr],singlePuzzleString,3))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3225 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3226 |
singlePuzzle = true; //We will just have one puzzle |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3227 |
if (argv[argumentNr+1][1]!=0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3228 |
singlePuzzleNr = (argv[argumentNr+1][1]-'0')+(argv[argumentNr+1][0]-'0')*10; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3229 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3230 |
singlePuzzleNr = (argv[argumentNr+1][0]-'0'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3231 |
singlePuzzleFile = argv[argumentNr+2]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3232 |
argumentNr+=2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3233 |
cout << "SinglePuzzleMode, File: " << singlePuzzleFile << " and Level: " << singlePuzzleNr << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3234 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3235 |
if (!(strncmp(argv[argumentNr],noSoundAtAll,8))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3236 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3237 |
NoSound = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3238 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3239 |
if (!(strncmp(argv[argumentNr],IntegratedEditor,7))) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3240 |
{ |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
3241 |
#if LEVELEDITOR |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3242 |
editorMode = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3243 |
cout << "Integrated Puzzle Editor Activated" << endl; |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
3244 |
#else |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
3245 |
cout << "Integrated Puzzle Editor was disabled at compile time" << endl; |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
3246 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3247 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3248 |
argumentNr++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3249 |
} //while |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3250 |
} //if |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3251 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3252 |
SoundEnabled = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3253 |
MusicEnabled = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3254 |
int mousex, mousey; //Mouse coordinates |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3255 |
showOptions = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3256 |
b1playerOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3257 |
b2playersOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3258 |
bReplayOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3259 |
bScreenLocked = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3260 |
bool twoPlayers = false; //true if two players splitscreen |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3261 |
bool vsMode = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3262 |
theTopScoresEndless = Highscore(1); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3263 |
theTopScoresTimeTrial = Highscore(2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3264 |
drawBalls = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3265 |
puzzleLoaded = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3266 |
bool weWhereConnected = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3267 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3268 |
//Things used for repeating keystrokes: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3269 |
bool repeatingP1N = false; //The key is being held |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3270 |
bool repeatingP1S = false; //The key is being held |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3271 |
bool repeatingP1W = false; //The key is being held |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3272 |
bool repeatingP1E = false; //The key is being held |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3273 |
bool repeatingP2N = false; //The key is being held |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3274 |
bool repeatingP2S = false; //The key is being held |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3275 |
bool repeatingP2W = false; //The key is being held |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3276 |
bool repeatingP2E = false; //The key is being held |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3277 |
const int startRepeat = 200; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3278 |
const int repeatDelay = 100; //Repeating |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3279 |
unsigned long timeHeldP1N = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3280 |
unsigned long timeHeldP1S = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3281 |
unsigned long timeHeldP1E = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3282 |
unsigned long timeHeldP1W = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3283 |
unsigned long timeHeldP2N = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3284 |
unsigned long timeHeldP2S = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3285 |
unsigned long timeHeldP2E = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3286 |
unsigned long timeHeldP2W = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3287 |
unsigned long timesRepeatedP1N = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3288 |
unsigned long timesRepeatedP1S = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3289 |
unsigned long timesRepeatedP1E = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3290 |
unsigned long timesRepeatedP1W = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3291 |
unsigned long timesRepeatedP2N = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3292 |
unsigned long timesRepeatedP2S = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3293 |
unsigned long timesRepeatedP2E = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3294 |
unsigned long timesRepeatedP2W = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3295 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3296 |
theBallManeger = ballManeger(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3297 |
theExplosionManeger = explosionManeger(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3298 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3299 |
//We now set the paths were we are saving, we are using the keyword __unix__ . I hope that all UNIX systems has a home folder |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3300 |
#if defined(__unix__) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3301 |
string home = getenv("HOME"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3302 |
string optionsPath = home+"/.gamesaves/blockattack/options.dat"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3303 |
#elif defined(_WIN32) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3304 |
string home = getMyDocumentsPath(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3305 |
string optionsPath; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3306 |
if (&home!=NULL) //Null if no APPDATA dir exists (win 9x) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3307 |
optionsPath = home+"/My Games/blockattack/options.dat"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3308 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3309 |
optionsPath = "options.dat"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3310 |
#else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3311 |
string optionsPath = "options.dat"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3312 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3313 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3314 |
#if defined(__unix__) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3315 |
stageClearSavePath = home+"/.gamesaves/blockattack/stageClear.SCsave"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3316 |
puzzleSavePath = home+"/.gamesaves/blockattack/puzzle.levels.save"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3317 |
#elif defined(_WIN32) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3318 |
if (&home!=NULL) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3319 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3320 |
stageClearSavePath = home+"/My Games/blockattack/stageClear.SCsave"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3321 |
puzzleSavePath = home+"/My Games/blockattack/puzzle.levels.save"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3322 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3323 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3324 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3325 |
stageClearSavePath = "stageClear.SCsave"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3326 |
puzzleSavePath = "puzzle.levels.save"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3327 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3328 |
#else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3329 |
stageClearSavePath = "stageClear.SCsave"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3330 |
puzzleSavePath = "puzzle.levels.save"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3331 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3332 |
puzzleName="puzzle.levels"; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3333 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3334 |
Uint8 *keys; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3335 |
|
| 866417ca |
sago007 |
2009-05-10 21:35 |
3336 |
|
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
3337 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3338 |
//Init SDL |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3339 |
if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3340 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3341 |
cout << "Unable to init SDL: " << SDL_GetError() << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3342 |
exit(1); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3343 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3344 |
atexit(SDL_Quit); //quits SDL when the game stops for some reason (like you hit exit or Esc) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3345 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3346 |
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3347 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3348 |
Joypad_init(); //Prepare the joysticks |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3349 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3350 |
Joypad joypad1 = Joypad(); //Creates a joypad |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3351 |
Joypad joypad2 = Joypad(); //Creates a joypad |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3352 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3353 |
theTextManeger = textManeger(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3354 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3355 |
//Open Audio |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3356 |
if (!NoSound) //If sound has not been disabled, then load the sound system |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3357 |
if (Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 2048) < 0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3358 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3359 |
cout << "Warning: Couldn't set 44100 Hz 16-bit audio - Reason: " << SDL_GetError() << endl |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3360 |
<< "Sound will be disabled!" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3361 |
NoSound = true; //Tries to stop all sound from playing/loading |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3362 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3363 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3364 |
SDL_WM_SetCaption("Block Attack - Rise of the Blocks", NULL); //Sets title line |
| 866417ca |
sago007 |
2009-05-10 21:35 |
3365 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3366 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3367 |
//Copyright notice: |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
3368 |
cout << "Block Attack - Rise of the Blocks (" << VERSION_NUMBER << ")" << endl << "http://blockattack.sf.net" << endl << "Copyright 2004-2009 Poul Sander" << endl << |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3369 |
"A SDL based game (see www.libsdl.org)" << endl << |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3370 |
"The game is availeble under the GPL, see COPYING for details." << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3371 |
#if defined(_WIN32) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3372 |
cout << "Windows build" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3373 |
#elif defined(__linux__) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3374 |
cout << "Linux build" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3375 |
#elif defined(__unix__) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3376 |
cout << "Unix build" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3377 |
#else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3378 |
cout << "Alternative build" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3379 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3380 |
cout << "-------------------------------------------" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3381 |
|
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
3382 |
//The menu cannot be activated the first second to prevent unexpected events |
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
3383 |
keymenu.canBeActivatedTime = SDL_GetTicks()+1000; |
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
3384 |
keymenu.activated = false; |
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
3385 |
for(int i=0;i<KEYMENU_MAXWITH;i++) |
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
3386 |
keymenu.menumap[i][0] = true; |
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
3387 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3388 |
keySettings[0].up= SDLK_UP; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3389 |
keySettings[0].down = SDLK_DOWN; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3390 |
keySettings[0].left = SDLK_LEFT; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3391 |
keySettings[0].right = SDLK_RIGHT; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3392 |
keySettings[0].change = SDLK_RCTRL; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3393 |
keySettings[0].push = SDLK_RSHIFT; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3394 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3395 |
keySettings[2].up= SDLK_w; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3396 |
keySettings[2].down = SDLK_s; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3397 |
keySettings[2].left = SDLK_a; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3398 |
keySettings[2].right = SDLK_d; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3399 |
keySettings[2].change = SDLK_LCTRL; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3400 |
keySettings[2].push = SDLK_LSHIFT; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3401 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3402 |
player1keys=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3403 |
player2keys=2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3404 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3405 |
strcpy(player1name, "Player 1 \0"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3406 |
strcpy(player2name, "Player 2 \0"); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3407 |
|
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3408 |
Config *configSettings = Config::getInstance(); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3409 |
//configSettings->setString("aNumber"," A string"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3410 |
//configSettings->save(); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3411 |
if(configSettings->exists("fullscreen")) //Test if an configFile exists |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3412 |
{ |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3413 |
bFullscreen = (bool)configSettings->getInt("fullscreen"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3414 |
MusicEnabled = (bool)configSettings->getInt("musicenabled"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3415 |
SoundEnabled = (bool)configSettings->getInt("soundenabled"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3416 |
mouseplay1 = (bool)configSettings->getInt("mouseplay1"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3417 |
mouseplay2 = (bool)configSettings->getInt("mouseplay2"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3418 |
joyplay1 = (bool)configSettings->getInt("joypad1"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3419 |
joyplay2 = (bool)configSettings->getInt("joypad2"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3420 |
|
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3421 |
if(configSettings->exists("player1keyup")) keySettings[0].up = (SDLKey)configSettings->getInt("player1keyup"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3422 |
if(configSettings->exists("player1keydown")) keySettings[0].down = (SDLKey)configSettings->getInt("player1keydown"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3423 |
if(configSettings->exists("player1keyleft")) keySettings[0].left = (SDLKey)configSettings->getInt("player1keyleft"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3424 |
if(configSettings->exists("player1keyright")) keySettings[0].right = (SDLKey)configSettings->getInt("player1keyright"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3425 |
if(configSettings->exists("player1keychange")) keySettings[0].change = (SDLKey)configSettings->getInt("player1keychange"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3426 |
if(configSettings->exists("player1keypush")) keySettings[0].push = (SDLKey)configSettings->getInt("player1keypush"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3427 |
|
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3428 |
if(configSettings->exists("player2keyup")) keySettings[2].up = (SDLKey)configSettings->getInt("player2keyup"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3429 |
if(configSettings->exists("player2keydown")) keySettings[2].down = (SDLKey)configSettings->getInt("player2keydown"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3430 |
if(configSettings->exists("player2keyleft")) keySettings[2].left = (SDLKey)configSettings->getInt("player2keyleft"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3431 |
if(configSettings->exists("player2keyright")) keySettings[2].right = (SDLKey)configSettings->getInt("player2keyright"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3432 |
if(configSettings->exists("player2keychange")) keySettings[2].change = (SDLKey)configSettings->getInt("player2keychange"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3433 |
if(configSettings->exists("player2keypush")) keySettings[2].push = (SDLKey)configSettings->getInt("player2keypush"); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3434 |
if(configSettings->exists("player1name")) |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3435 |
strncpy(player1name,(configSettings->getString("player1name")).c_str(),28); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3436 |
if(configSettings->exists("player2name")) |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3437 |
strncpy(player2name,(configSettings->getString("player2name")).c_str(),28); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3438 |
cout << "Data loaded from config file" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3439 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3440 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3441 |
{ |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3442 |
//Reads options from file: |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3443 |
ifstream optionsFile(optionsPath.c_str(), ios::binary); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3444 |
if (optionsFile) |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3445 |
{ |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3446 |
//reads data: xsize,ysize,fullescreen, player1keys, player2keys, MusicEnabled, SoundEnabled,player1name,player2name |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3447 |
optionsFile.read(reinterpret_cast<char*>(&xsize), sizeof(int)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3448 |
optionsFile.read(reinterpret_cast<char*>(&ysize), sizeof(int)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3449 |
optionsFile.read(reinterpret_cast<char*>(&bFullscreen), sizeof(bool)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3450 |
optionsFile.read(reinterpret_cast<char*>(&keySettings[0].up), sizeof(SDLKey)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3451 |
optionsFile.read(reinterpret_cast<char*>(&keySettings[0].down), sizeof(SDLKey)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3452 |
optionsFile.read(reinterpret_cast<char*>(&keySettings[0].left), sizeof(SDLKey)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3453 |
optionsFile.read(reinterpret_cast<char*>(&keySettings[0].right), sizeof(SDLKey)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3454 |
optionsFile.read(reinterpret_cast<char*>(&keySettings[0].change), sizeof(SDLKey)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3455 |
optionsFile.read(reinterpret_cast<char*>(&keySettings[0].push), sizeof(SDLKey)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3456 |
optionsFile.read(reinterpret_cast<char*>(&keySettings[2].up), sizeof(SDLKey)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3457 |
optionsFile.read(reinterpret_cast<char*>(&keySettings[2].down), sizeof(SDLKey)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3458 |
optionsFile.read(reinterpret_cast<char*>(&keySettings[2].left), sizeof(SDLKey)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3459 |
optionsFile.read(reinterpret_cast<char*>(&keySettings[2].right), sizeof(SDLKey)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3460 |
optionsFile.read(reinterpret_cast<char*>(&keySettings[2].change), sizeof(SDLKey)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3461 |
optionsFile.read(reinterpret_cast<char*>(&keySettings[2].push), sizeof(SDLKey)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3462 |
optionsFile.read(reinterpret_cast<char*>(&MusicEnabled), sizeof(bool)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3463 |
optionsFile.read(reinterpret_cast<char*>(&SoundEnabled), sizeof(bool)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3464 |
optionsFile.read(player1name, 30*sizeof(char)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3465 |
optionsFile.read(player2name, 30*sizeof(char)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3466 |
//mouseplay? |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3467 |
if (!optionsFile.eof()) |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3468 |
{ |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3469 |
optionsFile.read(reinterpret_cast<char*>(&mouseplay1), sizeof(bool)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3470 |
optionsFile.read(reinterpret_cast<char*>(&mouseplay2), sizeof(bool)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3471 |
optionsFile.read(reinterpret_cast<char*>(&joyplay1),sizeof(bool)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3472 |
optionsFile.read(reinterpret_cast<char*>(&joyplay2),sizeof(bool)); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3473 |
} |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3474 |
optionsFile.close(); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3475 |
cout << "Data loaded from oldstyle options file" << endl; |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3476 |
} |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3477 |
else |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3478 |
{ |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3479 |
cout << "Unable to load options file, using default values" << endl; |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
3480 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3481 |
} |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
3482 |
|
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
3483 |
#if NETWORK |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
3484 |
strcpy(serverAddress, "192.168.0.2 \0"); |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
3485 |
if(configSettings->exists("address0")) |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
3486 |
{ |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
3487 |
strcpy(serverAddress, " \0"); |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
3488 |
strncpy(serverAddress,configSettings->getString("address0").c_str(),sizeof(serverAddress)-1); |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
3489 |
} |
| 27ae0175 |
sago007 |
2009-01-30 06:02 |
3490 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3491 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3492 |
if (singlePuzzle) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3493 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3494 |
xsize=300; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3495 |
ysize=600; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3496 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3497 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3498 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3499 |
//Open video |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3500 |
if ((bFullscreen)&&(!singlePuzzle)) screen=SDL_SetVideoMode(xsize,ysize,32,SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ANYFORMAT); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3501 |
else screen=SDL_SetVideoMode(xsize,ysize,32,SDL_SWSURFACE|SDL_ANYFORMAT); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3502 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3503 |
if ( screen == NULL ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3504 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3505 |
cout << "Unable to set " << xsize << "x" << ysize << " video: " << SDL_GetError() << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3506 |
exit(1); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3507 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3508 |
|
| 866417ca |
sago007 |
2009-05-10 21:35 |
3509 |
//Init the file system abstraction layer |
| 866417ca |
sago007 |
2009-05-10 21:35 |
3510 |
PHYSFS_init(argv[0]); |
| 866417ca |
sago007 |
2009-05-10 21:35 |
3511 |
//Load default theme |
| 866417ca |
sago007 |
2009-05-10 21:35 |
3512 |
loadTheme("start"); |
| 866417ca |
sago007 |
2009-05-10 21:35 |
3513 |
//Now sets the icon: |
| 866417ca |
sago007 |
2009-05-10 21:35 |
3514 |
SDL_Surface *icon = IMG_Load2((char*)"gfx/icon.png"); |
| 866417ca |
sago007 |
2009-05-10 21:35 |
3515 |
SDL_WM_SetIcon(icon,NULL); |
| 866417ca |
sago007 |
2009-05-10 21:35 |
3516 |
//SDL_FreeSurface(icon); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3517 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3518 |
cout << "Images loaded" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3519 |
|
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
3520 |
//InitMenues(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3521 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3522 |
BlockGame theGame = BlockGame(50,100); //creates game objects |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3523 |
BlockGame theGame2 = BlockGame(xsize-500,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3524 |
if (singlePuzzle) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3525 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3526 |
theGame.topy=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3527 |
theGame.topx=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3528 |
theGame2.topy=10000; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3529 |
theGame2.topx=10000; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3530 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3531 |
theGame.DoPaintJob(); //Makes sure what there is something to paint |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3532 |
theGame2.DoPaintJob(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3533 |
theGame.SetGameOver(); //sets the game over in the beginning |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3534 |
theGame2.SetGameOver(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3535 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3536 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3537 |
//Takes names from file instead |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3538 |
strcpy(theGame.name, player1name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3539 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3540 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3541 |
//Keeps track of background; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3542 |
int nowTime=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3543 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3544 |
|
| 1572de2b |
sago007 |
2008-09-11 18:15 |
3545 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3546 |
NetworkThing nt = NetworkThing(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3547 |
nt.setBGpointers(&theGame,&theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3548 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3549 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3550 |
if (singlePuzzle) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3551 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3552 |
LoadPuzzleStages(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3553 |
theGame.NewPuzzleGame(singlePuzzleNr,0,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3554 |
showGame = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3555 |
vsMode = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3556 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3557 |
//Draws everything to screen |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3558 |
if (!editorMode) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3559 |
MakeBackground(xsize,ysize,theGame,theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3560 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3561 |
MakeBackground(xsize,ysize,theGame); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3562 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3563 |
DrawEverything(xsize,ysize,theGame,theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3564 |
SDL_Flip(screen); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3565 |
//game loop |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3566 |
int done = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3567 |
cout << "Starting game loop" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3568 |
while (done == 0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3569 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3570 |
if (!(highPriority)) SDL_Delay(10); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3571 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3572 |
if ((standardBackground)&&(!editorMode)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3573 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3574 |
MakeBackground(xsize,ysize,theGame,theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3575 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3576 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3577 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3578 |
if ((standardBackground)&&(editorMode)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3579 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3580 |
DrawIMG(backgroundImage, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3581 |
MakeBackground(xsize,ysize,theGame); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3582 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3583 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3584 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3585 |
//updates the balls and explosions: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3586 |
theBallManeger.update(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3587 |
theExplosionManeger.update(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3588 |
theTextManeger.update(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3589 |
|
| 1572de2b |
sago007 |
2008-09-11 18:15 |
3590 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3591 |
if (nt.isConnected()) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3592 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3593 |
nt.updateNetwork(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3594 |
networkActive = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3595 |
if (!nt.isConnectedToPeer()) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3596 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3597 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3598 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3599 |
networkActive = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3600 |
if (nt.isConnectedToPeer()) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3601 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3602 |
networkPlay=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3603 |
if (!weWhereConnected) //We have just connected |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3604 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3605 |
theGame.NewVsGame(50,100,&theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3606 |
theGame.putStartBlocks(nt.theSeed); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3607 |
theGame2.playNetwork(xsize-500,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3608 |
nt.theGameHasStarted(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3609 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3610 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3611 |
weWhereConnected = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3612 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3613 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3614 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3615 |
networkPlay=false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3616 |
weWhereConnected = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3617 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3618 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3619 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3620 |
if (!bScreenLocked) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3621 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3622 |
SDL_Event event; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3623 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3624 |
while ( SDL_PollEvent(&event) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3625 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3626 |
if ( event.type == SDL_QUIT ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3627 |
done = 1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3628 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3629 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3630 |
if ( event.type == SDL_KEYDOWN ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3631 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3632 |
if ( event.key.keysym.sym == SDLK_ESCAPE ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3633 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3634 |
if (showOptions) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3635 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3636 |
showOptions = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3637 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3638 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3639 |
done=1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3640 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3641 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3642 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3643 |
if ((!editorMode)&&(!editorModeTest)&&(!theGame.AI_Enabled)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3644 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3645 |
//player1: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3646 |
if ( event.key.keysym.sym == keySettings[player1keys].up ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3647 |
theGame.MoveCursor('N'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3648 |
repeatingP1N=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3649 |
timeHeldP1N=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3650 |
timesRepeatedP1N=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3651 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3652 |
if ( event.key.keysym.sym == keySettings[player1keys].down ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3653 |
theGame.MoveCursor('S'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3654 |
repeatingP1S=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3655 |
timeHeldP1S=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3656 |
timesRepeatedP1S=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3657 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3658 |
if ( (event.key.keysym.sym == keySettings[player1keys].left) && (showGame) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3659 |
theGame.MoveCursor('W'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3660 |
repeatingP1W=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3661 |
timeHeldP1W=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3662 |
timesRepeatedP1W=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3663 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3664 |
if ( (event.key.keysym.sym == keySettings[player1keys].right) && (showGame) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3665 |
theGame.MoveCursor('E'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3666 |
repeatingP1E=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3667 |
timeHeldP1E=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3668 |
timesRepeatedP1E=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3669 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3670 |
if ( event.key.keysym.sym == keySettings[player1keys].push ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3671 |
theGame.PushLine(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3672 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3673 |
if ( event.key.keysym.sym == keySettings[player1keys].change ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3674 |
theGame.SwitchAtCursor(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3675 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3676 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3677 |
if (!editorMode && !theGame2.AI_Enabled) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3678 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3679 |
//player2: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3680 |
if ( event.key.keysym.sym == keySettings[player2keys].up ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3681 |
theGame2.MoveCursor('N'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3682 |
repeatingP2N=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3683 |
timeHeldP2N=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3684 |
timesRepeatedP2N=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3685 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3686 |
if ( event.key.keysym.sym == keySettings[player2keys].down ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3687 |
theGame2.MoveCursor('S'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3688 |
repeatingP2S=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3689 |
timeHeldP2S=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3690 |
timesRepeatedP2S=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3691 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3692 |
if ( (event.key.keysym.sym == keySettings[player2keys].left) && (showGame) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3693 |
theGame2.MoveCursor('W'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3694 |
repeatingP2W=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3695 |
timeHeldP2W=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3696 |
timesRepeatedP2W=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3697 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3698 |
if ( (event.key.keysym.sym == keySettings[player2keys].right) && (showGame) ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3699 |
theGame2.MoveCursor('E'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3700 |
repeatingP2E=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3701 |
timeHeldP2E=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3702 |
timesRepeatedP2E=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3703 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3704 |
if ( event.key.keysym.sym == keySettings[player2keys].push ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3705 |
theGame2.PushLine(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3706 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3707 |
if ( event.key.keysym.sym == keySettings[player2keys].change ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3708 |
theGame2.SwitchAtCursor(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3709 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3710 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3711 |
//common: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3712 |
if ((!singlePuzzle)&&(!editorMode)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3713 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3714 |
if ( event.key.keysym.sym == SDLK_F2 ) { |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3715 |
#if NETWORK |
| 47529580 |
sago007 |
2008-12-09 02:34 |
3716 |
if ((!showOptions)&&(!networkActive)){ |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3717 |
#else |
| 47529580 |
sago007 |
2008-12-09 02:34 |
3718 |
if ((!showOptions)){ |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3719 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3720 |
theGame.NewGame(50,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3721 |
theGame.timetrial = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3722 |
theGame.putStartBlocks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3723 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3724 |
twoPlayers =false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3725 |
theGame2.SetGameOver(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3726 |
showGame = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3727 |
vsMode = false; |
| c96f480e |
sago007 |
2009-03-28 18:59 |
3728 |
strcpy(theGame.name, player1name); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
3729 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3730 |
}} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3731 |
if ( event.key.keysym.sym == SDLK_F3 ) { |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3732 |
#if NETWORK |
| 47529580 |
sago007 |
2008-12-09 02:34 |
3733 |
if ((!showOptions)&&(!networkActive)){ |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3734 |
#else |
| 47529580 |
sago007 |
2008-12-09 02:34 |
3735 |
if ((!showOptions)){ |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3736 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3737 |
theGame.NewGame(50,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3738 |
theGame.timetrial = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3739 |
theGame.putStartBlocks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3740 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3741 |
twoPlayers =false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3742 |
theGame2.SetGameOver(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3743 |
showGame = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3744 |
vsMode = false; |
| c96f480e |
sago007 |
2009-03-28 18:59 |
3745 |
strcpy(theGame.name, player1name); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
3746 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3747 |
}} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3748 |
if ( event.key.keysym.sym == SDLK_F5 ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3749 |
{ |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3750 |
#if NETWORK |
| 47529580 |
sago007 |
2008-12-09 02:34 |
3751 |
if ((!showOptions)&&(!networkActive)) |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3752 |
#else |
| 47529580 |
sago007 |
2008-12-09 02:34 |
3753 |
if ((!showOptions)) |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3754 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3755 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3756 |
int myLevel = StageLevelSelect(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3757 |
theGame.NewStageGame(myLevel,50,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3758 |
MakeBackground(xsize,ysize,theGame,theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3759 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3760 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3761 |
twoPlayers =false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3762 |
theGame2.SetGameOver(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3763 |
showGame = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3764 |
vsMode = false; |
| c96f480e |
sago007 |
2009-03-28 18:59 |
3765 |
strcpy(theGame.name, player1name); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
3766 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3767 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3768 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3769 |
if ( event.key.keysym.sym == SDLK_F6 ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3770 |
{ |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3771 |
#if NETWORK |
| 47529580 |
sago007 |
2008-12-09 02:34 |
3772 |
if ((!showOptions)&&(!networkActive)) |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3773 |
#else |
| 47529580 |
sago007 |
2008-12-09 02:34 |
3774 |
if ((!showOptions)) |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3775 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3776 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3777 |
theGame.NewVsGame(50,100,&theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3778 |
theGame2.NewVsGame(xsize-500,100,&theGame); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3779 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3780 |
vsMode = true; |
| c96f480e |
sago007 |
2009-03-28 18:59 |
3781 |
strcpy(theGame.name, player1name); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
3782 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3783 |
theGame.setGameSpeed(player1Speed); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3784 |
theGame2.setGameSpeed(player2Speed); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3785 |
theGame.setHandicap(player1handicap); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3786 |
theGame2.setHandicap(player2handicap); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3787 |
theGame.AI_Enabled = player1AI; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3788 |
theGame2.AI_Enabled = player2AI; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3789 |
theGame.setAIlevel(player1AIlevel); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3790 |
theGame2.setAIlevel(player2AIlevel); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3791 |
int theTime = time(0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3792 |
theGame.putStartBlocks(theTime); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3793 |
theGame2.putStartBlocks(theTime); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3794 |
twoPlayers = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3795 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3796 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3797 |
if ( event.key.keysym.sym == SDLK_F4 ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3798 |
{ |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3799 |
#if NETWORK |
| 47529580 |
sago007 |
2008-12-09 02:34 |
3800 |
if ((!showOptions)&&(!networkActive)) |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3801 |
#else |
| 47529580 |
sago007 |
2008-12-09 02:34 |
3802 |
if ((!showOptions)) |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3803 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3804 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3805 |
theGame.NewGame(50,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3806 |
theGame2.NewGame(xsize-500,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3807 |
theGame.timetrial = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3808 |
theGame2.timetrial = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3809 |
int theTime = time(0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3810 |
theGame.putStartBlocks(theTime); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3811 |
theGame2.putStartBlocks(theTime); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3812 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3813 |
twoPlayers = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3814 |
theGame.setGameSpeed(player1Speed); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3815 |
theGame2.setGameSpeed(player2Speed); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3816 |
theGame.setHandicap(player1handicap); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3817 |
theGame2.setHandicap(player2handicap); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3818 |
theGame.AI_Enabled = player1AI; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3819 |
theGame2.AI_Enabled = player2AI; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3820 |
theGame.setAIlevel(player1AIlevel); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3821 |
theGame2.setAIlevel(player2AIlevel); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
3822 |
strcpy(theGame.name, player1name); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
3823 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3824 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3825 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3826 |
if ( event.key.keysym.sym == SDLK_F7 ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3827 |
{ |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3828 |
#if NETWORK |
| 47529580 |
sago007 |
2008-12-09 02:34 |
3829 |
if ((!showOptions)&&(!networkActive)) |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3830 |
#else |
| 47529580 |
sago007 |
2008-12-09 02:34 |
3831 |
if ((!showOptions)) |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
3832 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3833 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3834 |
int myLevel = PuzzleLevelSelect(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3835 |
theGame.NewPuzzleGame(myLevel,50,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3836 |
MakeBackground(xsize,ysize,theGame,theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3837 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3838 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3839 |
twoPlayers = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3840 |
theGame2.SetGameOver(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3841 |
showGame = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3842 |
vsMode = true; |
| c96f480e |
sago007 |
2009-03-28 18:59 |
3843 |
strcpy(theGame.name, player1name); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
3844 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3845 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3846 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3847 |
if ( event.key.keysym.sym == SDLK_F8 ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3848 |
{ |
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
3849 |
if(!keymenu.activated && keymenu.canBeActivatedTime > SDL_GetTicks()) |
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
3850 |
{ |
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
3851 |
keymenu.activated = true; |
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
3852 |
keymenu.x = 0; |
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
3853 |
keymenu.y = 0; |
| 95bc02ff |
sago007 |
2009-03-15 02:46 |
3854 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3855 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3856 |
if ( event.key.keysym.sym == SDLK_F9 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3857 |
writeScreenShot(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3858 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3859 |
if ( event.key.keysym.sym == SDLK_F11 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3860 |
/*This is the test place, place function to test here*/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3861 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3862 |
//theGame.CreateGreyGarbage(); |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
3863 |
//char mitNavn[30]; |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
3864 |
//SelectThemeDialogbox(300,400,mitNavn); |
| 78d03b38 |
sago007 |
2008-11-13 19:56 |
3865 |
// MainMenu(); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
3866 |
OpenScoresDisplay(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3867 |
} //F11 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3868 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3869 |
if ( event.key.keysym.sym == SDLK_F12 ) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3870 |
done=1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3871 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3872 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3873 |
} //while event PollEvent - read keys |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3874 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3875 |
/********************************************************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3876 |
**************************** Repeating start ************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3877 |
**********************************************************************/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3878 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3879 |
keys = SDL_GetKeyState(NULL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3880 |
//Also the joysticks: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3881 |
//Repeating not implemented |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3882 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3883 |
//Player 1 start |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3884 |
if (!(keys[keySettings[player1keys].up])) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3885 |
repeatingP1N=false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3886 |
while ((repeatingP1N)&&(keys[keySettings[player1keys].up])&&(SDL_GetTicks()>timeHeldP1N+timesRepeatedP1N*repeatDelay+startRepeat)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3887 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3888 |
theGame.MoveCursor('N'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3889 |
timesRepeatedP1N++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3890 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3891 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3892 |
if (!(keys[keySettings[player1keys].down])) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3893 |
repeatingP1S=false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3894 |
while ((repeatingP1S)&&(keys[keySettings[player1keys].down])&&(SDL_GetTicks()>timeHeldP1S+timesRepeatedP1S*repeatDelay+startRepeat)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3895 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3896 |
theGame.MoveCursor('S'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3897 |
timesRepeatedP1S++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3898 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3899 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3900 |
if (!(keys[keySettings[player1keys].left])) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3901 |
repeatingP1W=false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3902 |
while ((repeatingP1W)&&(keys[keySettings[player1keys].left])&&(SDL_GetTicks()>timeHeldP1W+timesRepeatedP1W*repeatDelay+startRepeat)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3903 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3904 |
timesRepeatedP1W++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3905 |
theGame.MoveCursor('W'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3906 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3907 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3908 |
if (!(keys[keySettings[player1keys].right])) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3909 |
repeatingP1E=false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3910 |
while ((repeatingP1E)&&(keys[keySettings[player1keys].right])&&(SDL_GetTicks()>timeHeldP1E+timesRepeatedP1E*repeatDelay+startRepeat)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3911 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3912 |
timesRepeatedP1E++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3913 |
theGame.MoveCursor('E'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3914 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3915 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3916 |
//Player 1 end |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3917 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3918 |
//Player 2 start |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3919 |
if (!(keys[keySettings[player2keys].up])) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3920 |
repeatingP2N=false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3921 |
while ((repeatingP2N)&&(keys[keySettings[player2keys].up])&&(SDL_GetTicks()>timeHeldP2N+timesRepeatedP2N*repeatDelay+startRepeat)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3922 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3923 |
theGame2.MoveCursor('N'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3924 |
timesRepeatedP2N++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3925 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3926 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3927 |
if (!(keys[keySettings[player2keys].down])) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3928 |
repeatingP2S=false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3929 |
while ((repeatingP2S)&&(keys[keySettings[player2keys].down])&&(SDL_GetTicks()>timeHeldP2S+timesRepeatedP2S*repeatDelay+startRepeat)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3930 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3931 |
theGame2.MoveCursor('S'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3932 |
timesRepeatedP2S++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3933 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3934 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3935 |
if (!(keys[keySettings[player2keys].left])) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3936 |
repeatingP2W=false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3937 |
while ((repeatingP2W)&&(keys[keySettings[player2keys].left])&&(SDL_GetTicks()>timeHeldP2W+timesRepeatedP2W*repeatDelay+startRepeat)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3938 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3939 |
theGame2.MoveCursor('W'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3940 |
timesRepeatedP2W++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3941 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3942 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3943 |
if (!(keys[keySettings[player2keys].right])) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3944 |
repeatingP2E=false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3945 |
while ((repeatingP2E)&&(keys[keySettings[player2keys].right])&&(SDL_GetTicks()>timeHeldP2E+timesRepeatedP2E*repeatDelay+startRepeat)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3946 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3947 |
theGame2.MoveCursor('E'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3948 |
timesRepeatedP2E++; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3949 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3950 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3951 |
//Player 2 end |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3952 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3953 |
/********************************************************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3954 |
**************************** Repeating end **************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3955 |
**********************************************************************/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3956 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3957 |
/********************************************************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3958 |
***************************** Joypad start **************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3959 |
**********************************************************************/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3960 |
|
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3961 |
//Menu |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3962 |
if(joypad1.working) |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3963 |
{ |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3964 |
joypad1.update(); |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3965 |
if(joypad1.but1) |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3966 |
{ |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3967 |
if(!keymenu.activated && keymenu.canBeActivatedTime > SDL_GetTicks()) |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3968 |
{ |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3969 |
keymenu.activated = true; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3970 |
keymenu.x = 0; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3971 |
keymenu.y = 0; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3972 |
} |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3973 |
} |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3974 |
} |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3975 |
|
| 6d48320c |
sago007 |
2009-03-28 17:06 |
3976 |
//Gameplay |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3977 |
if (joyplay1||joyplay2) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3978 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3979 |
if (joypad1.working && !theGame.AI_Enabled) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3980 |
if (joyplay1) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3981 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3982 |
joypad1.update(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3983 |
if (joypad1.up) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3984 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3985 |
theGame.MoveCursor('N'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3986 |
repeatingP1N=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3987 |
timeHeldP1N=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3988 |
timesRepeatedP1N=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3989 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3990 |
if (joypad1.down) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3991 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3992 |
theGame.MoveCursor('S'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3993 |
repeatingP1S=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3994 |
timeHeldP1S=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3995 |
timesRepeatedP1S=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3996 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3997 |
if (joypad1.left) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3998 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
3999 |
theGame.MoveCursor('W'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4000 |
repeatingP1W=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4001 |
timeHeldP1W=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4002 |
timesRepeatedP1W=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4003 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4004 |
if (joypad1.right) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4005 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4006 |
theGame.MoveCursor('E'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4007 |
repeatingP1E=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4008 |
timeHeldP1E=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4009 |
timesRepeatedP1E=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4010 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4011 |
if (joypad1.but1) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4012 |
theGame.SwitchAtCursor(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4013 |
if (joypad1.but2) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4014 |
theGame.PushLine(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4015 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4016 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4017 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4018 |
joypad1.update(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4019 |
if (joypad1.up) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4020 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4021 |
theGame2.MoveCursor('N'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4022 |
repeatingP2N=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4023 |
timeHeldP2N=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4024 |
timesRepeatedP2N=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4025 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4026 |
if (joypad1.down) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4027 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4028 |
theGame2.MoveCursor('S'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4029 |
repeatingP2S=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4030 |
timeHeldP2S=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4031 |
timesRepeatedP2S=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4032 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4033 |
if (joypad1.left) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4034 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4035 |
theGame2.MoveCursor('W'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4036 |
repeatingP2W=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4037 |
timeHeldP2W=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4038 |
timesRepeatedP2W=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4039 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4040 |
if (joypad1.right) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4041 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4042 |
theGame2.MoveCursor('E'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4043 |
repeatingP2E=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4044 |
timeHeldP2E=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4045 |
timesRepeatedP2E=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4046 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4047 |
if (joypad1.but1) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4048 |
theGame2.SwitchAtCursor(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4049 |
if (joypad1.but2) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4050 |
theGame2.PushLine(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4051 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4052 |
if (joypad2.working && !theGame2.AI_Enabled) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4053 |
if (!joyplay2) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4054 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4055 |
joypad2.update(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4056 |
if (joypad2.up) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4057 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4058 |
theGame.MoveCursor('N'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4059 |
repeatingP1N=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4060 |
timeHeldP1N=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4061 |
timesRepeatedP1N=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4062 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4063 |
if (joypad2.down) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4064 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4065 |
theGame.MoveCursor('S'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4066 |
repeatingP1S=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4067 |
timeHeldP1S=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4068 |
timesRepeatedP1S=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4069 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4070 |
if (joypad2.left) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4071 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4072 |
theGame.MoveCursor('W'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4073 |
repeatingP1W=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4074 |
timeHeldP1W=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4075 |
timesRepeatedP1W=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4076 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4077 |
if (joypad2.right) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4078 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4079 |
theGame.MoveCursor('E'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4080 |
repeatingP1E=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4081 |
timeHeldP1E=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4082 |
timesRepeatedP1E=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4083 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4084 |
if (joypad2.but1) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4085 |
theGame.SwitchAtCursor(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4086 |
if (joypad2.but2) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4087 |
theGame.PushLine(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4088 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4089 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4090 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4091 |
joypad2.update(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4092 |
if (joypad2.up) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4093 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4094 |
theGame2.MoveCursor('N'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4095 |
repeatingP2N=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4096 |
timeHeldP2N=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4097 |
timesRepeatedP2N=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4098 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4099 |
if (joypad2.down) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4100 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4101 |
theGame2.MoveCursor('S'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4102 |
repeatingP2S=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4103 |
timeHeldP2S=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4104 |
timesRepeatedP2S=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4105 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4106 |
if (joypad2.left) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4107 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4108 |
theGame2.MoveCursor('W'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4109 |
repeatingP2W=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4110 |
timeHeldP2W=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4111 |
timesRepeatedP2W=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4112 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4113 |
if (joypad2.right) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4114 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4115 |
theGame2.MoveCursor('E'); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4116 |
repeatingP2E=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4117 |
timeHeldP2E=SDL_GetTicks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4118 |
timesRepeatedP2E=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4119 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4120 |
if (joypad2.but1) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4121 |
theGame2.SwitchAtCursor(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4122 |
if (joypad2.but2) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4123 |
theGame2.PushLine(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4124 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4125 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4126 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4127 |
/********************************************************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4128 |
***************************** Joypad end ****************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4129 |
**********************************************************************/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4130 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4131 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4132 |
keys = SDL_GetKeyState(NULL); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4133 |
|
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4134 |
if(keymenu.activated) |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4135 |
{ |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4136 |
mousex = keymenu.x*buttonXsize-10; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4137 |
mousey = keymenu.y*buttonYsize-10; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4138 |
} |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4139 |
else |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4140 |
SDL_GetMouseState(&mousex,&mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4141 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4142 |
/******************************************************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4143 |
**************** Here comes mouse play ****************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4144 |
********************************************************************/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4145 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4146 |
if ((mouseplay1)&&((!editorMode)&&(!theGame.AI_Enabled)||(editorModeTest))) //player 1 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4147 |
if ((mousex > 50)&&(mousey>100)&&(mousex<50+300)&&(mousey<100+600)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4148 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4149 |
int yLine, xLine; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4150 |
yLine = ((100+600)-(mousey-100+theGame.pixels))/50; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4151 |
xLine = (mousex-50+25)/50; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4152 |
yLine-=2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4153 |
xLine-=1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4154 |
if ((yLine>10)&&(theGame.TowerHeight<12)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4155 |
yLine=10; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4156 |
if (((theGame.pixels==50)||(theGame.pixels==0)) && (yLine>11)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4157 |
yLine=11; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4158 |
if (yLine<0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4159 |
yLine=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4160 |
if (xLine<0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4161 |
xLine=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4162 |
if (xLine>4) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4163 |
xLine=4; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4164 |
theGame.cursorx=xLine; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4165 |
theGame.cursory=yLine; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4166 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4167 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4168 |
if ((mouseplay2)&&(!editorMode)&&(!theGame2.AI_Enabled)) //player 2 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4169 |
if ((mousex > xsize-500)&&(mousey>100)&&(mousex<xsize-500+300)&&(mousey<100+600)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4170 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4171 |
int yLine, xLine; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4172 |
yLine = ((100+600)-(mousey-100+theGame2.pixels))/50; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4173 |
xLine = (mousex-(xsize-500)+25)/50; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4174 |
yLine-=2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4175 |
xLine-=1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4176 |
if ((yLine>10)&&(theGame2.TowerHeight<12)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4177 |
yLine=10; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4178 |
if (((theGame2.pixels==50)||(theGame2.pixels==0)) && (yLine>11)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4179 |
yLine=11; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4180 |
if (yLine<0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4181 |
yLine=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4182 |
if (xLine<0) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4183 |
xLine=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4184 |
if (xLine>4) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4185 |
xLine=4; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4186 |
theGame2.cursorx=xLine; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4187 |
theGame2.cursory=yLine; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4188 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4189 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4190 |
/******************************************************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4191 |
**************** Here ends mouse play ******************************* |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4192 |
********************************************************************/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4193 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4194 |
// If the mouse button is released, make bMouseUp equal true |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4195 |
if (!SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4196 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4197 |
bMouseUp=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4198 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4199 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4200 |
// If the mouse button 2 is released, make bMouseUp2 equal true |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4201 |
if ((SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(3))!=SDL_BUTTON(3)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4202 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4203 |
bMouseUp2=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4204 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4205 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4206 |
if ((!singlePuzzle)&&(!editorMode)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4207 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4208 |
//read mouse events |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4209 |
if (SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(1) && bMouseUp) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4210 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4211 |
bMouseUp = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4212 |
DrawIMG(background, screen, 0, 0); |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
4213 |
#if NETWORK |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
4214 |
//Nothing |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
4215 |
#else |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
4216 |
bool networkActive=false; |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
4217 |
#endif |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4218 |
if ((0<mousex) && (mousex<buttonXsize) && (0<mousey) && (mousey<40) &&(!networkActive) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4219 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4220 |
//New game clicked |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4221 |
bool state = (!bNewGameOpen); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4222 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4223 |
bNewGameOpen = state; //theGame.NewGame(50,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4224 |
showOptions = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4225 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4226 |
else |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
4227 |
#if NETWORK |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4228 |
if ((0<mousex) && (mousex<buttonXsize) && (0<mousey) && (mousey<40) &&(networkActive)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4229 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4230 |
//Disconnect clicked! |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4231 |
cout << "Disconnect clicked!" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4232 |
nt.ntDisconnect(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4233 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4234 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4235 |
#endif |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4236 |
if ((0<mousex) && (mousex<buttonXsize) && (40<mousey) && (mousey<80) && (bNewGameOpen) &&(!networkActive)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4237 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4238 |
//1player |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4239 |
b1playerOpen = (!b1playerOpen); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4240 |
b2playersOpen = false; |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
4241 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4242 |
bNetworkOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4243 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4244 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4245 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4246 |
if ((0<mousex) && (mousex<buttonXsize) && (80<mousey) && (mousey<120) && (bNewGameOpen) &&(!networkActive)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4247 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4248 |
//2player |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4249 |
b2playersOpen = (!b2playersOpen); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4250 |
b1playerOpen = false; |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
4251 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4252 |
bNetworkOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4253 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4254 |
} |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
4255 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4256 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4257 |
if ((0<mousex) && (mousex<buttonXsize) && (120<mousey) && (mousey<160) && (bNewGameOpen) &&(!networkActive)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4258 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4259 |
//Network |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4260 |
b1playerOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4261 |
b2playersOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4262 |
bNetworkOpen = (!bNetworkOpen); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4263 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4264 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4265 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4266 |
if ((buttonXsize<mousex) && (mousex<240) && (40<mousey) && (mousey<80) && (b1playerOpen) &&(!networkActive)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4267 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4268 |
//1 player - endless |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4269 |
theGame.NewGame(50,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4270 |
theGame.putStartBlocks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4271 |
bNewGameOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4272 |
b1playerOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4273 |
twoPlayers =false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4274 |
theGame2.SetGameOver(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4275 |
showGame = true; |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4276 |
strcpy(theGame.name, player1name); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4277 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4278 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4279 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4280 |
if ((buttonXsize<mousex) && (mousex<240) && (80<mousey) && (mousey<120) && (b1playerOpen) &&(!networkActive) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4281 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4282 |
//1 player - time trial |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4283 |
theGame.NewGame(50,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4284 |
theGame.timetrial=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4285 |
theGame.putStartBlocks(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4286 |
bNewGameOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4287 |
b1playerOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4288 |
twoPlayers =false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4289 |
theGame2.SetGameOver(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4290 |
showGame = true; |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4291 |
strcpy(theGame.name, player1name); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4292 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4293 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4294 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4295 |
if ((buttonXsize<mousex) && (mousex<240) && (120<mousey) && (mousey<160) && (b1playerOpen)&&(!networkActive) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4296 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4297 |
//1 player - stage clear |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4298 |
bNewGameOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4299 |
b1playerOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4300 |
int myLevel = StageLevelSelect(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4301 |
theGame.NewStageGame(myLevel,50,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4302 |
MakeBackground(xsize,ysize,theGame,theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4303 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4304 |
twoPlayers =false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4305 |
theGame2.SetGameOver(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4306 |
showGame = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4307 |
vsMode = false; |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4308 |
strcpy(theGame.name, player1name); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4309 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4310 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4311 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4312 |
if ((buttonXsize<mousex) && (mousex<240) && (160<mousey) && (mousey<200) && (b1playerOpen)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4313 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4314 |
//1 player - puzzle |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4315 |
bNewGameOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4316 |
b1playerOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4317 |
int myLevel = PuzzleLevelSelect(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4318 |
theGame.NewPuzzleGame(myLevel,50,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4319 |
MakeBackground(xsize,ysize,theGame,theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4320 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4321 |
twoPlayers =false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4322 |
theGame2.SetGameOver(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4323 |
showGame = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4324 |
vsMode = false; |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4325 |
strcpy(theGame.name, player1name); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4326 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4327 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4328 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4329 |
if ((buttonXsize<mousex) && (mousex<240) && (200<mousey) && (mousey<240) && (b1playerOpen)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4330 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4331 |
//1 player - Vs mode |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4332 |
bNewGameOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4333 |
b1playerOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4334 |
int theAIlevel = startSingleVs(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4335 |
theGame.NewVsGame(50,100,&theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4336 |
theGame2.NewVsGame(xsize-500,100,&theGame); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4337 |
MakeBackground(xsize,ysize,theGame,theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4338 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4339 |
twoPlayers = true; //Single player, but AI plays |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4340 |
showGame = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4341 |
vsMode = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4342 |
theGame2.AI_Enabled=true; //Of course we need an AI |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4343 |
theGame2.setAIlevel((Uint8)theAIlevel); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4344 |
int theTime = time(0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4345 |
theGame.putStartBlocks(theTime); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4346 |
theGame2.putStartBlocks(theTime); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4347 |
strcpy(theGame.name, player1name); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4348 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4349 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4350 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4351 |
if ((buttonXsize<mousex) && (mousex<240) && (80<mousey) && (mousey<120) && (b2playersOpen)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4352 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4353 |
//2 player - time trial |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4354 |
theGame.NewGame(50,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4355 |
theGame.timetrial=true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4356 |
bNewGameOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4357 |
b2playersOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4358 |
theGame.NewGame(50,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4359 |
theGame2.NewGame(xsize-500,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4360 |
theGame.timetrial = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4361 |
theGame2.timetrial = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4362 |
int theTime = time(0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4363 |
theGame.putStartBlocks(theTime); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4364 |
theGame2.putStartBlocks(theTime); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4365 |
theGame.setGameSpeed(player1Speed); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4366 |
theGame2.setGameSpeed(player2Speed); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4367 |
theGame.setHandicap(player1handicap); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4368 |
theGame2.setHandicap(player2handicap); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4369 |
theGame.AI_Enabled = player1AI; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4370 |
theGame2.AI_Enabled = player2AI; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4371 |
theGame.setAIlevel(player1AIlevel); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4372 |
theGame2.setAIlevel(player2AIlevel); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4373 |
twoPlayers = true; |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4374 |
strcpy(theGame.name, player1name); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4375 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4376 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4377 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4378 |
if ((buttonXsize<mousex) && (mousex<240) && (120<mousey) && (mousey<160) && (b2playersOpen)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4379 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4380 |
//2 player - VsMode |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4381 |
theGame.NewVsGame(50,100,&theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4382 |
theGame2.NewVsGame(xsize-500,100,&theGame); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4383 |
bNewGameOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4384 |
vsMode = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4385 |
twoPlayers = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4386 |
b2playersOpen = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4387 |
theGame.setGameSpeed(player1Speed); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4388 |
theGame2.setGameSpeed(player2Speed); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4389 |
theGame.setHandicap(player1handicap); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4390 |
theGame2.setHandicap(player2handicap); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4391 |
theGame.AI_Enabled = player1AI; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4392 |
theGame2.AI_Enabled = player2AI; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4393 |
theGame.setAIlevel(player1AIlevel); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4394 |
theGame2.setAIlevel(player2AIlevel); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4395 |
int theTime = time(0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4396 |
theGame.putStartBlocks(theTime); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4397 |
theGame2.putStartBlocks(theTime); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4398 |
strcpy(theGame.name, player1name); |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4399 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4400 |
} |
| 1572de2b |
sago007 |
2008-09-11 18:15 |
4401 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4402 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4403 |
if ((buttonXsize<mousex) && (mousex<240) && (120<mousey) && (mousey<160) && (bNetworkOpen)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4404 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4405 |
//Host |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4406 |
cout << "Host" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4407 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4408 |
theGame.SetGameOver(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4409 |
theGame2.SetGameOver(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4410 |
nt.startServer(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4411 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4412 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4413 |
if ((buttonXsize<mousex) && (mousex<240) && (160<mousey) && (mousey<200) && (bNetworkOpen)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4414 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4415 |
//Connect |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4416 |
cout << "Connect" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4417 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4418 |
theGame.SetGameOver(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4419 |
theGame2.SetGameOver(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4420 |
if (OpenDialogbox(200,100,serverAddress)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4421 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4422 |
char buf[30]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4423 |
memcpy(buf,serverAddress,30); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4424 |
nt.connectToServer(strtok(buf," ")); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4425 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4426 |
while ( SDL_PollEvent(&event) ); //If the user have pressed ESC or the like |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4427 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4428 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4429 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4430 |
if ((buttonXsize<mousex) && (mousex<2*buttonXsize) && (0<mousey) && (mousey<40) &&(!networkActive)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4431 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4432 |
//options button clicked |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4433 |
if (bOptionsOpen) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4434 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4435 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4436 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4437 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4438 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4439 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4440 |
bOptionsOpen = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4441 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4442 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4443 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4444 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4445 |
if ((buttonXsize<mousex) && (mousex<2*buttonXsize) && (40<mousey) && (mousey<80) && (bOptionsOpen) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4446 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4447 |
//Configure button clicked |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4448 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4449 |
if (!showOptions) { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4450 |
showOptions = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4451 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4452 |
else showOptions = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4453 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4454 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4455 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4456 |
if ((buttonXsize<mousex) && (mousex<2*buttonXsize) && (80<mousey) && (mousey<120) && (bOptionsOpen) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4457 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4458 |
//Configure button clicked |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4459 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4460 |
changePuzzleLevels(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4461 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4462 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4463 |
if ((buttonXsize<mousex) && (mousex<2*buttonXsize) && (120<mousey) && (mousey<160) && (bOptionsOpen) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4464 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4465 |
//vsMode button clicked |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4466 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4467 |
startVsMenu(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4468 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4469 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4470 |
if ((buttonXsize<mousex) && (mousex<2*buttonXsize) && (160<mousey) && (mousey<200) && (bOptionsOpen) ) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4471 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4472 |
//selectThemClicked |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4473 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4474 |
char temp[30]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4475 |
SelectThemeDialogbox(200,100,temp); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4476 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4477 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4478 |
if ((buttonXsize*2<mousex) && (mousex<3*buttonXsize) && (0<mousey) && (mousey<40) &&(!networkActive)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4479 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4480 |
//highscore button clicked |
| 47529580 |
sago007 |
2008-12-09 02:34 |
4481 |
OpenScoresDisplay(); |
| 47529580 |
sago007 |
2008-12-09 02:34 |
4482 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4483 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4484 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4485 |
if ((360<mousex) && (mousex<4*buttonXsize) && (0<mousey) && (mousey<40) &&(!networkActive)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4486 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4487 |
//Replay clicked! |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4488 |
bool state = (!bReplayOpen); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4489 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4490 |
bReplayOpen = state; //theGame.NewGame(50,100); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4491 |
showOptions = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4492 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4493 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4494 |
if ((360<mousex) && (mousex<4*buttonXsize) && (40<mousey) && (mousey<80) &&(bReplayOpen)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4495 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4496 |
//Replay->Save clicked! |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4497 |
//cout << "Replay->Save clicked" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4498 |
char buf[30]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4499 |
for (int i=0;i<29;i++)buf[i]=' '; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4500 |
buf[30]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4501 |
OpenDialogbox(200,100,buf); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4502 |
for (int i=28;buf[i]==' ';i--) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4503 |
buf[i]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4504 |
#ifdef __unix__ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4505 |
string saveHere = (string)getenv("HOME")+(string)"/.gamesaves/blockattack/replays/"+(string)buf; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4506 |
#elif WIN32 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4507 |
string saveHere = home+(string)"/My Games/blockattack/replays/"+(string)buf; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4508 |
#else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4509 |
string saveHere = (string)"./replays"+(string)buf; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4510 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4511 |
if (lastNrOfPlayers<2) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4512 |
theGame.theReplay.saveReplay(saveHere); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4513 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4514 |
theGame.theReplay.saveReplay(saveHere,theGame2.theReplay); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4515 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4516 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4517 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4518 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4519 |
if ((360<mousex) && (mousex<4*buttonXsize) && (80<mousey) && (mousey<120)&&(bReplayOpen)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4520 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4521 |
//Replay->Load clicked! |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4522 |
//cout << "Replay->Load clicked" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4523 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4524 |
char buf[30]; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4525 |
for (int i=0;i<29;i++)buf[i]=' '; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4526 |
buf[30]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4527 |
if (OpenReplayDialogbox(50,100,buf)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4528 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4529 |
//cout << "Good way" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4530 |
for (int i=28;buf[i]==' ';i--) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4531 |
buf[i]=0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4532 |
#ifdef __unix__ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4533 |
string loadThis = (string)getenv("HOME")+(string)"/.gamesaves/blockattack/replays/"+(string)buf; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4534 |
#elif WIN32 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4535 |
string loadThis = home+(string)"/My Games/blockattack/replays/"+(string)buf; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4536 |
#else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4537 |
string loadThis = (string)"./replays/"+(string)buf; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4538 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4539 |
ifstream replayFileIn; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4540 |
replayFileIn.open(loadThis.c_str(),ios::binary); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4541 |
bool play2 = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4542 |
if (replayFileIn) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4543 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4544 |
Uint8 version = 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4545 |
replayFileIn.read(reinterpret_cast<char*>(&version),sizeof(Uint8)); replayFileIn.close(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4546 |
Replay r1; |
| e03ae476 |
sago007 |
2009-03-06 22:49 |
4547 |
if(r1.loadReplay(loadThis)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4548 |
{ |
| e03ae476 |
sago007 |
2009-03-06 22:49 |
4549 |
Replay r2; |
| e03ae476 |
sago007 |
2009-03-06 22:49 |
4550 |
play2 = r2.loadReplay2(loadThis); |
| e03ae476 |
sago007 |
2009-03-06 22:49 |
4551 |
theGame.playReplay(50,100); //Fejlen sker her |
| e03ae476 |
sago007 |
2009-03-06 22:49 |
4552 |
theGame.theReplay = r1; |
| e03ae476 |
sago007 |
2009-03-06 22:49 |
4553 |
if (play2) |
| e03ae476 |
sago007 |
2009-03-06 22:49 |
4554 |
{ |
| e03ae476 |
sago007 |
2009-03-06 22:49 |
4555 |
theGame2.playReplay(xsize-500,100); |
| e03ae476 |
sago007 |
2009-03-06 22:49 |
4556 |
theGame2.theReplay = r2; |
| e03ae476 |
sago007 |
2009-03-06 22:49 |
4557 |
} |
| e03ae476 |
sago007 |
2009-03-06 22:49 |
4558 |
else |
| e03ae476 |
sago007 |
2009-03-06 22:49 |
4559 |
theGame2.SetGameOver(); |
| e03ae476 |
sago007 |
2009-03-06 22:49 |
4560 |
cout << "Replay should have been read" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4561 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4562 |
else |
| e03ae476 |
sago007 |
2009-03-06 22:49 |
4563 |
cout << "Failed to read replay" << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4564 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4565 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4566 |
closeAllMenus(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4567 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4568 |
else |
| 9050a50a |
sago007 |
2008-12-09 13:35 |
4569 |
if ((xsize-120<mousex) && (xsize-20>mousex) && (ysize-buttonXsize<mousey) && (ysize-20>mousey)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4570 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4571 |
//Exit clicked |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4572 |
done=1; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4573 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4574 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4575 |
if ((showOptions) && (mousex>500) && (mousex<560) && (mousey>220) && (mousey<260)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4576 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4577 |
MusicEnabled = !MusicEnabled; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4578 |
if (!MusicEnabled) Mix_FadeOutMusic(500); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4579 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4580 |
if ((showOptions) && (mousex>500) && (mousex<560) && (mousey>270) && (mousey<310)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4581 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4582 |
SoundEnabled = !SoundEnabled; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4583 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4584 |
if ((showOptions) && (mousex>500) && (mousex<560) && (mousey>320) && (mousey<360)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4585 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4586 |
//Fullscreen |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4587 |
bFullscreen = !bFullscreen; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4588 |
#if defined(WIN32) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4589 |
if (bFullscreen) screen=SDL_SetVideoMode(xsize,ysize,32,SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ANYFORMAT); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4590 |
else screen=SDL_SetVideoMode(xsize,ysize,32,SDL_SWSURFACE|SDL_ANYFORMAT); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4591 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4592 |
#else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4593 |
SDL_WM_ToggleFullScreen(screen); //Will only work in Linux |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4594 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4595 |
SDL_ShowCursor(SDL_DISABLE); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4596 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4597 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4598 |
if ((showOptions) && (mousex>330) && (mousex<470) && (mousey>535) && (mousey<585)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4599 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4600 |
//change name |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4601 |
bScreenLocked = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4602 |
showDialog = true; |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4603 |
strcpy(theGame.name, player1name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4604 |
if (OpenDialogbox(200,100,player1name)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4605 |
strcpy(theGame.name, player1name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4606 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4607 |
strcpy(player1name,theGame.name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4608 |
bScreenLocked = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4609 |
showDialog = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4610 |
MakeBackground(xsize,ysize,theGame,theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4611 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4612 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4613 |
if ((showOptions) && (mousex>330) && (mousex<470) && (mousey>600) && (mousey<640)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4614 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4615 |
//change name |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4616 |
bScreenLocked = true; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4617 |
showDialog = true; |
| c96f480e |
sago007 |
2009-03-28 18:59 |
4618 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4619 |
if (OpenDialogbox(200,100,player2name)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4620 |
strcpy(theGame2.name, player2name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4621 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4622 |
strcpy(player2name,theGame2.name); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4623 |
bScreenLocked = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4624 |
showDialog = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4625 |
MakeBackground(xsize,ysize,theGame,theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4626 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4627 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4628 |
if ((showOptions) && (mousex>510) && (mousex<630) && (mousey>535) && (mousey<585)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4629 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4630 |
//changeControls |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4631 |
OpenControlsBox(200,100,0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4632 |
MakeBackground(xsize,ysize,theGame,theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4633 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4634 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4635 |
if ((showOptions) && (mousex>510) && (mousex<630) && (mousey>600) && (mousey<640)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4636 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4637 |
//changeControls |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4638 |
OpenControlsBox(200,100,2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4639 |
MakeBackground(xsize,ysize,theGame,theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4640 |
DrawIMG(background, screen, 0, 0); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4641 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4642 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4643 |
/******************************************************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4644 |
**************** Here comes mouse play ****************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4645 |
********************************************************************/ |
| 47529580 |
sago007 |
2008-12-09 02:34 |
4646 |
if ((!showOptions)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4647 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4648 |
if (mouseplay1 && !theGame.AI_Enabled) //player 1 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4649 |
if ((mousex > 50)&&(mousey>100)&&(mousex<50+300)&&(mousey<100+600)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4650 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4651 |
theGame.SwitchAtCursor(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4652 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4653 |
if (mouseplay2 && !theGame2.AI_Enabled) //player 2 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4654 |
if ((mousex > xsize-500)&&(mousey>100)&&(mousex<xsize-500+300)&&(mousey<100+600)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4655 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4656 |
theGame2.SwitchAtCursor(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4657 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4658 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4659 |
/******************************************************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4660 |
**************** Here ends mouse play ******************************* |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4661 |
********************************************************************/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4662 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4663 |
if(stageButtonStatus != SBdontShow && (mousex > theGame.topx+cordNextButton.x) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4664 |
&&(mousex < theGame.topx+cordNextButton.x+cordNextButton.xsize) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4665 |
&&(mousey > theGame.topy+cordNextButton.y)&&(mousey < theGame.topy+cordNextButton.y+cordNextButton.ysize)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4666 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4667 |
//Clicked the next button after a stage clear or puzzle |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4668 |
theGame.nextLevel(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4669 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4670 |
if(stageButtonStatus != SBdontShow && (mousex > theGame.topx+cordRetryButton .x) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4671 |
&&(mousex < theGame.topx+cordRetryButton.x+cordRetryButton.xsize) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4672 |
&&(mousey > theGame.topy+cordRetryButton.y)&&(mousey < theGame.topy+cordRetryButton.y+cordRetryButton.ysize)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4673 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4674 |
//Clicked the retry button |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4675 |
theGame.retryLevel(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4676 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4677 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4678 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4679 |
//cout << "Mouse x: " << mousex << ", mouse y: " << mousey << endl; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4680 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4681 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4682 |
//Mouse button 2: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4683 |
if ((SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(3))==SDL_BUTTON(3) && bMouseUp2) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4684 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4685 |
bMouseUp2=false; //The button is pressed |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4686 |
/******************************************************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4687 |
**************** Here comes mouse play ****************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4688 |
********************************************************************/ |
| 47529580 |
sago007 |
2008-12-09 02:34 |
4689 |
if (!showOptions) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4690 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4691 |
if (mouseplay1 && !theGame.AI_Enabled) //player 1 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4692 |
if ((mousex > 50)&&(mousey>100)&&(mousex<50+300)&&(mousey<100+600)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4693 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4694 |
theGame.PushLine(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4695 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4696 |
if (mouseplay2 && !theGame2.AI_Enabled) //player 2 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4697 |
if ((mousex > xsize-500)&&(mousey>100)&&(mousex<xsize-500+300)&&(mousey<100+600)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4698 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4699 |
theGame2.PushLine(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4700 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4701 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4702 |
/******************************************************************** |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4703 |
**************** Here ends mouse play ******************************* |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4704 |
********************************************************************/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4705 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4706 |
} //if !singlePuzzle |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4707 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4708 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4709 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4710 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4711 |
} //if !bScreenBocked; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4712 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4713 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4714 |
//Sees if music is stopped and if music is enabled |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4715 |
if ((!NoSound)&&(!Mix_PlayingMusic())&&(MusicEnabled)&&(!bNearDeath)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4716 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4717 |
// then starts playing it. |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4718 |
Mix_VolumeMusic(MIX_MAX_VOLUME); |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4719 |
Mix_PlayMusic(bgMusic, -1); //music loop |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4720 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4721 |
|
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4722 |
if(bNearDeath!=bNearDeathPrev) |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4723 |
{ |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4724 |
if(bNearDeath) |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4725 |
{ |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4726 |
if(!NoSound &&(MusicEnabled)) { |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4727 |
Mix_VolumeMusic(MIX_MAX_VOLUME); |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4728 |
Mix_PlayMusic(highbeatMusic, 1); |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4729 |
} |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4730 |
} |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4731 |
else |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4732 |
{ |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4733 |
if(!NoSound &&(MusicEnabled)) { |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4734 |
Mix_VolumeMusic(MIX_MAX_VOLUME); |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4735 |
Mix_PlayMusic(bgMusic, -1); |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4736 |
} |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4737 |
} |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4738 |
} |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4739 |
|
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4740 |
bNearDeathPrev = bNearDeath; |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4741 |
|
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4742 |
|
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4743 |
//set bNearDeath to false theGame*.Update() will change to true as needed |
| 6d48320c |
sago007 |
2009-03-28 17:06 |
4744 |
bNearDeath = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4745 |
//Updates the objects |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4746 |
theGame.Update(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4747 |
theGame2.Update(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4748 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4749 |
//see if anyone has won (two players only) |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
4750 |
#if NETWORK |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4751 |
if (!networkPlay) |
| 2f30c381 |
sago007 |
2008-09-14 13:08 |
4752 |
#endif |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4753 |
if (twoPlayers) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4754 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4755 |
lastNrOfPlayers = 2; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4756 |
if ((theGame.bGameOver) && (theGame2.bGameOver)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4757 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4758 |
if (theGame.score+theGame.handicap>theGame2.score+theGame2.handicap) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4759 |
theGame.setPlayerWon(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4760 |
else |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4761 |
if (theGame.score+theGame.handicap<theGame2.score+theGame2.handicap) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4762 |
theGame2.setPlayerWon(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4763 |
else { |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4764 |
theGame.setDraw(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4765 |
theGame2.setDraw(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4766 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4767 |
twoPlayers = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4768 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4769 |
if ((theGame.bGameOver) && (!theGame2.bGameOver)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4770 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4771 |
theGame2.setPlayerWon(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4772 |
twoPlayers = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4773 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4774 |
if ((!theGame.bGameOver) && (theGame2.bGameOver)) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4775 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4776 |
theGame.setPlayerWon(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4777 |
twoPlayers = false; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4778 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4779 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4780 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4781 |
//Once evrything has been checked, update graphics |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4782 |
DrawEverything(xsize,ysize,theGame, theGame2); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4783 |
SDL_GetMouseState(&mousex,&mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4784 |
//Remember mouse placement |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4785 |
oldMousex = mousex; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4786 |
oldMousey = mousey; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4787 |
//Draw the mouse: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4788 |
DrawIMG(mouse,screen,mousex,mousey); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4789 |
SDL_Flip(screen); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4790 |
} //game loop |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4791 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4792 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4793 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4794 |
//Saves options |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4795 |
if (!editorMode) |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4796 |
{ |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4797 |
configSettings->setInt("fullscreen",(int)bFullscreen); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4798 |
configSettings->setInt("musicenabled",(int)MusicEnabled); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4799 |
configSettings->setInt("soundenabled",(int)SoundEnabled); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4800 |
configSettings->setInt("mouseplay1",(int)mouseplay1); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4801 |
configSettings->setInt("mouseplay2",(int)mouseplay2); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4802 |
configSettings->setInt("joypad1",(int)joyplay1); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4803 |
configSettings->setInt("joypad2",(int)joyplay2); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4804 |
|
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4805 |
configSettings->setInt("player1keyup",(int)keySettings[0].up); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4806 |
configSettings->setInt("player1keydown",(int)keySettings[0].down); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4807 |
configSettings->setInt("player1keyleft",(int)keySettings[0].left); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4808 |
configSettings->setInt("player1keyright",(int)keySettings[0].right); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4809 |
configSettings->setInt("player1keychange",(int)keySettings[0].change); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4810 |
configSettings->setInt("player1keypush",(int)keySettings[0].push); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4811 |
|
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4812 |
configSettings->setInt("player2keyup",(int)keySettings[2].up); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4813 |
configSettings->setInt("player2keydown",(int)keySettings[2].down); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4814 |
configSettings->setInt("player2keyleft",(int)keySettings[2].left); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4815 |
configSettings->setInt("player2keyright",(int)keySettings[2].right); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4816 |
configSettings->setInt("player2keychange",(int)keySettings[2].change); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4817 |
configSettings->setInt("player2keypush",(int)keySettings[2].push); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4818 |
|
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4819 |
configSettings->setString("player1name",player1name); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4820 |
configSettings->setString("player2name",player2name); |
| 769a41a0 |
sago007 |
2008-09-24 12:54 |
4821 |
configSettings->save(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4822 |
} |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4823 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4824 |
//calculate uptime: |
| c09d0e4f |
sago007 |
2009-01-27 01:15 |
4825 |
//int hours, mins, secs, |
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
4826 |
commonTime ct = TimeHandler::ms2ct(SDL_GetTicks()); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4827 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4828 |
cout << "Block Attack - Rise of the Blocks ran for: " << ct.hours << " hours " << ct.minutes << " mins and " << ct.seconds << " secs" << endl; |
| c09d0e4f |
sago007 |
2009-01-27 01:15 |
4829 |
|
| cd12e0fe |
sago007 |
2009-01-29 08:47 |
4830 |
ct = TimeHandler::addTime("totalTime",ct); |
| c09d0e4f |
sago007 |
2009-01-27 01:15 |
4831 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4832 |
cout << "Total run time is now: " << ct.days << " days " << ct.hours << " hours " << ct.minutes << " mins and " << ct.seconds << " secs" << endl; |
| c09d0e4f |
sago007 |
2009-01-27 01:15 |
4833 |
|
| c09d0e4f |
sago007 |
2009-01-27 01:15 |
4834 |
Stats::getInstance()->save(); |
| c09d0e4f |
sago007 |
2009-01-27 01:15 |
4835 |
|
| c09d0e4f |
sago007 |
2009-01-27 01:15 |
4836 |
Config::getInstance()->save(); |
| c09d0e4f |
sago007 |
2009-01-27 01:15 |
4837 |
|
| c09d0e4f |
sago007 |
2009-01-27 01:15 |
4838 |
//Frees memory from music and fonts |
| c09d0e4f |
sago007 |
2009-01-27 01:15 |
4839 |
//This is done after writing of configurations and stats since it often crashes the program :( |
| c09d0e4f |
sago007 |
2009-01-27 01:15 |
4840 |
UnloadImages(); |
| 41f02ab2 |
sago007 |
2009-05-10 21:40 |
4841 |
|
| 91886cae |
sago007 |
2008-09-12 16:28 |
4842 |
//Close file system Apstraction layer! |
| 91886cae |
sago007 |
2008-09-12 16:28 |
4843 |
PHYSFS_deinit(); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4844 |
return 0; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
4845 |
} |
|
|
1970-01-01 00:00 |
4846 |
|