-
Ok. Here is what I have to do. It sucks that the IMG tag is off, it seriously should not be cuz it inhibits proper explanation of a problem. Anyways, what its supposed to do, is go through each pixel in the 50x50 pic, and if it's a shading of either magenta, blue, or green, replace it with the appropriate shading of the other color contained in Color(X, (r1-b2-andg3-values)) so here is the code:
Code:
For i2 = 0 To 49
For i3 = 0 To 49
pixel = GetPixel(Picture1.hdc, i2, i3)
If pixel <> &H8000000F Then
For i4 = 0 To 15
If pixel = RGB(90 + i4 * 11, 0, 90 + i4 * 11) Then SetPixelV Picture1.hdc, i2, i3, RGB(Color(1, 1) * (i4 / 16), Color(1, 2) * (i4 / 16), Color(1, 3) * (i4 / 16))
If pixel = RGB(0, 0, 90 + i4 * 11) Then SetPixelV Picture1.hdc, i2, i3, RGB(Color(2, 1) * (i4 / 16), Color(2, 2) * (i4 / 16), Color(2, 3) * (i4 / 16))
If pixel = RGB(0, 90 + i4 * 11, 0) Then SetPixelV Picture1.hdc, i2, i3, RGB(Color(3, 1) * (i4 / 16), Color(3, 2) * (i4 / 16), Color(3, 3) * (i4 / 16))
Next i4
End If
Next i3
Next i2
Ok. The "If pixel <> &H8000000F Then" line is so that if its of the background color, it doesnt have to go through all the other if's. Anyways, the problem is that it's incredibly SLOW!!!!!!!!!!!!!!!!!!!!!!!!!
To demonstrate how slow it is, you can download the latest version of my game thats in the process of being made here:
http://www.geocities.com/vvuueenn/rts.ZIP (70k I think)
The time it loads is the time it takes to change the colors in approximately 100 50x50 sprites, or 250000 pixels. On my comp it takes about 5 or 6 seconds. This may not seem as much, but this is done AT RUNTIME in games like starcraft. Besides, when the game's done, there wont be 100 sprites, there'll be more like 10000 sprites, TIMES the amount of teams (races), and a 20 minute load time before you can start playing before EACH GAME is not exactly cool. SO! I need a faster way to replace pixels. IF ANYONE KNOWS HOW TELL ME!
-
Speed
Instead of calling like:
SetPixel(Picture1.hDC, blah, blah...)
do this:
dim pDC as long
pDC = Picture1.hDC
SetPixel(pDC, blah, blah...)
This WILL speed it up. By how much, I dont know.
-
Ya but see its using an API-created memDC so that is exactly what you need to use a memDC and I already have that.
-
You may have to leave your work and start learning DirectDraw if you want to do starcraft games, but if you still want to do it the DC on form way, and still have a fast startup, you should save all your converted bitmaps and load them instead in the game.
I'm not sure but that looks like some kind of mask generating algoritm, but you could probably correct me.
If youre desperate, i have a faster mask generating algoritm for you