[WIP] Dungeon Crawler Style / Map Rendering

My first arduboy demo

Move a character around a dungeon and open doors / explore

Includes NES / PC music (~94% program storage used)

UPDATE! The collision is fully functional including keys / doors.

Keys are found in chests

Also you can push barrels

and you play as a fish

Let me know how it is

https://github.com/JoeRagu/First-Game

2 Likes

So a random map?
If so then cool

To make it random I would have to procedurally generate it some how by modifying the map array
not sure how to do that

#pragma once
#include "globals.h"

byte map1[mapWidth][mapHeight] {
  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  {0, 5, 5, 5, 5, 5, 5, 5, 5, 0},
  {0, 5, 1, 5, 0, 0, 3, 0, 5, 0},
  {0, 5, 5, 5, 0, 0, 5, 0, 5, 0},
  {0, 0, 5, 0, 0, 0, 5, 0, 5, 0},
  {0, 7, 5, 5, 0, 0, 5, 0, 5, 0},
  {0, 0, 5, 5, 5, 0, 5, 0, 6, 0},
  {0, 0, 0, 0, 5, 0, 5, 0, 0, 0},
  {8, 5, 5, 5, 5, 0, 5, 5, 4, 0},
  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};
1 Like

@JoeRagu If you want to read a bit more on this, have look at redacted.
You can’t play this game on Arduboy, but you can still look at the code in Arduino IDE. Also have look at redacted.

And make sure to read the next Arduboy Magazine Issue 5 (coming out by the 2nd of June)

You don’t need a 2 dimensional array, and if all your maps all have the same size, you even don’t have to include the size in the map. Also it is best to put a map in PROGMEM, but then you can’t change it obviously. If you have a closer look at the link I gave you, you could use a trick, where you have map parts that never change, but you use those pieces to build a bigger map in RAM.


Moderator Note:
Links to Team ARG’s website have been removed due to malicious new owners.

1 Like

Interesting I like that way of doing it. How would I do collision detection? I don’t even know where to start with that

@JoeRagu Well I’m going to write an article on that in Issue 6 (so for July), but it comes down to “tile based collision”. This means you create a function to check the surrounding tiles and see if it is a floor tile or wall tile.

You could wait on that article and continue to work on creating maps and a title screen and other stuff :slight_smile:

2 Likes

UPDATE! The collision is fully functional including keys / doors.

Keys are found in chests

Also you can push barrels

3 Likes

Cool.
Question how did you print this
{1,0,0,0,1}
{1,0,0,0,1}
(Not actual map)

I used 2 for loops.

//Draw Map
for (int y = 0; y < mapHeight; y++)
 {
    for (int x = 0; x < mapWidth; x++)
     {
     //Draw tile at  map1[y][x]
     }
}
1 Like

thanks this was really helpful.