20220727 - Menu pour le crafting terminé.
This commit is contained in:
parent
0db6dd3238
commit
02a36f236c
|
@ -14,6 +14,7 @@ set(SOURCES
|
|||
)
|
||||
set(ASSETS_fx
|
||||
assets-fx/title.png
|
||||
assets-fx/microfont.png
|
||||
assets-fx/tiles/blocks/soil.png
|
||||
assets-fx/tiles/blocks/grass.png
|
||||
assets-fx/tiles/blocks/stone.png
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
title.png:
|
||||
type: bopti-image
|
||||
name: title_img
|
||||
name: title_img
|
||||
microfont.png:
|
||||
type: font
|
||||
charset: print
|
||||
grid.size: 4x4
|
||||
grid.padding: 1
|
||||
proportional: true
|
||||
name: microfont
|
Binary file not shown.
After Width: | Height: | Size: 496 B |
Binary file not shown.
|
@ -5,4 +5,4 @@
|
|||
# define WORLD_HEIGHT 64 // World height.
|
||||
# define INVENTORY_SIZE 5 // Size of the inventory.
|
||||
# define CRAFTSIZE 9 // How many different blocks you can use to craft something.
|
||||
# define CRAFTINGS 3 // How many things you can craft.
|
||||
# define CRAFTINGS 1 // How many things you can craft.
|
58
src/main.c
58
src/main.c
|
@ -35,6 +35,7 @@ extern bopti_image_t overlay_break_1;
|
|||
extern bopti_image_t overlay_break_2;
|
||||
extern bopti_image_t overlay_break_3;
|
||||
extern bopti_image_t overlay_break_4;
|
||||
extern font_t microfont;
|
||||
|
||||
# include "objects.h"
|
||||
|
||||
|
@ -43,6 +44,7 @@ int pos, hour;
|
|||
char tmp_char[2];
|
||||
|
||||
Player player;
|
||||
Crafting crafting;
|
||||
|
||||
void drawoverlay() {
|
||||
/*
|
||||
|
@ -125,6 +127,8 @@ void mappartdisplaying(int x, int y, unsigned short int * terrain, int player) {
|
|||
dimage(px, py, &steel_tile); break;
|
||||
case 5:
|
||||
dimage(px, py, &wood_tile); break;
|
||||
case 6:
|
||||
dimage(px, py, &woodplanks_tile); break;
|
||||
}
|
||||
px += 8;
|
||||
}
|
||||
|
@ -200,6 +204,8 @@ void drawinventory(){
|
|||
dimage(26+i*15+3, 52, &steel_tile); break;
|
||||
case 5:
|
||||
dimage(26+i*15+3, 52, &wood_tile); break;
|
||||
case 6:
|
||||
dimage(26+i*15+3, 52, &woodplanks_tile); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -219,6 +225,8 @@ void drawdetailinv(){
|
|||
dimage(5, pos, &steel_tile); break;
|
||||
case 5:
|
||||
dimage(5, pos, &wood_tile); break;
|
||||
case 6:
|
||||
dimage(5, pos, &woodplanks_tile); break;
|
||||
}
|
||||
itoa(player.inventorynum[i], tmp_char);
|
||||
dtext(20, pos, C_BLACK, tmp_char);
|
||||
|
@ -231,9 +239,49 @@ void drawdetailinv(){
|
|||
}
|
||||
}
|
||||
void drawcrafting(){
|
||||
int i;
|
||||
dfont(µfont);
|
||||
dimage(32, 0, &craftselection);
|
||||
dimage(4, 28, &arrow_2);
|
||||
dimage(116, 28, &arrow_1);
|
||||
switch(craftingitem[crafting.selected]){
|
||||
case 1:
|
||||
dimage(36, 28, &soil_tile); break;
|
||||
case 2:
|
||||
dimage(36, 28, &stone_tile); break;
|
||||
case 3:
|
||||
dimage(36, 28, &coal_tile); break;
|
||||
case 4:
|
||||
dimage(36, 28, &steel_tile); break;
|
||||
case 5:
|
||||
dimage(36, 28, &wood_tile); break;
|
||||
case 6:
|
||||
dimage(36, 28, &woodplanks_tile); break;
|
||||
}
|
||||
pos = 4;
|
||||
for(i=crafting.selected*CRAFTSIZE;i!=(crafting.selected+1)*CRAFTSIZE;i++){
|
||||
if(craftingsnum[i]!=0){
|
||||
switch(craftingsitems[i]){
|
||||
case 1:
|
||||
dtext(58, pos, C_BLACK, SOIL_TILE); break;
|
||||
case 2:
|
||||
dtext(58, pos, C_BLACK, STONE_TILE); break;
|
||||
case 3:
|
||||
dtext(58, pos, C_BLACK, COAL_TILE); break;
|
||||
case 4:
|
||||
dtext(58, pos, C_BLACK, STEEL_TILE); break;
|
||||
case 5:
|
||||
dtext(58, pos, C_BLACK, WOOD_TILE); break;
|
||||
case 6:
|
||||
dtext(58, pos, C_BLACK, WOODPLANKS_TILE); break;
|
||||
}
|
||||
itoa(craftingsnum[i], tmp_char);
|
||||
dtext(46, pos, C_BLACK, tmp_char);
|
||||
dtext(52, pos, C_BLACK, MULTIPLY);
|
||||
pos+=6;
|
||||
}
|
||||
}
|
||||
dfont(dfont_default());
|
||||
}
|
||||
int main(void) {
|
||||
dclear(C_WHITE);
|
||||
|
@ -551,11 +599,21 @@ int main(void) {
|
|||
}
|
||||
clearevents();
|
||||
if (keydown(KEY_LEFT)){
|
||||
if(crafting.selected>0){
|
||||
crafting.selected--;
|
||||
}else{
|
||||
crafting.selected=CRAFTINGS-1;
|
||||
}
|
||||
while(keydown(KEY_LEFT)){
|
||||
clearevents();
|
||||
}
|
||||
}
|
||||
if (keydown(KEY_RIGHT)){
|
||||
if(crafting.selected<CRAFTINGS-1){
|
||||
crafting.selected++;
|
||||
}else{
|
||||
crafting.selected=0;
|
||||
}
|
||||
while(keydown(KEY_RIGHT)){
|
||||
clearevents();
|
||||
}
|
||||
|
|
|
@ -3,4 +3,11 @@
|
|||
# define WORLDGEN_INFO "Generation ..." // Text when waiting for world generation.
|
||||
# define SELECTED "<" // Selected block info.
|
||||
# define MOVING "M" // Moving block info.
|
||||
# define INV_INFO "INVENTAIRE & CRAFTING"
|
||||
# define INV_INFO "INVENTAIRE & CRAFTING"
|
||||
# define SOIL_TILE "Terre"
|
||||
# define STONE_TILE "Pierre"
|
||||
# define COAL_TILE "Charbon"
|
||||
# define STEEL_TILE "M. aci."
|
||||
# define WOOD_TILE "Bois"
|
||||
# define WOODPLANKS_TILE "Planche"
|
||||
# define MULTIPLY "x"
|
|
@ -30,17 +30,11 @@ struct Crafting{
|
|||
int ispossible;
|
||||
};
|
||||
const int craftingsitems[CRAFTINGS*CRAFTSIZE] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
5, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
const int craftingsnum[CRAFTINGS*CRAFTSIZE] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
1, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
const int craftingitem[CRAFTINGS] = {
|
||||
0,
|
||||
0,
|
||||
0
|
||||
6,
|
||||
};
|
Loading…
Reference in New Issue