Skip to content

Commit

Permalink
more tiles!
Browse files Browse the repository at this point in the history
  • Loading branch information
goudreinette committed Mar 1, 2024
1 parent d054968 commit 0bd559f
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 22 deletions.
Binary file modified nds_framebuffer_bitmaps/assets/tiles.aseprite
Binary file not shown.
Binary file added nds_framebuffer_bitmaps/assets/tiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# magic

```
cd assets && sh convert.sh && cd .. && make clean && make && open tilechange.nds
```


32 x 32 tiles in a 256px map

first rows, then columns


25 = separate squares
Binary file modified tilechange/assets/tiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 32 additions & 22 deletions tilechange/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ int main(int argc, char **argv)
for (int j = 0; j < 64; j++)
{
// NF_SetTileOfMap(1, 2, i, j, 2);
NF_SetTileOfMap(1, 2, i, j, rand() % 8);
// NF_SetTileOfMap(1, 2, i, j, rand() % 8);
}
}

int t = 0;
int tilenum_2 = 0;

while (1)
{
Expand All @@ -99,10 +100,18 @@ int main(int argc, char **argv)
scanKeys();
u16 keys = keysHeld();

if (keys & KEY_UP)
if (keys & KEY_UP) {
if (t%10 == 0) {
tilenum_2--;
}
y--;
if (keys & KEY_DOWN)
y++;
}
if (keys & KEY_DOWN) {
if (t%10 == 0) {
tilenum_2++;
}
y++;
}

if (keys & KEY_LEFT)
x--;
Expand Down Expand Up @@ -157,32 +166,33 @@ int main(int argc, char **argv)

for (int i = 0; i < 128; i++)
{
NF_SetTileOfMap(0, 3, rand() % 32, rand() % 32, rand() % 32);
NF_SetTileOfMap(0, 2, rand() % 32, rand() % 32, rand() % 16);
NF_SetTileOfMap(1, 2, rand() % 64, rand() % 64, rand() % 16);
// NF_SetTileOfMap(0, 3, rand() % 64, rand() % 64, rand() % 32);
// NF_SetTileOfMap(0, 2, rand() % 32, rand() % 32, rand() % 16);
NF_SetTileOfMap(1, 2, rand() % 64, rand() % 64, 25);
}


// For demos
// for (int i = 0; i < 64; i++)
// {
// for (int j = 0; j < 64; j++)
// {
// // NF_SetTileOfMap(1, 2, i, j, 2);
// // NF_SetTileOfMap(1, 2, i, j, rand() % 8);
// NF_SetTileOfMap(1, 2, i, j, tilenum_2);
// }
// }


NF_UpdateVramMap(0, 3);
NF_UpdateVramMap(1, 2);

// Print the color of the tile under the pointer
int tilenum = NF_GetTileOfMap(1, 2, x / 8, y / 8);
switch (tilenum)
{
case 0:
sprintf(mytext,"Tile: Vacio / Void / %d ", tilenum);
break;
case 1:
sprintf(mytext,"Tile: Azul / Blue / %d ", tilenum);
break;
case 2:
sprintf(mytext,"Tile: Verde / Green / %d ", tilenum);
break;
case 3:
sprintf(mytext,"Tile: Rojo / Red / %d ", tilenum);
break;
}

sprintf(mytext," %d ", tilenum);


NF_WriteText(0, 2, 1, 3, mytext);

// Update text layers
Expand Down

0 comments on commit 0bd559f

Please sign in to comment.