Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (550)
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  Java Game APIs & Engines / Java 2D / Re: Reviving Mini Adventure on: 2005-02-11 13:17:57
I'd like to implement the combat system. The user will have to wait a certain amount of time based on the character's speed and profession ex. a thief would be able to attack quicker than a character of different class and has the same speed.  Likewise, damage would also be based on profession. Knights would be able to inflict greater damage with physical attacks. Wizards would be able to inflict greater damage with magical attacks. Clerics would have greater healing powers.  I was also thinking of damage multipliers. If two characters attack a monster at the exact ie within 1 ms of each other, each character will inflict twice as much damage on the monster.
2  Discussions / General Discussions / Re: inner class problem~ on: 2005-02-06 00:17:56
I don't really use inner classes nor do I care to. However, you should know all options when you are programming including "top-level nested classes." Considering how little the inner class is dependent on the inner class except for the main method, there is no need to instatiate an instance of both the outer and inner class. In this case, it is better just to make the class a nested class. Although, in this case it would be best just to have the outer class implement Runnable, supply an instance to the Thread constructor, and get rid of the inner class altogether.  

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 TestThread implements Runnable
{
    private int num;
    private String name;

    public  TestThread(String name, int num)
    {
          this.name = name;
          this.num = num;
    }

    public void run()
    {
          for (int i=0; i<num; i++)
        {
              try
            {
                  Thread.currentThread().sleep((long)100);
            }
            catch (Exception e) {};
            System.out.println(name + "\trunning: " +    i);
        }
    }
 
    public void main(String[] args)
    {
          Thread t1 = new Thread(new TestThread("black",5));
             Thread t2 = new Thread(new TestThread("white",3));
          t1.start();
          t2.start();
    }
}
 

However, I see that blackjava is just using the class to test inner classes so best practices aren't necessarily applicable.
3  Java Game APIs & Engines / JOGL Development / Re: Help with Animator on: 2005-02-04 23:46:45
First, are you drawing all of the tiles in your map? If so, you should modify your code to draw only the visible portions of the map. Second, use Timebased animation. It gives consistent movement regardless of frame rate.

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  
...

long start = System.currentTimeMillis();
ong current = start;
long prev = current;
           
long el = 0;
           
while(!done)
{
      current = System.currentTimeMillis();
                 
      if(!canvas.getSize().equals(getSize()));
            canvas.setSize(getSize());
                       
      el = current-prev;
                 
      prev = current;
     
      canvas.display();
     
      update(el); //update your sprites in this method
                 
      Thread.yield();
}
...


To ShadowCaster:
It is System.nanoTime() not System.currentTimeNanos()
4  Discussions / General Discussions / Re: Is PSP worth the price? on: 2005-02-03 20:31:21
I agree. Also, from the screenshots of the PSP games I have seen, the PSP games don't appear to be antialiased. I probably won't buy a PSP. However, i have already purchased a DS
5  Game Development / Newbie & Debugging Questions / Re: Display image on glcanvas ??? on: 2005-02-03 20:17:00
First I reccomend you go to http://today.java.net/pub/a/today/2003/09/11/jogl2d.html
It teaches some pretty basic techniques with JOGL.

Second, you should read through the nehe tutorials at http://nehe.gamedev.net.
A lot of the tutorials have been ported to JOGL. Just scroll down and download the JOGL source code.

After that, rely on personal ingenuity.
6  Game Development / Newbie & Debugging Questions / Re: Good Book on: 2005-02-03 20:06:07
My personal favorite is Developing Games in Java by David Brackeen. The source code for the book can be found here http://www.brackeen.com/javagamebook His code is pretty self descriptive, and there are plenty of comments to describe what he is doing.

With that being said, he uses a multithreaded approach to developing games which is fine for basic Java2D stuff; however, if you want to make a game with OpenGL either through JOGL or through LWJGL, you should try to pull everything into the main loop.
7  Discussions / General Discussions / Re: inner class problem~ on: 2005-02-03 19:57:17
Quote
TestThread.java:7: non-static variable this cannot be referenced from a static context


Simplest solution, make your inner class static.
8  Java Game APIs & Engines / JOGL Development / Re: Manual rendering??? on: 2005-01-31 19:41:04
On gl.glFlush(), all it basically does is force OpenGL to execute any current graphics operations.

As for your exception, could you post your reflection code. I could more clearly identify the cause of the exception.
9  Java Game APIs & Engines / Java 2D / Re: Fast scrolling on: 2005-01-19 21:05:54
I'm getting 300+ fps with the black boxes.  You really should make it a fullscreen app or convert into hybrid fullscreen app/applet. This way if the drawing is still slow you can more easily debug your code.

In case you don't know how to convert an applet into a fullscreen app.  I'm not saying you don't
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
public static void main(String[] args)
{
    GraphicsConfiguration ge =
    GraphicsEnvironment.getLocalGraphicsEnvrionment();
    final GraphicsDevice gd = gd.getDefaultScreenDevice();
    JFrame frame = new JFrame();
    frame.addKeyListener(new KeyAdapter()
    {
           public void keyPressed(KeyEvent e)
           {
                   if(e.getKeyCode == KeyEvent.VK_ESCAPE)
                   {
                       gd.setFullScreenWindow(null);
                   }
           }
     });
     JApplet a = new SubclassOfJApplet();
     frame.setIgnoreRepaint(true);
     frame.setUndecorated(true);
     frame.setResizable(false);
     frame.add(a);
     gd.setFullScreenWindow(frame);
     a.init();
}      

