bzr branch
http://gegoxaren.bato24.eu/bzr/%2Bjunk/c_sdl_joypad_ducktape
21
by Gustav Hatvigsson
* added Modeline to (almost) all files. |
1 |
/* c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil
|
2 |
* vi: set shiftwidth=2 tabstop=2 expandtab:
|
|
3 |
* :indentSize=2:tabSize=2:noTabs=true:
|
|
4 |
*/
|
|
5 |
||
1
by Gustav Hartvigsson
Initial code. |
6 |
#include "game_utils.h" |
7 |
||
17
by Gustav Hartvigsson
* fixed a few Doxygen problems. |
8 |
/*
|
7
by Gustav Hartvigsson
* Added licensing information to the files. |
9 |
* This file, as the rest of the project is under MIT license.
|
10 |
* see http://opensource.org/licenses/MIT
|
|
11 |
*
|
|
8
by Gustav Hartvigsson
* added and changed little in the files Lincening information. |
12 |
* Author Gustav Hartvigsson <gustav.hartvigsson _at_ gmail.com> 2014
|
7
by Gustav Hartvigsson
* Added licensing information to the files. |
13 |
*/
|
14 |
||
1
by Gustav Hartvigsson
Initial code. |
15 |
SDL_Color game_color_set_draw_color (SDL_Renderer * renderer, |
16 |
const SDL_Color color) { |
|
17 |
SDL_Color nc = color; |
|
18 |
SDL_Color oc = {0,0,0,0}; /* Save the old colour */ |
|
19 |
int ret = SDL_GetRenderDrawColor (renderer, &oc.r, &oc.g, &oc.b, &oc.a); |
|
20 |
if (ret < 0) { |
|
21 |
fprintf(stderr, "Couldn't get Colour: %s\n", SDL_GetError()); |
|
22 |
} |
|
23 |
ret = SDL_SetRenderDrawColor (renderer, nc.r, nc.g, nc.b, nc.a); |
|
24 |
if (ret < 0) { |
|
25 |
fprintf(stderr, "Couldn't set Colour: %s\n", SDL_GetError()); |
|
26 |
} |
|
27 |
return oc; |
|
28 |
}
|
|
29 |
||
30 |
SDL_Color game_color_create_color (int r, int g, int b, int a) { |
|
31 |
return (SDL_Color) {.r = r, .g = g, .b = b, .a = a}; |
|
32 |
}
|
|
33 |
||
34 |
SDL_Rect game_rect_create_rect (int x, int y, int h, int w) { |
|
35 |
return (SDL_Rect) {.x = x, .y = y, .h = h, .w = w}; |
|
36 |
}
|
|
37 |
||
38 |
SDL_Rect * game_rect_new (int x, int y, int h, int w) { |
|
39 |
SDL_Rect * self = malloc (sizeof(SDL_Rect)); |
|
40 |
self->x = x; |
|
41 |
self->y = y; |
|
42 |
self->w = w; |
|
43 |
self->h = h; |
|
44 |
return self; |
|
45 |
}
|
|
10
by Gustav Hartvigsson
created a generic error print function that should print nice looking |
46 |
|
47 |
void print_error (const char * str, ... ) { |
|
48 |
fprintf (stderr, |
|
49 |
"============================================================================\n" |
|
50 |
); |
|
51 |
|
|
52 |
va_list args; |
|
15
by Gustav Hartvigsson
* moved the files to ./src/ |
53 |
va_start (args, str); |
10
by Gustav Hartvigsson
created a generic error print function that should print nice looking |
54 |
vfprintf (stderr, str, args); |
55 |
va_end (args); |
|
56 |
|
|
57 |
fprintf (stderr, |
|
58 |
"\n" |
|
59 |
"============================================================================\n" |
|
60 |
); |
|
61 |
}
|