Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JButton;
- import javax.swing.JComponent;
- import java.awt.Graphics;
- import javax.swing.JFrame;
- import java.awt.image.*;
- import javax.swing.Icon;
- import javax.swing.ImageIcon;
- import java.awt.event.*;
- import java.awt.*;
- import javax.swing.*;
- public class gameLoop extends Thread{
- public static boolean gameIsRunning = false;
- public static final int FPS = 60;
- public static boolean sentinel = false;
- public static void main(String[] Args){
- getResources get = new getResources();
- JFrame window = new JFrame("Out from Eden");
- window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- window.setBounds(30, 30, 516, 424); // it's a 500 x 385 image idk what's up
- Icon startButtonImg = new ImageIcon(get.getImg("Start"));
- Icon startButtonOverImg = new ImageIcon(get.getImg("StartOver"));
- Icon stopButtonImg = new ImageIcon(get.getImg("Stop"));
- Icon stopButtonOverImg = new ImageIcon(get.getImg("StopOver"));
- JButton startButton = new JButton(startButtonImg);
- startButton.setRolloverIcon(startButtonOverImg);
- JButton stopButton = new JButton(stopButtonImg);
- stopButton.setRolloverIcon(stopButtonOverImg);
- window.add(startButton);
- startButton = setButtonSize(startButton,140,115,300,50);
- window.add(stopButton);
- stopButton = setButtonSize(stopButton,121,133,300,200);
- startButton.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e) {
- window.dispose();
- gameStart();
- }
- });
- stopButton.addActionListener(new Stop());
- window.getContentPane().add(new MyCanvas());
- window.setVisible(true);
- }
- public static JButton setButtonSize(JButton button,
- int w, int h, int x, int y){
- button.setSize(w,h);
- button.setLocation(x,y);
- button.setBorderPainted(false);
- button.setFocusPainted(false);
- button.setBorder(BorderFactory.createEmptyBorder());
- button.setContentAreaFilled(false);
- return button;
- }
- static class Stop implements ActionListener{
- public void actionPerformed (ActionEvent e){
- System.exit(0);
- }
- }
- public void run(){
- if (gameIsRunning == true){
- System.out.println("This should start the game");
- }
- }
- public static void gameStart(){
- gameIsRunning = true;
- (new Thread(new gameLoop())).start();
- }
- }
- class MyCanvas extends JComponent{
- public void paint(Graphics g){
- getResources get = new getResources();
- BufferedImage titleImg = get.getImg("Title");
- BufferedImage testImg = get.getImage("");
- g.drawImage(titleImg, 0, 0, null);
- g.drawImage(testImg, 0 , 0, null);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment