La descarga está en progreso. Por favor, espere

La descarga está en progreso. Por favor, espere

TP Grupo 7: Presentación Algoritmos y Programación III (75.07) Cursos Fontela Primer Cuatrimestre de 2009.

Presentaciones similares


Presentación del tema: "TP Grupo 7: Presentación Algoritmos y Programación III (75.07) Cursos Fontela Primer Cuatrimestre de 2009."— Transcripción de la presentación:

1 TP Grupo 7: Presentación Algoritmos y Programación III (75.07) Cursos Fontela Primer Cuatrimestre de 2009

2 Modelo

3

4

5

6 Vista

7

8 import ar.uba.fi.algo3.titiritero.Dibujable; import ar.uba.fi.algo3.titiritero.vista.SubVista; public class JuegoSubVista extends SubVista { private Juego juego; public JuegoSubVista(Juego juego) { super(0, 0, 580, 800); setColor(Color.GREEN); this.juego = juego; } protected void cargarDibujablesDeLaSubVista() { Nivel nivel = juego.getNivel(); ListIterator iterator = nivel.getCamino().iterator(); while (iterator.hasNext()){ agregarDibujable(new VistaPeldañoDelCamino((Posicion) iterator.next())); } for (Object atacanteObject : nivel.getAtacantes()){ agregarDibujable(new VistaElemento((ElementoUbicableEnTerreno) atacanteObject)); } for (Object enemigoObject : nivel.getEnemigos()){ agregarDibujable(new VistaElemento((ElementoUbicableEnTerreno) enemigoObject)); }

9 Controlador

10

11 import componentes.Juego; import enemigo.EnemigoFactory; import ar.uba.fi.algo3.titiritero.ObjetoVivo; public class JuegoVivo implements ObjetoVivo { private Juego juego; private static final int CICLOS_HASTA_AGREGAR_ENEMIGO = 20; private int cantCiclosPasaron; public JuegoVivo(Juego juego){ this.juego = juego; cantCiclosPasaron = 10; } public void vivir() { if (cantCiclosPasaron == CICLOS_HASTA_AGREGAR_ENEMIGO){ juego.getNivel().agregarEnemigo(EnemigoFactory.generarEnemigo(juego)); cantCiclosPasaron = 0; } juego.continuar(); cantCiclosPasaron++; }

12 Programa Principal (Pequeño ejemplo) public static void main(String[] args) throws FileNotFoundException { ControladorJuego controlador = new ControladorJuego(); Juego juego = new Juego("Matata"); Ventana ventana = new VentanaPrincipal(controlador); controlador.setSuperficieDeDibujo(ventana); ventana.setVisible(true); Nivel nivel = juego.getNivel(); Torre torreBlanca = new TorreBlanca(new Posicion(5,2)); Obstaculo pegote = new Gelatina(new Posicion(5,4)); nivel.agregarAtacante(torreBlanca); nivel.agregarAtacante(pegote); nivel.agregarAtacante(torreBlanca2);

13 //juego. //Agrego las vistas del juego JugadorSubVista vistaJugador = new JugadorSubVista(juego.getJugador()); controlador.agregarDibujable(vistaJugador); controlador.agregarDibujable(new JuegoSubVista(juego)); controlador.agregarDibujable(new MenuSubVista()); //Agrego al objeto vivo controlador.agregarObjetoVivo(new JuegoVivo(juego)); controlador.setIntervaloSimulacion(50); try { controlador.comenzar(); } catch (JugadorSeMurioException jsme){ controlador.detener(); }

14 FIN MUCHAS GRACIAS


Descargar ppt "TP Grupo 7: Presentación Algoritmos y Programación III (75.07) Cursos Fontela Primer Cuatrimestre de 2009."

Presentaciones similares


Anuncios Google