Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.applet.*;
- import java.awt.event.*;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- import javax.swing.JApplet;
- import javax.swing.JButton;
- import java.awt.image.BufferedImage;
- import java.io.*;
- import javax.imageio.ImageIO;
- import javax.swing.ImageIcon;
- public class LylaMain extends JApplet
- {
- int RETURN_SUCC = 0;
- int RETURN_FAIL = -1;
- Image backGround = null;
- Image startBtn = null;
- Image Logo = null;
- Image credits = null;
- int screen;
- public void init()
- {
- setSize(1280,720);
- playMusic();
- }
- public void start()
- {
- // provide any code requred to run each time applet is visited
- }
- public void stop()
- {
- // provide any code that needs to be run when page is replaced by another applet or before JApplet is destroyed.
- }
- public void paint(Graphics g)
- {
- //This is the Main method for the program flow.
- init();
- startScreen(g);
- }
- public void playMusic()
- {
- AudioClip player = getAudioClip(getCodeBase(), "assets/main.wav");
- player.play();
- player.loop();
- }
- public void startScreen(Graphics g)
- {
- screen = 1; // start screen phase
- Toolkit toolkit = Toolkit.getDefaultToolkit();
- // BackGround
- backGround = toolkit.getImage("assets/bg.jpg");
- g.drawImage(backGround, 0, 0, this);
- //Start button
- startBtn = toolkit.getImage("assets/startBTN.png");
- g.drawImage(startBtn, 850, 300, this);
- //BufferedImage buttonIcon = ImageIO.read(new File("assets/startBTN.png"));
- //JButton buton = new JButton(new ImageIcon(buttonIcon)); BROKEN CODE WILL FIX KEK
- //startBtn.addActionListener(this);
- //Credits button
- credits = toolkit.getImage("assets/creditsBtn.png");
- g.drawImage(credits, 850, 400, this);
- // Primary Banner
- Logo = toolkit.getImage("assets/ao.png");
- g.drawImage(Logo, 650, 0, this);
- // left/right, height
- //clickng detection implemented later
- //creditsScreen(g);
- }
- public int creditsScreen(Graphics g)
- {
- if(screen == 1)
- screen = 3; // credits screen
- else
- return RETURN_FAIL;
- int x,x1,x2,x3,x4,x5,x6,x7;
- int y,y1,y2,y3,y4,y5,y6;
- String s = "Development Team";
- String line1 = "Nadia - Organizer & Leader";
- String line2 = "Tanzia - Story writer & planner of choices";
- String line3 = "Edward - Mouse interaction & Swing";
- String line4 = "Andrew - Cover page & sound";
- String line5 = "Semrah - Graphics & Textboxes";
- String line6 = "Tyler - Animation & Helper";
- String kek = "Special Guest - gEoRgE";
- Dimension d = getSize();
- Font f = new Font("Old English Text MT",Font.BOLD,28);
- g.setFont(f);
- FontMetrics fm = g.getFontMetrics();
- x = d.width/2 - fm.stringWidth(s)/2 ;
- y = d.height/2 - fm.getHeight();
- x1 = d.width/2 - fm.stringWidth(line1)/2 ;
- x2 = d.width/2 - fm.stringWidth(line2)/2 ;
- x3 = d.width/2 - fm.stringWidth(line3)/2 ;
- x4 = d.width/2 - fm.stringWidth(line4)/2 ;
- x5 = d.width/2 - fm.stringWidth(line5)/2 ;
- x6 = d.width/2 - fm.stringWidth(line6)/2 ;
- setBackground(Color.white);
- g.drawImage(backGround, 0, 0, this);
- g.drawString(s,x,y - 30);
- g.drawString(line1, x1, y+35 - 30);
- g.drawString(line2, x2, y + 70 - 30);
- g.drawString(line3, x3, y + 105 - 30);
- g.drawString(line4, x4, y + 140 - 30);
- g.drawString(line5, x5, y + 175 - 30);
- g.drawString(line6, x6, y + 210 - 30);
- x7 = d.width/2 - fm.stringWidth(kek)/2 ;
- Font a = new Font("Arial",Font.PLAIN,10);
- g.setFont(a);
- g.drawString(kek,x7,y + 350);
- return RETURN_SUCC;
- }
- /*public void actionPerformed(ActionEvent e) {
- if (e.getSource() == start) {
- Toolkit.getDefaultToolkit().beep();
- }
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement