map gen, wip
This commit is contained in:
parent
8279703f9b
commit
f987630754
86
w/w.c
86
w/w.c
|
@ -88,26 +88,7 @@ Character currentmonster;
|
||||||
Round* firstround = NULL;
|
Round* firstround = NULL;
|
||||||
Round* currentround = NULL;
|
Round* currentround = NULL;
|
||||||
|
|
||||||
//int mapsize = 15;
|
int freedom = 2;
|
||||||
|
|
||||||
/*char map[15][15] = {
|
|
||||||
"wwwwwwwwwwwwwww",
|
|
||||||
"w w",
|
|
||||||
"w wwwww wwwww w",
|
|
||||||
"w w w d w w w",
|
|
||||||
"w w w w w w w",
|
|
||||||
"w w w w w w",
|
|
||||||
"wdwwwwwdwwwdwdw",
|
|
||||||
"w w w w w w",
|
|
||||||
"w www w w w",
|
|
||||||
"ws w w w w",
|
|
||||||
"wwwwwww w w w",
|
|
||||||
"w w w w",
|
|
||||||
"w w w w",
|
|
||||||
"w w",
|
|
||||||
"wwwwwwwwwwwwwww"
|
|
||||||
};*/
|
|
||||||
|
|
||||||
char map[MAP_SIZE * MAP_SIZE];
|
char map[MAP_SIZE * MAP_SIZE];
|
||||||
|
|
||||||
Character monsters[2] = {
|
Character monsters[2] = {
|
||||||
|
@ -139,6 +120,15 @@ char charatpos(int x, int y)
|
||||||
return map[y * MAP_SIZE + x];
|
return map[y * MAP_SIZE + x];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setatpos(int x, int y, char c)
|
||||||
|
{
|
||||||
|
if (x < 0 || y < 0 || x >= MAP_SIZE || y >= MAP_SIZE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
map[y * MAP_SIZE + x] = c;
|
||||||
|
}
|
||||||
|
|
||||||
void drawmap()
|
void drawmap()
|
||||||
{
|
{
|
||||||
for (int y = 0; y < MAP_SIZE; y++) {
|
for (int y = 0; y < MAP_SIZE; y++) {
|
||||||
|
@ -155,6 +145,7 @@ void drawmap()
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
printf("freedom: %d\n", freedom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawpov3d()
|
void drawpov3d()
|
||||||
|
@ -338,6 +329,26 @@ void update3dpov()
|
||||||
|
|
||||||
void updatepov()
|
void updatepov()
|
||||||
{
|
{
|
||||||
|
// generate map
|
||||||
|
/*setatpos(state.position.x, state.position.y, ' ');
|
||||||
|
|
||||||
|
Position front;
|
||||||
|
memcpy(&front, &state.position, sizeof(Position));
|
||||||
|
if (state.position.orientation
|
||||||
|
|
||||||
|
// right
|
||||||
|
if (state.position.x + 1 == 0)
|
||||||
|
{
|
||||||
|
setatpos(state.position.x + 1, state.position.y, 'w');
|
||||||
|
}
|
||||||
|
else if (charatpos(state.position.x + 1, state.position.y) == '?')
|
||||||
|
{
|
||||||
|
char c = dice() > 3 ? 'w' : ' ';
|
||||||
|
setatpos(state.position.x + 1, state.position.y, c);
|
||||||
|
if (c == 'w') freedom--;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
int x = state.position.x;
|
int x = state.position.x;
|
||||||
int y = state.position.y;
|
int y = state.position.y;
|
||||||
char orientation = state.position.orientation;
|
char orientation = state.position.orientation;
|
||||||
|
@ -576,6 +587,37 @@ void drawrounds()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char gentile()
|
||||||
|
{
|
||||||
|
int r = dice();
|
||||||
|
if (r == 1) return 'd';
|
||||||
|
if (r < 4) return 'w';
|
||||||
|
return ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
void initmap()
|
||||||
|
{
|
||||||
|
// init map
|
||||||
|
for (int i = 0; i < 15; i++)
|
||||||
|
{
|
||||||
|
setatpos(0, i, TILE_WALL);
|
||||||
|
setatpos(14, i, TILE_WALL);
|
||||||
|
setatpos(i, 0, TILE_WALL);
|
||||||
|
setatpos(i, 14, TILE_WALL);
|
||||||
|
}
|
||||||
|
setatpos(1, 13, TILE_FREE);
|
||||||
|
|
||||||
|
char c = gentile();
|
||||||
|
setatpos(1, 12, c);
|
||||||
|
if (c == TILE_WALL) freedom--;
|
||||||
|
else if (c == TILE_FREE)
|
||||||
|
{
|
||||||
|
setatpos(1, 11, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
c = gentile();
|
||||||
|
}
|
||||||
|
|
||||||
void update(char* command)
|
void update(char* command)
|
||||||
{
|
{
|
||||||
char c = command[0];
|
char c = command[0];
|
||||||
|
@ -631,8 +673,10 @@ void update(char* command)
|
||||||
{
|
{
|
||||||
state.screen = SC_MAP;
|
state.screen = SC_MAP;
|
||||||
state.position.x = 1;
|
state.position.x = 1;
|
||||||
state.position.y = 9;
|
state.position.y = 13;
|
||||||
state.position.orientation = NORTH;
|
state.position.orientation = NORTH;
|
||||||
|
|
||||||
|
initmap();
|
||||||
updatepov();
|
updatepov();
|
||||||
}
|
}
|
||||||
else if (c == CMD_GOTOMARKET)
|
else if (c == CMD_GOTOMARKET)
|
||||||
|
|
Loading…
Reference in New Issue