| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
1 |
/* |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
2 |
=========================================================================== |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
3 |
blockattack - Block Attack - Rise of the Blocks |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
4 |
Copyright (C) 2005-2012 Poul Sander |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
5 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
6 |
This program is free software: you can redistribute it and/or modify |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
7 |
it under the terms of the GNU General Public License as published by |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
8 |
the Free Software Foundation, either version 2 of the License, or |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
9 |
(at your option) any later version. |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
10 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
11 |
This program is distributed in the hope that it will be useful, |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
14 |
GNU General Public License for more details. |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
15 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
16 |
You should have received a copy of the GNU General Public License |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
17 |
along with this program. If not, see http://www.gnu.org/licenses/ |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
18 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
19 |
Source information and contacts persons can be found at |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
20 |
http://blockattack.sf.net |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
21 |
=========================================================================== |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
22 |
*/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
23 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
24 |
//headerfile for replay.h |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
25 |
/* |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
26 |
replay is used to save a replay, there is saved 10 moves per second, should be |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
27 |
able to give a realistic replay |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
28 |
*/ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
29 |
|
| 17916a2e |
sago007 |
2010-11-07 11:26 |
30 |
#ifndef REPLAY_H |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
31 |
#define REPLAY_H 1 |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
32 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
33 |
//constants - 3000 is 5 minutes |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
34 |
#define FRAMESPERSEC 10 |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
35 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
36 |
#include "SDL.h" |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
37 |
#include <stdlib.h> |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
38 |
#include <iostream> |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
39 |
#include <fstream> |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
40 |
#include <vector> |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
41 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
42 |
using namespace std; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
43 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
44 |
//board_package, stores a board can be used for network play and replay |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
45 |
struct boardPackage //92 bytes |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
46 |
{ |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
47 |
Uint32 time; //game time |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
48 |
Uint8 brick[6][13]; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
49 |
Uint8 pixels; //pixels pushed |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
50 |
Uint8 cursorX; //Cursor coordinate |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
51 |
Uint8 cursorY; // -||- |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
52 |
Uint32 score; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
53 |
Uint8 speed; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
54 |
Uint8 chain; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
55 |
Uint8 result; //0=none,1=gameOver,2=winner,4=draw |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
56 |
}; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
57 |
|
| d12916ab |
sago007 |
2012-04-19 23:30 |
58 |
struct Action |
| d12916ab |
sago007 |
2012-04-19 23:30 |
59 |
{ |
| d12916ab |
sago007 |
2012-04-19 23:30 |
60 |
Uint32 time; |
| d12916ab |
sago007 |
2012-04-19 23:30 |
61 |
string action; |
| d12916ab |
sago007 |
2012-04-19 23:30 |
62 |
}; |
| d12916ab |
sago007 |
2012-04-19 23:30 |
63 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
64 |
class Replay |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
65 |
{ |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
66 |
private: |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
67 |
//Our replay is stored in an array of TOTALFRAMES length |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
68 |
//boardPackage bps[TOTALFRAMES]; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
69 |
vector<boardPackage> bps; |
| d12916ab |
sago007 |
2012-04-19 23:30 |
70 |
vector<Action> actions; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
71 |
//The final package is not set to any specific time |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
72 |
boardPackage finalPack; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
73 |
//We store number of frames, so we know how long to read the array |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
74 |
Uint32 nrOfFrames; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
75 |
//An enumerator, so we know how it ends! (should be removed then boardPackage is the 92 byte version) |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
76 |
enum { gameOver=0, winner, looser, draw } theResult; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
77 |
//If we are loaded from a file, then we are read only |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
78 |
bool isLoaded; |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
79 |
|
| c96f480e |
sago007 |
2009-03-28 18:59 |
80 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
81 |
public: |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
82 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
83 |
//Store player name |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
84 |
char name[30]; |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
85 |
|
| c53e6443 |
sago007 |
2012-04-17 11:04 |
86 |
Replay(); //Constructor |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
87 |
Replay(const Replay& r); //Copy constructor |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
88 |
Uint32 getNumberOfFrames(); //Returns number of frames |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
89 |
void setFrameSecTo(Uint32,boardPackage); //Sets frame at a given time to the package |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
90 |
void setFinalFrame(boardPackage,int); //Sets the final package |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
91 |
boardPackage getFrameSec(Uint32); //Gets a frame to a time |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
92 |
boardPackage getFinalFrame(); //Gets the last frame, that must remain |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
93 |
int getFinalStatus(); //Return the result: winner, looser, draw or gameOver |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
94 |
bool isFinnished(Uint32); //Returns true if we are done |
| d12916ab |
sago007 |
2012-04-19 23:30 |
95 |
|
| d12916ab |
sago007 |
2012-04-19 23:30 |
96 |
//New replay type 1.5.0+: |
| d12916ab |
sago007 |
2012-04-19 23:30 |
97 |
void addAction(int tick, string action); |
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
98 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
99 |
//Ok, I'll ignore this for some time, and just save to file, if however, we ever use a dynamic saving structure, we are fucked |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
100 |
bool saveReplay(string); //Saves a replay |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
101 |
bool saveReplay(string,Replay p2); //saves a replay, plus another replay given as a parameter |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
102 |
bool loadReplay(string); //laods a replay |
| c53e6443 |
sago007 |
2012-04-17 11:04 |
103 |
bool loadReplay2(string); //loads the second part of the replay file, if it exists, returns false otherwise |
| c96f480e |
sago007 |
2009-03-28 18:59 |
104 |
|
| c96f480e |
sago007 |
2009-03-28 18:59 |
105 |
|
| 89c4a3a6 |
sago007 |
2008-08-29 14:32 |
106 |
}; |
| 17916a2e |
sago007 |
2010-11-07 11:26 |
107 |
|
| 17916a2e |
sago007 |
2010-11-07 11:26 |
108 |
#endif |
|
|
1970-01-01 00:00 |
109 |
|