-
poker game
Hello, I'm thinking of making an online poker game, it will have simple 2d graphics. I have never made a game before, and I don't know any opengl/directx stuff only pure win32. Do you think it is feasible to do this in pure win32 code?
The chips and cards need to be capable of smoothly moving across the table. My first problem I have hit is that how do I make certain pixels of my bitmaps not be drawn?
The table is not all one solid color, so I can't just set the background of the chip to a solid color.
Because if I have a square bitmap with a circle in it, how do I make it appear like a circle and not a square? I hope you understand what I'm trying to ask, because I'm having a hard time explaining it.
thanks
-
You are talking about alpha blending and it can be accomplished with pure win32 bit blitting however you really should take a look at DirectX or OpenGL. They are not as hard to implement as you may think, in fact if you can figure out how to do it in Win32 then you can figure out how to do it in DirectX. Just take a look on MSDN for the DirectX SDK
-
Which is easier to learn, OpenGL or DirectX?
Because I don't want to have to put back this project a month or two in order to learn either.
-
> Hello, I'm thinking of making an online poker game
Have you thought about the architecture of this?
It seems to me that the actual game will be managed on a central server, which sends "draw" commands to each logged-in client to indicate the progress of the game. I mean if you're using browser type technology, the server shouldn't care about what each client OS is, so any talk of "directx" or "opengl" is a moot point (it may in fact be neither).
Or is it some kind of peer-to-peer arrangement where more of the intelligence is inside the software running on the local machine.
-
When I said online, I meant multiplayer. All players will connect to a central server. The central server will simply send the card values and a few other things. The clients will do most of the work.
-
In the amount of time it would take you to learn how to do it with the Win32 GDI functions you could learn how to do it with DirectX or OpenGL.
Happy Coding!!!!
-
OpenGL is cross-platform, but since you're using the WindowsAPI, it obviously doesn't matter, so I'd personally go with DirectX. OpenGL is also only a graphics library, so, unless you want to learn a sound library(if your program has sound), I'd go with DirectX.
-
I've just read that alpha blending is just combining two colors to make a blended color, therefore giving the effect of transparency. But what I want to do is only make certain pixels of a bitmap transparent.
For example if I have a bitmap which is a red circle with the background white. But in my program the background of the window is black, how do I only show the red circle and not the white background?
I've decided I'm going to make it using the GDI and just make the cards/chips stationary, because I can already do that. Does anybody know a tutorial for what I'm trying to achieve using the GDI?
thanks
-
> I've just read that alpha blending is just combining two colors to make a blended color
Yes, with an alpha value of 0x00, you get all the background colour, and with an alpha value of 0xff, you get all the foreground colour.
So you create a mask of alpha values which matches your foreground image, which is 0xFF where you want the image, and 0x00 where you want transparency.
-
ok... How do I 'create a mask of alpha values'?
I'm sorry, I'm new to the graphics scene.
I did have one idea, which was that, if I set all the pixels that I don't want drawn to somthing like pink, then I could just use GetPixel() and only draw the pixels that aren't pink?
I imagine this would be heavy on the cpu if it was constantly refreshing though.
-
If you are using the GDI you are NOT going to be alpha blending. You will be using color keying. You select a color you wish to act as the transparent color. Assign this color either via the Windows GUI or via your own functions. When scanning through the bitmap, if the color in the bitmap is the same as the transparent color, don't plot any pixels ELSE plot pixels from the bitmap to the screen.
Code:
void TransparentBlit(WORD x,WORD y,BMPBitmap &Bitmap)
{
//Width of screen and bitmap
DWORD dwScreenPitch=Screen.Width;
DWORD dwBitmapWidth=Bitmap.Width;
//BitmapOffset and ScreenOffset
DWORD dwBitmapOffset=0;
DWORD dwScreenOffset=y*dwScreenPitch+x;
//Size of bitmap to blit
DWORD dwSize=Bitmap.ImageSize;
//DWORD value of transparent color
DWORD dwTransparent=Bitmap.Transparent;
//Pixel to be output to screen
DWORD dwOutPixelColor;
//Buffer pointers for screen and bitmap
DWORD *dwBitmap_ptr=Bitmap.Data;
DWORD *dwScreen_ptr=Screen.Buffer;
//Tells whether or not to move down one line on screen
DWORD dwWidthCount=0;
for (dwBitmapOffset=0;dwBitmapOffset<dwSize;dwBitmapOffset++)
{
dwOutPixelColor=dwBitmap_ptr[dwBitmapOffset];
if (dwOutPixelColor!=dwTransparent)
{
dwScreen_ptr[dwScreenOffset]=dwOutPixelColor;
dwScreenOffset++;
dwWidthCount++;
if (dwWidthCount>dwBitmapWidth)
{
dwWidthCount=0;
dwScreenOffset+=dwScreenPitch;
}
}
}
}
That's the jist of it. I coded it so that you linearily traverse the bitmap in memory and pre-computes the screen offset. This boils down to incrementing two pointers and is much faster than re-computing the offset inside the loop.
This should work as is, but I coded it here on the board so it's not tested. But the principle is there so you should be able to get it from here.
EDIT:
That's it I'm sick of the WYSIWYG editor. Back to the old one.
-
is BMPBitmap a typo?
I've never seen that type before, and msdn has nothing about it either. Also, where is 'Bitmap' and 'Screen' declared?
-
Those are types that I did not include with the post.
Screen would be a pointer to the screen buffer and bitmap would be a pointer to a bitmap class or structure. I left them out because those implementations have more to do with the how and why of the platform rather than the color keying concept.
But once you figure out how to get access to those pointers/buffers you can simply plug and chug with this code.
There are far too many implementations out there for me to show you every possible way of retrieving a pointer to a bitmap surface and/or screen surface.
-
Oh right thanks, I wasn't sure, I thought maybe there was something I was missing. Thanks for the help bubba
-
I'm struggling with this. I'm using type BITMAP.
And I don't know how to get:
Code:
//Size of bitmap to blit
DWORD dwSize=Bitmap.ImageSize;
or
Code:
//Buffer pointers for screen and bitmap
DWORD *dwBitmap_ptr=Bitmap.Data;
DWORD *dwScreen_ptr=Screen.Buffer;
I don't think this is going to be as easy as I expected...