-Anagramarama 0.1
-(c) 2003 Colm Gallagher - under the terms of the GPL - see gpl.txt for details.
+Anagramarama 0.2
+(c) 2003-2007 Colm Gallagher - under the terms of the GPL - see gpl.txt for details.
Version 0.1 - still needs a high score table and some
informational messages, but you can play a game.
+Version 0.2 - Added keyboard support and the scrabble wordlist
-Need to do a major code clean up too and document some stuff...
-
-I'll get round to it for the v1 release
-
-in the meantime have fun and let me know if you find any problems
-
+Version 0.3 - Added internationalisation, portuguese is the first available
+ language, many more to follow!
--
colm@coralquest.com
0.5 Colm Added keyboard input
+
+0.6 Paulo Added i18n and Portugues dict
+
+
***********************************************************/
#include <stdio.h>
//module level variables for game control
char shuffle[] = "£££££££";
char answer[] = "£££££££";
-
+char language[10];
+char txt[50];
char* rootWord;
int updateAnswers = 0;
int startNewGame = 0;
int done = 0;
filelocation = rand()%10000;
- wordlist=fopen("wordlist.txt","r");
+
+ strcpy(txt,language);
+ wordlist=fopen(strcat(txt,"wordlist.txt"),"r");
for (i=0;i<=filelocation;i++){
else{
// go back to the start of the file
fclose(wordlist);
- fopen("wordlist.txt", "r");
+ strcpy(txt,language);
+ fopen(strcat(txt,"wordlist.txt"), "r");
}
}
else{
// go back to the start of the file
fclose(wordlist);
- fopen("wordlist.txt", "r");
+ strcpy(txt,language);
+ fopen(strcat(txt,"wordlist.txt"), "r");
fscanf(wordlist, "%s", wordFromList);
}
}
int i;
// show background
- ShowBMP("images/background.bmp",screen, 0,0);
+ strcpy(txt,language);
+ ShowBMP(strcat(txt,"images/background.bmp"),screen, 0,0);
destroyLetters(&(*letters));
// main game loop
while (!done){
-
if(winGame){
stopTheClock = 1;
struct dlb_node* dlbHead = NULL;
SDL_Surface *screen;
struct sprite* letters = NULL;
-//pthread_t audio;
+//pthread_t audio;
+ strcpy(language,"i18n/");
+
+ if(argc == 2) {
+ strcat(language,argv[1]);
+ }
+ else {
+ char * language2 = getenv("LANG");
+
+ if(language2 == 0){
+ strcpy(language,"i18n/en_GB/");
+ }
+ else {
+ char local[10];
+ int len = strlen(language2);
+ int i = 0;
+
+ while((language2[i] != '.')&&(i< len)){
+ local[i] = language2[i];
+ i++;
+ }
+ local[i] = '\0';
+
+ strcat(language,local);
+ }
+ }
+ strcat(language,"/");
+
+ strcpy(txt,language);
+ strcat(txt,"wordlist.txt");
+ FILE* wordlist;
+ wordlist = fopen(txt,"r");
+ //if(wordlist == 0){
+ // strcpy(language,"i18n/en_GB/");
+ //}
+ //else {
+ // fclose(wordlist);
+ //}
+
// seed the random generator
srand(time(NULL));
bufferSounds(&soundCache);
// create dictionary
- createDLBTree(&dlbHead);
+ createDLBTree(&dlbHead,language);
+
+
// cache in-game graphics
- letterBank = SDL_LoadBMP("images/letterBank.bmp");
- smallLetterBank = SDL_LoadBMP("images/smallLetterBank.bmp");
- numberBank = SDL_LoadBMP("images/numberBank.bmp");
+ strcpy(txt,language);
+ letterBank = SDL_LoadBMP(strcat(txt,"images/letterBank.bmp"));
+ strcpy(txt,language);
+ smallLetterBank = SDL_LoadBMP(strcat(txt,"images/smallLetterBank.bmp"));
+ strcpy(txt,language);
+ numberBank = SDL_LoadBMP(strcat(txt,"images/numberBank.bmp"));
rootWord = malloc(sizeof(char)*9);
newGame(&head, dlbHead, screen, &letters);
}
/***************************************************************/
-void createDLBTree(struct dlb_node** dlbHead){
+void createDLBTree(struct dlb_node** dlbHead,char* language){
// open the wordlist file and push all words onto the dictionary
FILE* wordlist;
char wordFromList[50];
//printf("createDLBTree\n");
-
+
// open wordlist file
- wordlist = fopen("wordlist.txt", "r");
+ char txt[50];
+ strcpy(txt,language);
+ wordlist = fopen(strcat(txt,"wordlist.txt"), "r");
// get each word from the list
while (fscanf(wordlist, "%s", wordFromList) != EOF){