0 Members and 1 Guest are viewing this topic.
char buf[20];sprintf(buf, "%i", thenumber);
The screen is 240x320.Use something like this to convert it to a string:char buf[20];sprintf(buf, "%i", thenumber);Then display the string with nRGBlib.
Also, is there a way to save high scores?
FILE * f = fopen("/documents/mygame_highscore.tns", "w+");char buf[integerSize(highscore) + 2];sprintf(buf, "%d", highscore);fputs(buf, f);fclose(f);refresh_osscr(); // refresh OS screen so that we can see the created file when we exit the program
int integerSize(int n) { int i; for(i = 0; n > 0; n/= 10, i++); return n }
I suppose so, but it isn't the most easy thing to do. Maybe someone can make a lib for it
I wonder... is self-modifying code possible in Ndless, as in highscores storing themselves inside their respective games rather than external files? I saw that happen often on the TI-83 Plus in the past.
Levak, if you store the data on the end of the tns file, and you can get the size of it using Ndless there should not be any problem.
char *fgets(char *str, int num, FILE *str2eam) { char *str2 = str; while (num--) { char c = fgetc(str2eam); //THIS IS THE BUGGY LINE if (c == EOF) { *str2 = '\0'; return NULL; } *str2++ = c; if (c == '\n') break; } *str2 = '\0'; return str;}