From a17ce759dd046448d078b29226f011b739782440 Mon Sep 17 00:00:00 2001 From: Slyvtt Date: Sat, 28 Jan 2023 21:22:51 +0100 Subject: [PATCH] WIP Keyboard enhanced manager Part 2 - WIP --- TODO.txt | 2 +- assets-cg/Levels/Level1.json | 32 +++++ assets-cg/Levels/Tileset_Space.json | 14 +++ .../__pycache__/converters.cpython-310.pyc | Bin 0 -> 1512 bytes src/extrakeyboard.cpp | 111 ++++++++++++++---- src/extrakeyboard.h | 16 +-- src/main.cpp | 60 +++------- 7 files changed, 158 insertions(+), 77 deletions(-) create mode 100644 assets-cg/Levels/Level1.json create mode 100644 assets-cg/Levels/Tileset_Space.json create mode 100644 assets-cg/__pycache__/converters.cpython-310.pyc diff --git a/TODO.txt b/TODO.txt index 0aa947f..8e81a3c 100644 --- a/TODO.txt +++ b/TODO.txt @@ -16,7 +16,7 @@ The SHMUP Todo list : - possibilité de transformer les trajectoires (grossissement/rétrécissement, translation et rotation) Partie interaction / gameplay : -- implémen./buildter les tirs ennemis (avec une IA minimale) +- implémenter les tirs ennemis (avec une IA minimale) - implémenter les hits des tirs ennemis sur le joueur - implémenter les collisions avec les ennemies - implémenter le tir des satellites diff --git a/assets-cg/Levels/Level1.json b/assets-cg/Levels/Level1.json new file mode 100644 index 0000000..e62f68b --- /dev/null +++ b/assets-cg/Levels/Level1.json @@ -0,0 +1,32 @@ +{ "compressionlevel":-1, + "height":14, + "infinite":false, + "layers":[ + { + "data":[52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 23, 19, 94, 93, 22, 23, 122, 124, 23, 19, 20, 21, 22, 23, 122, 124, 23, 19, 94, 93, 22, 23, 122, 124, 23, 19, 20, 21, 22, 23, 122, 124, 23, 19, 94, 93, 22, 23, 122, 124, 23, 19, 20, 21, 22, 23, 122, 124, 23, 19, 94, 93, 22, 23, 122, 124, 23, 19, 20, 21, 22, 23, 122, 124, 23, 19, 94, 93, 22, 23, 122, 124, 23, 19, 20, 21, 22, 23, 122, 124, 23, 19, 94, 93, 22, 23, 122, 124, 23, 19, 20, 21, 22, 23, 122, 124, 23, 19, 94, 93, 22, 23, 50, 102, 82, 83, 103, 50, 0, 0, 50, 28, 29, 30, 31, 50, 0, 0, 50, 102, 82, 83, 103, 50, 0, 0, 50, 28, 29, 30, 31, 50, 0, 0, 50, 102, 82, 83, 103, 50, 0, 0, 50, 28, 29, 30, 31, 50, 0, 0, 50, 102, 82, 83, 103, 50, 0, 0, 50, 28, 29, 30, 31, 50, 0, 0, 50, 102, 82, 83, 103, 50, 0, 0, 50, 28, 29, 30, 31, 50, 0, 0, 50, 102, 82, 83, 103, 50, 0, 0, 50, 28, 29, 30, 31, 50, 0, 0, 50, 102, 82, 83, 103, 50, 134, 0, 0, 0, 0, 116, 0, 0, 116, 0, 0, 0, 0, 116, 0, 0, 116, 0, 0, 0, 0, 134, 0, 0, 134, 0, 0, 0, 0, 116, 0, 0, 116, 0, 0, 0, 0, 116, 0, 0, 116, 0, 0, 0, 0, 134, 0, 0, 9, 0, 0, 0, 0, 9, 0, 0, 134, 0, 0, 0, 0, 116, 0, 0, 116, 0, 0, 0, 0, 116, 0, 0, 116, 0, 0, 0, 0, 134, 0, 0, 134, 0, 0, 0, 0, 116, 0, 0, 116, 0, 0, 0, 0, 116, 0, 0, 116, 0, 0, 0, 0, 134, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 134, 0, 0, 134, 0,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, 0, 0, 0, 0, 134, 23, 93, 82, 83, 94, 23, 0, 0, 23, 37, 38, 39, 40, 23, 0, 0, 23, 93, 82, 83, 94, 23, 0, 0, 23, 37, 38, 39, 40, 23, 0, 0, 23, 93, 82, 83, 94, 23, 0, 0, 23, 37, 38, 39, 40, 23, 0, 0, 23, 93, 82, 83, 94, 23, 0, 0, 23, 37, 38, 39, 40, 23, 0, 0, 23, 93, 82, 83, 94, 23, 0, 0, 23, 37, 38, 39, 40, 23, 0, 0, 23, 93, 82, 83, 94, 23, 0, 0, 23, 37, 38, 39, 40, 23, 0, 0, 23, 93, 82, 83, 94, 23, 50, 46, 103, 102, 49, 50, 122, 124, 50, 46, 47, 48, 49, 50, 122, 124, 50, 46, 103, 102, 49, 50, 122, 124, 50, 46, 47, 48, 49, 50, 122, 124, 50, 46, 103, 102, 49, 50, 122, 124, 50, 46, 47, 48, 49, 50, 122, 124, 50, 46, 103, 102, 49, 50, 122, 124, 50, 46, 47, 48, 49, 50, 122, 124, 50, 46, 103, 102, 49, 50, 122, 124, 50, 46, 47, 48, 49, 50, 122, 124, 50, 46, 103, 102, 49, 50, 122, 124, 50, 46, 47, 48, 49, 50, 122, 124, 50, 46, 103, 102, 49, 50, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53, 52, 53], + "height":14, + "id":1, + "name":"Calque de Tuiles 1", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":102, + "x":0, + "y":0 + }], + "nextlayerid":3, + "nextobjectid":1, + "orientation":"orthogonal", + "renderorder":"right-down", + "tiledversion":"1.8.0", + "tileheight":16, + "tilesets":[ + { + "firstgid":1, + "source":"Tileset_Space.tsx" + }], + "tilewidth":16, + "type":"map", + "version":"1.8", + "width":102 +} \ No newline at end of file diff --git a/assets-cg/Levels/Tileset_Space.json b/assets-cg/Levels/Tileset_Space.json new file mode 100644 index 0000000..071b8ae --- /dev/null +++ b/assets-cg/Levels/Tileset_Space.json @@ -0,0 +1,14 @@ +{ "columns":9, + "image":"tileset.png", + "imageheight":240, + "imagewidth":144, + "margin":0, + "name":"Level1_Tiles", + "spacing":0, + "tilecount":135, + "tiledversion":"1.8.0", + "tileheight":16, + "tilewidth":16, + "type":"tileset", + "version":"1.8" +} \ No newline at end of file diff --git a/assets-cg/__pycache__/converters.cpython-310.pyc b/assets-cg/__pycache__/converters.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0ea00271be458238b54f8632d46d0ee7e9f770f0 GIT binary patch literal 1512 zcmZ8h&2J+$6t_K|k9;R>*)$hGD}l&i6Lyi{QdLO1;zqTiJ)lTcG#$Iil$p%b_H?(A zM;x+nMB=~+Ate$Q{vD3Ka_W`iUf_9>t_mLc+3$_thu`}>XRTHp!TA2~KcjCwg#NP3 z!$E-g5~j3-A%+u_;t9rfPZBaA)#^-~YNZoet?tBS4x?|-#A7b=VD%X}MMM7%te_z_ zz6cjAUZ|6ZTFGwMy$ka>O!*jyCJYb2(RW026w*jzO|-M3;NCe!jDkt`WZ8%csj~Em zy3M(9(l8eobnh$ySB)rJ+;E|$@MB1g8!z%g880hTwdSD+Q)xUEiWygbAYt?I_GmoM zQa+Zq$xRq9#xF%SgJUU|bpAE40RnXvp-6Y;Z|6Wdu^-z@!7Tc5FU3q;wV4?h5Ll-L=d7 z4Q9arl^$>&s{vQ8Y*5+J9oRKBSgF?5 z2KUhy_wp9o*WRz_H@M?FSyMN*oNDX#3co<-AC_I!S)sDG^`g6Q$34Br4y?!XTDh-# zV7sgLE4|+JFO|=p?rrT{|ETI$d%B}Bdk>)WXn^|Y(ut9Fe#bvm7zP0KPYf0&P;tU- zH7o2GPiBRP_>zv4d~MKMJihw}#*&Oi!lHEPj;>_3u$4}VbRmuVDrRbKyg83&a}`+BccDoZ zGDEYR!@UI0lQ81O%>}fnab=#wutZq_9KFiog>j%?K$2vV8}IV9jltATl_(-r2x!FO zvuDN;{L;A4>@zTRajUol`P0vhlPh5yo?H$OgoVGbts-ozh?*r;gbf?s*|sjG^MLtE zaBhOd#W!3*nM`9>yO$wUz~3>ZY127<$L%͵lPuMD1>#^T}(tXH`)HCaXeHM|~& z5P_*z;;A)a-0cx+ZTzn!!oF8+m~sT9iw~Uuw@I6POzNbL>o~xB6lCO(9KajUbUfUI zuZz3nu~X>|1LN7pFiVB4ruf8?_kkEchx;V)g>fQzQ@tFO!h--TRzwAi;3&;lk?>;+ QJZa-;q5zy%A8Gpk0xHRd{r~^~ literal 0 HcmV?d00001 diff --git a/src/extrakeyboard.cpp b/src/extrakeyboard.cpp index b7e92b6..ac46845 100644 --- a/src/extrakeyboard.cpp +++ b/src/extrakeyboard.cpp @@ -3,15 +3,32 @@ #include #include + +typedef struct +{ + bool pressed; + bool has_been_pressed; + bool has_been_released; + bool is_hold_pressed; + bool is_hold_released; + uint32_t lasttickevent; +} keyinfo; + + +keyinfo MyKeyMapper[MYKEY_LASTENUM+1]; + + + KeyboardExtra::KeyboardExtra() { uint32_t timer = rtc_ticks(); for(int i=0; i<=MYKEY_LASTENUM; i++) { - MyKeyMapper[i].pressed_lastframe=false; - MyKeyMapper[i].pressed_thisframe=false; + MyKeyMapper[i].pressed=false; MyKeyMapper[i].has_been_pressed=false; MyKeyMapper[i].has_been_released=false; + MyKeyMapper[i].is_hold_pressed=false; + MyKeyMapper[i].is_hold_released=false; MyKeyMapper[i].lasttickevent=timer; } } @@ -33,70 +50,124 @@ void KeyboardExtra::Update( float dt ) { if(ev.key == KEY_F3) // Manage the key sequence for KEY_F3 { - if (ev.type == KEYEV_DOWN || ev.type == KEYEV_HOLD) // We have a keydown event detected in the pollevent queue + if (ev.type == KEYEV_DOWN) // We have a keydown event detected in the pollevent queue { - if(MyKeyMapper[MYKEY_F3].pressed_lastframe) // the key was already pressed so nothing changed + if(MyKeyMapper[MYKEY_F3].pressed) // the key was already pressed so nothing changed { MyKeyMapper[MYKEY_F3].has_been_pressed = false; MyKeyMapper[MYKEY_F3].has_been_released = false; + MyKeyMapper[MYKEY_F3].lasttickevent = timer; + MyKeyMapper[MYKEY_F3].is_hold_pressed = true; + MyKeyMapper[MYKEY_F3].is_hold_released = false; + MyKeyMapper[MYKEY_F3].pressed = true; } else // the key was not pressed, so we can raise the keypressed event { MyKeyMapper[MYKEY_F3].has_been_pressed = true; MyKeyMapper[MYKEY_F3].has_been_released = false; MyKeyMapper[MYKEY_F3].lasttickevent = timer; + MyKeyMapper[MYKEY_F3].is_hold_pressed = false; + MyKeyMapper[MYKEY_F3].is_hold_released = false; + MyKeyMapper[MYKEY_F3].pressed = true; } - // and we update the current status of the key - MyKeyMapper[MYKEY_F3].pressed_lastframe = MyKeyMapper[MYKEY_F3].pressed_thisframe; - MyKeyMapper[MYKEY_F3].pressed_thisframe = true; } else if (ev.type == KEYEV_UP) // We have a keyup event detected in the pollevent queue { - if(MyKeyMapper[MYKEY_F3].pressed_lastframe) // the key was pressed, so we can raise the keypressed event + if(MyKeyMapper[MYKEY_F3].pressed) // the key was pressed, so we can raise the keypressed event { MyKeyMapper[MYKEY_F3].has_been_pressed = false; MyKeyMapper[MYKEY_F3].has_been_released = true; MyKeyMapper[MYKEY_F3].lasttickevent = timer; + MyKeyMapper[MYKEY_F3].is_hold_pressed = false; + MyKeyMapper[MYKEY_F3].is_hold_released = false; + MyKeyMapper[MYKEY_F3].pressed = false; } else // the key was already not pressed so nothing changed { MyKeyMapper[MYKEY_F3].has_been_pressed = false; MyKeyMapper[MYKEY_F3].has_been_released = false; + MyKeyMapper[MYKEY_F3].lasttickevent = timer; + MyKeyMapper[MYKEY_F3].is_hold_pressed = false; + MyKeyMapper[MYKEY_F3].is_hold_released = true; + MyKeyMapper[MYKEY_F3].pressed = false; } - // and we update the current status of the key - MyKeyMapper[MYKEY_F3].pressed_lastframe = MyKeyMapper[MYKEY_F3].pressed_thisframe; - MyKeyMapper[MYKEY_F3].pressed_thisframe = false; } } - else MyKeyMapper[MYKEY_F3].pressed_lastframe = MyKeyMapper[MYKEY_F3].pressed_thisframe; - + else + { + MyKeyMapper[MYKEY_F3].has_been_pressed = false; + MyKeyMapper[MYKEY_F3].has_been_released = false; + + if (MyKeyMapper[MYKEY_F3].pressed) + { + MyKeyMapper[MYKEY_F3].is_hold_pressed = true; + MyKeyMapper[MYKEY_F3].is_hold_released = false; + } + else + { + MyKeyMapper[MYKEY_F3].is_hold_pressed = false; + MyKeyMapper[MYKEY_F3].is_hold_released = true; + } + } if(ev.key == KEY_EXIT) { - if (ev.type == KEYEV_DOWN || ev.type == KEYEV_HOLD) + if (ev.type == KEYEV_DOWN) { - MyKeyMapper[MYKEY_EXIT].pressed_lastframe = MyKeyMapper[MYKEY_EXIT].pressed_thisframe; - MyKeyMapper[MYKEY_EXIT].pressed_thisframe = true; + MyKeyMapper[MYKEY_EXIT].pressed = true; } } } } -bool KeyboardExtra::IsKeyPressed( int key ) +bool KeyboardExtra::IsKeyPressedEvent( int key ) { return MyKeyMapper[key].has_been_pressed; } -bool KeyboardExtra::IsKeyReleased( int key ) +bool KeyboardExtra::IsKeyReleasedEvent( int key ) { return MyKeyMapper[key].has_been_released; } -bool KeyboardExtra::IsKeyOn( int key ) +bool KeyboardExtra::IsKeyPressed( int key ) { - return MyKeyMapper[key].pressed_thisframe; + return MyKeyMapper[key].pressed; } + + +bool KeyboardExtra::IsKeyReleased( int key ) +{ + return (!MyKeyMapper[key].pressed); +} + + +uint32_t KeyboardExtra::IsKeyHoldPressed( int key ) +{ + if (MyKeyMapper[key].is_hold_pressed) + { + uint32_t a = rtc_ticks(); + return (uint32_t) (a - MyKeyMapper[key].lasttickevent); + } + else return 0; +} + + +uint32_t KeyboardExtra::IsKeyHoldReleased( int key ) +{ + if (MyKeyMapper[key].is_hold_released) + { + uint32_t a = rtc_ticks(); + return (uint32_t) (a - MyKeyMapper[key].lasttickevent); + } + else return 0; +} + +uint32_t KeyboardExtra::GetLastTickKeyEvent( int key ) +{ + return MyKeyMapper[key].lasttickevent; +} \ No newline at end of file diff --git a/src/extrakeyboard.h b/src/extrakeyboard.h index 5a452f9..a0158de 100644 --- a/src/extrakeyboard.h +++ b/src/extrakeyboard.h @@ -3,14 +3,6 @@ #include -typedef struct -{ - bool pressed_lastframe; - bool pressed_thisframe; - bool has_been_pressed; - bool has_been_released; - uint32_t lasttickevent; -} keyinfo; enum { @@ -40,8 +32,6 @@ enum }; -static keyinfo MyKeyMapper[MYKEY_LASTENUM+1]; - class KeyboardExtra { @@ -50,9 +40,13 @@ class KeyboardExtra ~KeyboardExtra(); void Update( float dt ); + bool IsKeyPressedEvent( int key ); + bool IsKeyReleasedEvent( int key ); bool IsKeyPressed( int key ); bool IsKeyReleased( int key ); - bool IsKeyOn( int key ); + uint32_t IsKeyHoldPressed( int key ); + uint32_t IsKeyHoldReleased( int key ); + uint32_t GetLastTickKeyEvent( int key ); }; diff --git a/src/main.cpp b/src/main.cpp index 454e749..60a6786 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -215,8 +215,11 @@ static void render( void ) #if(BIAS) if (texttodraw>=1) Azur_draw_text(1,01, "FPS = %.0f", (float) (1000000.0f / elapsedTime) ); - if (texttodraw>=1) Azur_draw_text(1,11, "Render = %.0f mc secs", (float) time_render ); - + if (texttodraw>=1) Azur_draw_text(1,11, "Render = %.0f mc secs", (float) time_render / 1000.0f ); + if (texttodraw>=1) Azur_draw_text(1,21, "Hold Down : %d ", MyKeyboard.IsKeyHoldPressed(MYKEY_F3)); + if (texttodraw>=1) Azur_draw_text(1,31, "Hold Up : %d ", MyKeyboard.IsKeyHoldReleased(MYKEY_F3)); + if (texttodraw>=1) Azur_draw_text(1,41, "Last Tick Event : %d ", MyKeyboard.GetLastTickKeyEvent(MYKEY_F3)); + /* if (texttodraw>=1) Azur_draw_text(1,11, "Part.= %d - Bull.= %d", MyParticles.size(), MyPlayerBullets.size() ); if (texttodraw>=1 && !MyEnemies.empty()) Azur_draw_text(1,21, "Ennmy Life= %d", MyEnemies[0]->life ); if (texttodraw>=2) Azur_draw_text(1,31, "Update = %.0f mc secs", (float) time_update ); @@ -255,14 +258,15 @@ static void get_inputs( float dt ) if (MyPlayer->Shoot_OK(tempshoot, 1)) Create_Player_Shoot(1); } //if(keydown(KEY_F3)) - if(MyKeyboard.IsKeyPressed(MYKEY_F3)) + if(MyKeyboard.IsKeyPressedEvent(MYKEY_F3)) { if (MyPlayer->Shoot_OK(tempshoot, 2)) Create_Player_Shoot(2); } +// if (MyKeyboard.IsKeyPressed(MYKEY_F3)) color=C_RED; + // if (MyKeyboard.IsKeyReleased(MYKEY_F3)) color=C_GREEN; - if (MyKeyboard.IsKeyOn(MYKEY_EXIT)) {exitToOS = true; }; - + if (MyKeyboard.IsKeyPressed(MYKEY_EXIT)) {exitToOS = true; }; if(keydown(KEY_EXIT)) {exitToOS = true; }; @@ -275,45 +279,22 @@ static void get_inputs( float dt ) #endif if(keydown(KEY_SHIFT) && keydown(KEY_F1)) {texttodraw=0;} - if(keydown(KEY_SHIFT) && keydown(KEY_F2)) {texttodraw=1;} - if(keydown(KEY_SHIFT) && keydown(KEY_F3)) {texttodraw=2;} - if(keydown(KEY_SHIFT) && keydown(KEY_F4)) {texttodraw=3;} - if(keydown(KEY_SHIFT) && keydown(KEY_F6)) { azrp_starfield_close( ); azrp_starfield_init( 100 ); } +// if(keydown(KEY_F5)) drawback = !drawback; +// if(keydown(KEY_F6)) drawstars = !drawstars; - if(keydown(KEY_F5)) drawback = !drawback; - - if(keydown(KEY_F6)) drawstars = !drawstars; - - - if(keydown(KEY_LEFT)) - { - MyPlayer->Go_Left( dt ); - } - if(keydown(KEY_RIGHT)) - { - MyPlayer->Go_Right( dt ); - } - if(keydown(KEY_UP)) - { - MyPlayer->Go_Up( dt ); - } - if(keydown(KEY_DOWN)) - { - MyPlayer->Go_Down( dt ); - } - - - - + if(keydown(KEY_LEFT)) { MyPlayer->Go_Left( dt ); } + if(keydown(KEY_RIGHT)) { MyPlayer->Go_Right( dt ); } + if(keydown(KEY_UP)) { MyPlayer->Go_Up( dt ); } + if(keydown(KEY_DOWN)) { MyPlayer->Go_Down( dt ); } } @@ -446,17 +427,6 @@ int main(void) prof_leave(perf_render); time_render = prof_time(perf_render); - #if(NOBIAS) - dclear(C_BLACK); - dprint(1,01, C_WHITE, "Update = %.0f mc secs", (float) time_update ); - dprint(1,11, C_WHITE, "Render = %.0f mc secs", (float) time_render ); - dprint(1,21, C_WHITE, ">Total = %.3f ml secs", (float) elapsedTime / 1000.0f ); - dprint(1,31, C_WHITE, ">Total = %.0f", (float) elapsedTime ); - dprint(1,41, C_WHITE, " FPS = %.0f", (float) (1000000.0f / elapsedTime) ); - dprint(1,51, C_WHITE, "Parts = %d", MyParticles.size() ); - dupdate(); - #endif - elapsedTime = ((float) (time_update+time_render)); #if(DEBUG_MODE)