Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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 / Newbie & Debugging Questions / Programming with C++/C and Java at the same time on: 2006-02-24 21:21:28
I need to know how to make a game, partly using C/C++ and partly using Java. 
2  Game Development / Newbie & Debugging Questions / Re: need help to learn with JMF on: 2006-02-08 04:22:09
I've fixed the problem.
3  Game Development / Newbie & Debugging Questions / Re: ConcurrentModificationException on: 2006-02-06 17:08:17
this might help you:
CopyOnWriteArrayList

its in java.util.List
4  Game Development / Newbie & Debugging Questions / Re: need help to learn with JMF on: 2006-02-06 06:37:50
I still need help  Smiley
5  Game Development / Newbie & Debugging Questions / need help to learn with JMF on: 2006-02-05 07:55:38
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
                if(moviePlayer == null){
                        try {
                            System.out.println("s");
                            moviePlayer = Manager.createPlayer(this.getClass().getResource("videos/intro.avi"));
                            moviePlayer.start();


                        } catch (IOException e) {
                            e.printStackTrace();
                        } catch (NoPlayerException e) {
                            e.printStackTrace();
                        }
             }


I have that code, but when I run my program I see a white blank screen.
I'm using a JPanel and a JFrame with a resolution of 800x600.
I cheked to see that the video was working with the JMStudio.
6  Game Development / Newbie & Debugging Questions / Re: Need help to implement sound in my game on: 2006-02-04 23:45:39
now the clip gets played again if I ask it too, but sometimes it is played correctly and sometimes it isn't. Any ideas?. To explain myself, sometimes I hear the full .wav that is 2 secs long and others I just hear a small beep and nothing more.
7  Game Development / Newbie & Debugging Questions / Re: Need help to implement sound in my game on: 2006-02-04 17:01:44
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  
public class SoundPlayer implements LineListener{
    private Clip clip;
    public SoundPlayer()  {
        clips = new ArrayList<Clip>();
        loadSounds();
    }
    public void playClip(){
        if(clip!=null){
            clip.start();
        }
    }

    public void loadSounds(){
        try{
            AudioInputStream stream = AudioSystem.getAudioInputStream(getClass().getResource("sounds/shotsingle.wav"));
            AudioFormat format = stream.getFormat();
            DataLine.Info info = new DataLine.Info(Clip.class, format);
            clip = (Clip) AudioSystem.getLine(info);
            clip.addLineListener(this);
            clip.open(stream);
           
        }catch(UnsupportedAudioFileException e){

        }
        catch(IOException e){

        }catch(LineUnavailableException e){

        }
    }
    public void update(LineEvent event) {
       
        if (event.getType() == LineEvent.Type.STOP) {
            event.getLine().close();
        }
    }
}


