Minor style corrections
This commit is contained in:
parent
f620334510
commit
6d939729a3
|
@ -365,9 +365,12 @@ void delayFrame()
|
||||||
|
|
||||||
// Add 16 2/3 to frameLimit
|
// Add 16 2/3 to frameLimit
|
||||||
frameLimit += 16;
|
frameLimit += 16;
|
||||||
if(thirds >= 2) {
|
if (thirds >= 2)
|
||||||
|
{
|
||||||
thirds = 0;
|
thirds = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
thirds++;
|
thirds++;
|
||||||
frameLimit++;
|
frameLimit++;
|
||||||
}
|
}
|
||||||
|
@ -388,7 +391,8 @@ void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
|
||||||
/* Here p is the address to the pixel we want to set */
|
/* Here p is the address to the pixel we want to set */
|
||||||
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
|
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
|
||||||
|
|
||||||
switch(bpp) {
|
switch(bpp)
|
||||||
|
{
|
||||||
case 1:
|
case 1:
|
||||||
*p = pixel;
|
*p = pixel;
|
||||||
break;
|
break;
|
||||||
|
@ -398,11 +402,14 @@ void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
|
if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||||
|
{
|
||||||
p[0] = (pixel >> 16) & 0xff;
|
p[0] = (pixel >> 16) & 0xff;
|
||||||
p[1] = (pixel >> 8) & 0xff;
|
p[1] = (pixel >> 8) & 0xff;
|
||||||
p[2] = pixel & 0xff;
|
p[2] = pixel & 0xff;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
p[0] = pixel & 0xff;
|
p[0] = pixel & 0xff;
|
||||||
p[1] = (pixel >> 8) & 0xff;
|
p[1] = (pixel >> 8) & 0xff;
|
||||||
p[2] = (pixel >> 16) & 0xff;
|
p[2] = (pixel >> 16) & 0xff;
|
||||||
|
@ -419,8 +426,10 @@ void drawLine(SDL_Surface *dest, int x1, int y1, int x2, int y2, int col)
|
||||||
{
|
{
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|
||||||
if ( SDL_MUSTLOCK(dest) ) {
|
if ( SDL_MUSTLOCK(dest) )
|
||||||
if ( SDL_LockSurface(dest) < 0 ) {
|
{
|
||||||
|
if ( SDL_LockSurface(dest) < 0 )
|
||||||
|
{
|
||||||
printf("Can't lock screen: %s\n", SDL_GetError());
|
printf("Can't lock screen: %s\n", SDL_GetError());
|
||||||
showErrorAndExit(2, "");
|
showErrorAndExit(2, "");
|
||||||
}
|
}
|
||||||
|
@ -442,7 +451,8 @@ void drawLine(SDL_Surface *dest, int x1, int y1, int x2, int y2, int col)
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( SDL_MUSTLOCK(dest) ) {
|
if (SDL_MUSTLOCK(dest))
|
||||||
|
{
|
||||||
SDL_UnlockSurface(dest);
|
SDL_UnlockSurface(dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -459,22 +469,22 @@ mailing list... I didn't write it myself.
|
||||||
void circle(int xc, int yc, int R, SDL_Surface *PIX, int col)
|
void circle(int xc, int yc, int R, SDL_Surface *PIX, int col)
|
||||||
{
|
{
|
||||||
int x = 0, xx = 0;
|
int x = 0, xx = 0;
|
||||||
int y = R, yy = R+R;
|
int y = R, yy = 2 * R;
|
||||||
int p = 1-R;
|
int p = 1 - R;
|
||||||
|
|
||||||
putpixel(PIX, xc, yc - y, col);
|
putpixel(PIX, xc, yc - y, col);
|
||||||
putpixel(PIX, xc, yc + y, col);
|
putpixel(PIX, xc, yc + y, col);
|
||||||
putpixel(PIX, xc - y, yc, col);
|
putpixel(PIX, xc - y, yc, col);
|
||||||
putpixel(PIX, xc + y, yc, col);
|
putpixel(PIX, xc + y, yc, col);
|
||||||
|
|
||||||
while(x < y)
|
while (x < y)
|
||||||
{
|
{
|
||||||
xx += 2;
|
xx += 2;
|
||||||
++x;
|
x++;
|
||||||
if (p >= 0)
|
if (p >= 0)
|
||||||
{
|
{
|
||||||
yy -= 2;
|
yy -= 2;
|
||||||
--y;
|
y--;
|
||||||
p -= yy;
|
p -= yy;
|
||||||
}
|
}
|
||||||
p += xx + 1;
|
p += xx + 1;
|
||||||
|
|
|
@ -75,7 +75,8 @@ void loadGameGraphics()
|
||||||
{
|
{
|
||||||
if (shipShape[i - SHIP_HIT_INDEX] == NULL)
|
if (shipShape[i - SHIP_HIT_INDEX] == NULL)
|
||||||
continue;
|
continue;
|
||||||
shipShape[i] = createSurface(shipShape[i - SHIP_HIT_INDEX]->w, shipShape[i- SHIP_HIT_INDEX]->h);
|
shipShape[i] = createSurface(shipShape[i - SHIP_HIT_INDEX]->w,
|
||||||
|
shipShape[i- SHIP_HIT_INDEX]->h);
|
||||||
blit(shipShape[i - SHIP_HIT_INDEX], 0, 0, shipShape[i]);
|
blit(shipShape[i - SHIP_HIT_INDEX], 0, 0, shipShape[i]);
|
||||||
|
|
||||||
switch(shipShape[i]->format->BytesPerPixel) {
|
switch(shipShape[i]->format->BytesPerPixel) {
|
||||||
|
|
Loading…
Reference in New Issue