Show Posts
|
|
Pages: [1]
|
|
1
|
Game Development / Newbie & Debugging Questions / Re: How to add cutscenes to your game
|
on: 2012-06-17 19: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 15: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!
|
|
|
|
|
4
|
Game Development / Newbie & Debugging Questions / How to add cutscenes to your game
|
on: 2012-06-17 12: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!
|
|
|
|
|
6
|
Game Development / Newbie & Debugging Questions / cannot make my sprite walk and stop
|
on: 2012-05-21 20: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; }
public boolean isPaused() { return paused; }
public void setPaused(boolean p) { if (paused != p) { this.paused = p; inputManager.resetAllGameActions(); } }
public void update(long elapsedTime) { checkSystemInput();
if (!isPaused()) { checkGameInput();
player.update(elapsedTime); } }
public void checkSystemInput() { if (pause.isPressed()) { setPaused(!isPaused()); } if (exit.isPressed()) { stop(); } }
public void checkGameInput() { float velocityX = 0;
if (moveRight.isPressed()) { player.walk(); player.setState(Player.STATE_WALK); } player.setVelocityX(velocityX);
}
public void draw(Graphics2D g) { g.drawImage(bgImage, 0, 0, null);
g.drawImage(player.getImage(), Math.round(player.getX()), Math.round(player.getY()), null); }
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);
}
private void createSprite() { Image[][] images = new Image[4][]; 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]; 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.*;
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; }
public int getState() { return state; }
public void setState(int state) { if (this.state != state) { this.state = state; } }
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); } }
public void update(long elapsedTime) { Animation newAnim = anim; if (getVelocityX() < 0) { newAnim = animWalk; } else if (getVelocityX() > 0) { newAnim = animWalk; } else if (getVelocityX() == 0) { newAnim = animStand; }
if (anim != newAnim) { anim = newAnim; anim.start(); } else { anim.update(elapsedTime); } 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; private float x=0; private float y=0; private float dx; private float dy;
public Sprite(Animation anim) { this.anim = anim; }
public void update(long elapsedTime) { x += dx * elapsedTime; y += dy * elapsedTime; anim.update(elapsedTime); }
public float getX() { return x; }
public float getY() { return y=750; }
public void setX(float x) { this.x = x; }
public void setY(float y) { this.y = y; }
public int getWidth() { return anim.getImage().getWidth(null); }
public int getHeight() { return anim.getImage().getHeight(null); }
public float getVelocityX() { return dx; }
public float getVelocityY() { return dy; }
public void setVelocityX(float dx) { this.dx = dx; }
public void setVelocityY(float dy) { this.dy = dy; }
public Image getImage() { return anim.getImage(); } } |
|
|
|
|
|
9
|
Discussions / General Discussions / Re: How Long Have You Been Coding?
|
on: 2012-04-21 23: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 
|
|
|
|
|
11
|
Java Game APIs & Engines / Java 2D / 2D point and click adventure: my firsts steps
|
on: 2012-04-21 19: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...]
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|