From 0de0766cbcf8204607f280d0940c6326d575f492 Mon Sep 17 00:00:00 2001 From: SemvdH Date: Thu, 20 May 2021 00:12:11 +0200 Subject: [PATCH] [ADD] start of controls --- sce_sys/livearea/contents/bg.png | Bin sce_sys/livearea/contents/startup.png | Bin src/main.c | 35 ++++++++++++++++++++++---- 3 files changed, 30 insertions(+), 5 deletions(-) mode change 100644 => 100755 sce_sys/livearea/contents/bg.png mode change 100644 => 100755 sce_sys/livearea/contents/startup.png diff --git a/sce_sys/livearea/contents/bg.png b/sce_sys/livearea/contents/bg.png old mode 100644 new mode 100755 diff --git a/sce_sys/livearea/contents/startup.png b/sce_sys/livearea/contents/startup.png old mode 100644 new mode 100755 diff --git a/src/main.c b/src/main.c index 20d0faf..809ea3b 100644 --- a/src/main.c +++ b/src/main.c @@ -21,9 +21,10 @@ * @brief should be called when an unhandlable exception or error occurs. Triggers coredump. * */ -__attribute__((__noreturn__)) -void shit_yourself(void){ - while(1){ +__attribute__((__noreturn__)) void shit_yourself(void) +{ + while (1) + { *(int *)(0xAA) = 0x55; // trigger coredump } } @@ -31,6 +32,8 @@ void shit_yourself(void){ int main(int argc, char *argv[]) { + /* to enable analog sampling */ + sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG); SceCtrlData pad; vita2d_pgf *pgf; vita2d_pvf *pvf; @@ -49,11 +52,13 @@ int main(int argc, char *argv[]) memset(&pad, 0, sizeof(pad)); - BULLET b1 = {1,200,200,RGBA8(255,0,255,255)}; + BULLET b1 = {1, 200, 200, RGBA8(255, 0, 255, 255)}; SceUInt64 deltaTime = 0; // delta time in ms SceKernelSysClock sysclock; + float x1 = 300, y1 = 50, x2 = 400, y2 = 50; + while (1) { deltaTime = timing_get_deltatime(&sysclock); @@ -68,6 +73,26 @@ int main(int argc, char *argv[]) vita2d_start_drawing(); vita2d_clear_screen(); + int16_t lxpos = -128 + pad.lx; // full left is 0 so -128 and full right is 255 so 128 + char leftStick[50] = "left stick: "; + sprintf(leftStick, "left stick: %d", lxpos); + + vita2d_pgf_draw_text(pgf, 300, 30, RGBA8(255, 255, 0, 255), 1.0f, leftStick); + if (abs(lxpos) > 15) + x1 += (lxpos) * (deltaTime / 1000.0); + char xtext[50]; + sprintf(xtext, "x: %f", x1); + + vita2d_pgf_draw_text(pgf, 200, 80, RGBA8(255, 0, 0, 255), 1.0f, xtext); + + if (x1 <= 0) + x1 = 0; + if (x1 > 700) + x1 = 700; + + vita2d_draw_rectangle(x1, y1, (float)10, (float)10, RGBA8(100, 100, 100, 255)); + vita2d_draw_rectangle(x2, y2, (float)10, (float)10, RGBA8(169, 60, 23, 255)); + // vita2d_draw_texture(image, 100, 100); char text[80] = "process time: "; @@ -78,7 +103,7 @@ int main(int argc, char *argv[]) vita2d_pgf_draw_text(pgf, 700, 30, RGBA8(0, 255, 0, 255), 1.0f, text); - vita2d_pvf_draw_text(pvf, 700, 80, RGBA8(0,255,0,255), 1.0f, fps); + vita2d_pvf_draw_text(pvf, 700, 80, RGBA8(0, 255, 0, 255), 1.0f, fps); sprites_draw_bullet(&b1);