hi guys well im start learning Java scripting and to start i make a simple 2d game but im stuck at the part of it and i hope some one can help for that i know it`s not about Sro but i learn it to get some skill`s to make somthing for Sro by Java script this is my code
when i call the image it dont appear it just open the frame and the title that`s it
here the full code
best regards
mats0o0o0
Code:
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class GameFrame extends JPanel{
public GameFrame() {
setFocusable(true);
}
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D)g;
g2d.drawString("Hello ESFA ", 150, 100);
ImageIcon ic = new ImageIcon("C:/New Folder/Player.PNG");
Image i= ic.getImage();
g2d.drawImage(i, 500, 200, null);
}
}
here the full code
Code:
import javax.swing.JFrame;
public class ESFA {
public static void main(String[] args) {
JFrame frame=new JFrame("ESFA Game");
frame.setSize(800,600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.add(new GameFrame());
frame.setVisible(true);
}
}
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class GameFrame extends JPanel{
public GameFrame() {
setFocusable(true);
}
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D)g;
g2d.drawString("Hello ESFA ", 150, 100);
ImageIcon ic = new ImageIcon("C:/New Folder/Player.PNG");
Image i= ic.getImage();
g2d.drawImage(i, 500, 200, null);
}
}
mats0o0o0