Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Performance Tuning / Re: Active AND Passive Rendering? JPanel on: 2011-09-03 09:22:32
http://www.realapplets.com/tutorial/DoubleBuffering.html

The 3 boxes depict it well, although due to the black background they seem slightly harmless as the flashes themselves are black.


So are you suggesting I just forget about double buffering? :/ And see what happens if I let it automatically deal with it?
2  Game Development / Performance Tuning / Active AND Passive Rendering? JPanel on: 2011-09-03 08:40:15
[size=10pt]Greetings all! [/size] Cool

At the moment I have created a physics engine which I am using to produce both a game and simulation. For my simulation, I need to use quite a lot of swing, and am having to created the program using an applet rather than straight JFrame etc.

The program itself is a JPanel and I'm merely opening it through a separate class which extends applet, I'm painting by overriding the paintComponent method and calling it through repaint in actionPerformed (using a swing timer obviously). However, the issue is, even after altering freedom of the components contained by the JPanel program to repaint, and after implementing a basic buffer using BufferedImage alone, there is lots of typical applet flashing when the timer delay is low (frame rate is high)! All my painting is being done in paintComponent as well, therefore I'm not using any form of rendering/game loop that seems modern formality in Java animation that doesn't use swing!

I wondered if there is a possible approach I can take to this using both active and passive rendering, and the most important bit, complies with the fact my main program body is a JPanel! I've endlessly struggle to employ BufferStrategies etc, but keep returning to what I thought would mean having to rewrite my program heavily as a JFrame.


This is the way in which I am opening the program's JPanel body,

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
public class Simulation extends JApplet
{

    public static void main(String []args)
    {

        EventQueue.invokeLater(new Runnable()
            {
                public void run()
                {

                    JFrame window = new JFrame();
                    window.setDefaultCloseOperation(3);
                    window.setTitle("Kinetic Theory Simulator");

                    JApplet applet = new Simulation();
                    applet.init();
                    window.getContentPane().add(applet);
                    window.pack();
                    window.setVisible(true);
                }
            }
        );

    }  

    public void init()
    {  
        JPanel panel = new KineticSimulation();
        getContentPane().add(panel);
    }

}


1  
class KineticSimulation  extends JPanel implements MouseListener, MouseMotionListener, KeyListener, ActionListener



This is the relevant painting code,

( this initial code snippet is in the KineticSimulation() constructor)
1  
2  
3  
4  
        _delay = 1000 / _initFrameRate;
        timer = new Timer(_delay, this);
        timer.setCoalesce(true);
        timer.start();


1  
2  
3  
4  
5  
6  
7  
    public void actionPerformed(ActionEvent e) 
    {
        collisionTest();
        reCalculateAll();
        updateSimulationSpeed();
        repaint();
    }


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
    public void paintComponent(Graphics g) 
    {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;

        g2 = (Graphics2D)buffer.getGraphics();

          //this is where all the painting code is

        getGraphics().drawImage(buffer, 0, 0, null);

    }


If I haven't made myself clear feel free to ask me to clarify,

Thanks in advance!  Smiley



3  Discussions / General Discussions / Re: Is Java the right way for me to go? on: 2011-08-12 07:29:36
You've all pretty much reassured me that Java is the right way to go! Maybe I shouldn't have addressed it as an MMO, it will start off as merely a 6 player lobby game, so i think I'll forget the future plans currently as that certainly is too ambitious. However it is merely a 2D platformer, employing networking, so I think although slightly ambitious, it's probably suitable consider the fact I have already made an asteroids/pong clone, a basic platformer and physics simulation program using a spring based engine. Yet if I am looking to create a 2D game, is it recommended I look into libraries such as LWJGL or JOGL? I understand there is debate over which is "best", and I think LWJGL would be the way to go for me, however they seem to be geared towards 3D games?

Thanks again, K.

4  Discussions / General Discussions / Is Java the right way for me to go? on: 2011-08-11 20:50:06
I'm only a young programmer, and Java is the first language I have encountered (I am now one year in and relatively proficient), yet that hasn't stopped me from being ambitious! I am tired of sitting around dealing with toy problems, making silly applications in both the console and in graphics which take me no where. I've decided I want to plunge into the deep end of the pool, seeing as that's the way I find I learn best as an individual. Therefore I've spent a long time rigorously designing an online (browser based) social MMO game.

This project is going to sap a whole lot of my time, and I would love to go ahead with it, yet this worries me, seeing as it will not be much more than a year before I head to university, and I do not want to lead myself down a rabbit hole if Java won't provide me with the tools I require (I will not be able to learn another language over this year). From what I have gathered from my research and experience in the language, Java's diversity, high-level complexity, power, object oriented nature and class libraries such as LWGL (which I don't know how to use) will perfectly set me up for a project such as this. However, there is too much questioning these days as to how powerful Java is compared to other industrial standard game scripting languages such as C++, many seem to disregard it out of what is almost concern over it's true power, and this seems unlikely to be resolved in the near future seeing as people seem settled in their ways.

Any thoughts out there?  Huh


Regards, K.
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (36 views)
2014-12-15 09:26:44

Mr.CodeIt (29 views)
2014-12-14 19:50:38

BurntPizza (61 views)
2014-12-09 22:41:13

BurntPizza (98 views)
2014-12-08 04:46:31

JscottyBieshaar (58 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (76 views)
2014-11-29 21:32:03

toopeicgaming1999 (136 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36

toopeicgaming1999 (37 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!