viernes, 2 de agosto de 2019

Ignacio Suanes Juego 1 01

package Juego;

import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Dimension;

import javax.swing.JFrame;

public class Juego extends Canvas implements Runnable {

/**
*
*/
private static final long serialVersionUID = 1L;

private static final int ANCHO = 800;
private static final int ALTO = 800;
private static final String NOMBRE = "Juego";

private static JFrame ventana;

private static Thread thread;

private Juego() {
setPreferredSize(new Dimension(ANCHO, ALTO));

ventana = new JFrame(NOMBRE);

// detalle importante, el siguiente paso es para que la aplicacion no se siga
// ejecutando en segundo plano

ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

ventana.setResizable(false);
ventana.setLayout(new BorderLayout());

ventana.add(this, BorderLayout.CENTER);
ventana.pack();
ventana.setLocationRelativeTo(null);
ventana.setVisible(true);

}

public static void main(String[] args) {

Juego juego = new Juego();

//si queremos que dos cosas funcionen a la vez necesitamos threads
}

private void iniciar()
{
//iniciar segundo thread o el juego en general


}

private void detener()
{
thread = new Thread(this,"Graficos"): //hay que indicarle desde la clase de la que se va a ejecutar y ponerle un nombre

}

@Override
public void run() {
// TODO Auto-generated method stub

}

}

No hay comentarios:

Publicar un comentario