From aa961319e43f6947641c28a20fd9d2340788e5bf Mon Sep 17 00:00:00 2001 From: mibi88 Date: Mon, 27 Jun 2022 21:26:01 +0200 Subject: [PATCH] =?UTF-8?q?20220627=20-=20Scrolling=20cod=C3=A9=20(mais=20?= =?UTF-8?q?pas=20fonctionnel).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gamesettings.h | 2 +- src/itemsizes.h | 4 +++- src/main.c | 26 ++++++++++++++++++++++++-- src/msg_fr.h | 5 +++-- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/gamesettings.h b/src/gamesettings.h index ffd5d92..201f825 100644 --- a/src/gamesettings.h +++ b/src/gamesettings.h @@ -1,5 +1,5 @@ # define GAMESNUM 5 // How many games you can save (and play). # define WORLDGEN_SOIL 8 // Blocks (y) of soil. -# define WORLD_WIDTH 256 // World width. +# define WORLD_WIDTH 64 // World width. # define WORLD_HEIGHT 64 // World height. \ No newline at end of file diff --git a/src/itemsizes.h b/src/itemsizes.h index 23a767b..a8b1beb 100644 --- a/src/itemsizes.h +++ b/src/itemsizes.h @@ -3,4 +3,6 @@ # define LINEPADDING 2 // Padding (y) of the font. # define TITLE_MARGIN 46 // Margin (y) over the text at the top of the tile screen. # define TITLE_IMAGE_MARGIN 8 // Margin (y) over the image at the top of the tile screen. -# define WORLDSEL_MARGIN 5 // Margin (y) at the top of the game selection menu. \ No newline at end of file +# define WORLDSEL_MARGIN 5 // Margin (y) at the top of the game selection menu. +# define SCREEN_WIDTH 128 // Screen width. +# define SCREEN_HEIGHT 64 // Screen height. \ No newline at end of file diff --git a/src/main.c b/src/main.c index 5cc8441..f12b298 100644 --- a/src/main.c +++ b/src/main.c @@ -8,6 +8,9 @@ # include "worldgen.h" extern bopti_image_t title_img; +extern bopti_image_t soil_tile; +extern bopti_image_t stone_tile; +extern bopti_image_t coal_tile; void drawselectedgame(int selected) { dclear(C_WHITE); @@ -19,7 +22,23 @@ void drawselectedgame(int selected) { dupdate(); } void mappartdisplaying(int x, int y, unsigned short terrain) { - // + int firsttile_x = x>>3, firsttile_y = y>>3; + 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; + for(cy = 0;cy != ty;cy++){ + for(cx = 0;cx != tx;cx++){ + type = terrain[(int *)(cy*tx+px)]; + switch(type){ + case 1: + dimage(px, py, &soil_tile); + } + px += 8; + } + py += 8; + px = sx; + } } int main(void) { dclear(C_WHITE); @@ -27,6 +46,7 @@ int main(void) { dtext(1, TITLE_MARGIN, C_BLACK, TITLE_START); dupdate(); int key = 0, game = 0, selected = 0, i, x, y; + unsigned short terrain[WORLD_WIDTH*WORLD_HEIGHT]; while(key != KEY_EXIT){ key=getkey().key; ////////// TITLE SCREEN ////////// @@ -58,7 +78,8 @@ int main(void) { } }else if(game == 2){ - unsigned short terrain[WORLD_WIDTH*WORLD_HEIGHT]; + dtext(1, 1, C_BLACK, WORLDSEL_EMPTY); + dupdate(); for(i=0;i!=WORLD_WIDTH*WORLD_HEIGHT;i++){ terrain[i] = 0; } @@ -74,6 +95,7 @@ int main(void) { if(key==KEY_RIGHT){ // } + mappartdisplaying(0, 256, terrain); dupdate(); } } diff --git a/src/msg_fr.h b/src/msg_fr.h index 7dc596e..bc14807 100644 --- a/src/msg_fr.h +++ b/src/msg_fr.h @@ -1,2 +1,3 @@ -# define TITLE_START "[EXE] pour jouer" -# define WORLDSEL_EMPTY "--- VIDE ---" // Empty slot in the game selection menu. \ No newline at end of file +# define TITLE_START "[EXE] pour jouer" // Start screen text. +# define WORLDSEL_EMPTY "--- VIDE ---" // Empty slot in the game selection menu. +# define WORLDGEN_INFO "Génération du terrain ..." // Text when waiting for world generation. \ No newline at end of file