Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (552)
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 / Re: How to add cutscenes to your game on: 2012-06-17 17:38:32
Well guys, thank you very much for the help... this is really an awesome community!


I think I will just not do videos for the moment - I will keep programming and, on the end, when I know more java and I have a semi finish game, then I will confront the video issue, probably with the help of vlcj, that sound quite good.


2  Game Development / Newbie & Debugging Questions / Re: How to add cutscenes to your game on: 2012-06-17 13:53:05
Hey Cero, yes I have read your threads about this, and that's how I know it is hard.

Well the point it is that I really need cut scenes... I was making a point and click adventure, so the cut scenes were supposed to be a very important part. But if it is to difficult to make it work, well, I have another projects in mind, so I can start making another videogame that don't need any video.
And let's see if in the future I want to make the point and click adventure in java or not!

3  Game Development / Newbie & Debugging Questions / Re: How to add cutscenes to your game on: 2012-06-17 11:15:15
Thanks a lot Cas, I will follow your advice!
4  Game Development / Newbie & Debugging Questions / How to add cutscenes to your game on: 2012-06-17 10:31:47

Hello people,


I am making my first steps into java game developing, and I have kind of a prototype of a game. I wanted to add a small intro video (and cut scenes in the future) before the menu and the game launches, and I am finding that is not easy.
I have read about JMF, and about javaFX and Xuggler to add a video file... but everything looks quite complex, and not everybody looks happy with their solutions.

So, my question is, how do you add cutscenes to your games? Of course if it is something simple/small I can directly animate the frames, as I do with sprites, but I guess that's not the solution for comples/long cutscenes. To be able of add a video file and play it before the game, or en between will be awesome...

I don't want to re invent the wheel and I want to solve this as easy as possible! I guess most of you have wanted to add some cutscenes or intros to your games...


Thanks a lot!
5  Game Development / Newbie & Debugging Questions / Re: cannot make my sprite walk and stop on: 2012-05-21 20:00:42
That's right, i mess up the names, and I set playerSprite when I wanted to set player... Now at least I solved that one, thanks again!
6  Game Development / Newbie & Debugging Questions / cannot make my sprite walk and stop on: 2012-05-21 18:31:57
Hi guys,

I'm an absolute newbie, and during the past weeks I have started writing a small point and click adventure game.

Until yesterday I have a "game" that was able to load a background and the sprite for the player, and listening to the mouse move the sprite to the point were you click. But I only have one animation, so the player animation was always "walking".
I have read a bit about how to manage more than one animation using arrays, so now I'm trying to have the same thing but with two animations: one when the player is walking, and another one for when it is not moving at all (in this animation the sprite will blink or something like that). My problem is that now I cannot make it run anymore, right now I have a null pointer exception that I cannot explain... (because I think I didn't change anything there!)
Exception in thread "main" java.lang.NullPointerException
   at InputManagerTest.checkGameInput(InputManagerTest.java:135)

and line 135 is just
1  
player.setVelocityX(velocityX);
The problem is calling the player.anything, but I don't know why it always give the null pointer exception. but it was working fine before last changes!

Aaaaany help will be super useful for me, and I thank you in advance because I'm sure I am doing hundreds of things incorrectly... but I already spent some hours playing around, looking on my java book and on the forum I am stuck.

I copy the relevant 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  
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  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
    
import java.awt.*;
import java.awt.event.KeyEvent;
import javax.swing.ImageIcon;

import graphics.*;
import input.*;
import test.GameCore;

public class InputManagerTest extends GameCore {

    public static void main(String[] args) {
        new InputManagerTest().run();
    }

    protected GameAction exit;
    protected GameAction moveRight;
    protected GameAction pause;
    protected InputManager inputManager;
    private Player player;
    private Image bgImage;
    private boolean paused;
   
    private int mouseX;
   
    private Sprite playerSprite;

    public void init() {
        super.init();
        Window window = screen.getFullScreenWindow();
        inputManager = new InputManager(window);

        createGameActions();
        createSprite();
        paused = false;
    }


    /**
        Tests whether the game is paused or not.
    */

    public boolean isPaused() {
        return paused;
    }


    /**
        Sets the paused state.
    */

    public void setPaused(boolean p) {
        if (paused != p) {
            this.paused = p;
            inputManager.resetAllGameActions();
        }
    }


    public void update(long elapsedTime) {
        // check input that can happen whether paused or not
       checkSystemInput();

        if (!isPaused()) {
            // check game input
           checkGameInput();

            // update sprite
           player.update(elapsedTime);
        }
    }


