Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (575)
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  Discussions / General Discussions / Re: Java2d, LWJGL or JOGL? on: 2005-04-14 22:55:48
It looks like your game might benifit from using LWJGL, but not significantly.  Although I can't really tell without playing your game, it appears that you aren't rotating any images or making other image transformations - which are some of the areas in which LWJGL is much faster than Java2D.  What kind of frame rate do you get now?  Assuming you're using the proper techniques, Java2D should be giving you good results.
2  Discussions / General Discussions / Re: i need help!!!!!!!!!!!!!!! on: 2005-04-14 22:44:31
You might get a better response if you were to post this in the "newless clubies" forum.  In order for anyone to help you, more information needs to be provided.  Are you trying to display a custom cursor, or do you want an image to follow the movements of the mouse?
3  Java Game APIs & Engines / Java 2D / Re: Animation without additional thread, Using Swi on: 2005-04-14 21:48:23
I'm a little confused as to what the advantage of this technique is.  Can you clarify how this is better, (or what the pros and cons are), than creating my own thread and performing the game logic and rendering every time through my main loop?  Where is the time control in your code?  I am also confused by what you said about notify/wait.  I have never needed to use notify() or wait() in any of my games - either I am uninformed or they are unnecessary for most games.   When using one thread for both rendering and game logic, (which seems to be standard for most of the developers here), there should be no need for notify/wait or synchronization.
4  Java Game APIs & Engines / Java 2D / Re: Can't get consistent FPS in Applet on: 2005-04-14 21:35:50
Thread.sleep(1) is not a good idea.  It has been mentioned on many threads in these forums that the granularity of the timer for Java in Windows is 10ms, which means that your thread will not reliably sleep for any time period less than 10ms.  I have also read that sleeping for less than 10ms on a Windows machine can cause the system's clock to drift, which  is not cool.  All this is assuming you plan on running your software in Windows.  If you don't, ignore everything I just said :].
5  Game Development / Newbie & Debugging Questions / strange applet behavior on: 2005-04-10 01:41:07
I have written a moon lander game which can be found here:

[link]www.epikgames.com/launch.php?id=1[/link]

(Instructions: use the arrow keys to power the thrusters left, right, or up.  For extra thrust up, use the space bar.)

While testing it, I've noticed some strange behavior that happens when I refresh the applet.  It's happened on multiple systems so i'm pretty sure it's not just a system/browser specific thing.  When you play the game, you'll notice that if you hit the ground with enough force, you'll explode and little particles will go flying everywhere.  If, while there are still particles present in the atmosphere, you pause the applet, (which is done by making the applet lose focus, aka click somewhere outside of your browser window), then refresh the page, the same particles will still be in the atmosphere in the new applet.

So at first this didn't make ANY sense to me at all.  How could objects from a previous instance of my applet be carried over when a new instance of the applet?  Then I realised as I was typing this that the ArrayList that held my particle objects was probably static.  Then it made a whole lot more sense.  Still, this doesn't feel right to me.  Why aren't the references to all my objects being destroyed when the page is refreshed?  Does this mean I could have two browser windows open running the same applet and they would share static variables?  Does this seem remotely interesting to anyone else?

EDIT:  I tried running the game in two windows and the particles show up in both windows.  Cool.
6  Game Development / Newbie & Debugging Questions / Re: newbie here plzz help on: 2005-03-30 01:06:50
http://www.google.com
7  Game Development / Newbie & Debugging Questions / Re: Input Box and output box - applet on: 2005-03-30 01:02:41
If I were in your situation, I would render the text box completely myself, instead of trying to use existing Java components to do the job.  While JTextField is very nice for non-game applications, it really isn't meant for what you'd like to do.  By actively rendering your text box like whatever else is on your screen, you can have absolute control over where it appears and even give it some transparency if you want to get fancy.  Like I said before, designate a "say" key that will send all your key strokes to your text box.  To implement back space, all you need to do is get the key code of the KeyEvent that is passed into the keyPressed(KeyEvent) method and check if it is equal to KeyEvent.BACK_SPACE, and then delete the apropriate character from the String in your text box.  Here's what I'm thinking:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
public class MessageBox implements KeyListener {

      private StringBuffer text;

      public MessageBox() {...}

      public draw(Graphics g) {...}

      public keyPressed(KeyEvent e) {

            int code = e.getKeyCode();

            if(code = KeyEvent.BACK_SPACE && text.length() > 0) {
                  text.deleteCharAt(text.length()-1);
            } else {
                  //add character to text corresponding to the key pressed
            }

      }

}


