From 988844a87f0f133f914c76f7b87082b8d257e6e8 Mon Sep 17 00:00:00 2001 From: TheWahlolly Date: Sun, 10 Mar 2024 20:26:03 +0200 Subject: [PATCH] added block picker and every scratch block and went insane --- source/block_data.c | 110 +++++++++++++++++++++++++++++++++++++++++ source/editor.c | 58 +++++++++++++++++----- source/main.c | 12 +++-- source/screen_manage.c | 12 +++-- 4 files changed, 173 insertions(+), 19 deletions(-) create mode 100644 source/block_data.c diff --git a/source/block_data.c b/source/block_data.c new file mode 100644 index 0000000..51ead12 --- /dev/null +++ b/source/block_data.c @@ -0,0 +1,110 @@ +static int blockColor[10][2] = {{0,17},{18,37},{38,46},{47,54},{55,65},{66,83},{84,101},{102,106},{107,107}}; +static char blockText[105][35] = +{"move 10 steps", +"turn clockwise 15 degrees", +"turn counterclockwise 15 degrees", +"go to random position", +"go to x:0 y:0", +"glide 1 secs to random position", +"glide 1 secs to x:0 y:0", +"point in direction 90", +"point towards mouse-pointer", +"change x by 10", +"set x to 0", +"change y by 10", +"set y to 0", +"if on edge, bounce", +"set rotation style left-right", +"x position", +"y position", +"direction", +"say Hello! for 2 seconds", +"say Hello!", +"think Hmm... for 2 seconds", +"think Hmm...", +"switch costume to costume2", +"next costume", +"switch backdrop to backdrop1", +"next backdrop", +"change size by 10",//i wish you could do that irl iykwim +"set size to 100%", +"change color effect by 25", +"set color effect to 0", +"clear graphic effects", +"show", +"hide", +"go to front layer", +"go forward 1 layers", +"costume number", +"backdrop number", +"size", +"play sound Meow until done", +"start sound Meow", +"stop all sounds", +"change pitch effect by 10", +"set pitch effect to 100", +"clear sound effects", +"change volume by -10", +"set volume to 100", +"volume", +"when flag clicked", +"when space key pressed", +"when this sprite clicked", +"when backdrop switches to backdrop1", +"when loudness > 10", +"when I receive message1", +"broadcast message1", +"broadcast message1 and wait", +"wait 1 seconds", +"repeat 10", +"forever", +"if < > then", +"if < > then else", +"wait until < >", +"repeat until < >", +"stop all", +"when I start as a clone", +"create clone of myself", +"delete this clone", +"touching mouse pointer?", +"touching color?", +"color is touching color?", +"distance to mouse-pointer", +"ask What's your name? and wait", +"answer", +"key space pressed?", +"mouse down?", +"mouse x", +"mouse y", +"set drag mode draggable", +"loudness", +"timer", //timer till i fucking lose it +"reset timer", +"backdrop # of stage", +"current year", +"days since 2000", +"username", +"( ) + ( )", +"( ) - ( )", +"( ) * ( )", +"( ) / ( )", +"pick random 1 to 10", +"( ) > 50", +"( ) < 50", +"( ) = 50", +"< > and < >", +"< > or < >", +"not < >", +"join apple banana", +"letter 1 of apple", +"length of apple", +"apple contains a?", +"( ) mod ( )", +"( ) round", +"abs of ( )", +"my variable", +"set my variable to 0", +"change my variable by 1", +"show variable my variable", +"hide variable my variable", +"placeholder block"}; \ No newline at end of file diff --git a/source/editor.c b/source/editor.c index 90c5536..9bbfa78 100644 --- a/source/editor.c +++ b/source/editor.c @@ -1,25 +1,27 @@ #include "render_block.c" +#include "block_data.c" static float stylusDiffX = 0; static float stylusDiffY = 0; static bool movingBlock = false; static int movingBlockIdx = 0; static int blockMatrix[2][4] = {{0,0,0,0},{50,50,0,0}}; //3rd entry would be block index +static int bselSelectedBlock = 0; static void editorRender(bool scr){ u32 motion_tab_color = C2D_Color32(76, 151, 255, 0xFF); - u32 looks_tab_color = C2D_Color32(153, 102, 255, 0xFF); - u32 sound_tab_color = C2D_Color32(207, 99, 207, 0xFF); - u32 events_tab_color = C2D_Color32(255, 191, 0, 0xFF); - u32 control_tab_color = C2D_Color32(255, 171, 25, 0xFF); - u32 sensing_tab_color = C2D_Color32(92, 177, 214, 0xFF); - u32 operators_tab_color = C2D_Color32(89, 192, 89, 0xFF); - u32 variables_tab_color = C2D_Color32(255, 140, 26, 0xFF); - u32 my_blocks_tab_color = C2D_Color32(255, 102, 128, 0xFF); - u32 extension_tab_color = C2D_Color32(15, 189, 140, 0xFF); - u32 colorarray[10] = {motion_tab_color,looks_tab_color,sound_tab_color,events_tab_color,control_tab_color,sensing_tab_color,operators_tab_color,variables_tab_color,my_blocks_tab_color,extension_tab_color}; + u32 looks_tab_color = C2D_Color32(153, 102, 255, 0xFF); + u32 sound_tab_color = C2D_Color32(207, 99, 207, 0xFF); + u32 events_tab_color = C2D_Color32(255, 191, 0, 0xFF); + u32 control_tab_color = C2D_Color32(255, 171, 25, 0xFF); + u32 sensing_tab_color = C2D_Color32(92, 177, 214, 0xFF); + u32 operators_tab_color = C2D_Color32(89, 192, 89, 0xFF); + u32 variables_tab_color = C2D_Color32(255, 140, 26, 0xFF); + u32 my_blocks_tab_color = C2D_Color32(255, 102, 128, 0xFF); + u32 extension_tab_color = C2D_Color32(15, 189, 140, 0xFF); + u32 colorArray[10] = {motion_tab_color,looks_tab_color,sound_tab_color,events_tab_color,control_tab_color,sensing_tab_color,operators_tab_color,variables_tab_color,my_blocks_tab_color,extension_tab_color}; for(int i=0;i<2;i++){ - renderBlock(colorarray[i],blockMatrix[i][0],blockMatrix[i][1],"sample block text"); + renderBlock(colorArray[i],blockMatrix[i][0],blockMatrix[i][1],"sample block text"); } } @@ -45,4 +47,38 @@ static void editorBackend(bool scr, float touchX, float touchY){ } } editorRender(scr); +} + +static void blockSelector(bool scr, u32 kDown){ + u32 motion_tab_color = C2D_Color32(76, 151, 255, 0xFF); //temporary duplicate colors since ponali went offline and i couldnt think of any way to use the colors from editorrender + u32 looks_tab_color = C2D_Color32(153, 102, 255, 0xFF); + u32 sound_tab_color = C2D_Color32(207, 99, 207, 0xFF); + u32 events_tab_color = C2D_Color32(255, 191, 0, 0xFF); + u32 control_tab_color = C2D_Color32(255, 171, 25, 0xFF); + u32 sensing_tab_color = C2D_Color32(92, 177, 214, 0xFF); + u32 operators_tab_color = C2D_Color32(89, 192, 89, 0xFF); + u32 variables_tab_color = C2D_Color32(255, 140, 26, 0xFF); + u32 my_blocks_tab_color = C2D_Color32(255, 102, 128, 0xFF); + u32 extension_tab_color = C2D_Color32(15, 189, 140, 0xFF); + u32 colorArray[10] = {motion_tab_color,looks_tab_color,sound_tab_color,events_tab_color,control_tab_color,sensing_tab_color,operators_tab_color,variables_tab_color,my_blocks_tab_color,extension_tab_color}; + if (kDown & KEY_L) { + if (bselSelectedBlock==0) { + bselSelectedBlock=104; + } else { + bselSelectedBlock--; + } + } + if (kDown & KEY_R) { + if (bselSelectedBlock==104) { + bselSelectedBlock=0; + } else { + bselSelectedBlock++; + } + } + int bselColorIndex; + for (int i=0;i<9;i++) { + if (bselSelectedBlock>=blockColor[i][0] && bselSelectedBlock<=blockColor[i][1]) + bselColorIndex=i; + } + renderBlock(colorArray[bselColorIndex],10,10,blockText[bselSelectedBlock]); } \ No newline at end of file diff --git a/source/main.c b/source/main.c index 7110307..18da19f 100644 --- a/source/main.c +++ b/source/main.c @@ -1,10 +1,12 @@ -float max(a,b){return a>b?a:b;} -float min(a,b){return ab?a:b;}; +float min(a,b){return a #include <3ds.h> #include "screen_manage.c" +bool bsel = false; + int main(int argc, char* argv[]) { gfxInitDefault(); C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); @@ -27,6 +29,8 @@ int main(int argc, char* argv[]) { screenSwapCheck(kDown); if (kDown & KEY_SELECT) break; + if (kDown & KEY_X) + bsel=!bsel; touchPosition touch; hidTouchRead(&touch); @@ -39,14 +43,14 @@ int main(int argc, char* argv[]) { C2D_TargetClear(bot, clear_color); C2D_SceneBegin(bot); - renderScreen(kHeld,false,touch.px,touch.py,cStickPos.dx,cStickPos.dy); + renderScreen(kHeld,false,touch.px,touch.py,cStickPos.dx,cStickPos.dy,bsel,kDown); C2D_Flush(); C2D_TargetClear(top, clear_color); C2D_SceneBegin(top); - renderScreen(kHeld,true,touch.px,touch.py,cStickPos.dx,cStickPos.dy); + renderScreen(kHeld,true,touch.px,touch.py,cStickPos.dx,cStickPos.dy,bsel,kDown); C2D_Flush(); C3D_FrameEnd(0); diff --git a/source/screen_manage.c b/source/screen_manage.c index cc1e484..5ddad3f 100644 --- a/source/screen_manage.c +++ b/source/screen_manage.c @@ -19,7 +19,7 @@ static void renderCursor(float cursorX, float cursorY, bool pressedA){ C2D_DrawTriangle(cursorX+0,cursorY+0,c,cursorX+15,cursorY+0,c,cursorX+0,cursorY+15,c,0); } -static void renderScreen(u32 kHeld, bool scr, float touchX, float touchY, s16 cStickX, s16 cStickY){ +static void renderScreen(u32 kHeld, bool scr, float touchX, float touchY, s16 cStickX, s16 cStickY, bool bsel, u32 kDown){ bool pressedA=false;if(kHeld&KEY_A){pressedA=true;} float useX=touchX;float useY=touchY; if(scr){ @@ -34,8 +34,12 @@ static void renderScreen(u32 kHeld, bool scr, float touchX, float touchY, s16 cS if(scr^screenSwap){ editorBackend(scr,useX,useY); } else { - // temporary triangle - C2D_DrawTriangle(0,0,C2D_Color32(0xFF,10,10,0xFF),150,0,C2D_Color32(10,0xFF,10,0xFF),0,150,C2D_Color32(10,10,0xFF,0xFF),0); + if (bsel){ + blockSelector(scr, kDown); + } else { + // temporary triangle + C2D_DrawTriangle(0,0,C2D_Color32(0xFF,10,10,0xFF),150,0,C2D_Color32(10,0xFF,10,0xFF),0,150,C2D_Color32(10,10,0xFF,0xFF),0); + } } if(scr){ renderCursor(cursorX,cursorY,pressedA); @@ -43,6 +47,6 @@ static void renderScreen(u32 kHeld, bool scr, float touchX, float touchY, s16 cS } static void screenSwapCheck(u32 kDown){ - if (kDown & KEY_L) + if (kDown & KEY_ZL) screenSwap=!screenSwap; } \ No newline at end of file