This commit is contained in:
Tituya 2021-03-13 22:05:55 +01:00
parent 32d32070c6
commit 9be21c70fb
11 changed files with 36 additions and 53 deletions

View File

@ -7,6 +7,7 @@ project(MyAddin)
include(GenerateG1A)
include(GenerateG3A)
include(Fxconv)
include_directories(include)
find_package(Gint 2.1 REQUIRED)
set(SOURCES
@ -33,10 +34,7 @@ add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}})
target_compile_options(myaddin PRIVATE -Wall -Wextra -Os)
target_link_libraries(myaddin Gint::Gint)
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
generate_g1a(TARGET myaddin OUTPUT "MyAddin.g1a"
NAME "MyAddin" ICON assets-fx/icon.png)
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
if("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
generate_g3a(TARGET myaddin OUTPUT "isometric.g3a"
NAME "isometri" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png)
endif()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 704 B

After

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 901 B

After

Width:  |  Height:  |  Size: 956 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 819 B

After

Width:  |  Height:  |  Size: 869 B

2
include/drawiso.h Normal file
View File

@ -0,0 +1,2 @@
void draw_map_player(int map[], int taillex, int tailley, int taillemap, char isometric);
void draw(int posx, int posy, char isometric, bopti_image_t *image, int height);

View File

@ -6,33 +6,15 @@
extern bopti_image_t img_1;
extern bopti_image_t img_2;
extern bopti_image_t img_3;
extern bopti_image_t img_3;
void draw_map_at(tile_t map[], int posx, int posy, int width) {
int j = 0;
int x = 0;
for(int i=0; i < width; i++) {
switch(map[i]) {
case 1:
draw_iso(x,j,posx,posy,&img_1);
break;
case 2:
draw_iso(x,j,posx,posy,&img_2);
break;
case 3:
draw_from_bottom(x,j,posx,posy,&img_3,16);
break;
case 9:
draw_iso(x,j,posx,posy,&img_3);
break;
}
x++;
if(!(i%level_width) && i != 0) { j++; x = 0; }
}
dupdate();
}
void draw_map_player(tile_t map[], int indx, int indy, int taillemap) {
/* generate and draw the map around the player (player_view)
* @param map : the map you want to draw
* @param indx : the virtual x position of the player
* @param indy : the virtual y position of the player
* @param taillemap : the length of the map
* @param isometric : 0 = top view, 1 = isometric view
*/
void draw_map_player(int map[], int indx, int indy, int taillemap, char isometric) {
int j = 0;
int x = 0;
@ -88,16 +70,13 @@ void draw_map_player(tile_t map[], int indx, int indy, int taillemap) {
int y = j + (2-ycentre);
switch(map[i]) {
case 1:
draw_iso(x,y,150,60,&img_1);
draw(x,y,isometric,&img_1,0);
break;
case 2:
draw_iso(x,y,150,60,&img_2);
draw(x,y,isometric,&img_2,0);
break;
case 3:
draw_from_bottom(x,y,150,60,&img_3,16);
break;
case 9:
draw_iso(x,y,150,60,&img_3);
case 3:
draw(x,y,isometric,&img_3,16);
break;
}
x++;
@ -109,10 +88,17 @@ void draw_map_player(tile_t map[], int indx, int indy, int taillemap) {
}
}
void draw_iso(int i, int j, int posx, int posy, bopti_image_t *image) {
dimage(posx+(-j*tile+i*tile),posy+((i*tile/2)+(j*tile/2)),image);
}
void draw_from_bottom(int i, int j, int posx, int posy, bopti_image_t *image, int height) {
draw_iso(i,j,posx,posy-height,image);
/* draw at a certain position the block depends of the type of view
* @param posx : where to draw on the x axis
* @param posy : where to draw on the y axis
* @param isometric : type of view
* @param image : the texture
* @param height : draw the block upper. If you need to draw a higher block
*/
void draw(int posx, int posy, char isometric, bopti_image_t *image, int height) {
if(isometric) {
dsubimage(150+(-posy*tile+posx*tile),60-height+((posx*tile/2)+(posy*tile/2)),image,0,0,32,32+height,DIMAGE_NONE);
} else {
dsubimage(150+(posx-3)*tile*2,60+(posy-1)*tile*2,image,0,32+height,32,32,DIMAGE_NONE);
}
}

View File

@ -1,6 +0,0 @@
typedef uint8_t tile_t;
void draw_map_at(tile_t map[], int taillex, int tailley, int width);
void draw_map_player(tile_t map[], int taillex, int tailley, int taillemap);
void draw_iso(int i, int j, int posx, int posy, bopti_image_t *image);
void draw_from_bottom(int i, int j, int posx, int posy, bopti_image_t *image, int height);

View File

@ -8,18 +8,19 @@
int main(void)
{
dclear(C_WHITE);
tile_t map[450] = { 0, 0, 0, 1, 2, 0, 2, 2, 3, 0, 0, 2, 0, 1, 3, 0, 0, 0, 3, 0, 0, 3, 3, 0, 3, 2, 2, 2, 3, 0, 1, 0, 0, 2, 0, 3, 1, 2, 2, 0, 1, 1, 2, 0, 2, 2, 3, 2, 2, 1, 3, 0, 3, 1, 0, 2, 2, 1, 2, 1, 3, 3, 1, 3, 2, 2, 3, 1, 1, 1, 3, 0, 2, 2, 3, 2, 1, 1, 2, 3, 1, 3, 3, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 2, 1, 0, 1, 0, 3, 2, 2, 0, 2, 3, 0, 3, 0, 2, 2, 1, 1, 2, 2, 3, 0, 2, 2, 2, 3, 1, 3, 2, 1, 1, 1, 3, 1, 2, 2, 1, 3, 2, 0, 2, 2, 2, 0, 2, 2, 3, 3, 0, 1, 1, 0, 2, 0, 1, 0, 2, 2, 2, 3, 0, 3, 1, 3, 3, 0, 3, 0, 0, 0, 3, 0, 1, 0, 0, 1, 3, 3, 1, 2, 1, 0, 1, 3, 3, 3, 0, 0, 0, 1, 3, 3, 0, 2, 1, 3, 1, 0, 2, 1, 2, 3, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 0, 1, 0, 0, 2, 0, 3, 3, 1, 2, 2, 1, 1, 1, 3, 1, 0, 0, 1, 2, 1, 0, 1, 1, 3, 1, 3, 2, 1, 0, 1, 3, 3, 2, 2, 1, 0, 1, 2, 3, 3, 1, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 1, 3, 1, 1, 2, 2, 2, 2, 1, 1, 1, 2, 3, 3, 3, 3, 2, 1, 1, 1, 1, 3, 3, 1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 3, 1, 0, 0, 1, 2, 1, 0, 1, 1, 3, 1, 3, 2, 1, 0, 1, 3, 3, 2, 2, 1, 0, 1, 2, 3, 3, 1, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 1, 3, 1, 1, 2, 2, 2, 2, 1, 1, 1, 2, 3, 3, 3, 3, 2, 1, 1, 1, 1, 3, 3, 1, 0, 1, 0, 0, 1, 1, 3, 2, 2, 2, 0, 0, 1, 1, 0, 3, 3, 3, 2, 3, 1, 2, 1, 1, 0, 1, 1, 0, 0, 2, 0, 0, 2, 1, 1, 2, 0, 0, 3, 2, 0, 2, 3, 3, 2, 0, 3, 2, 3, 2, 0, 0, 3, 0, 2, 0, 1, 0, 3, 3, 3, 0, 1, 3, 3, 0, 0, 0, 0, 0, 3, 0, 0, 3, 0, 0, 0, 0, 1, 0, 3, 1, 1, 3, 2, 0, 0, 2, 1, 0, 1, 0, 3, 0, 1, 1, 3, 3, 0, 1, 2, 2, 3, 0, 1, 1, 1, 0 };
int x = 5;
int y = 2;
int buffer = 0;
int nbtiles = 400;
char view_type = 0;
while(1)
{
dclear(C_WHITE);
//draw_map_at(map,80,30,50);
draw_map_player(map,x,y,nbtiles);
draw_map_player(map,x,y,nbtiles,view_type);
draw_player(3,1);
dprint(1,1,C_BLACK,"(%d;%d)",x,y);
dprint(1,30,C_BLACK,"%d",map[x+y*level_width]);
@ -29,11 +30,13 @@ int main(void)
{
break;
}
if(keydown(KEY_F1)) view_type = 0;
if(keydown(KEY_F2)) view_type = 1;
if(keydown(KEY_RIGHT) && x+1 < level_width && !buffer) x+=1;
if(keydown(KEY_LEFT) && x > 0 && !buffer) x-=1;
if(keydown(KEY_UP) && y > 0 && !buffer) y-=1;
if(keydown(KEY_DOWN) && y+1 < nbtiles/level_width && !buffer) y+=1;
if(keydown_any(KEY_RIGHT,KEY_LEFT,KEY_UP,KEY_DOWN)) {
if(keydown_any(KEY_RIGHT,KEY_LEFT,KEY_UP,KEY_DOWN,KEY_SHIFT)) {
buffer = 1;
} else {
buffer = 0;

View File

@ -6,5 +6,5 @@
extern bopti_image_t img_player;
void draw_player(int posx, int posy) {
draw_iso(posx,posy,150,60,&img_player);
dimage(150+(-posy*tile+posx*tile),60+((posx*tile/2)+(posy*tile/2)),&img_player);
}