craps

import java.awt.event.MouseListener; import java.awt.event.MouseEvent; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Toolkit; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.Timer; import java.util.ArrayList; import java.util.Iterator; import java.util.Random; import javax.swing.ImageIcon; import javax.swing.JPanel; import javax.imageio.*; import java.awt.image.*; import java.io.*; public class Pong extends JPanel implements Runnable, MouseListener { boolean inGame = false; private Dimension d; int BOARD_WIDTH=500; int BOARD_HEIGHT=500; int x = 0; int die1; int die2; int dice; int point; int counter = 0; int inGame1; int inGame2; int p1; int p2; int imageX = 0; int imageY = 0; int spacer = 64; int imageX1 = 0; int imageY1 = 0; BufferedImage img; String message = "Click Board to Start"; String message1; private Thread animator; public Pong() { addMouseListener(this); setFocusable(true); d = new Dimension(BOARD_WIDTH, BOARD_HEIGHT); setBackground(Color.black); try { img = ImageIO.read(this.getClass().getResource("dice.png")); } catch (IOException e) { System.out.println("Image could not be read"); // System.exit(1); } if (animator == null || !inGame) { animator = new Thread(this); animator.start(); } setDoubleBuffered(true); } public void paint(Graphics g) { super.paint(g); g.setColor(Color.white); g.fillRect(0, 0, d.width, d.height); g.setColor(Color.red); g.fillRect(0, 0, 50, 50); g.fillOval(x,20,70,20); Font small = new Font("Helvetica", Font.BOLD, 14); FontMetrics metr = this.getFontMetrics(small); g.setColor(Color.black); g.setFont(small); g.drawString(message, 10, d.height-60); g.drawString(message1, 10, d.height-100); if (inGame) { placeDiceOnScreen(); g.drawImage(img,100,200, 164,264,imageX,imageY,imageX + spacer,imageY + spacer,null); g.drawImage(img,300,200, 364,264,imageX1,imageY1,imageX1 + spacer,imageY1 + spacer,null); } //x = x + 5; //drawImage(Image img,int dstx1, int dsty1, int dstx2, int dsty2, //int srcx1, int srcy1, int srcx2, int srcy2,ImageObserver observer); Toolkit.getDefaultToolkit().sync(); g.dispose(); } public void placeDiceOnScreen(){ if(die1>=4){ imageY = spacer; }else{ imageY = 0; } if(die1<=3){ imageX = (spacer * die1) - spacer; }else{ imageX = ((spacer * die1) - spacer) - 192; } if(die2>=4){ imageY1 = spacer; }else{ imageY1 = 0; } if(die2<=3){ imageX1 = (spacer * die2) - spacer; }else{ imageX1 = ((spacer * die2) - spacer) - 192; } } public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); inGame=true; while(counter < 1){ openRoll(); counter ++; } //message = "die1: " + die1 + " die2: " + die2; openRollLogic(); inGameLogic(); /* inGameLogic(); cashValue(); */ } public void openRoll(){ die1 = makeRandomNumbers(1,6); die2 = makeRandomNumbers(1,6); dice = die1 + die2; point = die1 + die2; message1 = "Point is equal to " + dice; placeDiceOnScreen(); } public int makeRandomNumbers(int min, int max){ int rand = (int) (Math.random( ) * (max)) + min; return rand; } public void openRollLogic(){ while(counter<2){ if(dice == 7 || dice == 11) win(); else{ inGameLogic(); counter++; placeDiceOnScreen(); } if(dice == 2 || dice == 3 || dice == 12) lose(); else{ inGameLogic(); counter++; placeDiceOnScreen(); } } } public void win(){ message = "You won with: " + dice; //inGame=false; } public void lose(){ message = "You lost with: " + dice; //inGame=false; } public void inGameLogic(){ placeDiceOnScreen(); message = "Opening roll does not win or lose. Win if your roll " + point + " Lose if you roll 7"; inGame1 = makeRandomNumbers(1,6); inGame2 = makeRandomNumbers(1,6); if(inGame1 + inGame2 == point){ message = "You Win, click to play again"; }else{ inGame1 = makeRandomNumbers(1,6); inGame2 = makeRandomNumbers(1,6); message = "You rolled: " + inGame1 + " " + inGame2; placeDiceOnScreen(); } if(inGame1+inGame2 == 7){ message = "You Lose, click to play again"; }else{ inGame1 = makeRandomNumbers(1,6); inGame2 = makeRandomNumbers(1,6); placeDiceOnScreen(); } } public void mouseReleased(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mouseClicked(MouseEvent e) { } public void run() { long beforeTime, timeDiff, sleep; beforeTime = System.currentTimeMillis(); int animationDelay = 20; long time = System.currentTimeMillis(); while (true) {//infinite loop // spriteManager.update(); repaint(); try { time += animationDelay; Thread.sleep(Math.max(0,time - System.currentTimeMillis())); }catch (InterruptedException e) { System.out.println(e); }//end catch }//end while loop }//end of run }//end of class

2 Responses

Yeah you're right this game is crap
@Sameer Saxena What the fuck did you just fucking say about me, you little bitch? I’ll have you know I graduated top of my class in the Navy Seals, and I’ve been involved in numerous secret raids on Al-Quaeda, and I have over 300 confirmed kills.

I am trained in gorilla warfare and I’m the top sniper in the entire US armed forces. You are nothing to me but just another target. I will wipe you the fuck out with precision the likes of which has never been seen before on this Earth, mark my fucking words.

You think you can get away with saying that shit to me over the Internet? Think again, fucker. As we speak I am contacting my secret network of spies across the USA and your IP is being traced right now so you better prepare for the storm, maggot. The storm that wipes out the pathetic little thing you call your life. You’re fucking dead, kid. I can be anywhere, anytime, and I can kill you in over seven hundred ways, and that’s just with my bare hands.

Not only am I extensively trained in unarmed combat, but I have access to the entire arsenal of the United States Marine Corps and I will use it to its full extent to wipe your miserable ass off the face of the continent, you little shit. If only you could have known what unholy retribution your little “clever” comment was about to bring down upon you, maybe you would have held your fucking tongue.

But you couldn’t, you didn’t, and now you’re paying the price, you goddamn idiot. I will shit fury all over you and you will drown in it.

You’re fucking dead, kiddo.

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.