The alpha value should be between 0 and 1, so you should probably use 0.5 instead of 50. You didn't hear what I said about doing the math for all the RGB components independently. What you're trying to do, treating the whole Pixel struct as a single number, won't work. You need to extract the RGB components, do the math on each of them, and then put them back together into a Pixel again. See lesson 9 for more about this. Your math for addressing the screen pixels is also wrong. Remember the destination image is not 32x32, so you need to calculate the correct address using the destination width, the posX and posY, and the x, y within the tile. You'll probably want to do separate y and x loops instead of doing one loop on readPixel.
Aah man, you know I did read it, but in the excitement of getting it to work I totally forgot. Sorry!
Ok, I have tried almost everything but I can't get anything working now.. Here's the code with stuff commented out of what I tried earlier.
I first thought I could use the >> operator to get the colours out of the Pixel struct, but that didn't seem to work, then I tried using the Color struct, but that doesn't do anything with it's alpha value.
I can't even get the positioning right...
for (int readPixelX = 0; readPixelX < 32; readPixelX++)
for (int readPixelY = 0; readPixelY < 32; readPixelY++)
Pixel original_color = worldAddress[readPixelX * readPixelY]; //worldAddress[readPixelX * readPixelY] * (1.0f - 0.5f) + tileAddress[readPixelX * readPixelY] * 0.5f;
Pixel src_color = tileAddress[readPixelX * readPixelY];
extractedOriginal.Set(float (original_color >> 16), float (original_color >> 8), (float) original_color);
extractedSource.Set(float (src_color >> 16), float (src_color >> 8), (float) src_color);
int dest_color_red = int (extractedOriginal.r * (1.0f - extractedSource.a) + extractedSource.r * extractedSource.a);
int dest_color_green = int (extractedOriginal.g * (1.0f - extractedSource.a) + extractedSource.g * extractedSource.a);
int dest_color_blue = int (extractedOriginal.b * (1.0f - extractedSource.a) + extractedSource.b * extractedSource.a);
Color endColor = extractedOriginal + extractedSource;
//worldAddress[readPixel] = (Pixel) dest_color; //tileAddress[readPixel]
screenAddress[((posX * 32) + readPixelX) + ((posY * 32) + readPixelY) * SCRWIDTH] = (Pixel) ((int (endColor.r) << 16) + (int (endColor.g) << 8) + endColor.b);//(dest_color_red << 16) + (dest_color_green << 8) + (dest_color_blue);
You must know that while I'm trying to make this work, I'm still reading a lot of tutorials on how to actually program in c++, so far I haven't learned anything related to stuff like this... -.-"