poker game

This is a discussion on poker game within the Game Programming forums, part of the General Programming Boards category; Hello, I'm thinking of making an online poker game, it will have simple 2d graphics. I have never made a ...

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    102

    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

  2. #2
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    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
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    102
    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.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,542
    > 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.

  5. #5
    Registered User
    Join Date
    Apr 2004
    Posts
    102
    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.

  6. #6
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    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!!!!
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  7. #7
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942
    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.

  8. #8
    Registered User
    Join Date
    Apr 2004
    Posts
    102
    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

  9. #9
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,542
    > 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.

  10. #10
    Registered User
    Join Date
    Apr 2004
    Posts
    102
    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.

  11. #11
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    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.
    Last edited by VirtualAce; 01-03-2005 at 09:38 AM.

  12. #12
    Registered User
    Join Date
    Apr 2004
    Posts
    102
    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?

  13. #13
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    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.

  14. #14
    Registered User
    Join Date
    Apr 2004
    Posts
    102
    Oh right thanks, I wasn't sure, I thought maybe there was something I was missing. Thanks for the help bubba

  15. #15
    Registered User
    Join Date
    Apr 2004
    Posts
    102
    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...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help!For poker game simulation
    By tx1988 in forum C++ Programming
    Replies: 24
    Last Post: 05-25-2007, 09:59 PM
  2. Try my game
    By LuckY in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 09-15-2004, 11:58 AM
  3. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM
  5. world of problems with poker game
    By blight2c in forum C++ Programming
    Replies: 5
    Last Post: 04-21-2002, 08:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21