    /**
        Checks input from GameActions that can be pressed
        regardless of whether the game is paused or not.
    */

    public void checkSystemInput() {
        if (pause.isPressed()) {
            setPaused(!isPaused());
        }
        if (exit.isPressed()) {
            stop();
        }
    }


    /**
        Checks input from GameActions that can be pressed
        only when the game is not paused.
    */

    public void checkGameInput() {
        float velocityX = 0;

        if (moveRight.isPressed()) {
           player.walk();
           player.setState(Player.STATE_WALK);
       
        }
       
        player.setVelocityX(velocityX);

    }


    public void draw(Graphics2D g) {
        // draw background
       g.drawImage(bgImage, 0, 0, null);

        // draw sprite
       g.drawImage(player.getImage(),
            Math.round(player.getX()),
            Math.round(player.getY()),
            null);
    }


    /**
        Creates GameActions and maps them to keys.
    */

    public void createGameActions() {
        exit = new GameAction("exit",
            GameAction.DETECT_INITAL_PRESS_ONLY);
        moveRight = new GameAction("moveRight");
        pause = new GameAction("pause",
            GameAction.DETECT_INITAL_PRESS_ONLY);

        inputManager.mapToKey(exit, KeyEvent.VK_ESCAPE);
        inputManager.mapToKey(pause, KeyEvent.VK_P);

        inputManager.mapToMouse(moveRight, InputManager.MOUSE_BUTTON_1);

    }


    /**
        Load images and creates the Player sprite.
    */

    private void createSprite() {
       Image[][] images = new Image[4][];
        // load images
       bgImage = loadImage("dcity.JPG");
        images[0] = new Image[] {
                loadImage("titocamina1.PNG"),
                loadImage("titocamina2.PNG"),
                loadImage("titocamina3.PNG"),
                loadImage("titowink3.PNG"),
            };

            images[1] = new Image[images[0].length];
       
        // create animation            
         Animation [] playerAnim = new Animation[2];
          playerAnim[0] = createPlayerAnim(images[1][0], images[1][1], images[1][2]);
          playerAnim[1] = createPlayerAnim(images[1][2], images[1][2], images[1][3]);
         
          playerSprite = new Player(playerAnim[0], playerAnim[1]);
 
    }
    private Animation createPlayerAnim(Image player1,Image player2, Image player3)
        {
            Animation anim = new Animation();
            anim.addFrame(player1, 150);
            anim.addFrame(player2, 150);
            anim.addFrame(player3, 150);
            anim.addFrame(player2, 150);
           
            return anim;
        }

}


and now the Player:
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  
package input;

import graphics.*;
//import input.InputManager;


/**
    The Player class extends the Sprite class to add states
*/

public class Player extends Sprite {
   
    protected InputManager inputManager;

    public static final int STATE_WALK = 0;
    public static final int STATE_STAND = 1;

    public static final float SPEED = .4f;

    private int state;
    private Animation animWalk;
    private Animation animStand;
   
    private int mouseX;

    public Player(Animation animWalk, Animation animStand) {
        super(animStand);
        this.animWalk=animWalk;
        this.animStand=animStand;
        state = STATE_STAND;
    }


    /**
        Gets the state of the Player;
    */

    public int getState() {
        return state;
    }


    /**
        Sets the state of the Player;
    */


        public void setState(int state) {
            if (this.state != state) {
                this.state = state;
            }
        }


    /**
        Causes the Player to Walk
    */
 
        public void walk() {
       
       mouseX=inputManager.mouseLocation.x;
       state = STATE_WALK;

       if ((mouseX-(getX()))>10 && mouseX>(getX()+200)){
           setVelocityX(+1);
       }
       else {
                    setState(STATE_STAND);
       }
       
       if ((mouseX-(getX()))<10 && mouseX<getX()){
           setVelocityX(-1);  
       }
       else {
             setState(STATE_STAND);
       }
       
    }

    /**
        Updates the player's position and animation. Also, sets the
        Player's state.
    */

        public void update(long elapsedTime) {
            // select the correct Animation
           Animation newAnim = anim;
            if (getVelocityX() < 0) {
                newAnim = animWalk;
            }
            else if (getVelocityX() > 0) {
                newAnim = animWalk;
           }
            else if (getVelocityX() == 0) {
                newAnim = animStand;
            }

            // update the Animation
           if (anim != newAnim) {
                anim = newAnim;
                anim.start();
            }
            else {
                anim.update(elapsedTime);
           }
            // move player
           super.update(elapsedTime);
        }

    }


