From 6a4d9d52a2a5cf0dc915476c59de02b4b06bfdf7 Mon Sep 17 00:00:00 2001 From: SlyVTT Date: Thu, 11 May 2023 22:37:22 +0200 Subject: [PATCH] Save --- fxlink-image-2023.05.11-21h50-1.png | Bin 0 -> 5287 bytes src/level.cpp | 8 +- src/main.cpp | 18 +- src/player copy.cpp | 257 ---------------------------- src/player.cpp | 14 +- src/utilities.cpp | 2 +- src/utilities.h | 2 +- 7 files changed, 22 insertions(+), 279 deletions(-) create mode 100644 fxlink-image-2023.05.11-21h50-1.png delete mode 100644 src/player copy.cpp diff --git a/fxlink-image-2023.05.11-21h50-1.png b/fxlink-image-2023.05.11-21h50-1.png new file mode 100644 index 0000000000000000000000000000000000000000..657dd35076fbf9750b56f7d941b36a77cfca5e27 GIT binary patch literal 5287 zcmZu#cT`i$w+=;71OY{*Nv~15fFL1JI;eppTtK8;loo`bh=dl3G?5w*kP@U5lyaq) zP!v#*VlaRL1|f8%1cVR*5=QgjvH}Yw4?l2EHXSf+vR`8&EZD%@E|6pF<+-IzyhOk;C=q~ddbby>;qqrNGPlI`Wr5m_d}k%jV-WDQs) z!C(1$Eh%^JysMscC3bn(`CSR4n?oM`y5XR(G@nU`L{rKDul#wey|NFFx)zpn5ER4T$VEV^b|lTSj*_b=?DBiiw~ zq=MkJu&R>93Ddl+5b8sVo?9CKbu>w~H3zzf_4v2QNbH$R%clO{fXOwGBa9em1FhR9 z8eg9_N<;t0kucjDh%%j|)I`QeXKXNKXysD~a0ROy~gd&@)Tn^P&y zMbL}=_`z5tH3&(zY645N7l03*!NB;SsvC|4aG*Ke4U>hKA8 zw2sd zI-#fvcq6Gcau&xy?Hg$vR&wst_B|97039$k_6W(_#9yTn7eU=qVqJA^T}qu&P^S=pgi zsvKvew{|}Mf_@{nihucj_>xr7a-Ph|>p7?RL6e$8 z0-3&hv(Dh@6|D>o>UloKsRvs;wBs6qfww$k%slWkrtP!!K#L&7@U+IWXKT`R@pY7Z zoeVpsQv~`skgsV#(=y?Veys3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MAGE_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 ) ); + if (textbacktile) azrp_draw_text( i*16, j*16, "%d", GetTileBackgroundINT( i, j ) ); + if (textforetile) azrp_draw_text( i*16+8, j*16+8, "%d", GetTileForegroundINT( i, j ) ); #endif } } @@ -137,8 +137,8 @@ void Level::Render( void ) 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_draw_text( i*16+1, j*16+1, "B=%d", GetTileBackgroundINT( i, j ) ); + //azrp_draw_text( i*16+1, j*16+1, "F=%d", GetTileForegroundINT( i, j ) ); } diff --git a/src/main.cpp b/src/main.cpp index 73ddfde..6f57b28 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -120,15 +120,15 @@ static void render( void ) // MyPlayer.Render(); #if(BIAS) - if (texttodraw>=1) Azur_draw_text(1,01, "FPS = %.0f", (float) (1000.0f / elapsedTime) ); + if (texttodraw>=1) azrp_draw_text(1,01, "FPS = %.0f", (float) (1000.0f / elapsedTime) ); - if (texttodraw>=2) Azur_draw_text(1,31, "Update = %.3f ms", (float) time_update / 1000.0f ); - if (texttodraw>=2) Azur_draw_text(1,41, "Render = %.3f ms", (float) time_render / 1000.0f ); - if (texttodraw>=2) Azur_draw_text(1,51, ">Total = %.0f ms", (float) elapsedTime ); + if (texttodraw>=2) azrp_draw_text(1,31, "Update = %.3f ms", (float) time_update / 1000.0f ); + if (texttodraw>=2) azrp_draw_text(1,41, "Render = %.3f ms", (float) time_render / 1000.0f ); + if (texttodraw>=2) azrp_draw_text(1,51, ">Total = %.0f ms", (float) elapsedTime ); - if (texttodraw>=3) Azur_draw_text(1,81, "Mem Used : %d", _uram_stats->used_memory + extram_stats->used_memory); - if (texttodraw>=3) Azur_draw_text(1,91, "Mem Free : %d", _uram_stats->free_memory + extram_stats->free_memory); - if (texttodraw>=3) Azur_draw_text(1,101, "Mem Peak Used : %d", _uram_stats->peak_used_memory + extram_stats->peak_used_memory ); + if (texttodraw>=3) azrp_draw_text(1,81, "Mem Used : %d", _uram_stats->used_memory + extram_stats->used_memory); + if (texttodraw>=3) azrp_draw_text(1,91, "Mem Free : %d", _uram_stats->free_memory + extram_stats->free_memory); + if (texttodraw>=3) azrp_draw_text(1,101, "Mem Peak Used : %d", _uram_stats->peak_used_memory + extram_stats->peak_used_memory ); #endif } @@ -291,9 +291,9 @@ int main(void) render(); - Azur_draw_text(1,01, "FPS = %.0f", (float) (1000.0f / elapsedTime) ); + azrp_draw_text(1,01, "FPS = %.0f", (float) (1000.0f / elapsedTime) ); - //azrp_circle( 198, 112, 20, C_RED ); + azrp_circle( 198, 112, 40, C_RED ); azrp_update(); } diff --git a/src/player copy.cpp b/src/player copy.cpp deleted file mode 100644 index 07674b1..0000000 --- a/src/player copy.cpp +++ /dev/null @@ -1,257 +0,0 @@ -#include "player.h" -#include -#include -#include "level.h" -#include "utilities.h" - -/* -extern bopti_image_t img_walking; -extern bopti_image_t img_running; -extern bopti_image_t img_static; -*/ - -extern bopti_image_t img_circle; - -static uint32_t framecounter = 0; - -extern Level MyLevel; - -#define SPEEDWALK 6.0f -#define SPEEDRUN 12.0f -#define SPEEDSTATIC 0.0f - -#define SPEEDJUMPWALK 4.0f -#define SPEEDJUMPRUN 12.0f -#define SPEEDJUMPSTATIC 8.0f - -#define MAXFALLSPEED 20.0f - - -Player::Player( int16_t _x, int16_t _y ) -{ - this->x = _x; - this->y = _y; - - this->vx = 0.0f; - this->vy = 0.0f; - - this->ax = 0.0f; - this->ay = 1.0f; - - this->width = 8; - this->height = 8; - - this->xmin = (int) this->x - this->width; - this->xmax = (int) this->x + this->width; - this->ymin = (int) this->y - this->height; - this->ymax = (int) this->y + this->height; - - last_tick = rtc_ticks(); -} - -Player::~Player() -{ - - -} - - - - -void Player::Update( float dt ) -{ - float DeltaTime = dt / 100.0f ; - - //this->vx += this->ax * DeltaTime; // horizontal acceleration not considered (yet) - this->vy += this->ay * DeltaTime; - - if (this->vy >= MAXFALLSPEED) this->vy = MAXFALLSPEED; - - // we were jumping and are reaching the top of the curve or even starting falling - if (this->action == JUMP && this->vy >= 0) - { - this->action = FALL; - } - - this->nextx = this->x + this->vx * DeltaTime; - this->nexty = this->y + this->vy * DeltaTime; - - - bool testdestination = MyLevel.CanGo( this ); // true if we can go to the planed position - - if (testdestination) - { - this->x = this->nextx; - this->y = this->nexty; - } - else if(this->action == JUMP) - { - this->vx = 0; - this->vy = 0; - this->action = FALL; - } - else - { - this->vx = 0; - this->vy = 0; - this->action = STATIC; - } - - xmin = (int) x - width; - xmax = (int) x + width; - ymin = (int) y - height; - ymax = (int) y + height; - -} - -void Player::Render( void ) -{ - uint32_t temptick = rtc_ticks(); - if (temptick-last_tick>=10) - { - last_tick = temptick; - framecounter++; - } - /* - if (action==RUN) - { - uint8_t frameinternal = framecounter % 8; - azrp_subimage_p8_effect(xmin, ymin, &img_running, frameinternal*16, 0, 16, 16, direction==RIGHT ? DIMAGE_NONE : IMAGE_HFLIP ); - } - else if (action==WALK) - { - uint8_t frameinternal = framecounter % 7; - azrp_subimage_p8_effect(xmin, ymin, &img_walking, frameinternal*16, 0, 16, 16, direction==RIGHT ? DIMAGE_NONE : IMAGE_HFLIP ); - } - else if (action==STATIC) - { - uint8_t frameinternal = framecounter % 8; - azrp_subimage_p8_effect(xmin, ymin, &img_static, frameinternal*16, 0, 16, 16, DIMAGE_NONE); - } - */ - - azrp_image_p8_effect(xmin, ymin, &img_circle, DIMAGE_NONE); - - -} - -/* -void Player::Walk_Left( float dt ) -{ - if ( this->action != JUMP && this->action != FALL ) - { - this->vx -= 1.0f; - - if ( this->vx <= SPEEDWALK*-1.0f ) - this->vx = -1.0f*SPEEDWALK; - - this->direction = LEFT; - this->action = WALK; - } - - this->Update( dt ); -} - -void Player::Walk_Right( float dt ) -{ - if ( this->action != JUMP && this->action != FALL ) - { - this->vx += 1.0f; - - if ( this->vx >= SPEEDWALK ) - this->vx = SPEEDWALK; - - this->direction = RIGHT; - this->action = WALK; - } - - this->Update( dt ); -} -*/ - -void Player::Run_Left( float dt ) -{ - if ( this->action != JUMP && this->action != FALL ) - { - this->vx -= 1.0f; - - if ( this->vx <= -SPEEDRUN ) - this->vx = -SPEEDRUN; - - this->direction = LEFT; - this->action = RUN; - } - - this->Update( dt ); -} - -void Player::Run_Right( float dt ) -{ - if ( this->action != JUMP && this->action != FALL ) - { - this->vx += 1.0f; - - if ( this->vx >= SPEEDRUN ) - this->vx = SPEEDRUN; - - this->direction = RIGHT; - this->action = RUN; - } - - this->Update( dt ); -} - -void Player::Jump( float dt ) -{ - // check if we are already jumping or not - if (this->action != JUMP && this->action != FALL) // not in a jump or in a fall - { - /* - if ( this->action == WALK ) - { - this->vy -= SPEEDJUMPWALK; - } - else - */ - if ( this->action == RUN ) - { - this->vy -= SPEEDJUMPRUN; - } - else - { - this->vy -= SPEEDJUMPSTATIC; - } - } - else if ( this->action == FALL) // descending phase (FALL) of a jump, we can start a new small jump - { - this->vy -= SPEEDJUMPSTATIC; - } - else - { - - } - - this->action = JUMP; - - this->Update( dt ); -} - -void Player::No_Order( float dt ) -{ - - if (this->action == RUN || this->action == WALK) - { - this->action = BREAK; - - this->vx *= 0.9; - - if (ABS(this->vx) <= 0.2 ) - { - this->vx = 0; - this->action = STATIC; - this->direction = STATIC; - } - } - - this->Update( dt ); -} diff --git a/src/player.cpp b/src/player.cpp index cc44e27..f429de3 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -82,13 +82,13 @@ void Player::Render( void ) azrp_image_p8_effect((int) (this->currx*16.0f), (int) (this->curry*16.0f), &img_circle, DIMAGE_NONE); #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" ); + if (this->action==STATIC) azrp_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "S" ); + else if (this->action==DRAFT) azrp_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "D" ); + else if (this->action==WALK) azrp_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "W" ); + else if (this->action==RUN) azrp_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "R" ); + else if (this->action==JUMP) azrp_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "J" ); + else if (this->action==FALL) azrp_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "F" ); + else azrp_draw_text( (int) (this->currx*16.0f+4.0f), (int) (this->curry*16.0f+4.0f) , "X" ); #endif } diff --git a/src/utilities.cpp b/src/utilities.cpp index 570ddac..7c0a510 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -7,7 +7,7 @@ #include /* Render text with Azur images - quite bad, but I don't have time lol. */ -void Azur_draw_text(int x, int y, char const *fmt, ...) +void azrp_draw_text(int x, int y, char const *fmt, ...) { char str[128]; va_list args; diff --git a/src/utilities.h b/src/utilities.h index d6f39f7..66616ad 100644 --- a/src/utilities.h +++ b/src/utilities.h @@ -1,7 +1,7 @@ #ifndef UTILITIES_H #define UTILITIES_H -void Azur_draw_text(int x, int y, char const *fmt, ...); +void azrp_draw_text(int x, int y, char const *fmt, ...); #define ABS(a) ( ( (a) >= 0 ) ? (a) : -(a) )