Welcome! Log In Create A New Profile

Advanced

[solved]What's wrong with my code?*using GRRLIB*

Posted by Putzpie 
[solved]What's wrong with my code?*using GRRLIB*
May 26, 2009 01:17AM
Before you tell me it's horrible code, I already know that, but what earth is wrong? First off, the wiimote doesn't even connect, so that's why I have both WPAD and PAD on, and when I use GRRLIB_Printf, it only prints the first letter.

Here's my code. I'm just using font four from the lesson 5 example.
EDIT: Figured out the problem with the text. I only have uppercase letters, so I need to type all the letters in caps <___<.

I'm still confused on why the wiimote doesn't connect...

/*===========================================
        GRRLIB 4.0.0
        Code     : NoNameNo
        Additional Code : Crayon
        GX hints : RedShade

        Minimum Code To Use GRRLIB

============================================
Download and Help Forum : [grrlib.santo.fr]
============================================*/
#include "../../grrlib/GRRLIB/GRRLIB/GRRLIB.h"


#include 
#include 

#include "gfx/font.h"

Mtx GXmodelView2D;


int main() {
	int x=10,dir=0;
    u32 wpaddown;
	
	GRRLIB_texImg tex_font = GRRLIB_LoadTexture(font);
    GRRLIB_InitTileSet(&tex_font, 32, 33, 32);
    
	GRRLIB_Init();
    WPAD_Init();
	PAD_Init();
	
	while(1) {
        WPAD_ScanPads();
		PAD_ScanPads();
        wpaddown = WPAD_ButtonsDown(0);
		
                GRRLIB_FillScreen(0x0000AA77);
		GRRLIB_Printf(x,32,tex_font,0xAAAAAAFF, 1,"OMG TILESET");
		GRRLIB_DrawImg(-20,80,tex_font,0, .75, .75, 0xFFFFFFFF);	//draw the entire fontmap or w/e for the heck of it, at 3/4 size
        GRRLIB_Render();
		
		x+=dir;
		if(x<20)dir=1;
		if(x>100)dir=-1;
        if(wpaddown & WPAD_BUTTON_HOME||PAD_ButtonsDown(0) & PAD_BUTTON_START) {
            exit(0);	//exit
        }
    }
    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
	free(tex_font.data);
    return 0;
}



Edited 6 time(s). Last edit at 05/27/2009 05:15AM by Putzpie.
Re: What's wrong with my code?*using GRRLIB*
May 26, 2009 08:35PM
Try putting GRRLIB_Render() under your if statements, like so:
x+=dir;
if(x<20)dir=1;
if(x>100)dir=-1;
GRRLIB_Render();
Also, try including math.h



Edited 1 time(s). Last edit at 05/26/2009 08:39PM by RazorChrist.
Re: What's wrong with my code?*using GRRLIB*
May 26, 2009 09:27PM
Don't you have to call GRRLIB_Init() before you call GRRLIB_InitTileSet()?
Re: What's wrong with my code?*using GRRLIB*
May 26, 2009 11:15PM
See if the Wiimote connects if you get rid of Pad_Init()
Re: What's wrong with my code?*using GRRLIB*
May 27, 2009 01:58AM
Quote
RazorChrist
Try putting GRRLIB_Render() under your if statements, like so:
x+=dir;
if(x<20)dir=1;
if(x>100)dir=-1;
GRRLIB_Render();
Also, try including math.h
Will do.
Quote
profetylen
Don't you have to call GRRLIB_Init() before you call GRRLIB_InitTileSet()?
By looking at the GRRLIB demos, no. My wiimote works just fine with those too.
Quote
Arikado
See if the Wiimote connects if you get rid of Pad_Init()
I'll try this too.

Just an FYI, the only thing wrong with my code atm is the wiimote problem. I'll try these suggestions and post back results.

EDIT: Still no luck :(
Could my makefile have anything to do with it?
Also, I downloaded the wiiuse lib from some older tutorial, because it wasn't connecting with my wiimote, but even after doing that it still didn't connect. Could that have anything to do with it?

EDIT EDIT: Yeah, I'm sure that that's probably it. I just ran a hello world program that connected just fine, and then I cleaned, and rebuilt it, and ran it, and the wiimote didn't work this time.



Edited 6 time(s). Last edit at 05/27/2009 02:18AM by Putzpie.
Re: What's wrong with my code?*using GRRLIB*
May 27, 2009 02:17AM
Try adding the following under WPAD_Init();
WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(0, 640, 480);
Re: What's wrong with my code?*using GRRLIB*
May 27, 2009 02:56AM
Yeah, I reinstalled the stuff, and it all works now. Stupid mistake on my part <_<

I appreciate your help though guys. :D



Edited 1 time(s). Last edit at 05/27/2009 02:57AM by Putzpie.
Sorry, only registered users may post in this forum.

Click here to login