Advertisement

blackjack

Started by September 25, 2024 07:27 PM
34 comments, last by pbivens67 1 month ago

How did you end up handling the duplicate card problem?
Do tell, maybe your way was better.
Do you pre randomize the deck or loop per card until random gives something usable.

true, false, maybe, probably_not

i have not implemented the card problem yet.

Advertisement

I am working on having the mouse click and drag the betting chips. Here is the code I am using so far.

bool quit = false; 
			while( quit == false )
			{ 
				while( SDL_PollEvent( &e ) )
				{ 
					if( e.type == SDL_QUIT ) 
						quit = true; 
					if (e.type == SDL_MOUSEBUTTONDOWN||SDL_MOUSEMOTION)
					{
						if (e.button.button == SDL_BUTTON_LEFT)
						{
							SDL_GetMouseState(&x, &y);
							if (x >= 830 && x <= 870 && y >= 600 && y <= 640)
							{
								SDL_Rect rect_seven;
								rect_seven.x = x;
								rect_seven.y = y;
								SDL_BlitSurface(gHelloWorld_orange, NULL, gScreenSurface, &rect_seven);
								cout << x << " " << y << endl;
								SDL_UpdateWindowSurface(gWindow);
							}
						}
					}

pbivens67 said:
if (e.type == SDL_MOUSEBUTTONDOWN||SDL_MOUSEMOTION)

Not sure what you think this is doing, but it looks quite wrong. Why do you have a constant as second condition ?

I have got the mouse to drag a betting chip around the screen but it does so by writing over the background images. I just want it to drag from the pile of chips to the center of the screen. here is the code I am working on.

				SDL_Rect rect_seven = { objectX, objectY, objectWidth, objectHeight };

				SDL_FillRect(gScreenSurface, &rect_seven,0x007000);
				SDL_BlitSurface(gHelloWorld_orange, NULL, gScreenSurface, &rect_seven);
				SDL_UpdateWindowSurface(gWindow);
Advertisement

I have decided not to use click and drag but only click using the mouse, sorry ignore my previous post.

This topic is closed to new replies.

Advertisement