exploring a bit the sound api and reading from a book I made this. however, the clip gets played once, and then when it needs to be replayed it does not play. how can I fix this?
8  Game Development / Newbie & Debugging Questions / Need help to implement sound in my game on: 2006-02-04 15:25:52
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 class SoundPlayer {
    private AudioClip backgroundMusic;
    private AudioClip gunFire;
    private AudioClip hit;
    private AudioClip flak;
    private AudioClip mayday;
    private AudioClip explosion;

    public SoundPlayer() {
        loadAllSounds();
    }

    private void loadAllSounds() {
        try{
            backgroundMusic = Applet.newAudioClip(getClass().getResource("sounds/03 Crush.wav"));
            gunFire = Applet.newAudioClip(getClass().getResource("sounds/shotsingle.wav"));
            hit = Applet.newAudioClip(getClass().getResource("sounds/hit2.wav"));
            flak = Applet.newAudioClip(getClass().getResource("sounds/flak1.wav"));
            mayday = Applet.newAudioClip(getClass().getResource("sounds/mayday.wav"));
            explosion = Applet.newAudioClip(getClass().getResource("sounds/exp1.wav"));

        }catch(Exception e){
        }
    }


My main game panel has a static instance of this soundPlayer called sp. and then the different classes in my game get the SoundPlayer by doing:
PacificFighterPanel.sp.playSound();

the problem is the sometimes the sounds are played, sometimes they are not, and when too many get played it sounds like crap.
9  Game Development / Newbie & Debugging Questions / Re: AffineTransform problems on: 2005-12-18 18:18:58
thanks for the help:
Here is the final code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
public void draw(Graphics g) {
        if(IS_ALIVE){
            Graphics2D g2 = (Graphics2D)g;
            rads=0.07;
            if (initialRelativeYPos<15){
                AffineTransform af = new AffineTransform();
                af.rotate(rads*initialRelativeYPos,width/2,height/2);
                AffineTransformOp op = new AffineTransformOp(af,AffineTransformOp.TYPE_BILINEAR);
                g2.drawImage(frames.get(currentFrame),op,xPos,yPos);
            }else{
                AffineTransform af = new AffineTransform();
                af.rotate(1.05,width/2,height/2);
                AffineTransformOp op = new AffineTransformOp(af,AffineTransformOp.TYPE_BILINEAR);
                g2.drawImage(frames.get(currentFrame),op,xPos,yPos);
            }
            g2.dispose();
        }
10  Game Development / Newbie & Debugging Questions / Re: Connecting two points. on: 2005-12-18 00:59:33
See if this helps you:
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  
public float toXPos;
    public float toYPos;
    public float vectX;
    public float vectY;
    public int initialYpos;
    public int initialXpos;
    private int dist;
    public float d = 0;
    public Rectangle targetRectangle;

// in constructor
       initialYpos = (int)yPos;
        initialXpos = (int)xPos;
        this.toXPos = (float)(fighterRectangle.getX()+Math.random()*(fighterRectangle.getWidth()));
        this.toYPos = (float)(fighterRectangle.getY()+Math.random()*(fighterRectangle.getHeight()));
        vectY =(toYPos-yPos);
        vectX = (toXPos-xPos);
        dist = (int)(Math.sqrt(vectX*vectX + vectY*vectY))/10; //by changin the 10 you will vary the speed of the object.

//in update
public void update(){
        d++;
        xPos = (int)(d/dist*vectX + initialXpos);
        yPos = (int)(d/dist*vectY+initialYpos);
        rectangle.x = xPos;
        rectangle.y = yPos;
    }

 
pd: did not try it. but i beleive it should work.
forgot to tell you, this will pick a random point of a rectangle to shoot to, if you want to always shoot straight just assign toXPos and toYPos an exact value.
11  Game Development / Newbie & Debugging Questions / Re: How to make 8 directions movements on: 2005-12-17 22:03:45
In an array you put the radians of the different directions like this:
North = Pi/2
East = 0
West = Pi
(you complete the rest)

then by doing:
1  
2  
xPos += Math.cos(array[direction]); 
yPos += Math.sin(array[direction]);  

you are moving the ball in the direction you want, and can change the direction if you please. by changing the variable direction.
salutes

12  Game Development / Newbie & Debugging Questions / AffineTransform problems on: 2005-12-17 19:06:05
hi to all,
My problem is that when I rotate my BufferedImage and then draw it on screen the image is cut and not fully drawn.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
 
void update() {
    //...
       rads=0.068*3;
        if (initialRelativeYPos<23 && initialRelativeYPos%3==0){
            AffineTransform af = new AffineTransform();
            af.rotate(rads,width/2,height/2);
            AffineTransformOp op = new AffineTransformOp(af,AffineTransformOp.TYPE_BILINEAR);
            frames.set(currentFrame,(op.filter(frames.get(currentFrame) ,null)));
        }
    }

    public void draw(Graphics g) {
        if(IS_ALIVE){
            g.drawImage(frames.get(currentFrame),xPos,yPos,null);
        }
       //...

Original image:


In Game image after Transformed:
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.

xsi3rr4x (55 views)
2014-04-15 18:08:23

BurntPizza (53 views)
2014-04-15 03:46:01

UprightPath (66 views)
2014-04-14 17:39:50

UprightPath (49 views)
2014-04-14 17:35:47

Porlus (66 views)
2014-04-14 15:48:38

tom_mai78101 (90 views)
2014-04-10 04:04:31

BurntPizza (151 views)
2014-04-08 23:06:04

tom_mai78101 (247 views)
2014-04-05 13:34:39

trollwarrior1 (204 views)
2014-04-04 12:06:45

CJLetsGame (211 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!