My problem is, I have an array for a log object, the parameters are made in the same class. But the problem is I don't know how to get the parameters called logX logY etc into an actual object.
This is to make the object appear on the screen, but if I can even get it to become an object fist, that would solve so many problems!
This is the Log class:
package Frogger;
import javax.swing.JFrame;
public class Logs extends JFrame
{
private int X;
private int Y;
private int width;
private int height;
Logs[] LogArray = new Logs[10];
{
LogArray[0].X = 0;
LogArray[0].Y = 0;
LogArray[0].width = 50;
LogArray[0].height = 50;
}
}
This is the main:
package Frogger;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Random;
public class Frogger_Main extends JFrame implements ActionListener
{
private Container cPane;
private JMenuBar mb;
private JMenu mSystem;
private JMenuItem mIRules, mIExit;
private JButton btnExit, btnStart,btnReset;
private JLabel lblTitle;
private JPanel pNorth, pSouth, pCentre, pEast;
private JPanel imagePanel;
public void actionPerformed(ActionEvent e)
{/*For the main public class*/}
public Frogger_Main()//Constructor
{
cPane = getContentPane();
imagePanel = new JPanel()
{
public void paint(Graphics g)//The background thing
{
try
{
BufferedImage image = ImageIO.read(new File("Background.jpg"));
g.drawImage(image, 1, 1, null);
}
catch (IOException e)
{
e.printStackTrace();
}
}
};
imagePanel.setPreferredSize(new Dimension(500,500));
cPane.add(imagePanel); // End of the background thing
}
}
And this is the class that will run it:
package Frogger;
import javax.swing.JFrame;
public class Test_Frogger
{
public static void main(String[] args)
{
Frogger_Main f = new Frogger_Main();
f.setTitle("Frogger");
f.setSize(1280,980);
f.setResizable(false);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
}
Logsclass?