-
Notifications
You must be signed in to change notification settings - Fork 0
/
cosmos.cpp
96 lines (88 loc) · 2.9 KB
/
cosmos.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "../user/user.h"
#include "cosmos.h"
#include "planet.h"
#include "game.h"
#include "troop.h"
Screen *screen;
Keyboard *key;
Mouse *mouse;
InputQueue *input;
Planet *plan[MAX_PLANETS];
Graphic *troopg[TROOP_MAX];
Graphic *troopimg[TROOP_MAX];
Graphic *buildimg[BUILDING_MAX];
Graphic *buildg[BUILDING_MAX][BUILDSTAT_MAX];
Graphic *dmdth[17];
int builds[BUILDING_MAX][BUILDSTAT_MAX];
Sound *sound[SOUND_MAX];
int soundh[SOUND_MAX][2];
Speaker *spk=NULL;
int player=0;
int main(int argc, char **argv) {
U2_Init(argc, argv);
screen = new Screen(1024, 768, 32, "Cosmos");
spk = new Speaker(1, 16, 44100);
screen->SetFrameRate(20);
screen->SetFont("fonts/basic30.sgf");
screen->SetPaletteEntry(0, 0, 0, 0);
screen->SetPaletteEntry(255, 255, 255, 255);
screen->SetApparentDepth(32);
int ctr;
for(ctr=0; ctr<SHOT_MAX; ctr++) {
wsp[ctr] = -1;
wsn[ctr] = 0;
}
for(ctr=0; ctr<17; ctr++) {
char buf[256];
sprintf(buf, "graphics/deaths/dome/%.4d.bmp%c", ctr, 0);
dmdth[ctr] = new Graphic(buf);
Palette p(buf);
dmdth[ctr]->DepthConvert(32, p);
screen->MakeFriendly(dmdth[ctr]);
}
Debug("Loading sound \"GUN\"");
sound[SOUND_GUN] = new Sound("sounds/gun.wav");
if(spk) spk->MakeFriendly(*sound[SOUND_GUN]);
Debug("Loading sound \"OPEN\"");
sound[SOUND_OPEN] = new Sound("sounds/open.wav");
if(spk) spk->MakeFriendly(*sound[SOUND_OPEN]);
Debug("Loading sound \"DEATH\"");
sound[SOUND_DEATH] = new Sound("sounds/death.wav");
if(spk) spk->MakeFriendly(*sound[SOUND_DEATH]);
Debug("Loading sound \"LASER\"");
sound[SOUND_LASER] = new Sound("sounds/laser.wav");
if(spk) spk->MakeFriendly(*sound[SOUND_LASER]);
Debug("Loading sound \"MASER\"");
sound[SOUND_MASER] = new Sound("sounds/maser.wav");
if(spk) spk->MakeFriendly(*sound[SOUND_MASER]);
Debug("Loading sound \"LASERMASER\"");
sound[SOUND_LASERMASER] = new Sound("sounds/lmaser.wav");
if(spk) spk->MakeFriendly(*sound[SOUND_LASERMASER]);
Debug("Loading sound \"BALLISTIC\"");
sound[SOUND_BALLISTIC] = new Sound("sounds/ballistic.wav");
if(spk) spk->MakeFriendly(*sound[SOUND_BALLISTIC]);
Debug("Loading sound \"SHELL\"");
sound[SOUND_SHELL] = new Sound("sounds/shell.wav");
if(spk) spk->MakeFriendly(*sound[SOUND_SHELL]);
Debug("Loading sound \"AMBIENT\"");
sound[SOUND_AMBIENT] = new Sound("sounds/ambient.wav");
Debug("Loading sound \"DOMEDIE\"");
sound[SOUND_DOMEDIE] = new Sound("sounds/domedie.wav");
if(spk) spk->MakeFriendly(*sound[SOUND_AMBIENT]);
if(spk) spk->SetAsAmbient(*sound[SOUND_AMBIENT]);
for(ctr=0; ctr<SOUND_MAX; ++ctr) { soundh[ctr][0]=-1; soundh[ctr][1]=-1; }
key = new Keyboard;
mouse = new Mouse;
{ Graphic cur("cursor.tga");
screen->MakeFriendly(&cur);
mouse->SetCursor(cur);
}
input = new InputQueue;
Game *game = new Game;
while(game->Initialize()) { game->Play(); }
U2_Exit(0);
delete game;
delete key;
delete screen;
return 0;
}