forked from mibi88/Builder
20220627 - Scrolling codé (mais pas fonctionnel).
This commit is contained in:
parent
ed1de7d313
commit
aa961319e4
|
@ -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.
|
|
@ -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.
|
||||
# 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.
|
26
src/main.c
26
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# define TITLE_START "[EXE] pour jouer"
|
||||
# define WORLDSEL_EMPTY "--- VIDE ---" // Empty slot in the game selection menu.
|
||||
# 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.
|
Loading…
Reference in New Issue