i've been trying to get into 2D game programing
i started a tutorial on utube (java game programing)(the new boston channel)
PHP Code:
package bucky;
import javax.swing.ImageIcon;
import java.awt.*;
import javax.swing.JFrame;
public class buckyy extends JFrame
{
public static void main(String[] args)
{
DisplayMode dm = new DisplayMode(800,600,16,
DisplayMode.REFRESH_RATE_UNKNOWN);
buckyy b = new buckyy();
b.run(dm);
}
private Screen s;
private Image bg;
private Image pic;
private boolean loaded;
public void run(DisplayMode dm)
{
setBackground(Color.green);
setForeground(Color.red);
loaded = false;
load();
s = new Screen();
try
{
s.setFullScreen(dm, this);
try
{
Thread.sleep(5000);
} catch (Exception e)
{
}
} finally
{
s.restoreScreen();
}
}
public void load()
{
bg = new ImageIcon("bardejov.jpg").getImage();
pic = new ImageIcon("p.png").getImage();
loaded = true;
repaint();
}
public void paint(Graphics g)
{
setBackground(Color.green);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
if (loaded)
{
g.drawImage(pic,0,0,null);
g.drawString("LOL", 110, 200);
}
}
}
this is the other class
PHP Code:
package bucky;
import java.awt.*;
import javax.swing.JFrame;
public class Screen
{
private GraphicsDevice vc;
public Screen()
{
GraphicsEnvironment env = GraphicsEnvironment
.getLocalGraphicsEnvironment();
vc = env.getDefaultScreenDevice();
}
public void setFullScreen(DisplayMode dm, JFrame window)
{
window.setUndecorated(true);
window.setResizable(false);
vc.setFullScreenWindow(window);
try{
vc.setDisplayMode(dm);
}catch(Exception e){
}
}
public Window getFullScreenWindow(){
return vc.getFullScreenWindow();
}
public void restoreScreen(){
Window w = vc.getFullScreenWindow();
if(w != null)
w.dispose();
vc.setFullScreenWindow(null);
}
}
the problem is it's not working on win 7 , it just gives me full black screen with the String "LOL"
but no background color ... no images !!
but i tried the same code in wind XP and it worked !