Boa noite,
Estou tentanto clicar um applet que realiza movimentos. Achei este código na internet e gostaria de realizar algumas tarefas.
Fazer com que a bola retorne ao atingir a moldura direita
Fazer com que a bola retorne ao atingir a moldura direita ou esquerda
Fazer abola subir e descer com inclinação de 45 graus
Não permitir que a bolas saia das molduras
Adicionar mais uma bola ao ?jogo? com cor diferente
Podem me dar umas dicas para realizar outros eventos. Tipo eventos com mouse.
import java.awt.*;
import java.applet.*;
public class Primeirojogo extends Applet implements Runnable {
int x_pos = 20;
int y_pos = 100;
int radius = 20;
public void init() {
}
public void start() {
Thread th = new Thread(this);
th.start();
}
public void stop() {
}
public void destroy() {
}
public void run() {
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
while (true) {
repaint();
try {
Thread.sleep(20);
} catch (InterruptedException ex) {
}
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
x_pos++;
}
}
public void paint(Graphics g) {
g.setColor(Color.red);
g.fillOval(x_pos - radius, y_pos - radius, 2 * radius, 2 * radius);
}
}