-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiceInvaders.h
52 lines (40 loc) · 1.41 KB
/
DiceInvaders.h
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
#ifndef DICEINVADERS_H
#define DICEINVADERS_H
struct ISprite
{
// Destroys the sprite instance
virtual void destroy() = 0;
// Draw the sprite at the given position.
// Valid coordinates are between (0,0) (upper left) and (width-32, height-32) (lower right).
// (All sprites are 32*32 pixels, clipping is not supported)
virtual void draw(int x, int y) = 0;
};
struct IDiceInvaders
{
// Destroys the dice invaders instance
virtual void destroy() = 0;
// Creates the main window. Returns true on success.
virtual bool init(int width, int height) = 0;
// Clears the screen and draws all sprites and texts which have been drawn
// since the last update call.
// If update returns false, the application should terminate.
virtual bool update() = 0;
// Create a sprite given a string.
// All sprites are 32*32 pixels.
virtual ISprite* createSprite(const char* name) = 0;
// Draws the given text.
virtual void drawText(int x, int y, const char* msg) = 0;
// Return the total time spent in the game, in seconds.
virtual float getElapsedTime() = 0;
struct KeyStatus
{
bool fire; // space
bool left; // left arrow
bool right; // right arrow
};
// Returns the keyboard status. If a flag is set, the corresponding key is being held down.
virtual void getKeyStatus(KeyStatus& keys) = 0;
};
// A factory type for creating IDiceInvaders instances.
typedef IDiceInvaders* (__cdecl DiceInvadersFactoryType)();
#endif