diff --git a/src/main.c b/src/main.c index 8a147d3..9a53584 100644 --- a/src/main.c +++ b/src/main.c @@ -2,6 +2,7 @@ # include # include # include +# include # include "msg_fr.h" # include "itemsizes.h" # include "gamesettings.h" @@ -9,8 +10,10 @@ extern bopti_image_t title_img; extern bopti_image_t soil_tile; +extern bopti_image_t grass_tile; extern bopti_image_t stone_tile; extern bopti_image_t coal_tile; +extern bopti_image_t steel_tile; void drawselectedgame(int selected) { dclear(C_WHITE); @@ -26,17 +29,21 @@ void mappartdisplaying(int x, int y, unsigned short int * terrain) { int base_x = firsttile_x*8, base_y = firsttile_y*8; int sx = base_x - x, sy = base_y - y, tx = (SCREEN_WIDTH>>3) + 1, ty = (SCREEN_HEIGHT>>3) + 1; int cx, cy, px = sx, py = sy; - unsigned short type; + unsigned short type, type_over; + dclear(C_WHITE); for(cy = 0;cy != ty;cy++){ for(cx = 0;cx != tx;cx++){ - type = terrain[cy*tx+px]; + type = terrain[(firsttile_y+cy)*WORLD_WIDTH+(firsttile_x+cx)]; + type_over = terrain[(firsttile_y+cy-1)*WORLD_WIDTH+(firsttile_x+cx)]; switch(type){ case 1: - dimage(px, py, &soil_tile); break; + if(type_over == 0){dimage(px, py, &grass_tile);}else{dimage(px, py, &soil_tile);} break; case 2: dimage(px, py, &stone_tile); break; case 3: dimage(px, py, &coal_tile); break; + case 4: + dimage(px, py, &steel_tile); break; } px += 8; } @@ -44,12 +51,13 @@ void mappartdisplaying(int x, int y, unsigned short int * terrain) { px = sx; } } +int x, y; int main(void) { dclear(C_WHITE); dimage(16, TITLE_IMAGE_MARGIN, &title_img); dtext(1, TITLE_MARGIN, C_BLACK, TITLE_START); dupdate(); - int key = 0, game = 0, selected = 0, i, x = 0, y = 0; + int key = 0, game = 0, selected = 0, i; unsigned short terrain[WORLD_WIDTH*WORLD_HEIGHT]; while(key != KEY_EXIT){ key=getkey().key; @@ -91,11 +99,17 @@ int main(void) { generateworld(terrain, WORLD_WIDTH, WORLD_HEIGHT, (int)((rand() % ((WORLD_HEIGHT - 40) - (WORLD_HEIGHT - 60) + 1)) + WORLD_HEIGHT - 60), WORLD_HEIGHT - 60, WORLD_HEIGHT - 40, 0, 1); srand(clock()); generateworld(terrain, WORLD_WIDTH, WORLD_HEIGHT, (int)((rand() % ((WORLD_HEIGHT - 25) - (WORLD_HEIGHT - 40) + 1)) + WORLD_HEIGHT - 40), WORLD_HEIGHT - 40, WORLD_HEIGHT - 25, 3, 2); + srand(clock()); + generateworld(terrain, WORLD_WIDTH, WORLD_HEIGHT, (int)((rand() % ((WORLD_HEIGHT - 10) - (WORLD_HEIGHT - 25) + 1)) + WORLD_HEIGHT - 25), WORLD_HEIGHT - 25, WORLD_HEIGHT - 10, 4, 2); + x = 200; + for(i=0;i!=WORLD_HEIGHT;i++){ + if(terrain[i*WORLD_WIDTH+(x>>3)] != 0){ + y = i * 8; + break; + } + } game = 3; }else if(game == 3){ - x = 0; - y = 0; - dclear(C_WHITE); if(key==KEY_RIGHT){ x++; }else if(key==KEY_LEFT){ diff --git a/src/worldgen.h b/src/worldgen.h index cb9e5c0..8620f30 100644 --- a/src/worldgen.h +++ b/src/worldgen.h @@ -8,11 +8,11 @@ void generateworld(unsigned short terrain[], int w, int h, int genstart, int genmin, int genmax, int someof, int type) { int x = 0, y = genstart, n, i, a, t; for(x=0;x!=w;x++){ - srand(clock()); + //srand(clock()); a = (int)rand() % 2; if(a==0){ for(i=y;i!=h;i++){ - srand(clock()); + //srand(clock()); t = (int)rand() % 11; if(t==0){ terrain[i*w+x] = someof; @@ -25,7 +25,7 @@ void generateworld(unsigned short terrain[], int w, int h, int genstart, int gen terrain[i*w+x] = type; } } - srand(clock()); + //srand(clock()); n = (int)rand() % 2; if(n==0 && y