start rogue map

This commit is contained in:
quenousimporte 2025-04-07 20:14:10 +00:00
parent f2eb437ac1
commit 8279703f9b
1 changed files with 21 additions and 14 deletions

27
w/w.c
View File

@ -9,6 +9,7 @@
#define POV_3D_SIZE 10
#define POV_SIZE 3
#define INVENTORY_SIZE 2
#define MAP_SIZE 15
#define CMD_NULL "-"
#define CMD_FWD 's'
@ -38,6 +39,7 @@
#define TILE_FREE ' '
#define TILE_DOOR 'd'
#define TILE_START 's'
#define TILE_UNKNOWN '?'
#define ITEM_POTION '0'
#define ITEM_TRUC '1'
@ -86,8 +88,9 @@ Character currentmonster;
Round* firstround = NULL;
Round* currentround = NULL;
int mapsize = 15;
char map[15][15] = {
//int mapsize = 15;
/*char map[15][15] = {
"wwwwwwwwwwwwwww",
"w w",
"w wwwww wwwww w",
@ -103,7 +106,9 @@ char map[15][15] = {
"w w w w",
"w w",
"wwwwwwwwwwwwwww"
};
};*/
char map[MAP_SIZE * MAP_SIZE];
Character monsters[2] = {
{ "alien bleu", 2, 2, 1, 1 },
@ -127,17 +132,17 @@ int dices(int count)
char charatpos(int x, int y)
{
if (x < 0 || y < 0 || x >= mapsize || y >= mapsize)
if (x < 0 || y < 0 || x >= MAP_SIZE || y >= MAP_SIZE)
{
return ' ';
}
return map[y][x];
return map[y * MAP_SIZE + x];
}
void drawmap()
{
for (int y = 0; y < mapsize; y++) {
for (int x = 0; x < mapsize; x++) {
for (int y = 0; y < MAP_SIZE; y++) {
for (int x = 0; x < MAP_SIZE; x++) {
char toprint = charatpos(x,y);
if (y == state.position.y && x == state.position.x)
{
@ -446,6 +451,7 @@ void clearscreen()
void init()
{
memset(&map, TILE_UNKNOWN, MAP_SIZE * MAP_SIZE);
srand(time(NULL));
FILE* file = fopen(statepath, "r");
if (file)
@ -524,7 +530,8 @@ void freerounds()
void gotomonster()
{
int index = dice() == 6 ? 1 : 0;
//int index = dice() == 6 ? 1 : 0;
int index = 0;
memcpy(&currentmonster, &(monsters[index]), sizeof(Character));
state.screen = SC_MONSTER;
}
@ -749,8 +756,8 @@ void draw()
else if (state.screen == SC_MAP)
{
update3dpov();
drawpov3d();
//drawmap();
//drawpov3d();
drawmap();
if (charatpos(state.position.x, state.position.y) == TILE_START)
{