gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Confused

#174851 - GeneralFOL - Mon Jul 26, 2010 1:49 am

Hi all, im trying very hard to learn DS codeing in C++, i dont seem to be able to get the result im looking for, bascially i want the small cube to move to a position clicked on the screen, but nothing happens, can anyone tell me where im going wrong?.

Sorry for all the miver guys, im a noob lol.

Code:
int main(void) {
//---------------------------------------------------------------------------------
   
   lcdMainOnBottom();
   
   touchPosition touchXY;
   
   glInit();
   
   videoSetMode(MODE_0_3D);
   
   glViewport(0,0,255,191);
   
   glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE );
   
   float translate = - 2;
   
   float playerx = 0;
   float playerz = 0;
   
   float newplayerx = 0;
   float newplayerz = 0;
   
   irqSet(IRQ_VBLANK, Vblank);

   consoleDemoInit();

   iprintf("Nintendo DS Test Engine\n");
   iprintf("By Iain McCluskey\n");
   
 
   while(1) {
   
       glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
       gluPerspective(70, 256.0 / 192.0, 0.1, 10);
      
      glViewport(0,0,255,191);
      
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      
      glTranslatef(0,0,translate);
         
       DrawBox(-2,-1,-1,4,2,4);
      
      DrawBox(newplayerx,-1,newplayerz,0.4,0.4,0.4);
   
      swiWaitForVBlank();
      touchRead(&touchXY);
      
      int held = keysHeld();
      
      if(held & KEY_TOUCH)
      {
        playerx = touchXY.px;
        playerz = touchXY.py;
        newplayerx = playerx;
        newplayerz = playerz;
      }

      iprintf("Frame = %4u",frame);
      iprintf("\x1b[16;0HTouch x = %04u, %04u\n", touchXY.rawx, touchXY.px);
      iprintf("Touch y = %04u, %04u\n", touchXY.rawy, touchXY.py);
      
      iprintf("Player X = %04u\n",playerx);
      iprintf("Player Y = %04u\n",playerz);
      
      glFlush(0);      
   
   }