Implemented scores & local best score

* Should have been aligned on the right, but had issues with the log()
function
* Best score is currently reset every time you launch the game
* Removed useless project files
This commit is contained in:
Geoffrey Frogeye 2014-04-08 18:09:21 +02:00
parent 91e395a35e
commit 08888717c5
5 changed files with 29 additions and 364 deletions

5
.gitignore vendored
View file

@ -3,4 +3,7 @@
/SDCard/*
/imgres/*
*.sublime-*
*Thumbs.db
*Thumbs.db
*.dlw
*.dlr
*.G1A

BIN
2048.G1A

Binary file not shown.

27
2048.c
View file

@ -3,6 +3,7 @@
#include "MonochromeLib.h"
// Sprites
char tile[14][26] = {{127,240,213, 88,170,168,213, 88,170,168,213, 88,170,168,213, 88,170,168,213, 88,170,168,213, 88,127,240},
{127,240,128, 8,128, 8,135, 8,136,136,128,136,129, 8,130, 8,132, 8,143,136,128, 8,128, 8,127,240},
@ -61,6 +62,26 @@ int Storage_bestScore = 0;
Grid Grid_grid;
// Usual functions
unsigned char* intToStr(unsigned char* c, int n) { // Code par Eiyeron, Licence Creative Commons BY-SA
if(n==0) {
c[0] = '0';
c[1] = 0;
} else {
int i, l=0;
if(n<0) {
c[0] = '-';
n = abs(n);
l++;
}
for(i=n ; i ; i/=10)
l++;
c[l] = 0;
for(i=n ; i ; i/=10)
c[--l] = i%10+'0';
}
return c;
}
int rand_int(int min, int max) {
return min + (rand() % (int)(max - min + 1));
}
@ -184,11 +205,13 @@ int Screen_drawMovingTiles(float percentage) {
}
void Screen_updateScore() {
PrintXY(100, 14, "0", 1);
unsigned char chaineScore[6];
PrintXY(70, 14, intToStr(chaineScore, Game_score), 1);
}
void Screen_updateBestScore() {
PrintXY(100, 35, "0", 1);
unsigned char chaineScore[6];
PrintXY(70, 35, intToStr(chaineScore, Storage_bestScore), 1);
}
void Screen_message(bool won) {

235
2048.dlr
View file

@ -1,235 +0,0 @@
[DLSimRunSpace]
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=184
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=149
Flags=00001012
Sublevel=1
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=130
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=198
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=204
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=210
Flags=00001012
Sublevel=1
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=150
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=117
Flags=00001012
Sublevel=1
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=124
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=151
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=147
Flags=00001012
Sublevel=1
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=157
Flags=00001012
Sublevel=1
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=158
Flags=00001012
Sublevel=1
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=54
Flags=00001012
Sublevel=1
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=54
Flags=00001012
Sublevel=2
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=49
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=47
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=46
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=45
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=55
Flags=00001012
Sublevel=1
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=55
Flags=00001012
Sublevel=2
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=147
Flags=00001012
Sublevel=2
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=147
Flags=00001012
Sublevel=3
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=220
Flags=00001012
Sublevel=1
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=210
Flags=00001012
Sublevel=2
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=220
Flags=00001012
Sublevel=2
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=117
Flags=00001012
Sublevel=2
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=157
Flags=00001012
Sublevel=2
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=149
Flags=00001012
Sublevel=2
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=158
Flags=00001012
Sublevel=2
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=188
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\ECode.c
Line=321
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\ECode.c
Line=323
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\ECode.c
Line=330
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\ECode.c
Line=343
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=191
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=477
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=474
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=475
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=197
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=194
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=473
Flags=00001012
[Breakpoint]
File=C:\Users\Geoffrey\Documents\Programmation\CASIO\2048\2048.c
Line=189
Flags=00001012

126
2048.dlw
View file

@ -1,126 +0,0 @@
[DLSimWorkSpace]
[_1]
Type=5
Order=0
Top=60
Left=1965
Height=8295
Width=10470
State=0
Flags=00000020
Setting=417:1:2048.c
OptionA=0
[_2]
Type=1
Order=1
Top=0
Left=12645
Height=4665
Width=5535
State=0
Flags=00000001
OptionA=15
OptionB=15
[_3]
Type=6
Order=3
Top=4680
Left=12720
Height=6840
Width=5490
State=0
Flags=00000001
OptionA=0
[_4]
Type=7
Order=5
Top=8400
Left=2040
Height=4815
Width=5145
State=0
Flags=00000000
OptionA=0
[_5]
Type=8
Order=4
Top=8400
Left=7200
Height=4845
Width=5475
State=0
Flags=00000000
OptionA=0
[_6]
Type=3
Order=10
Top=0
Left=10788
Height=6348
Width=2232
State=16
Flags=00000000
OptionA=0
[_7]
Type=2
Order=9
Top=6495
Left=7800
Height=3435
Width=5130
State=16
Flags=00000000
OptionA=0
[_8]
Type=17
Order=7
Top=30
Left=30
Height=13200
Width=1965
State=0
Flags=00000000
OptionA=0
[_9]
Type=15
Order=2
Top=0
Left=2010
Height=11580
Width=10740
State=0
Flags=00000000
OptionA=0
[_32]
Type=16
Order=6
Top=15
Left=1995
Height=10095
Width=10710
State=0
Flags=00000020
Setting=412:1:2048.c
OptionA=0
[_33]
Type=16
Order=8
Top=990
Left=990
Height=9060
Width=13635
State=16
Flags=00000020
Setting=1:1:MonochromeLib.c
OptionA=0