Code
This is my little game of pig. I only got it coded for 2 players. I have ran multiple scenarios and it seems to work out good.
I just can’t seem to exit the while loop
I am having trouble at line #109.
I set it to break, but i believe it may be break from the small if statement, which I don’t want.
I am wanting to break from the large while loop ( game loop ) line #100
I also want to use pygame to add some graphics of dice i have created.
I was wondering if I can keep my code as is and just modify it to work with pygame easily or do I have change the entire code to work with pygame?
I just want to do a simple interface
It will be similar to this : http://cs.gettysburg.edu/projects/pig/pi…
but I will add in dice, simulation of dice rolling 2d, sounds, a win state graphics and sounds, and input, mainly mouse toggle.
Any tips on how to do the pygame portion is much appreciated.
I have read many tutorials on pygame, but I just don’t feel confident to get it to work with my own game.
I have made a ball bounce, but I really don’t understand what some of pygame’s code mean.
I am a little confused on display screen vs background
screen would be pygame.display.set_mode((some size))
then background will capture the exact size of the screen, but not really sure.
I have figured out how to put dice on the screen, and change face every half a second, but that’s it.
nice little program. it seems to work fine for me (break exits for and while loops, not if).
when you play the game it’s a little confusing because the check to see if someone has won comes only after the other player plays and then you enter ‘hold’. perhaps that is what made you think it wasn’t working? it might be better (i don’t know the exact rules of pig) to put the check for winning right after the code that runs on ‘hold’?
sorry can’t help with pygame; just wanted to post to say it seems to work.
also, if you wanted, you could put the two players in an array:
and then the current player would be:
and you could use the same code for either player, duplicating the logic in the main loop. so the code would be more like: