Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. import java.awt.*;
  2. import java.applet.*;
  3. import java.awt.event.*;
  4.  
  5.  
  6.  
  7.  
  8. public class Maze extends Applet implements MouseListener,KeyListener{
  9. int xPos, yPos,level;
  10.  
  11.  
  12. public void init() {
  13. setBackground(Color.WHITE);
  14. xPos = 100; //original position x
  15. yPos = 50; // original position y
  16. addMouseListener(this);
  17. addKeyListener(this);
  18. requestFocus();
  19.  
  20.  
  21. setBackground(Color.BLACK); //sets background color
  22. }
  23.  
  24. public void keyReleased(KeyEvent ke){
  25. }
  26.  
  27. public void keyTyped(KeyEvent ke){
  28. }
  29.  
  30. public void mouseExited(MouseEvent ae){
  31. }
  32.  
  33. public void mouseEntered(MouseEvent ae){
  34. }
  35.  
  36. public void mouseReleased(MouseEvent ae){
  37. }
  38.  
  39. public void mousePressed(MouseEvent ae){
  40. }
  41.  
  42. public void mouseClicked(MouseEvent ae){
  43. }
  44.  
  45. public void mouseDragged(MouseEvent ae){
  46. }
  47.  
  48. public void keyPressed(KeyEvent ke){
  49. int x = ke.getKeyCode();
  50. switch(x){
  51. case(KeyEvent.VK_SPACE):
  52. level=1;
  53. break;
  54. }
  55. }
  56.  
  57. public void paint(Graphics g) {
  58. Font myFont = new Font("Party LET", Font.BOLD, 30);
  59.  
  60. //drawing the boxes for menus
  61. g.setColor(ColorLibZhang.BABYBLUE());
  62. g.fillRect(220,220,100,50);
  63. g.setColor(Color.BLACK);
  64. g.drawString("SPACE to start!",225,250);
  65.  
  66. //title
  67. g.setColor(ColorLibZhang.BABYBLUE());
  68. g.setFont(myFont);
  69. g.drawString("aMAZEing maze!",150,100);
  70.  
  71. //fonts
  72. g.setColor(Color.WHITE);
  73. g.setFont(myFont);
  74. g.drawString("Use the MOUSE to guide the ball!", 10, 40);
  75.  
  76. //level 1
  77. if (level==1){
  78. //clearing the background
  79. g.setColor(Color.BLACK);
  80. g.fillRect(0,0,500,500);
  81. }
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement