ccdevnet / openc2e

openc2e

This URL has Read+Write access

openc2e / SDLBackend.h
100644 58 lines (48 sloc) 1.611 kb
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
/*
* SDLBackend.h
* openc2e
*
* Created by Alyssa Milburn on Sun Oct 24 2004.
* Copyright (c) 2004 Alyssa Milburn. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
 
#ifndef _SDLBACKEND_H
#define _SDLBACKEND_H
 
#include <SDL/SDL.h>
#include "SDL_mixer.h"
#include "creaturesImage.h"
#include "endianlove.h"
#include <map>
 
extern class SDLBackend *g_backend; // global hack, for now
 
class SDLBackend {
protected:
bool soundenabled;
static const unsigned int nosounds = 12;
Mix_Chunk *sounds[12];
int soundchannels[12];
 
std::map<std::string, Mix_Chunk *> soundcache;
 
int width, height;
 
public:
SDL_Surface *screen;
 
public:
SDLBackend() { g_backend = this; }
unsigned int ticks() { return SDL_GetTicks(); }
void init();
void resizeNotify(int _w, int _h);
void playFile(std::string filename);
void render(creaturesImage *image, unsigned int frame, unsigned int x, unsigned int y);
void renderLine(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int colour);
int getWidth() const { return width; }
int getHeight() const { return height; }
};
 
#endif