Skip to content

Commit

Permalink
New version 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
wjtje committed Jul 5, 2019
1 parent f268b2b commit 3654f6f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 47 deletions.
Binary file modified 2048 (cg-10)(cg-20).g3a
Binary file not shown.
Binary file modified 2048 (cg-50).g3a
Binary file not shown.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# 2048-fx-GC50
The game 2048 for the casio fx-CG10/20/50
# 2048 for the Casio fx-cg 10/20/50
Use the correct file for your calculator
Casio fx-cg 10/20 -> 2048 (cg-10)(cg-20).g3a
Casio fx-cg 50 -> 2048 (cg-50).g3a

If there are no graphics showing up try using the other file.
This programm is under the GNU V3 license
79 changes: 34 additions & 45 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const color_t logo[9280] = {

// Custom function
void fillArea(unsigned x,unsigned y,unsigned w,unsigned h,unsigned short col){
unsigned short*s=(unsigned short*)0xA8000000;
unsigned short*s=(unsigned short*)0xAC000000;
s+=(y*384)+x;
while(h--){
unsigned w2=w;
Expand Down Expand Up @@ -184,7 +184,7 @@ void drawBackground() {
fillArea(247, 106, 1, 40, 0x9c4f);
fillArea(332, 105, 1, 40, 0x9c4f);

int xa = 270;
int xa = 265;
int ya = 82;
PrintMini(&xa, &ya, "score", 0x02, 0xffffffff, 0, 0, 0xe6fa, 0x9c4f, 1, 0);

Expand Down Expand Up @@ -293,61 +293,50 @@ int createRandomTile() {

void slideTile(int p) {
int times = 0;

// Movement vars
int a = 0;
int b = 0;
int c = 0;
int d = 0;

while (times != 4) {
int xTile = 0;
int yTile = 0;

while (xTile != 4) {
while (yTile != 4) {
// Set correct move vars
if (p == 0) {
// Go up
if (yTile != 0) { // top row is skiped
if (board[yTile-1][xTile] == 0) {
board[yTile-1][xTile] = board[yTile][xTile];
board[yTile][xTile] = 0;
} else if (board[yTile-1][xTile] == board[yTile][xTile]) {
board[yTile-1][xTile] = board[yTile][xTile]*2;
board[yTile][xTile] = 0;
score = score + board[yTile-1][xTile];
}
}
a = -1;
c = yTile;
d = 0;
} else if (p == 1) {
// Go down
if (yTile != 3) { // top row is skiped
if (board[yTile+1][xTile] == 0) {
board[yTile+1][xTile] = board[yTile][xTile];
board[yTile][xTile] = 0;
} else if (board[yTile+1][xTile] == board[yTile][xTile]) {
board[yTile+1][xTile] = board[yTile][xTile]*2;
board[yTile][xTile] = 0;
score = score + board[yTile+1][xTile];
}
}
a = 1;
c = yTile;
d = 3;
} else if (p == 2) {
// Go left
if (xTile != 0) {
if (board[yTile][xTile-1] == 0) {
board[yTile][xTile-1] = board[yTile][xTile];
board[yTile][xTile] = 0;
} else if (board[yTile][xTile-1] == board[yTile][xTile]) {
board[yTile][xTile-1] = board[yTile][xTile]*2;
board[yTile][xTile] = 0;
score = score + board[yTile][xTile-1];
}
}
b = -1;
c = xTile;
d = 0;
} else if (p == 3) {
// Go right
if (xTile != 3) {
if (board[yTile][xTile+1] == 0) {
board[yTile][xTile+1] = board[yTile][xTile];
board[yTile][xTile] = 0;
} else if (board[yTile][xTile+1] == board[yTile][xTile]) {
board[yTile][xTile+1] = board[yTile][xTile]*2;
board[yTile][xTile] = 0;
score = score + board[yTile][xTile+1];
}
b = 1;
c = xTile;
d = 3;
}

// Move
if (c != d) {
if (board[yTile+a][xTile+b] == 0) {
board[yTile+a][xTile+b] = board[yTile][xTile];
board[yTile][xTile] = 0;
} else if (board[yTile+a][xTile+b] == board[yTile][xTile]) {
board[yTile+a][xTile+b] = board[yTile][xTile]*2;
board[yTile][xTile] = 0;
score = score + board[yTile+a][xTile+b];
}
}

yTile = yTile + 1;
}
yTile = 0;
Expand Down

0 comments on commit 3654f6f

Please sign in to comment.