some small improvements + added tile background/foreground color change with subimage DYE effect/clear

This commit is contained in:
Sylvain PILLOT 2023-05-07 22:05:25 +02:00
parent 2aaadbfb11
commit 0ad32f6297
8 changed files with 57 additions and 33 deletions

View File

@ -5,4 +5,4 @@
tileset.png:
type: bopti-image
name: img_tilesetnpp
profile: p8_rgb565a
profile: rgb565a

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -1,3 +1,6 @@
#include "parameters.h"
#include "level.h"
#include "player.h"
#include <azur/azur.h>
@ -25,6 +28,9 @@ extern bool drawborders;
extern bool textbacktile;
extern bool textforetile;
extern uint16_t tilecolor;
extern std::vector<Border*> MyLevelBorders;
@ -97,36 +103,39 @@ void Level::Render( void )
{
uint16_t xtile = (currentTile % map_level->tileset_size) * 16;
uint16_t ytile = (currentTile / map_level->tileset_size) * 16;
azrp_subimage_p8( i*16, j*16, map_level->tileset, xtile, ytile, 16, 16, DIMAGE_NONE );
if (textbacktile) Azur_draw_text( i*16, j*16, "%d", GetTileBackgroundINT( i, j ) );
if (textforetile) Azur_draw_text( i*16+8, j*16+8, "%d", GetTileForegroundINT( i, j ) );
if (u==0) azrp_subimage_rgb16_dye( i*16, j*16, map_level->tileset, xtile, ytile, 16, 16, IMAGE_DYE | IMAGE_NOCLIP_INPUT, tilecolor );
else azrp_subimage_rgb16( i*16, j*16, map_level->tileset, xtile, ytile, 16, 16, DIMAGE_NONE | IMAGE_NOCLIP_INPUT );
#if(DEBUG_MODE)
if (textbacktile) Azur_draw_text( i*16, j*16, "%d", GetTileBackgroundINT( i, j ) );
if (textforetile) Azur_draw_text( i*16+8, j*16+8, "%d", GetTileForegroundINT( i, j ) );
#endif
}
}
}
}
if (drawborders)
for( int i=0; i<MyLevelBorders.size(); i++)
azrp_line( (int) MyLevelBorders[i]->A.x, (int) MyLevelBorders[i]->A.y,
(int) MyLevelBorders[i]->B.x, (int) MyLevelBorders[i]->B.y,
C_GREEN );
if (drawnormals)
for( int i=0; i<MyLevelBorders.size(); i++)
azrp_line( ((int) MyLevelBorders[i]->A.x+(int) MyLevelBorders[i]->B.x)/2, ((int) MyLevelBorders[i]->A.y+(int) MyLevelBorders[i]->B.y)/2,
((int) MyLevelBorders[i]->A.x+(int) MyLevelBorders[i]->B.x)/2 + (int) MyLevelBorders[i]->N.x/2, ((int) MyLevelBorders[i]->A.y+(int) MyLevelBorders[i]->B.y)/2 + (int) MyLevelBorders[i]->N.y/2,
C_BLUE );
#if(DEBUG_MODE)
if (drawborders)
for( int i=0; i<MyLevelBorders.size(); i++)
azrp_line( (int) MyLevelBorders[i]->A.x, (int) MyLevelBorders[i]->A.y,
(int) MyLevelBorders[i]->B.x, (int) MyLevelBorders[i]->B.y,
C_GREEN );
if (drawnormals)
for( int i=0; i<MyLevelBorders.size(); i++)
azrp_line( ((int) MyLevelBorders[i]->A.x+(int) MyLevelBorders[i]->B.x)/2, ((int) MyLevelBorders[i]->A.y+(int) MyLevelBorders[i]->B.y)/2,
((int) MyLevelBorders[i]->A.x+(int) MyLevelBorders[i]->B.x)/2 + (int) MyLevelBorders[i]->N.x/2, ((int) MyLevelBorders[i]->A.y+(int) MyLevelBorders[i]->B.y)/2 + (int) MyLevelBorders[i]->N.y/2,
C_BLUE );
#endif
}
void Level::RenderSelected( uint8_t i, uint8_t j )
{
azrp_image_p8( i*16, j*16, &img_selected, DIMAGE_NONE );
Azur_draw_text( i*16+1, j*16+1, "B=%d", GetTileBackgroundINT( i, j ) );
Azur_draw_text( i*16+1, j*16+1, "F=%d", GetTileForegroundINT( i, j ) );
//azrp_image_p8( i*16, j*16, &img_selected, DIMAGE_NONE );
//Azur_draw_text( i*16+1, j*16+1, "B=%d", GetTileBackgroundINT( i, j ) );
//Azur_draw_text( i*16+1, j*16+1, "F=%d", GetTileForegroundINT( i, j ) );
}

View File

@ -1,7 +1,5 @@
#define DEBUG_MODE 1
#define BIAS 1
#define NOBIAS (1-BIAS)
#include "parameters.h"
#include <azur/azur.h>
#include <azur/gint/render.h>
@ -70,6 +68,10 @@ bool drawforeground = true;
bool drawnormals = false;
bool drawborders = false;
uint16_t tilecolor = C_BLACK;
uint16_t backcolor = C_WHITE;
static void hook_prefrag(int id, void *fragment, int size)
{
if(!screenshot && !record)
@ -286,7 +288,7 @@ int main(void)
{
// all the stuff to be rendered should be put here
azrp_clear( C_WHITE );
azrp_clear( backcolor );
render();

9
src/parameters.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef PARAMETERS_H
#define PARAMETERS_H
#define DEBUG_MODE 1
#define BIAS 1
#define NOBIAS (1-BIAS)
#endif

View File

@ -1,3 +1,6 @@
#include "parameters.h"
#include "player.h"
#include <num/num.h>
#include <gint/rtc.h>
@ -78,15 +81,16 @@ void Player::Render( void )
azrp_image_p8_effect((int) (this->currx*16.0f), (int) (this->curry*16.0f), &img_circle, DIMAGE_NONE);
if (this->action==STATIC) Azur_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "S" );
else if (this->action==DRAFT) Azur_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "D" );
else if (this->action==WALK) Azur_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "W" );
else if (this->action==RUN) Azur_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "R" );
else if (this->action==JUMP) Azur_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "J" );
else if (this->action==FALL) Azur_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "F" );
else Azur_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "X" );
#if(DEBUG_MODE)
if (this->action==STATIC) Azur_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "S" );
else if (this->action==DRAFT) Azur_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "D" );
else if (this->action==WALK) Azur_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "W" );
else if (this->action==RUN) Azur_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "R" );
else if (this->action==JUMP) Azur_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "J" );
else if (this->action==FALL) Azur_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "F" );
else Azur_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "X" );
#endif
}