The example is simplistic but I think it illustrates what I mean.
8  Game Development / Newbie & Debugging Questions / Re: Input Box and output box - applet on: 2005-03-27 01:21:46
You'll probably need to make a custom component to get the transparency you want.  What do you mean by the JTextField making your controls not work?  Is it a focus issue, (the text field is taking all the key input and therefore the keys you've specified to control your character aren't being listened to by the game)?  Or do you mean that adding the text field to your game is making your gui not appear correctly?
9  Game Development / Newbie & Debugging Questions / Re: Input Box and output box - applet on: 2005-03-26 12:13:44
Designate a specific key as the "say" key.  Then, whenever that key is pressed, set a flag in your key listening class to true.  In your keypressed method, check if that flag is set to true, and if it is, send all the keystrokes recieved to a string that will appear on the screen.  When the user presses enter, turn your "say" flag back off.  You can see this type of behavior in many professional games and it's easy to implement.
10  Games Center / Archived Projects / Re: Need testers 3D Space Game's Engine (JNLP laun on: 2005-03-14 02:05:09
nice looking game although it doesnt' run well enough on my beast to be enjoyable - i got a wopping 3-4 fps for both engine and gfx.  win xp, 2.4ghz, 512 ram, ati 7500 64mb, windowed mode
11  Java Game APIs & Engines / Java 2D / Re: Looking To Develop a 2D game for Yahoo on: 2005-02-03 19:56:09
I dunno about difficult to use... IMHO it's very easy to use.  I don't think I've seen any 2D graphics packages that are developed well enough to base a commercial game off of - most people just use the JDK.  If you compare Java to other major programming languages, the JDK does a very good job of providing easy ways to get decent graphical output. All of the games I've seen on Yahoo wouldn't need any special libraries to develop easily.  If you think Java is difficult to use for your task, I would suggest looking into Flash or Shockwave instead - I've never used them myself, but I've heard that they're very easy to work with.
12  Java Game APIs & Engines / Java 2D / Re: Copy image/part of image on: 2005-02-02 18:28:30
First load your image, i.e.

1  
BufferedImage image = ImageIO.read(new BufferedInputStream(this.getClass().getClassLoader().getResourceAsStream("myimage.gif")));


To get a new subsection of that image, do something like this:

1  
BufferedImage subImage = image.getSubImage(0,0,100,100);


The image above created above is the 100 pixel by 100 pixel square section from the top left corner of the original image.  Then, to draw that sub image onto an already existing image, you could do this:

1  
2  
Graphics2D g = existingImage.createGraphics();
g.drawImage(subImage,0,0,null);


Now that 100 by 100 section of the original image is drawn onto a different, already existing image.
13  Java Game APIs & Engines / Java 2D / Re: Graphic Tutorial on: 2005-01-29 12:03:55
There are many, many ways to load images, but this is the most universal, and best way:

1  
BufferedImage img = ImageIO.read(new BufferedInputStream(this.getClass().getClassLoader().getResourceAsStream("myimage.gif")));


Other ways include:

1  
Image img = Toolkit.getDefaultToolkit().getImage("myimage.jpg");


Then in your paint or render method:

1  
g.drawImage(img,0,0,this);


If you need more help than that, I suggest either reading more threads in this forum, which cover pretty much everything you could want to know about 2D graphics in java, or google for a beginners tutorial.
14  Java Game APIs & Engines / Java 2D / Re: Strange error with an applet on: 2004-12-29 00:22:51
Very cool - thank you for your help!
15  Java Game APIs & Engines / Java 2D / Re: Strange error with an applet on: 2004-12-28 19:19:48
Here's my loadImage() code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public BufferedImage loadImage(String file) {
            BufferedImage image;
           
            try {
                  image = ImageIO.read(LanderApplet.class.getClassLoader().getResource(file));
            } catch(IOException e) {
                  e.printStackTrace();
                  return null;
            }
           
            return image;
      }


I'll give tom's suggestion a try, that's probably what the problem is, right now.  If you get another chance, see if you can run it after I make the changes.

Quote

Works with 1.5 (though whatever method you are using for Threading/repainting sux - its horribly stuttery)

I appreciate the feedback, but I'd have to see what you're experiencing, as the applet runs relatively smoothly on my laptop, (2.6 ghz 512 ram,  64mb Radeon 7500).  I am manually double buffering which means that the applet currently is not making use of Vram, which may be the reason you're experiencing inadequate performance.  I tried to implement the standard double buffering system but for one reason or another I couldn't get it to work and I was crunched for time so I had to drop it.  I'm really not concerned with its visual performance right now as much as the accuracy of the physics, most of which still has to be implemented.  Anyways, thanks very much for everyone's help, it is much appreciated!
16  Java Game APIs & Engines / Java 2D / Re: Strange error with an applet on: 2004-12-28 04:52:16
Unfortunately I don't think its as simple as upgrading from 1.4.1 to 1.4.2.  Again if you could take a minute to try the page yourself, I'd appreciate it.
17  Java Game APIs & Engines / Java 2D / Re: Swing components panted over... on: 2004-12-26 18:50:04
it's hard to tell from your description what the job of the render() function is.  If its job is to paint the entire screen and it does not call the JFrame's standard repaint() method, then render() probably paints over your buttons.  If your design allows for it, I would suggest placing all your buttons into their own JPanel, and then use a Canvas to draw your game.    You can add the JPanel and the Canvas to the FullScreenJFrame, placing them wherever you want.  Note however that your render() method must now draw onto the canvas and not the FullScreenJFrame().
18  Java Game APIs & Engines / Java 2D / Strange error with an applet on: 2004-12-24 13:23:41
I've created an applet for a school project, and unfortunately it seems like no one but me can play it.  When I run it from my computer, (which is Java 1.5), it loads and plays flawlessly.  However, whenever I ask friends to test it for me, (and they have 1.4.x), it crashes on loading.  At first I assumed it was an issue with which version I compiled it in, but after compiling it with 1.4.1 and asking them to test it again, it still crashes.  The game is located at http://www.epikgames.com/test.html if you would like to try it yourself and see if you can run it.  If you do get an error and can explain why it doesn't load, I would much appreciate it.  The reason i'm posting in this forum is that it seems that the error is ImageIO related.  Thanks in advance!
19  Game Development / Game Mechanics / 2d Vector Addition on: 2004-11-27 14:43:26
I implemented some vector addition code for a 2d space sim that i'm working on that looks like this:

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  
public class Vector2D implements Cloneable {
      /**
       * Angle in radians.
       */

      private double angle;
     
      /**
       * Speed in units/second.
       */

      private double speed;
     
      /**
       * Constructor: takes an angle in radians and a speed.
       */

      public Vector2D(double ang, double spd) {
            angle = ang;
            speed = spd;
      }
     
      /**
       * Rotates the angle by n radians.
       */

      public void rotate(double n) {
            angle += n;
      }
     
      /**
       * Changes the speed by n.
       */

      public void changeSpeed(double n) {
            speed += n;
      }
     
      /**
       * Accessors
       */

      public double getAngle() {
            return angle;
      }
     
      public double getSpeed() {
            return speed;
      }
     
      /**
       * Vector addition - takes another vector to which
       * this vector should be added to and returns the resulting
       * vector.
       */

      public Vector2D add(Vector2D other) {
            double      angleC,newAngle, newSpeed;
           
            angleC = Math.PI + angle - other.angle;
            newSpeed =       Math.sqrt((speed * speed) + (other.speed * other.speed) -
                              2 * speed * other.speed * Math.cos(angleC));
           
            newAngle = angle + Math.asin((Math.sin(angleC)/newSpeed) * other.speed);
            newAngle = Math.abs(newAngle % (2 * Math.PI));
           
            return new Vector2D(newAngle, newSpeed);
      }
     
      public String toString() {
            return "Angle: " + Math.toDegrees(angle) + " Speed: " + speed;
      }
}


This code works great for steering my ship, (it looks just like it should), but it behaves very strangely with projectiles.  If my ship is traveling at low speeds, (under 1000 pixels/sec), projectiles will only fire in a specified 180 degree region.  For instance, if the ship is facing the way it's actually going, or close to it, the projectile fires with the correct angle.  However, if I turn the ship the opposite way of the direction it's going, the projectile still fires the way the ship is going.  To get the vector for the projectile, I just use my add method to add the vector of the ship and an arbitrary vector for the projectile:

1  
2  
3  
4  
if(keyboard.isPressed(FIRE_KEY)) {
                  Vector2D projVector = going.add(new Vector2D(facingTheta,800));
                  new Projectile(env,SpriteStore.loadImage("projectile.png"),getX() + width / 2,getY() + height / 2,10,10,projVector,300,0,this);
            }


If the ship is travelling very fast, projectiles will fire in all directions with no error in their vectors.  Can anyone explain why this happens, perhaps some flaw in the logic of my vector addition or an entirely different approach I should use?
20  Java Game APIs & Engines / Java 2D / Re: Canvas in fullscreen mode on: 2004-09-19 16:10:59
I've found that it's simply easier to cut the Canvas use the Frame's double buffering capabilities instead when going fullscreen.  In one game, I use a Canvas for debugging/windowed mode and just the frame itself for fullscreen.
21  Game Development / Newbie & Debugging Questions / Re: setting the CLASSPATH on: 2004-08-29 14:25:33
I figured it out.  Not nearly as annoying as I was making this out to be.  Thanks for your kind treatment of my Newbieness though.

On a side note - I use JCreator because it is the IDE that my Comp Sci class uses.  I'll look into Eclipse, (just Google for it?).  Thx very much!
22  Game Development / Newbie & Debugging Questions / Re: setting the CLASSPATH on: 2004-08-29 14:12:23
I think I wasn't being clear enough at the beginning of this post - sorry.  I want to be able to compile this with JCreator, as all this cmd-line crap is really annoying.  Does this change things?
23  Game Development / Newbie & Debugging Questions / Re: using JARed applets on: 2004-08-29 13:39:08
Thanks, though I have done this successfully before.  However, I wasn't able to get it to display on a web page using the JAR.  I read something about declaring a main directory in the manifest - is that something I have to do?
24  Game Development / Newbie & Debugging Questions / Re: setting the CLASSPATH on: 2004-08-29 13:35:14
Hmmm... that's what i'd call really annoying.  There isn't just a one time thing that you have to do to compile?  This would be especially annoying when trying to distribute something you make with a GAGE timer too.
25  Game Development / Newbie & Debugging Questions / using JARed applets on: 2004-08-29 02:38:24
Given the following situation:

Folder "Invaders" contains three other folders "img", "applet", and "game".  "applet" and "game" contain classes for my applet.  The main class is in "applet", and is called "Invaders.class".  Assume "Invaders" is located in the same folder as the jar.exe utility.  I want to make a JAR for this applet.

Can someone give a step-by-step instruction on how to make the JAR and then get it to display on a web page?  Sorry, I've seriously tried!  I've read quite a bit of documentation on creating and using JARs, but my attempts have failed and I fear I'm missing some crucial steps along the way.  Thanks in advance.
26  Game Development / Newbie & Debugging Questions / setting the CLASSPATH on: 2004-08-29 02:20:22
I read Kev Glasses Invaders 102 and was interested in using the GAGE timer he mentioned.  I downloaded it, but there is no documention on how to implement it.  I know how to set classpaths, but what i've done hasn't worked.  If someone could give me the exact line i need to add to the environment variables, (I'm on XP so all i need to do is add the variable to the "Environment Variables" section of the System Control Panel, right?), I would really appreciate it.  My GAGE timer files are located in :

C:\Program Files\Java\gagetimer\

Thanks in advance.
27  Java Game APIs & Engines / Java 2D / imageIO on: 2004-08-05 22:38:56
I am creating a gfx file for my game.  Basically, i just serialize my heirarchy into a file.  The files save fine, but when I reopen them in my editor, only the first image in each collection is available, the rest are null.  Here's my serialization code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
      private void writeObject(ObjectOutputStream out) throws IOException {
            out.writeObject(name);
            out.writeObject(sequences);
            out.writeInt(images.length);
           
            for(int i = 0; i < images.length; i++) {
                  try {
                        ImageIO.write(images[i],"PNG",out);
                  } catch(IOException e) {
                        e.printStackTrace();
                  }
            }
      }
     
      private void readObject(ObjectInputStream in) throws IOException,
                                                                                          ClassNotFoundException {
            name = (String)in.readObject();
            sequences = (ImageSequence[])in.readObject();
            images = new BufferedImage[in.readInt()];
           
            for(int i = 0; i < images.length; i++) {      
                  images[i] = ImageIO.read(in);
            }
      }      


I know that the images are getting saved because the size of the saved file is proportional to the number of images I used.  Any insight would be very helpful!
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.

Longarmx (35 views)
2014-10-17 03:59:02

Norakomi (26 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (26 views)
2014-10-15 16:18:58

TehJavaDev (50 views)
2014-10-14 00:39:48

TehJavaDev (50 views)
2014-10-14 00:35:47

TehJavaDev (40 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (75 views)
2014-10-11 22:30:10
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!