1 
   2 /**
   3  * Animación.java
   4  * @author Germán Augusto Rojas Pérez
   5  * Muestra una animacion de un muñeco en java con mi compañero de grupo Diego Saavedra.
   6  * Para la materia esquemas y técnicas jornada nocturna con el profesor Luis Alejandro Bernal
   7  */
   8 
   9 
  10 import java.awt.*;
  11 import javax.swing.*;
  12 import java.awt.event.*;
  13 
  14 
  15 
  16 
  17 class Lienzo extends Canvas{
  18     public void paint(Graphics g){
  19         int h;
  20             g.setColor( Color.BLUE );
  21             g.fillOval(200,40,35,5);
  22             for(h=1;h<=200;h=h+11){
  23                 if (h%2==0){
  24                     g.setColor(Color.WHITE );
  25                     g.fillOval(0+(h*1),0,20,20);
  26                     g.drawLine(10+(h*1),20,10+(h*1),40);
  27                     
  28                     g.drawLine(10+(h*1),25,20+(h*1),28);
  29                     g.drawLine(10+(h*1),25,10+(h*1),23);
  30                 }
  31                 else{
  32                     g.setColor(Color.WHITE );
  33                     g.fillOval(0+(h*1),0,20,20);
  34                     g.drawLine(10+(h*1),20,10+(h*1),30);
  35                     g.drawLine(10+(h*1),30,20+(h*1),40);
  36                     g.drawLine(10+(h*1),30,0+(h*1),40);
  37                     
  38                     g.drawLine(10+(h*1),23,20+(h*1),25);
  39                     g.drawLine(20+(h*1),25,25+(h*1),20);
  40                     
  41                     g.drawLine(10+(h*1),23,0+(h*1),25);
  42                     g.drawLine(0+(h*1),25,0+(h*1),27);
  43                     
  44                 }
  45                 try{
  46                     Thread.sleep(200);
  47                 }
  48                 catch(Exception e){
  49                 }
  50                 if (h%2==0){
  51                     g.setColor(Color.BLACK );
  52                     g.fillOval(0+(h*1),0,20,20);
  53                     g.drawLine(10+(h*1),20,10+(h*1),40);
  54                     
  55                     g.drawLine(10+(h*1),25,20+(h*1),28);
  56                     g.drawLine(10+(h*1),25,10+(h*1),23);
  57                 }
  58                 else{
  59                     g.setColor(Color.BLACK);
  60                     g.fillOval(0+(h*1),0,20,20);
  61                     g.drawLine(10+(h*1),20,10+(h*1),30);
  62                     g.drawLine(10+(h*1),30,20+(h*1),40);
  63                     g.drawLine(10+(h*1),30,0+(h*1),40);
  64                     g.drawLine(10+(h*1),23,20+(h*1),25);
  65                     g.drawLine(20+(h*1),25,25+(h*1),20);
  66                     g.drawLine(10+(h*1),23,0+(h*1),25);
  67                     g.drawLine(0+(h*1),25,0+(h*1),29);
  68                 }
  69             }
  70             g.setColor( Color.WHITE);
  71             g.fillOval(200,20,20,20);
  72             g.drawString("AAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHHHHHH",250,10);
  73             for(h=1;h<=300;h=h+11){
  74                 if (h%2==0){
  75                     g.setColor(Color.WHITE );
  76                     g.drawLine(210,40,230,30);
  77                 }
  78                 else{
  79                     g.setColor(Color.WHITE  );
  80                     g.drawLine(210,40,210,30);
  81                 }
  82                 try{
  83                     Thread.sleep(20);
  84                 }
  85                 catch(Exception e){
  86                 }
  87                 if (h%2==0){
  88                     g.setColor(Color.BLACK  );
  89                     g.drawLine(210,40,230,30);
  90                 }
  91                 else{
  92                     g.setColor(Color.BLACK  );
  93                     g.drawLine(210,40,210,30);
  94                 }
  95             }
  96             g.setColor( Color.BLACK );
  97             g.fillOval(200,20,20,20);
  98             
  99                 
 100     }
 101 }
 102 
 103 public class Animacion {
 104 
 105     public static void main(String args[]) {
 106         JFrame marco=new JFrame("Dibujar");
 107         Lienzo l=new Lienzo();
 108         l.setBackground(Color.BLACK );
 109         marco.setLayout(new GridLayout(1,4));
 110         marco.setBackground(Color.BLACK );
 111         marco.add(l);
 112         marco.setSize(500,500);
 113         marco.setLocation(300,300);
 114         marco.setVisible(true);
 115     }
 116 }
 117 

Java/Programas (last edited 2008-04-20 14:37:48 by localhost)