GP32 Newbie Wants A Little Help With Coding


Joined
Sep 14, 2005
Messages
458
Location
Sweden
Website
www.digitalawakening.net
Don't know if this is the most apropriate board to post this but here goes. I'm totally new to both C++ and SDL but I've been coding high-level stuff for years. Anyway, with Sol's tutorial as base I've started working on an image draw function, not that hard really. It's still very basic but I got an alpha color key coded in so I get transparency. Now the problem is when I want to use this function on another image. I really don't know how to do that so if someone could help me I would be quite happy.

Code:
void drawimage(int x, int y)
{
  // Lock surface if needed
  if (SDL_MUSTLOCK(gFG))
    if (SDL_LockSurface(gFG) < 0) 
      return;

  int i, j;
  for (i = 0; i < WIDTH; i++)
  {
    int screenofs = x + (y + i) * PITCH;
    for (j = 0; j < WIDTH; j++)
    {
  if ( ((unsigned int*)gFG->pixels)[screenofs] != 0xffffff ) {
  	((unsigned int*)gScreen->pixels)[screenofs] =
    ((unsigned int*)gFG->pixels)[screenofs];
  }
      screenofs++;
    }
  }

  // Unlock if needed
    if (SDL_MUSTLOCK(gFG)) 
        SDL_UnlockSurface(gFG);
}

I just got interested in developing for GP2X and I've decided to port my mobile game Goo Lab to it. It's made in Omega Basic but that software died before all the bugs got sorted out. Getting this image function fully working sould be my only problem, at least until I start with sounds. Here's a shot of the game, more on my website.

gl6.jpg
 
Back
Top