and the Sprite class:
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  
108  
109  
110  
111  
112  
113  
114  
115  
package graphics;


import java.awt.Image;

public class Sprite {

    protected Animation anim;
    // position (pixels)
   private float x=0;
    private float y=0;
    // velocity (pixels per millisecond)
   private float dx;
    private float dy;

    /**
        Creates a new Sprite object with the specified Animation.
    */

    public Sprite(Animation anim) {
        this.anim = anim;
    }

    /**
        Updates this Sprite's Animation and its position based
        on the velocity.
    */

    public void update(long elapsedTime) {
        x += dx * elapsedTime;
        y += dy * elapsedTime;
        anim.update(elapsedTime);
    }

    /**
        Gets this Sprite's current x position.
    */

    public float getX() {
        return x;
    }

    /**
        Gets this Sprite's current y position.
    */

    public float getY() {
        return y=750;
    }

    /**
        Sets this Sprite's current x position.
    */

    public void setX(float x) {
        this.x = x;
    }

    /**
        Sets this Sprite's current y position.
    */

    public void setY(float y) {
        this.y = y;
    }

    /**
        Gets this Sprite's width, based on the size of the
        current image.
    */

    public int getWidth() {
        return anim.getImage().getWidth(null);
    }

    /**
        Gets this Sprite's height, based on the size of the
        current image.
    */

    public int getHeight() {
        return anim.getImage().getHeight(null);
    }

    /**
        Gets the horizontal velocity of this Sprite in pixels
        per millisecond.
    */

    public float getVelocityX() {
        return dx;
    }

    /**
        Gets the vertical velocity of this Sprite in pixels
        per millisecond.
    */

    public float getVelocityY() {
        return dy;
    }

    /**
        Sets the horizontal velocity of this Sprite in pixels
        per millisecond.
    */

    public void setVelocityX(float dx) {
        this.dx = dx;
    }

    /**
        Sets the vertical velocity of this Sprite in pixels
        per millisecond.
    */

    public void setVelocityY(float dy) {
        this.dy = dy;
    }

    /**
        Gets this Sprite's current image.
    */

    public Image getImage() {
        return anim.getImage();
    }
}
7  Discussions / General Discussions / Re: JGO Frequently Asked Questions on: 2012-04-25 06:20:07
thanks for this sproingie.
I cannot help with the FAQ because I will probably be target audience for it, but I can say I will read it and appreciate very much your efforts!

thanks everybody!
8  Discussions / General Discussions / Re: What Religion Are You? on: 2012-04-24 07:24:56
Before! Always before!!!!
9  Discussions / General Discussions / Re: How Long Have You Been Coding? on: 2012-04-21 21:28:23

I started with Fortran during my bachelor, about 6 years ago. Since them I have also use C (for a short period), R (only for small things) and Matlab (during the last 3 years).
Now I am starting with Java (and making games for the first time). I hope to code in Java at least for a few years  Grin
10  Java Game APIs & Engines / Java 2D / Re: 2D point and click adventure: my firsts steps on: 2012-04-21 17:39:35
Thanks a lot Cruiser. I will work with that code during the weekend!
11  Java Game APIs & Engines / Java 2D / 2D point and click adventure: my firsts steps on: 2012-04-21 17:07:49
 Hello World!


I am new around here, and also new with Java. I have quite some experiences using other languages, but not for game developing!. I have started some weeks ago, learning the basics about Java, making some scripts, I made my first pong game and then I started to play around with graphics and Java 2D.

I want to do a 2D point and click adventure, and my first problem is precisely here: the point and click. I am able to paint my character over the background image, but when I click with the mouse in any other place it just repaint the character in the new position... I try to solve it using repaint inside a for loop (old obsessions from other languages...) changing the X and Y position in a vector that go from the initial position to the last position. But it is not working (it just stay for a moment in the old position and them appear on the new one). I guess I am doing something really stupid, and there is even more than one easy way to do this... can anybody help me? There is any trick or function to make the character move smoothly from the initial position to the position where I click with the mouse?


(I have search around the forum to don't repeat any topic unnecessarily, but I have not found anything. Anyway I am sorry if this was already explain before!)


thanks in advance!

[I hope the post is in the correct place...]
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 (23 views)
2014-08-22 19:31:30

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

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

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

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

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

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

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

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

Norakomi (41 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!