This should work.
Sorry the codes not properly aligned in the keyPress method
10  Java Game APIs & Engines / Java 2D / Re: Combining Images on: 2005-01-17 22:34:47
It should be possible to draw semi-transparent tiles onto a VolatileImage. However, the VolatileImage you are drawing onto can not be transparent unless you want to lose hardware accleration (Support for hardware acceleration of translucent and transparent VolatileImages is not completed yet.) Hopefully with Mustang, Sun will have complete support for hardware accleration of images.
11  Java Game APIs & Engines / Java 2D / Re: Combining Images on: 2005-01-17 16:52:39
Actually drawing several small images is faster. The memory consumption per image is width*height*depth. A 640x480  image at 16-bit depth takes up 600 KB of space. Add in the amount of space for your tiles and a huge chunk of ram is being taken up. Also, the BufferedImage probably is not being accelerated (It's being created in System Ram). My advice is either draw onto a VolatileImage which so long as you have a mediocre graphics card will be accelerated or get rid of the background image all together.
12  Discussions / General Discussions / Re: Using BufferStrategy with Applet on: 2004-09-25 23:08:21
First off, sorry for not replying. Been off for a while.
Thanks swpalmer for replying to baylor. For the most part your response was correct. Since you gave an good reply to baylor, I don't have to explain too much. The reason the getGraphics() method is problematic lies in the fact that you should not combine "active" and "passive" rendering. If you use paint and repaint, the methods request the getGraphics() of a component. To ensure that no calls request the standard getGraphics() method you should ignore repaint messages and stay away from overriding paint. Hope this is useful.  Wink
13  Discussions / General Discussions / Using BufferStrategy with Applet on: 2004-06-20 00:39:43
I do not know whether anyone has posted a way to use BufferStrategy with an Applet or a JApplet. However,
I have recently created a class called AppletGameCore which acts as a facility to easily create games with Applet. I apologize for the lack of detailed comments.
Here is the
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  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
import java.awt.Canvas;
import java.awt.Graphics2D;
import java.awt.Dimension;
import java.awt.image.BufferStrategy;
import java.applet.Applet;

/**
 *AppletGameCore.java
 *@author David Graham[font=Verdana][/font]
 */

 
public abstract class AppletGameCore extends Applet implements Runnable
{
      private BufferStrategy bufferStrategy;
      private Canvas drawArea;/*Drawing Canvas*/
      private boolean stopped = false;/*True if the applet has been destroyed*/
      private int x = 0;
     
      public void init()
      {
            Thread t = new Thread(this);
            drawArea = new Canvas();
            setIgnoreRepaint(true);
            t.start();
      }
     
      public void destroy()
      {
            stopped = true;
           
            /*Allow Applet to destroy any resources used by this applet*/
            super.destroy();
      }
     
      public void update()
      {
            if(!bufferStrategy.contentsLost())
            {
                  //Show bufferStrategy
                 bufferStrategy.show();
            }
      }
     
      //Return drawArea's BufferStrategy
     public BufferStrategy getBufferStrategy()
      {
            return bufferStrategy;
      }
     
      //Create drawArea's BufferStrategies
     public void createBufferStrategy(int numBuffers)
      {
            drawArea.createBufferStrategy(numBuffers);
      }
     
      //Subclasses should override this method to do any drawing
     public abstract void draw(Graphics2D g);
     
      public void update(Graphics2D g)
      {
            g.setColor(g.getBackground());
            g.fillRect(0,0,getWidth(),getHeight());
      }
     
      //Update any sprites, images, or primitives
     public abstract void update(long time);
     
      public Graphics2D getGraphics()
      {
            return (Graphics2D)bufferStrategy.getDrawGraphics();
      }
     
      //Do not override this method      
     public void run()
      {
            drawArea.setSize(new Dimension(getWidth(),getHeight()));
            add(drawArea);
            createBufferStrategy(2);
            bufferStrategy = drawArea.getBufferStrategy();
           
            long startTime = System.currentTimeMillis();
            long currTime = startTime;
           
            //animation loop
           while(!stopped)
            {
                  //Get time past
                 long elapsedTime = System.currentTimeMillis()-currTime;
                  currTime += elapsedTime;
                 
                  //Flip or show the back buffer
                 update();
                 
                  //Update any sprites or other graphical objects
                 update(elapsedTime);
                 
                  //Handle Drawing
                 Graphics2D g = getGraphics();
                  update(g);
                  draw(g);
                 
                  //Dispose of graphics context
                 g.dispose();
            }

      }
}


Feel free to modify and use this code for your own purposes.
If you have any questions or comments, please post them.  Grin

Note: This code is only compatible with J2SE 1.4 and up.

Quote
True knowledge is admitting what you don't no.
Confucius I think...
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.

CopyableCougar4 (14 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!