Welcome! Log In Create A New Profile

Advanced

GRRPRINTF weird issue.

Posted by mdbrim 
GRRPRINTF weird issue.
June 24, 2009 01:43AM
Very simple piece of code that i modified from the GRRLIB examples.

You load it up, you hit the A button, it should just grrlib printf and count up.

it doesn't count right!

For example... it'll go 1 2 3 4 3 5 6 7 8 7 9 8 11 etc etc.

I'm guessing it has to do with the rendering of GRRLIB_PrintF because i'm betting i didn't mess up "x++".

here's my code:

Any ideas?

#include "../../../GRRLIB/GRRLIB/GRRLIB.h"

#include 
#include 

#include "gfx/font3.h"

Mtx GXmodelView2D;
int x=0;

int main() {
    u32 wpaddown;

    // Load the image file and initilise the tiles
    GRRLIB_texImg tex_font3 = GRRLIB_LoadTexture(font3);
    GRRLIB_InitTileSet(&tex_font3, 32, 32, 32);

    GRRLIB_Init();
    WPAD_Init();

    while(1) {
        WPAD_ScanPads();
		
        wpaddown = WPAD_ButtonsDown(0);
		
		if(wpaddown & WPAD_BUTTON_A) {
        GRRLIB_FillScreen(0x000000FF);
        GRRLIB_Printf(20, 150, tex_font3, 0xFFFFFFFF, 1, "%i", x);
		x++;
        GRRLIB_Render();

		}
       if(wpaddown & WPAD_BUTTON_HOME) {
            exit(0);
        }
    }

    // Be a good boy, clear the memory allocated by GRRLIB
    GRRLIB_Exit(); 
    free(tex_font3.data);
    return 0;
}
Re: GRRPRINTF weird issue.
June 24, 2009 01:52AM
doing it like this

		if(wpaddown & WPAD_BUTTON_A) {
  		x++;
		}

and putting all the GRRLIB commands outside the if statement seemed to fix it.

Hey, if it wasn't for us newbs making dumb coding mistakes all you pros wouldn't be so cool!

Edited for spelling.



Edited 2 time(s). Last edit at 06/24/2009 01:53AM by mdbrim.
Sorry, only registered users may post in this forum.

Click here to login