Hello.
I've tried some coding for homebrew and, as I'm a newbie, I searched a lot of tutorials which I only found one with the basics.
Then, I went to something harder, GRRLIB.
I've tried some "gravity" logic and... it just won't work. The background is fine, the Wiimote cursor is fine, all fine, but the false pointer (which is the one with the gravity) just won't work.
I'll attach the code and the archive of everything you need.
I hope somebody helps me.
The problem may be in the "if" and "else" statements but I hope somebody helps
Edit: I'm using Dolphin because it's tiring to insert and eject the SD card all the time.
I've tried some coding for homebrew and, as I'm a newbie, I searched a lot of tutorials which I only found one with the basics.
Then, I went to something harder, GRRLIB.
I've tried some "gravity" logic and... it just won't work. The background is fine, the Wiimote cursor is fine, all fine, but the false pointer (which is the one with the gravity) just won't work.
I'll attach the code and the archive of everything you need.
I hope somebody helps me.
/*===========================================
GRRLIB (GX Version)
- Template Code -
Minimum Code To Use GRRLIB
============================================*/
#include <grrlib.h>
#include <stdlib.h>
#include <wiiuse/wpad.h>
int main(int argc, char **argv) {
// Initialise the Graphics & Video subsystem.
GRRLIB_Init();
// Initialise the Wiimotes.
WPAD_Init();
// Loop forever.
WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL, rmode->fbWidth, rmode->xfbHeight);
// Create variable.
GRRLIB_texImg *background;
GRRLIB_texImg *cursor;
GRRLIB_texImg *art_cursor;
// Load images.
background = GRRLIB_LoadTextureFromFile("sd:/images/background.jpg");
cursor = GRRLIB_LoadTextureFromFile("sd:/images/cursor.png");
art_cursor = GRRLIB_LoadTextureFromFile("sd:/images/cursor.png");
int x, y; // Define position variables for the Wiimote cursor.
int cur_X, cur_Y, cur_Speed; // Define artificial cursor position variables.
cur_X = 240;
cur_Y = 0;
cur_Speed = 0;
while(1)
{
x = WPAD_Data(0)->ir.x; // Scan X position of the pointer.
y = WPAD_Data(0)->ir.y; // Scan Y position of the pointer.
WPAD_ScanPads(); // Scan the Wiimotes.
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)
{
break;
}
// Gravity.
if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_A)
{
if (cur_Speed >= 7)
{
cur_Speed = 7;
}
else
{
cur_Speed += 0.1;
}
}
if (!WPAD_ButtonsHeld(0) & !WPAD_BUTTON_A)
{
if (cur_Speed <= -10)
{
cur_Speed = -10;
}
else
{
cur_Speed -= 0.2;
}
}
// Out of bounds limit.
cur_Y += cur_Speed;
if (cur_Y >= 480)
{
cur_Speed = 0;
cur_Y = 480;
}
GRRLIB_DrawImg(0, 0, background, 0, 1, 1, RGBA( 255, 255, 255, 255 ));
GRRLIB_DrawImg(x, y, cursor, 0, 1, 1, RGBA( 255, 255, 255, 255 ));
GRRLIB_DrawImg(cur_X, cur_Y, art_cursor, 0, 1, 1, RGBA( 255, 255, 255, 255 ));
GRRLIB_Render(); // Render the frame buffer to the TV.
}
GRRLIB_Exit(); // Clear allocated memory.
exit(0); // Use exit() to exit a program, do not use 'return' from main().
}
The problem may be in the "if" and "else" statements but I hope somebody helps
Edit: I'm using Dolphin because it's tiring to insert and eject the SD card all the time.
Attachments
Last edited by Arseniy_Kmit,







