Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Game Development
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Java
»
Game Development
Count a players wins in Connect four
Ollie Dee
,
Greenhorn
Jul 08, 2013 13:56:41
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Hi, could anyone show me how to write something to keep count of a players score, below is the code to display when either red wins or black wins, any ideas how I could add it to this code. Thanks
public void displayWinner(Graphics g, int n) { g.setColor(Color.GREEN); g.setFont(new Font("Courier", Font.BOLD, 80)); if (n==BLACK) g.drawString("Black Wins:)", 200, 400); else g.drawString("red Wins:)", 200, 400); end=true; } public void check4(Graphics g) { // see if there are 4 disks in a row: horizontal, vertical or diagonal // horizontal rows for (int row=0; row<MAXROW; row++) { for (int col=0; col<MAXCOL-3; col++) { int curr = theArray[row][col]; if (curr>0 && curr == theArray[row][col+1] && curr == theArray[row][col+2] && curr == theArray[row][col+3]) { displayWinner(g, theArray[row][col]); } } }
fred rosenberger
,
lowercase baba
staff
Jul 08, 2013 14:07:28
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Just posting "it doesn't work" doesn't really allow us to help you. We even have a couple of FAQs on that very topic (click each):
ItDoesntWorkIsUseless
TellTheDetails
.
Please read those and come back with more info. Remember - the best way to get help is to make it as easy as possible for someone to help you.
Post by:
autobot
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
This thread has been viewed 859 times.
Similar Threads
After two days, I still can't see the obvious.
Need some help, pleeaaase!!
Instance of Graphics ,g , can't be recognized in applen
problem with program hanging
synchronization.. and threads !!!
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:45:41
.