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
|
//kotzing.cpp
#include <allegro.h>
#include <time.h>
#include "kotzing.h"
#include "title.h"
volatile int timerCounter = 0;
static void timerCounterUpdater()
{
timerCounter++;
}
END_OF_STATIC_FUNCTION(timerCounterUpdater);
//Funktionen
void fatalError(char *str)
{
allegro_message(str);
exit(0);
}
int setGfxMode(int mode, int width, int height)
{
static int colorDepths[] = { 16, 24, 15, 32};
int a;
for (a=0; a < 4; a++)
{
set_color_depth(colorDepths[a]);
if (set_gfx_mode(mode, width, height, 0, 0) >= 0)
{
return TRUE;
}
}
return FALSE;
}
void show()
{
blit(doubleBuffer, screen, 0,0,0,0, doubleBuffer->w, doubleBuffer->h);
}
void init()
{
srand(time(NULL));
//init
allegro_init();
if (!setGfxMode(GFX_AUTODETECT_FULLSCREEN, 1024, 768))
{
if (!setGfxMode(GFX_AUTODETECT_WINDOWED, 1024, 768))
{
fatalError("Unable to set a graphics mode");
}
}
install_timer();
install_keyboard();
install_joystick(JOY_TYPE_AUTODETECT);
install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
doubleBuffer = create_bitmap(SCREEN_W, SCREEN_H);
if (!doubleBuffer)
{
fatalError("Unable to create double buffer");
}
LOCK_FUNCTION(timerCounterUpdater);
LOCK_VARIABLE(timerCounter);
install_int_ex(timerCounterUpdater, BPS_TO_TIMER(60));
}
//ende
void done()
{
destroy_bitmap(doubleBuffer);
}
//main
int main(int argc, char** argv)
{
int gameOver = FALSE;
init();
while (!gameOver)
{
title();
}
done();
}
END_OF_MAIN();
|