Voor alle dingen die een beetje onzin is om een topic voor te maken....
Kun je hier posten
Kun je hier posten


Antonn schreef:wat no?No


Fass schreef:Gewoon algemeen topic zodat je niet voor elk onzin ding een topic hoeft te makenZeg, een koe kan wel. 25 is niet mis voor zo een rare vraag durft niemand van die hoogte kan je het goed zien daar achter de bomen zijn lang.
Wat is het doel van dit topic?






Fass schreef:InderdaadMaar zoiets verdient zn eigen topic toch?
Dat ding is cool 


Fass schreef:waarom moeten mensen erop reageren?Maar zoiets verdient zn eigen topic toch?


Fass schreef:OK!Kijk, elke wasbeer heb een staart. Maar, niet elke staart heb n wasbeer.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Random;
public class Pong extends JFrame implements MouseMotionListener, ActionListener {
private JPanel panel;
private JButton button;
protected boolean mouse = true;
protected Ball ball;
protected int nowMouseX = 0;
protected int controlTheMouseX;
private boolean status;
private int score = 1;
public static void main(String[] args) {
Pong frame = new Pong();
frame.setSize(476, 284);
frame.createGUI();
frame.setResizable(false);
frame.setTitle("Pong");
frame.setLocationRelativeTo(null);
frame.show();
}
private void createGUI() {
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container window = getContentPane();
window.setLayout(new FlowLayout());
panel = new JPanel();
panel.setPreferredSize(new Dimension(450, 220));
panel.setBackground(Color.GREEN);
panel.addMouseMotionListener(this);
window.add(panel);
button = new JButton("New Game");
button.addActionListener(this);
window.add(button);
}
public void mouseDragged(MouseEvent e) {
}
public void stopGame() {
JOptionPane.showMessageDialog(null, "You have Lost!");
System.exit(0);
}
public void winStopGame() {
JOptionPane.showMessageDialog(null, "You have Won!");
System.exit(0);
}
private void draw() {
Graphics paper = panel.getGraphics();
paper.setColor(Color.green);
paper.fillRec
protected void clearPanel(JPanel panel) {
Graphics paper = panel.getGraphics();
int panelWidth = panel.getWidth();
int panelHeight = panel.getHeight();
paper.setColor(Color.green);
paper.drawRect(0, 0, panelWidth, panelHeight);
}
public int getMouseX() {
return nowMouseX;
}
public void mousoved(MouseEvent e) {
Graphics paper = panel.getGraphics();
if (!mouse) {
controlTheMouseX = e.getX();
nowMouseX = e.getX();
draw();
ball.setMouseX(e.getX());
}
}
public void actionPerformed(ActionEvent e) {
Graphics paper = panel.getGraphics();
paper.setColor(Color.DARK_GRAY);
paper.fillRect(0, 200, 450, 20);
paper.setColor(Color.WHITE);
Font font = new Font("tahoma", Font.LAYOUT_LEFT_TO_RIGHT, 18);
paper.setFont(font);
paper.drawString("New Game Started!", 1, 219);
if (mouse) {
ball = new Ball(panel);
ball.start();
ball.changeDiameter(15);
status = true;
mouse = false;
}
}
public void neBall() {
//Not finished yet!
}
class Ball extends Thread
private int diameter = 15;
private Color color = Color.yellow;
private Control control;
private int theCurrentMouseX;
private Random random;
private int theCurrentScore;
private int theDelay = 35;
public Ball(JPanel panel) {
graphics = panel.getGraphics();
}
public void randomColor() {
random = new Random();
int amount = random.nextInt(3);
if (amount == 0) {
color = Color.black;
}
if (amount == 1) {
color = Color.magenta;
}
if (amount == 2) {
color = Color.cyan;
}
if (amount == 3) {
color = Color.blue;
}
}
public void setMouseX(int set) {
theCurrentMouseX = set;
}
public void changeColor(Color c) {
color = c;
}
public Color getColor() {
return color;
}
public void changeDiameter(int d) {
if (d % 5 == 0) {
diameter = d;
}
else {
JOptionPane.showMessageDialog(null, "The value of changeDiameter isnt an integer that can share 5");
}
}
public int getDiameter() {
return diameter;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public void stopBall() {
running = false;
}
public void goBall() {
running = true;
}
public void run() {
while (running) {
control = new Control(getX(), getY(), theCurrentMouseX, getDiameter(), theCurrentScore, graphics);
delete();
move();
bounce();
draw();
delay();
theCurrentScore = control.getScore();
}
}
private void delete() {
graphics.setColor(Color.green);
graphics.fillOval(x,y,diameter,diameter);
}
private void move() {
x = x + xChange;
y = y + yChange;
}
private void bounce() {
//Handles x
if ((x == 0) || (x == 450 - diameter)) {
xChange = -xChange;
}
//Handles y
if ((y == 0) || (y == 190 - diameter)) {
yChange = -yChange;
}
}
private void draw() {
graphics.setColor(color);
graphics.fillOval(x,y,diameter,diameter);
}
private void delay() {
try {
Thread.sleep(theDelay);
}
catch (InterruptedException e) {
}
}
public void setDelay(int del) {
theDelay = del;
}
public int getDelay() {
return theDelay;
}
}
class Control extends Pong {
private int theBallX;
private int theBallY;
private int theMouseX;
private int theDiameter;
private int realBallX = 0;
private int realBallY = 0;
private int theScore = 1;
private Graphics graphics;
public Control(int ballX, int ballY, int mouseX, int diameter, int score, Graphics g) {
theBallX = ballX + diameter / 2;
theBallY = ballY;
theDiameter = diameter;
theScore = score;
graphics = g;
realBallX = ballX;
realBallY = ballY;
theMouseX = mouseX + 18;
controlLose();
}
public int getScore() {
return theScore;
}
private void controlLose() {
//Handles x
if (theBallY == 190 - theDiameter) {
if ((theMouseX + 18 + 10 <= theBallX) || (theMouseX - 18 - 10 >= theBallX)) {
theScore--;
graphics.setColor(Color.DARK_GRAY);
graphics.fillRect(0, 200, 450, 20);
graphics.setColor(Color.white);
Font font = new Font("tahoma", Font.LAYOUT_LEFT_TO_RIGHT, 18);
graphics.setFont(font);
graphics.drawString("Score: " + Integer.toString(theScore) + " Missed Ball :(", 1, 219);
newBall();
if (theScore <= 0) {
Font font2 = new Font("tahoma", Font.LAYOUT_LEFT_TO_RIGHT, 18);
graphics.setFont(font2);
graphics.setColor(Color.DARK_GRAY);
graphics.fillRect(0, 200, 450, 20);
graphics.setColor(Color.white);
graphics.drawString("Score: 0 You have Lost!", 1, 219);
stopGame();
}
}
else {
theScore++;
graphics.setColor(Color.DARK_GRAY);
graphics.fillRect(0, 200, 450, 20);
graphics.setColor(Color.white);
if (theScore == 10) {
Font font = new Font("tahoma", Font.LAYOUT_LEFT_TO_RIGHT, 18);
graphics.setFont(font);
graphics.drawString("Score: " + Integer.toString(theScore) + " Match Point!", 1, 219);
}
else if (theScore < 10) {
Font font = new Font("tahoma", Font.LAYOUT_LEFT_TO_RIGHT, 18);
graphics.setFont(font);
graphics.drawString("Score: " + Integer.toString(theScore), 1, 219);
}
if (theScore == 11) {
Font font = new Font("tahoma", Font.LAYOUT_LEFT_TO_RIGHT, 18);
graphics.setFont(font);
graphics.drawString("Score: 11 You have Won!", 1, 219);
winGame();
}
}
}
else {
}
}
private void controlLoseOrWin() {
if (theScore == 0) {
lostGame();
}
else {
if (theScore == 3) {
winGame();
}
}
}
public void winGame() {
winStopGame();
}
public void lostGame() {
stopGame();
}
}
} 

