Skip to content

Commit

Permalink
added block picker and every scratch block and went insane
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWahlolly committed Mar 10, 2024
1 parent 0774e65 commit 988844a
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 19 deletions.
110 changes: 110 additions & 0 deletions source/block_data.c
Original file line number Diff line number Diff line change
@@ -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"};
58 changes: 47 additions & 11 deletions source/editor.c
Original file line number Diff line number Diff line change
@@ -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");
}

}
Expand All @@ -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]);
}
12 changes: 8 additions & 4 deletions source/main.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
float max(a,b){return a>b?a:b;}
float min(a,b){return a<b?a:b;}
float max(a,b){return a>b?a:b;};
float min(a,b){return a<b?a:b;};

#include <citro2d.h>
#include <3ds.h>
#include "screen_manage.c"

bool bsel = false;

int main(int argc, char* argv[]) {
gfxInitDefault();
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
12 changes: 8 additions & 4 deletions source/screen_manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -34,15 +34,19 @@ 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);
}
}

static void screenSwapCheck(u32 kDown){
if (kDown & KEY_L)
if (kDown & KEY_ZL)
screenSwap=!screenSwap;
}

0 comments on commit 988844a

Please sign in to comment.