Original Post
Okay here is the code I got thus far only been working for a few minutes, and my first time with a double buffer.
The problem I am having is it takes between 2 and 5 seconds to render the image, if it wasn't going to become a game in the long run then I wouldn't mind but I would like to get at least 10FPS not .5 to .2 FPS.
So far the only way I know to speed it up is to remove the buffer, but then it flickers too much.
Can anyone tell me what I could do to speed up this process.
Just so you don't blame my PC the specs are:
2.67GHz Core2 Quad Q9400
8GB ram
NVidia 9400GT - 1GB
Windows 7 Ultimate x64 and UBUNTU 10.04 x64
Thanks in advance,
THoover
import java.io.*;import java.net.*;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.lang.*;import java.lang.Math;import javax.swing.JApplet;import java.sql.*;import javax.imageio.*;public class HalfDoomed extends JApplet implements Runnable, ActionListener, KeyListener, MouseListener, MouseMotionListener{ //USER types - 0=normal 1=admin 2=mod 3=member //CHAT types - 0=all 1=private int debug = 1; Image background = null; Image foreground = null; Thread runner; Thread chatter; Thread fighter; Thread walker; String currentScreen = "login"; int XPos; int YPos; int loggedin = 0; int field = 0; String username = ""; String password = ""; String passshow = ""; @Override public void init() { setSize( 800, 600 ); //Container content = getContentPane(); //content.setLayout(new GridBagLayout()); // Used to center the panel //content.add(myGame); addMouseListener(this); addKeyListener(this); addMouseMotionListener(this); runner = new Thread(this); runner.setPriority(10); runner.start(); } public void mouseClicked (MouseEvent me) { int got = 0; int X=me.getX(); int Y=me.getY(); } public void mouseDragged (MouseEvent mme) { } public void mouseMoved (MouseEvent mme) { XPos = mme.getX(); YPos = mme.getY(); } public void mouseEntered (MouseEvent me) { } public void mousePressed (MouseEvent me) { } public void mouseReleased (MouseEvent me) { } public void mouseExited (MouseEvent me) { } public void actionPerformed(ActionEvent e) { } public void keyTyped(KeyEvent event) { } public void keyPressed(KeyEvent event) { } public void keyReleased(KeyEvent event) { } public void run() { while (runner == Thread.currentThread() ) { repaint(); try { Thread.sleep(1); } catch(InterruptedException ien) { } } } @Override public void paint (Graphics gg) { Graphics2D g = (Graphics2D)gg; Graphics BGg; background = null; background = createImage(800, 600); BGg = background.getGraphics(); //menu all screens 25 down 1024 over screen(gg, background); paint(BGg); Graphics FGg; foreground = null; foreground = createImage(800, 600); BGg = foreground.getGraphics(); //menu all screens 25 down 1024 over game(gg, foreground); paint(BGg); g.drawImage(background, 0, 0, this); g.drawImage(foreground, 0, 0, this); } @Override public void update(Graphics g) { paint(g); } void game(Graphics g, Image gg) { if(loggedin == 1) { g.setColor(Color.decode("0x000000")); g.fill3DRect(0, 0, 600, 400, true); } } void screen(Graphics g, Image gg) { if(currentScreen.equals("login")) { g.setColor(Color.decode("0x000000")); g.fill3DRect(0,0,800,600,true); g.setColor(Color.decode("0xED1C24")); g.setFont(new Font ("Courier New", Font.PLAIN, 52)); g.drawString("Half-Doomed v.0.01 BETA", 20, 60); g.setColor(Color.decode("0x880015")); g.fill3DRect(18, 91, 757, 478, true); g.setColor(Color.decode("0x000000")); g.setFont(new Font ("Courier New", Font.BOLD, 24)); g.drawString("Username", 21, 221); g.drawString("Password", 21, 285); g.setColor(Color.decode("0xFFFFFF")); g.fill3DRect(174, 199, 582, 32, true); g.fill3DRect(174, 259, 582, 32, true); g.setColor(Color.decode("0x000000")); g.setFont(new Font ("Courier New", Font.PLAIN, 16)); if(field == 0) { g.drawString(username+"_", 180, 220); g.drawString(passshow, 180, 280); } if(field == 1) { g.drawString(username, 180, 220); g.drawString(passshow+"_", 180, 280); } g.setColor(Color.decode("0xC3C3C3")); g.fill3DRect(310, 325, 145, 50, true); g.setColor(Color.decode("0x000000")); g.setFont(new Font ("Courier New", Font.BOLD, 24)); g.drawString("Log In", 335, 355); } if(debug == 1) { g.setColor(Color.decode("0x000000")); g.setFont(new Font ("Courier New", Font.BOLD, 24)); g.drawString(XPos+", "+YPos, 40, 530); } }}The problem I am having is it takes between 2 and 5 seconds to render the image, if it wasn't going to become a game in the long run then I wouldn't mind but I would like to get at least 10FPS not .5 to .2 FPS.
So far the only way I know to speed it up is to remove the buffer, but then it flickers too much.
Can anyone tell me what I could do to speed up this process.
Just so you don't blame my PC the specs are:
2.67GHz Core2 Quad Q9400
8GB ram
NVidia 9400GT - 1GB
Windows 7 Ultimate x64 and UBUNTU 10.04 x64
Thanks in advance,
THoover