Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.event.MouseListener;
- import java.awt.event.MouseEvent;
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Toolkit;
- import java.awt.event.KeyAdapter;
- import java.awt.event.KeyEvent;
- import javax.swing.Timer;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.Random;
- import javax.swing.ImageIcon;
- import javax.swing.JPanel;
- import javax.imageio.*;
- import java.awt.image.*;
- import java.io.*;
- import java.util.Scanner;
- public class BoardFace extends JPanel implements Runnable, MouseListener
- {
- private Dimension d;
- int BOARD_WIDTH=500;
- int BOARD_HEIGHT=500;
- int x = 0;
- private Thread animator;
- boolean click=false;
- public BoardFace()
- {
- addMouseListener(this);
- setFocusable(true);
- d = new Dimension(BOARD_WIDTH, BOARD_HEIGHT);
- if (animator == null ) {
- animator = new Thread(this);
- animator.start();
- }
- setDoubleBuffered(true);
- }
- public void paint(Graphics g){
- super.paint(g);
- g.setColor(Color.white);
- g.fillRect(0, 0, d.width, d.height);
- //brown becmones a new instance of the Color class...
- Color brown = new Color(101,0,0);
- Color orange = new Color(255,69,0);
- Color purple=new Color(250,0,250);
- g.setColor(Color.black);
- //head
- g.fillOval(184,100, 160, 160);
- //body
- g.fillOval(164,180, 200, 250);
- //arms
- g.fillOval(100,250, 125, 50);
- g.fillOval(300,250, 125, 50);
- //white accents
- g.setColor(Color.white);
- //stomach
- g.fillOval(175,200, 165, 215);
- //eyes things
- g.fillOval(195,150, 80,80);
- g.fillOval(250,150, 80,80);
- //eyes
- g.setColor(Color.black);
- g.fillOval(220,170, 15, 25);
- g.fillOval(280,170, 15, 25);
- //pupils
- g.setColor(Color.white);
- g.fillOval(220,178, 10, 10);
- g.fillOval(280,178, 10, 10);
- //nose and feet
- g.setColor(orange);
- //nose
- g.fillOval(223,200, 70, 30);
- //feet
- g.fillOval(190,410, 60, 30);
- g.fillOval(270,410, 60, 30);
- //click feature
- if (click==true){
- g.setColor(purple);
- g.fillRect(175, 75, 175, 50);
- g.fillRect(200, 25, 125, 100);
- }
- //name
- g.setColor(Color.black);
- g.setFont (new Font("TimesRoman", Font.PLAIN, 25));
- g.drawString("Maya Gambhir" , 20, 20);
- Toolkit.getDefaultToolkit().sync();
- g.dispose();
- }
- public void run() {
- long beforeTime, timeDiff, sleep;
- beforeTime = System.currentTimeMillis();
- int animationDelay = 500;
- long time =
- System.currentTimeMillis();
- while (true) {//infinite loop
- // spriteManager.update();
- repaint();
- try {
- time += animationDelay;
- Thread.sleep(Math.max(0,time -
- System.currentTimeMillis()));
- }catch (InterruptedException e) {
- System.out.println(e);
- }//end catch
- }//end while loop
- }//end of run
- public void mousePressed(MouseEvent e) {
- int x = e.getX();
- int y = e.getY();
- if (click==false){
- click=true;
- }
- else
- {click=false;}
- }
- public void mouseReleased(MouseEvent e) {
- }
- public void mouseEntered(MouseEvent e) {
- }
- public void mouseExited(MouseEvent e) {
- }
- public void mouseClicked(MouseEvent e) {
- }
- }//end of class
- //end of class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement