[Tux4kids-commits] r1379 - branches/commonification/tuxtype/trunk/src
Bolesław Kulbabiński
bolekk-guest at alioth.debian.org
Wed Aug 5 21:09:29 UTC 2009
Author: bolekk-guest
Date: 2009-08-05 21:09:29 +0000 (Wed, 05 Aug 2009)
New Revision: 1379
Modified:
branches/commonification/tuxtype/trunk/src/SDL_extras.c
branches/commonification/tuxtype/trunk/src/SDL_extras.h
branches/commonification/tuxtype/trunk/src/audio.c
branches/commonification/tuxtype/trunk/src/funcs.h
branches/commonification/tuxtype/trunk/src/globals.h
branches/commonification/tuxtype/trunk/src/main.c
branches/commonification/tuxtype/trunk/src/menu.c
branches/commonification/tuxtype/trunk/src/playgame.c
branches/commonification/tuxtype/trunk/src/playgame.h
branches/commonification/tuxtype/trunk/src/setup.c
branches/commonification/tuxtype/trunk/src/titlescreen.c
Log:
TuxType almost working with t4kcommon
Modified: branches/commonification/tuxtype/trunk/src/SDL_extras.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/SDL_extras.c 2009-08-05 20:28:10 UTC (rev 1378)
+++ branches/commonification/tuxtype/trunk/src/SDL_extras.c 2009-08-05 21:09:29 UTC (rev 1379)
@@ -30,8 +30,23 @@
#ifndef HAVE_LIBT4KCOMMON
-SDL_Surface* screen;
+SDL_Surface* screen = NULL;
+/* window size */
+int win_res_x = 640;
+int win_res_y = 480;
+
+/* full screen size (set in initialize_SDL() ) */
+int fs_res_x = 0;
+int fs_res_y = 0;
+
+char* font_name;
+
+void SetFontName(char* fname)
+{
+ font_name = fname;
+}
+
/*
Return a pointer to the screen we're using, as an alternative to making screen
global. Not sure what is involved performance-wise in SDL_GetVideoSurface,
@@ -88,39 +103,10 @@
RoundCorners(tmp_surf, radius);
return tmp_surf;
}
-/* free every surface in the array together with the array itself */
-void FreeSurfaceArray(SDL_Surface** surfs, int length)
-{
- int i;
- if(surfs == NULL)
- return;
-
- for(i = 0; i < length; i++)
- if(surfs[i] != NULL)
- SDL_FreeSurface(surfs[i]);
- free(surfs);
-}
-
-void UpdateRect(SDL_Surface* surf, SDL_Rect* rect)
-{
- SDL_UpdateRect(surf, rect->x, rect->y, rect->w, rect->h);
-}
-
-void SetRect(SDL_Rect* rect, const float* pos)
-{
- rect->x = pos[0] * screen->w;
- rect->y = pos[1] * screen->h;
- rect->w = pos[2] * screen->w;
- rect->h = pos[3] * screen->h;
-}
-
-#endif
-
-
void RoundCorners(SDL_Surface* s, Uint16 radius)
{
- int y = 0;
+ int y = 0;
int x_dist, y_dist;
Uint32* p = NULL;
Uint32 alpha_mask;
@@ -215,7 +201,6 @@
SDL_UnlockSurface(s);
}
-
/**********************
Flip:
input: a SDL_Surface, x, y
@@ -322,7 +307,7 @@
Currently this works only with RGBA images, but this is largely to
make the (fast) pointer arithmetic work out; it could be easily
generalized to other image types. */
-SDL_Surface* Blend(SDL_Surface* S1, SDL_Surface* S2, float gamma)
+SDL_Surface* Blend(SDL_Surface *S1, SDL_Surface *S2, float gamma)
{
SDL_PixelFormat *fmt1, *fmt2;
Uint8 r1, r2, g1, g2, b1, b2, a1, a2;
@@ -426,33 +411,55 @@
}
+/* free every surface in the array together with the array itself */
+void FreeSurfaceArray(SDL_Surface** surfs, int length)
+{
+ int i;
+ if(surfs == NULL)
+ return;
-int inRect( SDL_Rect r, int x, int y)
+ for(i = 0; i < length; i++)
+ if(surfs[i] != NULL)
+ SDL_FreeSurface(surfs[i]);
+ free(surfs);
+}
+
+int inRect( SDL_Rect r, int x, int y) {
+ if ((x < r.x) || (y < r.y) || (x > r.x + r.w) || (y > r.y + r.h))
+ return 0;
+ return 1;
+}
+
+void UpdateRect(SDL_Surface* surf, SDL_Rect* rect)
{
- if ((x < r.x)
- || (y < r.y)
- || (x > r.x + r.w)
- || (y > r.y + r.h))
- return 0;
- return 1;
+ SDL_UpdateRect(surf, rect->x, rect->y, rect->w, rect->h);
}
+void SetRect(SDL_Rect* rect, const float* pos)
+{
+ rect->x = pos[0] * screen->w;
+ rect->y = pos[1] * screen->h;
+ rect->w = pos[2] * screen->w;
+ rect->h = pos[3] * screen->h;
+}
/* Darkens the screen by a factor of 2^bits */
void DarkenScreen(Uint8 bits)
{
-#if BPP == 32
+#if PIXEL_BITS == 32
Uint32* p;
-#elif BPP == 16
+#elif PIXEL_BITS == 16
Uint16* p;
#else
+ Uint16* p;
return;
#endif
-
Uint32 rm = screen->format->Rmask;
Uint32 gm = screen->format->Gmask;
Uint32 bm = screen->format->Bmask;
+
+
int x, y;
/* (realistically, 1 and 2 are the only useful values) */
@@ -473,28 +480,49 @@
}
}
-
-void SwitchScreenMode(void)
+/* change window size (works only in windowed mode) */
+void ChangeWindowSize(int new_res_x, int new_res_y)
{
- int window = (screen->flags & SDL_FULLSCREEN);
SDL_Surface* oldscreen = screen;
- if (!window)
+ if(!(screen->flags & SDL_FULLSCREEN))
{
- screen = SDL_SetVideoMode(fs_res_x,
- fs_res_y,
- BPP,
- SDL_SWSURFACE|SDL_HWPALETTE|SDL_FULLSCREEN);
- }
- else
- {
- screen = SDL_SetVideoMode(RES_X,
- RES_Y,
- BPP,
+ screen = SDL_SetVideoMode(new_res_x,
+ new_res_y,
+ PIXEL_BITS,
SDL_SWSURFACE|SDL_HWPALETTE);
+ if(screen == NULL)
+ {
+ fprintf(stderr,
+ "\nError: I could not change screen mode into %d x %d.\n",
+ new_res_x, new_res_y);
+ screen = oldscreen;
+ }
+ else
+ {
+ DEBUGMSG(debug_sdl, "ChangeWindowSize(): Changed window size to %d x %d\n", screen->w, screen->h);
+ oldscreen = NULL;
+ win_res_x = screen->w;
+ win_res_y = screen->h;
+ SDL_UpdateRect(screen, 0, 0, 0, 0);
+ }
}
+ else
+ DEBUGMSG(debug_sdl, "ChangeWindowSize() can be run only in windowed mode !");
+}
+/* switch between fullscreen and windowed mode */
+void SwitchScreenMode(void)
+{
+ int window = (screen->flags & SDL_FULLSCREEN);
+ SDL_Surface* oldscreen = screen;
+
+ screen = SDL_SetVideoMode(window ? win_res_x : fs_res_x,
+ window ? win_res_y : fs_res_y,
+ PIXEL_BITS,
+ screen->flags ^ SDL_FULLSCREEN);
+
if (screen == NULL)
{
fprintf(stderr,
@@ -507,22 +535,31 @@
}
else
{
- SDL_FreeSurface(oldscreen);
+ //success, no need to free the old video surface
+ DEBUGMSG(debug_sdl, "Switched screen mode to %s\n", window ? "windowed" : "fullscreen");
oldscreen = NULL;
SDL_UpdateRect(screen, 0, 0, 0, 0);
}
-
}
-
-int WaitForKeypress(void)
+/*
+Block application until SDL receives an appropriate event. Events can be
+a single or OR'd combination of event masks.
+e.g. e = WaitForEvent(SDL_KEYDOWNMASK | SDL_QUITMASK)
+*/
+SDL_EventType WaitForEvent(SDL_EventMask events)
{
SDL_Event evt;
while (1)
+ {
while (SDL_PollEvent(&evt) )
- if (evt.type == SDL_KEYDOWN)
- return evt.key.keysym.sym;
- else SDL_Delay(50);
+ {
+ if (SDL_EVENTMASK(evt.type) & events)
+ return evt.type;
+ else
+ SDL_Delay(50);
+ }
+ }
}
/* Swiped shamelessly from TuxPaint
Based on code from: http://www.codeproject.com/cs/media/imageprocessing4.asp
@@ -551,6 +588,8 @@
Uint8 r4, g4, b4, a4;
Uint8 r, g, b, a;
+ DEBUGMSG(debug_sdl, "Entering zoom():\n");
+
/* Create surface for zoom: */
s = SDL_CreateRGBSurface(src->flags, /* SDL_SWSURFACE, */
@@ -570,6 +609,10 @@
// exit(1);
}
+ DEBUGMSG(debug_sdl, "zoom(): orig surface %dx%d, %d bytes per pixel\n",
+ src->w, src->h, src->format->BytesPerPixel);
+ DEBUGMSG(debug_sdl, "zoom(): new surface %dx%d, %d bytes per pixel\n",
+ s->w, s->h, s->format->BytesPerPixel);
/* Now assign function pointers to correct functions based */
/* on data format of original and zoomed surfaces: */
@@ -643,11 +686,11 @@
SDL_UnlockSurface(s);
SDL_UnlockSurface(src);
+ DEBUGMSG(debug_sdl, "Leaving zoom():\n");
+
return s;
}
-
-
/*************************************************/
/* TransWipe: Performs various wipes to new bkgs */
/*************************************************/
@@ -664,8 +707,6 @@
SDL_Rect src;
SDL_Rect dst;
- LOG("->TransWipe(): START\n");
-
/* Input validation: ----------------------- */
if (!newbkg)
{
@@ -700,7 +741,6 @@
{
case WIPE_BLINDS_VERT:
{
- LOG("--+ Doing 'WIPE_BLINDS_VERT'\n");
step1 = screen->w/segments;
step2 = step1/duration;
@@ -719,8 +759,8 @@
dst.y = 0;
dst.w = step2;
dst.h = screen->h;
- SDL_BlitSurface(newbkg, &src, screen, &src);
- SDL_BlitSurface(newbkg, &dst, screen, &dst);
+ SDL_BlitSurface((SDL_Surface*)newbkg, &src, screen, &src);
+ SDL_BlitSurface((SDL_Surface*)newbkg, &dst, screen, &dst);
AddRect(&src, &src);
AddRect(&dst, &dst);
}
@@ -731,7 +771,7 @@
src.y = 0;
src.w = screen->w;
src.h = screen->h;
- SDL_BlitSurface(newbkg, NULL, screen, &src);
+ SDL_BlitSurface((SDL_Surface*)newbkg, NULL, screen, &src);
SDL_Flip(screen);
break;
@@ -739,7 +779,6 @@
case WIPE_BLINDS_HORIZ:
{
- LOG("--+ Doing 'WIPE_BLINDS_HORIZ'\n");
step1 = screen->h / segments;
step2 = step1 / duration;
@@ -758,8 +797,8 @@
dst.y = y2;
dst.w = screen->w;
dst.h = step2;
- SDL_BlitSurface(newbkg, &src, screen, &src);
- SDL_BlitSurface(newbkg, &dst, screen, &dst);
+ SDL_BlitSurface((SDL_Surface*)newbkg, &src, screen, &src);
+ SDL_BlitSurface((SDL_Surface*)newbkg, &dst, screen, &dst);
AddRect(&src, &src);
AddRect(&dst, &dst);
}
@@ -770,7 +809,7 @@
src.y = 0;
src.w = screen->w;
src.h = screen->h;
- SDL_BlitSurface(newbkg, NULL, screen, &src);
+ SDL_BlitSurface((SDL_Surface*)newbkg, NULL, screen, &src);
SDL_Flip(screen);
break;
@@ -778,7 +817,6 @@
case WIPE_BLINDS_BOX:
{
- LOG("--+ Doing 'WIPE_BLINDS_BOX'\n");
step1 = screen->w/segments;
step2 = step1/duration;
@@ -799,8 +837,8 @@
dst.y = 0;
dst.w = step2;
dst.h = screen->h;
- SDL_BlitSurface(newbkg, &src, screen, &src);
- SDL_BlitSurface(newbkg, &dst, screen, &dst);
+ SDL_BlitSurface((SDL_Surface*)newbkg, &src, screen, &src);
+ SDL_BlitSurface((SDL_Surface*)newbkg, &dst, screen, &dst);
AddRect(&src, &src);
AddRect(&dst, &dst);
y1 = step3 * (j - 0.5) - i * step4 + 1;
@@ -813,8 +851,8 @@
dst.y = y2;
dst.w = screen->w;
dst.h = step4;
- SDL_BlitSurface(newbkg, &src, screen, &src);
- SDL_BlitSurface(newbkg, &dst, screen, &dst);
+ SDL_BlitSurface((SDL_Surface*)newbkg, &src, screen, &src);
+ SDL_BlitSurface((SDL_Surface*)newbkg, &dst, screen, &dst);
AddRect(&src, &src);
AddRect(&dst, &dst);
}
@@ -825,7 +863,7 @@
src.y = 0;
src.w = screen->w;
src.h = screen->h;
- SDL_BlitSurface(newbkg, NULL, screen, &src);
+ SDL_BlitSurface((SDL_Surface*)newbkg, NULL, screen, &src);
SDL_Flip(screen);
break;
@@ -948,19 +986,12 @@
int DrawSprite(sprite* gfx, int x, int y)
{
- LOG("Entering DrawSprite()\n");
-
if (!gfx || !gfx->frame[gfx->cur])
{
fprintf(stderr, "DrawSprite() - 'gfx' arg invalid!\n");
- LOG("Leaving DrawSprite()\n");
return 0;
}
-
- LOG("Leaving DrawSprite()\n");
-
return DrawObject(gfx->frame[gfx->cur], x, y);
-
}
@@ -973,16 +1004,12 @@
{
struct blit *update;
- LOG("Entering DrawObject()\n");
-
if (!surf)
{
fprintf(stderr, "DrawObject() - invalid 'surf' arg!\n");
return 0;
}
- DOUT(numupdates);
-
if(numupdates >= MAX_UPDATES)
{
fprintf(stderr, "Warning - MAX_UPDATES exceeded, cannot add blit to queue\n");
@@ -1008,8 +1035,6 @@
update->dstrect->h = surf->h;
update->type = 'D';
- LOG("Leaving DrawObject()\n");
-
return 1;
}
@@ -1022,9 +1047,6 @@
{
int i;
- LOG("Entering UpdateScreen()\n");
- DOUT(numupdates);
-
/* -- First erase everything we need to -- */
for (i = 0; i < numupdates; i++)
{
@@ -1043,8 +1065,6 @@
}
}
- LOG("Done erasing\n");
-
// SNOW_erase();
/* -- then draw -- */
@@ -1065,8 +1085,6 @@
}
}
- LOG("Done drawing\n");
-
// SNOW_draw();
/* -- update the screen only where we need to! -- */
@@ -1077,32 +1095,22 @@
numupdates = 0;
*frame = *frame + 1;
-
- LOG("Leaving UpdateScreen()\n");
}
/* basically puts in an order to overdraw sprite with corresponding */
/* rect of bkgd img */
-int EraseSprite(sprite* img, int x, int y)
+int EraseSprite(sprite* img, SDL_Surface* curr_bkgd, int x, int y)
{
-// struct blit* update;
-
- LOG("Entering EraseSprite()\n");
-
if( !img
|| img->cur < 0
|| img->cur > MAX_SPRITE_FRAMES
|| !img->frame[img->cur])
{
fprintf(stderr, "EraseSprite() - invalid 'img' arg!\n");
- LOG("Leaving EraseSprite()\n");
return 0;
}
-
- LOG("Leaving EraseSprite()\n");
-
- return EraseObject(img->frame[img->cur], x, y);
+ return EraseObject(img->frame[img->cur], curr_bkgd, x, y);
}
@@ -1110,12 +1118,10 @@
/*************************
EraseObject : Erase an object from the screen
**************************/
-int EraseObject(SDL_Surface* surf, int x, int y)
+int EraseObject(SDL_Surface* surf, SDL_Surface* curr_bkgd, int x, int y)
{
struct blit* update = NULL;
- LOG("Entering EraseObject()\n");
-
if(!surf)
{
fprintf(stderr, "EraseObject() - invalid 'surf' arg!\n");
@@ -1136,7 +1142,7 @@
return 0;
}
- update->src = CurrentBkgd();
+ update->src = curr_bkgd;
/* take dimentsions from src surface: */
update->srcrect->x = x;
@@ -1166,10 +1172,10 @@
update->srcrect->y = 0;
}
- if (update->srcrect->x + update->srcrect->w > CurrentBkgd()->w)
- update->srcrect->w = CurrentBkgd()->w - update->srcrect->x;
- if (update->srcrect->y + update->srcrect->h > CurrentBkgd()->h)
- update->srcrect->h = CurrentBkgd()->h - update->srcrect->y;
+ if (update->srcrect->x + update->srcrect->w > curr_bkgd->w)
+ update->srcrect->w = curr_bkgd->w - update->srcrect->x;
+ if (update->srcrect->y + update->srcrect->h > curr_bkgd->h)
+ update->srcrect->h = curr_bkgd->h - update->srcrect->y;
update->dstrect->x = update->srcrect->x;
@@ -1178,15 +1184,11 @@
update->dstrect->h = update->srcrect->h;
update->type = 'E';
- LOG("Leaving EraseObject()\n");
-
return 1;
}
+#endif // HAVE_LIBT4KCOMMON
-
-
-
/************************************************************************/
/* */
/* Begin text drawing functions */
Modified: branches/commonification/tuxtype/trunk/src/SDL_extras.h
===================================================================
--- branches/commonification/tuxtype/trunk/src/SDL_extras.h 2009-08-05 20:28:10 UTC (rev 1378)
+++ branches/commonification/tuxtype/trunk/src/SDL_extras.h 2009-08-05 21:09:29 UTC (rev 1379)
@@ -19,8 +19,9 @@
#include "SDL.h"
#ifdef HAVE_LIBT4KCOMMON
-//#include <t4kcommon/tux4kids-common.h>
+#include <t4kcommon/tux4kids-common.h>
#else
+
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
#define rmask 0xff000000
#define gmask 0x00ff0000
@@ -32,26 +33,19 @@
#define bmask 0x00ff0000
#define amask 0xff000000
#endif
-#endif
-/* the colors we use throughout the game */
-static const SDL_Color black = {0x00, 0x00, 0x00, 0x00};
-static const SDL_Color gray = {0x80, 0x80, 0x80, 0x00};
-static const SDL_Color dark_blue = {0x00, 0x00, 0x60, 0x00};
-static const SDL_Color red = {0xff, 0x00, 0x00, 0x00};
-static const SDL_Color white = {0xff, 0xff, 0xff, 0x00};
-static const SDL_Color yellow = {0xff, 0xff, 0x00, 0x00};
-
-
-
-/* FIXME get rid of these 'evil' macros */
-#define NEXT_FRAME(SPRITE) if ((SPRITE)->num_frames) (SPRITE)->cur = (((SPRITE)->cur)+1) % (SPRITE)->num_frames;
-#define REWIND(SPRITE) (SPRITE)->cur = 0;
-#define MAX_SPRITE_FRAMES 30
//extra bkgd border around "erased" images.
#define ERASE_MARGIN 5
+#define PIXEL_BITS 32
+enum
+{
+ WIPE_BLINDS_VERT,
+ WIPE_BLINDS_HORIZ,
+ WIPE_BLINDS_BOX,
+ RANDOM_WIPE,
+ NUM_WIPES;
+}
-
typedef struct {
SDL_Surface* frame[MAX_SPRITE_FRAMES];
SDL_Surface* default_img;
@@ -60,7 +54,6 @@
} sprite;
-#ifndef HAVE_LIBT4KCOMMON
/* "Public" function prototypes: */
SDL_Surface* GetScreen();
void DrawButton(SDL_Rect* target_rect,
@@ -73,7 +66,6 @@
SDL_Surface* CreateButton(int w, int h, int radius,
Uint8 r, Uint8 g, Uint8 b, Uint8 a);
-#endif
void RoundCorners(SDL_Surface* s, Uint16 radius);
SDL_Surface* Flip(SDL_Surface *in, int x, int y);
int inRect(SDL_Rect r, int x, int y);
@@ -90,10 +82,27 @@
int AddRect(SDL_Rect* src, SDL_Rect* dst);
int DrawObject(SDL_Surface* surf, int x, int y);
int DrawSprite(sprite* gfx, int x, int y);
-int EraseObject(SDL_Surface* surf, int x, int y);
-int EraseSprite(sprite* img, int x, int y);
+int EraseObject(SDL_Surface* surf, SDL_Surface* curr_bkgd, int x, int y);
+int EraseSprite(sprite* img, SDL_Surface* curr_bkgd, int x, int y);
void UpdateScreen(int* frame);
+#endif
+
+/* the colors we use throughout the game */
+static const SDL_Color black = {0x00, 0x00, 0x00, 0x00};
+static const SDL_Color gray = {0x80, 0x80, 0x80, 0x00};
+static const SDL_Color dark_blue = {0x00, 0x00, 0x60, 0x00};
+static const SDL_Color red = {0xff, 0x00, 0x00, 0x00};
+static const SDL_Color white = {0xff, 0xff, 0xff, 0x00};
+static const SDL_Color yellow = {0xff, 0xff, 0x00, 0x00};
+
+
+
+/* FIXME get rid of these 'evil' macros */
+#define NEXT_FRAME(SPRITE) if ((SPRITE)->num_frames) (SPRITE)->cur = (((SPRITE)->cur)+1) % (SPRITE)->num_frames;
+#define REWIND(SPRITE) (SPRITE)->cur = 0;
+#define MAX_SPRITE_FRAMES 30
+
/*Text rendering functions: */
int Setup_SDL_Text(void);
void Cleanup_SDL_Text(void);
Modified: branches/commonification/tuxtype/trunk/src/audio.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/audio.c 2009-08-05 20:28:10 UTC (rev 1378)
+++ branches/commonification/tuxtype/trunk/src/audio.c 2009-08-05 21:09:29 UTC (rev 1379)
@@ -16,10 +16,10 @@
* *
***************************************************************************/
-#ifndef HAVE_LIBT4KCOMMON
#include "globals.h"
#include "funcs.h"
+#ifndef HAVE_LIBT4KCOMMON
static Mix_Music* defaultMusic = NULL; // holds music for audioMusicLoad/unload
@@ -71,6 +71,7 @@
return (defaultMusic != NULL);
}
+#endif //HAVE_LIBT4KCOMMON
/* audioMusicPlay attempts to play the passed music data.
* if a music file was loaded using the audioMusicLoad
@@ -86,4 +87,3 @@
AudioMusicUnload();
Mix_PlayMusic(musicData, loops);
}
-#endif //HAVE_LIBT4KCOMMON
Modified: branches/commonification/tuxtype/trunk/src/funcs.h
===================================================================
--- branches/commonification/tuxtype/trunk/src/funcs.h 2009-08-05 20:28:10 UTC (rev 1378)
+++ branches/commonification/tuxtype/trunk/src/funcs.h 2009-08-05 21:09:29 UTC (rev 1379)
@@ -81,12 +81,12 @@
Mix_Chunk* LoadSoundNoPrefix( char *datafile);
Mix_Music* LoadMusicNoPrefix(char *datafile);
-#ifndef HAVE_LIBT4KCOMMON
int LoadBothBkgds(const char* datafile);
SDL_Surface* CurrentBkgd(void);
void FreeBothBkgds(void);
void LoadLang(void);
+#ifndef HAVE_LIBT4KCOMMON
int CheckFile(const char* file);
SDL_Surface* LoadImage(const char* file_name, int mode);
SDL_Surface* LoadScaledImage(const char* file_name, int mode, int width, int height);
Modified: branches/commonification/tuxtype/trunk/src/globals.h
===================================================================
--- branches/commonification/tuxtype/trunk/src/globals.h 2009-08-05 20:28:10 UTC (rev 1378)
+++ branches/commonification/tuxtype/trunk/src/globals.h 2009-08-05 21:09:29 UTC (rev 1379)
@@ -20,6 +20,10 @@
#include "config.h"
+#ifdef HAVE_LIBT4KCOMMON
+#include <t4kcommon/tux4kids-common.h>
+#endif
+
/* debug data (declared in options.c) */
extern int debug_status;
@@ -54,11 +58,10 @@
#define DEBUGCODE(mask) if((mask) & debug_status)
#define DEBUGMSG(mask, ...) if((mask) & debug_status){ fprintf(stderr, __VA_ARGS__); fflush(stderr); }
-#ifdef HAVE_LIBT4KCOMMON
-//#include <t4kcommon/tux4kids-common.h>
+#ifndef HAVE_LIBT4KCOMMON
+typedef enum { false, true } bool;
#endif
-typedef enum { false, true } bool;
// Translation stuff:
#include "gettext.h"
@@ -249,15 +252,5 @@
#define MUSIC_FADE_OUT_MS 80
-/* For TransWipe(): */
-enum
-{
- WIPE_BLINDS_VERT,
- WIPE_BLINDS_HORIZ,
- WIPE_BLINDS_BOX,
- RANDOM_WIPE,
- NUM_WIPES
-};
-
#endif
Modified: branches/commonification/tuxtype/trunk/src/main.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/main.c 2009-08-05 20:28:10 UTC (rev 1378)
+++ branches/commonification/tuxtype/trunk/src/main.c 2009-08-05 21:09:29 UTC (rev 1379)
@@ -20,6 +20,7 @@
#include "funcs.h"
#include "SDL_extras.h"
+
SDL_Event event;
/* global debug masks */
@@ -204,11 +205,11 @@
Uint32 lib_flags = 0;
int i;
- handle_command_args(argc, argv);
srand(time(NULL));
Opts_Initialize(); // First, initialize settings with hard-coded defaults
+ handle_command_args(argc, argv);
// This sets settings.default_data_path to the default theme file path:
SetupPaths(NULL);
LoadSettings(); // Second, read saved any saved settings
Modified: branches/commonification/tuxtype/trunk/src/menu.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/menu.c 2009-08-05 20:28:10 UTC (rev 1378)
+++ branches/commonification/tuxtype/trunk/src/menu.c 2009-08-05 21:09:29 UTC (rev 1379)
@@ -877,7 +877,7 @@
if(curr_node->icon_name)
{
- sprintf(filename, "%s/images/sprites/%s", data_prefix, curr_node->icon_name);
+ sprintf(filename, "%s/images/menu/%s", data_prefix, curr_node->icon_name);
DEBUGMSG(debug_menu, "prerender_menu(): loading sprite %s for item #%d.\n", filename, i);
curr_node->icon = LoadSpriteOfBoundingBox(filename, IMG_ALPHA, button_h, button_h);
}
Modified: branches/commonification/tuxtype/trunk/src/playgame.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/playgame.c 2009-08-05 20:28:10 UTC (rev 1378)
+++ branches/commonification/tuxtype/trunk/src/playgame.c 2009-08-05 21:09:29 UTC (rev 1379)
@@ -232,7 +232,7 @@
oldlives = curlives;
oldfish_left = fish_left;
- EraseSprite( tux_object.spr[tux_object.state][tux_object.facing], tux_object.x, tux_object.y );
+ EraseSprite( tux_object.spr[tux_object.state][tux_object.facing], CurrentBkgd(), tux_object.x, tux_object.y );
/* --- Poll input queue, get keyboard info --- */
while (SDL_PollEvent(&event))
@@ -496,8 +496,8 @@
/* Do all pending blits and increment frame counter: */
UpdateScreen(&frame);
- EraseSprite( tux_object.spr[tux_object.state][tux_object.facing], tux_object.x, tux_object.y );
- EraseObject(temp_text[temp_text_count], text_rect.x, y_not);
+ EraseSprite( tux_object.spr[tux_object.state][tux_object.facing], CurrentBkgd(), tux_object.x, tux_object.y );
+ EraseObject(temp_text[temp_text_count], CurrentBkgd(), text_rect.x, y_not);
if (!settings.speed_up)
WaitFrame();
@@ -687,7 +687,7 @@
if (m)
{
- EraseObject(m, x, y);
+ EraseObject(m,CurrentBkgd(), x, y);
DrawObject(m, x, y);
SDL_FreeSurface(m);
}
@@ -806,14 +806,14 @@
if (needed_places < FNLEN && needed_places <= places) {
if (places > 0) {
for (i = 1; i <= (places - needed_places); i++) {
- EraseObject(number[0], x, y);
+ EraseObject(number[0], CurrentBkgd(), x, y);
x += number[0]->w;
}
}
}
for (i = 0; i < needed_places; i++) {
uddernumber = numnuts[i] - '0';
- EraseObject(number[uddernumber], x, y);
+ EraseObject(number[uddernumber],CurrentBkgd(), x, y);
x += number[uddernumber]->w;
}
@@ -1264,7 +1264,7 @@
if (fish_object[i].alive)
{
for (j = 0; j < fish_object[i].len; j++)
- EraseSprite( fish_sprite, fish_object[i].x + (fish_sprite->frame[0]->w*j), fish_object[i].y );
+ EraseSprite( fish_sprite,CurrentBkgd(), fish_object[i].x + (fish_sprite->frame[0]->w*j), fish_object[i].y );
fish_object[i].y += fish_object[i].dy;
@@ -1287,7 +1287,7 @@
if (splat_object[i].alive>1)
DrawSprite( splat_sprite, splat_object[i].x, splat_object[i].y);
else
- EraseSprite( splat_sprite, splat_object[i].x, splat_object[i].y);
+ EraseSprite( splat_sprite, CurrentBkgd(), splat_object[i].x, splat_object[i].y);
}
LOG("Leaving MoveFishies()\n\n");
@@ -1357,7 +1357,7 @@
fish_object[i].can_eat = 0;
for (j = 0; j < fish_object[i].len; j++)
- EraseSprite(fish_sprite, (fish_object[i].x + (j * fish_sprite->frame[0]->w)), fish_object[i].y);
+ EraseSprite(fish_sprite, CurrentBkgd(), (fish_object[i].x + (j * fish_sprite->frame[0]->w)), fish_object[i].y);
*fish_left = *fish_left - 1;
@@ -1404,7 +1404,7 @@
LOG( "Entering MoveTux()\n" );
- EraseSprite( tux_object.spr[tux_object.state][tux_object.facing], tux_object.x, tux_object.y );
+ EraseSprite( tux_object.spr[tux_object.state][tux_object.facing], CurrentBkgd(), tux_object.x, tux_object.y );
if (tux_object.state != TUX_GULPING) {
for (i=0; i<fishies; i++)
Modified: branches/commonification/tuxtype/trunk/src/playgame.h
===================================================================
--- branches/commonification/tuxtype/trunk/src/playgame.h 2009-08-05 20:28:10 UTC (rev 1378)
+++ branches/commonification/tuxtype/trunk/src/playgame.h 2009-08-05 21:09:29 UTC (rev 1379)
@@ -111,12 +111,12 @@
};
static char* tux_sprite_fns[TUX_NUM_STATES] = {
- "tux/walk",
- "tux/stand",
- "tux/run",
- "tux/gulp",
- "tux/win",
- "tux/yipe"
+ "/images/tux/walk",
+ "/images/tux/stand",
+ "/images/tux/run",
+ "/images/tux/gulp",
+ "/images/tux/win",
+ "/images/tux/yipe"
};
#define RIGHT 0
Modified: branches/commonification/tuxtype/trunk/src/setup.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/setup.c 2009-08-05 20:28:10 UTC (rev 1378)
+++ branches/commonification/tuxtype/trunk/src/setup.c 2009-08-05 21:09:29 UTC (rev 1379)
@@ -22,9 +22,6 @@
#include "SDL_extras.h"
-int fs_res_x = 0;
-int fs_res_y = 0;
-
/* Local function prototypes: */
static void seticon(void);
static int load_settings_fp(FILE* fp);
Modified: branches/commonification/tuxtype/trunk/src/titlescreen.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/titlescreen.c 2009-08-05 20:28:10 UTC (rev 1378)
+++ branches/commonification/tuxtype/trunk/src/titlescreen.c 2009-08-05 21:09:29 UTC (rev 1379)
@@ -461,38 +461,44 @@
break;
case RUN_CASCADE:
- switch(param)
+ if(chooseWordlist())
{
- case 0:
- PlayCascade(EASY);
- break;
- case 1:
- PlayCascade(MEDIUM);
- break;
- case 2:
- PlayCascade(HARD);
- break;
- case 3:
- PlayCascade(INSANE);
- break;
+ switch(param)
+ {
+ case 0:
+ PlayCascade(EASY);
+ break;
+ case 1:
+ PlayCascade(MEDIUM);
+ break;
+ case 2:
+ PlayCascade(HARD);
+ break;
+ case 3:
+ PlayCascade(INSANE);
+ break;
+ }
}
break;
case RUN_COMET_ZAP:
- switch(param)
+ if(chooseWordlist())
{
- case 0:
- PlayLaserGame(EASY);
- break;
- case 1:
- PlayLaserGame(MEDIUM);
- break;
- case 2:
- PlayLaserGame(HARD);
- break;
- case 3:
- PlayLaserGame(INSANE);
- break;
+ switch(param)
+ {
+ case 0:
+ PlayLaserGame(EASY);
+ break;
+ case 1:
+ PlayLaserGame(MEDIUM);
+ break;
+ case 2:
+ PlayLaserGame(HARD);
+ break;
+ case 3:
+ PlayLaserGame(INSANE);
+ break;
+ }
}
break;
@@ -504,6 +510,9 @@
return QUIT;
}
+ FreeBothBkgds();
+ LoadBothBkgds(bkg_path);
+ SDL_ShowCursor(1);
return 0;
}
More information about the Tux4kids-commits
mailing list