1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
// main.cpp: initialisation & main loop
#include "cube.h"
OF_APPLICATION_DELEGATE(Cube)
VARF(gamespeed, 10, 100, 1000, if (multiplayer()) gamespeed = 100);
VARP(minmillis, 0, 5, 1000);
@implementation Cube {
int _width, _height;
}
+ (Cube *)sharedInstance
{
return (Cube *)OFApplication.sharedApplication.delegate;
}
|
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
// main.cpp: initialisation & main loop
#include "cube.h"
OF_APPLICATION_DELEGATE(Cube)
VARF(gamespeed, 10, 100, 1000, if (multiplayer()) gamespeed = 100);
VARP(minmillis, 0, 5, 1000);
@implementation Cube {
int _width, _height;
OFIRI *_userDataIRI;
}
+ (Cube *)sharedInstance
{
return (Cube *)OFApplication.sharedApplication.delegate;
}
|
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
SDL_SetRelativeMouseMode(SDL_TRUE);
SDL_ShowCursor(0);
log("gl");
gl_init(_width, _height);
log("basetex");
int xs, ys;
if (!installtex(2, path(newstring("data/newchars.png")), xs, ys) ||
!installtex(3, path(newstring("data/martin/base.png")), xs, ys) ||
!installtex(6, path(newstring("data/martin/ball1.png")), xs, ys) ||
!installtex(7, path(newstring("data/martin/smoke.png")), xs, ys) ||
!installtex(8, path(newstring("data/martin/ball2.png")), xs, ys) ||
!installtex(9, path(newstring("data/martin/ball3.png")), xs, ys) ||
!installtex(4, path(newstring("data/explosion.jpg")), xs, ys) ||
!installtex(5, path(newstring("data/items.png")), xs, ys) ||
!installtex(1, path(newstring("data/crosshair.png")), xs, ys))
fatal(@"could not find core textures (hint: run cube from the "
@"parent of the bin directory)");
log("sound");
initsound();
log("cfg");
|
>
>
|
>
>
|
>
>
>
|
>
>
>
|
>
>
>
|
>
>
>
|
>
>
>
|
>
>
>
|
>
>
|
>
>
>
|
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
SDL_SetRelativeMouseMode(SDL_TRUE);
SDL_ShowCursor(0);
log("gl");
gl_init(_width, _height);
log("basetex");
_gameDataIRI = [OFFileManager.defaultManager currentDirectoryIRI];
_userDataIRI = [OFFileManager.defaultManager currentDirectoryIRI];
int xs, ys;
if (!installtex(2,
[_userDataIRI IRIByAppendingPathComponent:@"data/newchars.png"],
&xs, &ys, false) ||
!installtex(3,
[_userDataIRI
IRIByAppendingPathComponent:@"data/martin/base.png"],
&xs, &ys, false) ||
!installtex(6,
[_userDataIRI
IRIByAppendingPathComponent:@"data/martin/ball1.png"],
&xs, &ys, false) ||
!installtex(7,
[_userDataIRI
IRIByAppendingPathComponent:@"data/martin/smoke.png"],
&xs, &ys, false) ||
!installtex(8,
[_userDataIRI
IRIByAppendingPathComponent:@"data/martin/ball2.png"],
&xs, &ys, false) ||
!installtex(9,
[_userDataIRI
IRIByAppendingPathComponent:@"data/martin/ball3.png"],
&xs, &ys, false) ||
!installtex(4,
[_userDataIRI
IRIByAppendingPathComponent:@"data/explosion.jpg"],
&xs, &ys, false) ||
!installtex(5,
[_userDataIRI IRIByAppendingPathComponent:@"data/items.png"],
&xs, &ys, false) ||
!installtex(1,
[_userDataIRI
IRIByAppendingPathComponent:@"data/crosshair.png"],
&xs, &ys, false))
fatal(@"could not find core textures (hint: run cube from the "
@"parent of the bin directory)");
log("sound");
initsound();
log("cfg");
|
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
memcpy(dest,
(char *)image->pixels +
3 * _width * (_height - 1 - idx),
3 * _width);
endianswap(dest, 3, _width);
}
sprintf_sd(buf)(
"screenshots/screenshot_%d.bmp", lastmillis);
SDL_SaveBMP(temp, path(buf));
SDL_FreeSurface(temp);
}
SDL_FreeSurface(image);
}
}
|
>
>
|
|
>
|
>
>
>
>
|
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
|
memcpy(dest,
(char *)image->pixels +
3 * _width * (_height - 1 - idx),
3 * _width);
endianswap(dest, 3, _width);
}
@autoreleasepool {
OFString *path = [OFString
stringWithFormat:
@"screenshots/screenshot_%d.bmp",
lastmillis];
SDL_SaveBMP(temp,
[_userDataIRI
IRIByAppendingPathComponent:path]
.fileSystemRepresentation.UTF8String);
}
SDL_FreeSurface(temp);
}
SDL_FreeSurface(image);
}
}
|