forked from mibi88/Builder
20220705 - Meilleur terrain, scrolling 100% fonctionnel.
This commit is contained in:
parent
39f054b4ae
commit
e591d08be8
|
@ -2,7 +2,7 @@
|
|||
# include <stdlib.h>
|
||||
# include <time.h>
|
||||
|
||||
# define WORLD_WIDTH 256 // World width.
|
||||
# define WORLD_WIDTH 64 // World width.
|
||||
# define WORLD_HEIGHT 64 // World height.
|
||||
# define SCREEN_WIDTH 128 // Screen width.
|
||||
# define SCREEN_HEIGHT 64 // Screen height.
|
||||
|
@ -13,18 +13,20 @@ void mappartdisplaying(int x, int y, unsigned short int * terrain) {
|
|||
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;
|
||||
printf("values : %d, %d\n", tx, ty);
|
||||
for(cy = 0;cy != ty;cy++){
|
||||
for(cx = 0;cx != tx;cx++){
|
||||
type = terrain[cy*tx+px];
|
||||
printf("%d, %d, %d, %d\n", type, (cy*tx+px), cx, cy);
|
||||
if(type == 1){
|
||||
printf("soil : %d, %d\n", px, py);
|
||||
}else if(type == 2){
|
||||
printf("stone : %d, %d\n", px, py);
|
||||
}else if(type == 3){
|
||||
printf("coal : %d, %d\n", px, py);
|
||||
}else{
|
||||
printf("other : %d, %d\n", px, py);
|
||||
type = terrain[(firsttile_y+cy)*WORLD_WIDTH+(firsttile_x+cx)];
|
||||
printf("type pos : %d, %d, %d, %d\n", cy, cx, tx, (cy*tx+cx));
|
||||
switch(type){
|
||||
case 1:
|
||||
printf("soil : %d, %d, %d\n", px, py, type); break;
|
||||
case 2:
|
||||
printf("stone : %d, %d, %d\n", px, py, type); break;
|
||||
case 3:
|
||||
printf("coal : %d, %d, %d\n", px, py, type); break;
|
||||
default:
|
||||
printf("other : %d, %d, %d\n", px, py, type); break;
|
||||
}
|
||||
px += 8;
|
||||
}
|
||||
|
@ -64,7 +66,7 @@ void generateworld(unsigned short terrain[], int w, int h, int genstart, int gen
|
|||
|
||||
int main() {
|
||||
unsigned short terrain[WORLD_WIDTH*WORLD_HEIGHT];
|
||||
int i, x = 403, y = 403;
|
||||
int i, x = 403, y;
|
||||
for(i=0;i!=WORLD_WIDTH*WORLD_HEIGHT;i++){
|
||||
terrain[i] = 0;
|
||||
}
|
||||
|
@ -72,6 +74,13 @@ int main() {
|
|||
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);
|
||||
for(i=0;i!=WORLD_HEIGHT;i++){
|
||||
if(terrain[i*WORLD_WIDTH+(x>>3)] != 0){
|
||||
y = i * 8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
y+=200;
|
||||
mappartdisplaying(x, y, terrain);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue