Archived

This topic is now archived and is closed to further replies.

Java Help Needed!

This topic is 5582 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i''m programming an RTS (real-time-strategy) game in java, and I have a couple of questions: 1. how do i efficiently and repeatedly load images onto the screen (for vehicle movement, etc.) 2. how do i load sounds into my application? note - it is *NOT* an applet so I cant use methods inherited from applet to do so. 3. is full screen mode more efficient than windowed mode? Thanks in advance, Amir

Share this post


Link to post
Share on other sites
My friend told me that Java 1.4.1 has greatly improved bitmap stuff (faster and easier to use), so first step is to download that . As for question 3, I think you should make support for both because it''s not much more work.

(sorry for not being able to answer more.. haven''t used Java much for graphical applications)

Share this post


Link to post
Share on other sites
For audio you could try:

  
java.applet.AudioClip audio = Applet.newAudioClip(url);
audio.play();

Note that since newAudioClip is a static method of applet, you can use it even in a non-applet application.
It''s not perfect, and you''re probably better off looking for something that gives you a bit control, but it''s a start!

Hope this helps,

Enigma

Share this post


Link to post
Share on other sites
And how do I use full-screen mode in java?
another thing:

while trying to load images to the application, I found an
interesting phenomenon : I found out that creating a Swing ImageIcon with my file, then using its getImage method,
was actually faster than directly using Toolkit.getDefaultToolKit.getImage("fileName")!
why is this?

Share this post


Link to post
Share on other sites
The Java Tutorial has a section on full-screen exclusive mode. When you have questions like these, take some time to look around Sun''s site, they have a whole bunch of documentation available.

As for ImageIcon, this is from ImageIcon.java in the 1.4.0 sdk:

  
public ImageIcon(String filename, String description) {
image = Toolkit.getDefaultToolkit().getImage(filename);
if (image == null) {
return;
}
this.filename = filename;
this.description = description;
loadImage(image);
}

Look at src.zip in your jdk directory.

Share this post


Link to post
Share on other sites