Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (653)
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] 2
1  Game Development / Newbie & Debugging Questions / Re: Object Problem on: 2015-06-25 05:18:00
I had a thought and went and checked it out and it's all good now. My Wall class extends my WorldObject class which extended the Ashley AI Entity class. When I removed that extends for the Entity class, it was fixed. Looks like the hashcode for it was determined by the Entity ID, which ended up all being 0. Thanks SHC for your reply Smiley
2  Game Development / Newbie & Debugging Questions / Object Problem on: 2015-06-25 04:32:04
Hello all. Sorry about the vague topic title, however I really had no idea what to call it. I've never seen a problem like this before.

I'm using LibGDX and Java 8.

I was working on the level editor for my game and created an ArrayList to store the level objects. I also had another ArrayList that stored any objects that I selected. I was trying to make it so that any selected objects had a red box around them, and otherwise they just had an orange box. The problem occurred when I tried to use the contains() method on the selected objects ArrayList. It was telling me that every one of my objects was contained in that ArrayList, even though when I printed out the size, it only said one. I spent quite a while trying to figure the problem, and stepped through my code multiple times. Eventually, I tried printing out the two objects in the list and I got this:

1  
2  
com.exavolt.game.world.objects.Wall@0
com.exavolt.game.world.objects.Wall@0


I don't remember what the @0 part is, but I think that if they are different objects, they should be different. Or at least it usually isn't 0 and with only two different objects it should be different for each. I spent a little while looking around in my code to see if anything weird was going on, but I couldn't find anything, so I stripped it down to the most basic thing I could:

1  
2  
3  
objects = new ArrayList<WorldObject>();
objects.add(new Wall(4, 6, 2, 2));
objects.add(new Wall(-2, -2, 3, 3));


and the stuff in wall is just

1  
2  
3  
4  
5  
6  
7  
8  
9  
private Rectangle bounds;
   
public Wall(float x, float y, float width, float height) {
   bounds = new Rectangle(x, y, width, height);
}
   
public Wall(Rectangle bounds) {
   this.bounds = bounds;
}


when I printed that, I got the same thing.

I then took that most basic section and created a new java project and put it in there without any LibGDX stuff. I got what I should be getting:
1  
2  
com.dragon.blah.main.Wall@28d93b30
com.dragon.blah.main.Wall@1b6d3586


Thinking that there was some possibility that it may just be some kind of error in the project configuration, I copied all my code to a separate LibGDX project, however I ended up with the bad output. I tested this on both Windows and Mac and got the same results on each. What could I be doing in my code that is causing this? Thanks for the help!
3  Game Development / Newbie & Debugging Questions / Re: LibGDX - Tiled Map Collision on: 2015-06-03 03:53:51
On line 30 you have setY(....); then on line 34 you assign oldY to your y value, after you already moved the player. Try putting oldY before you do any movement, otherwise oldY is just your current Y value.
4  Game Development / Newbie & Debugging Questions / Re: Having trouble with the screen class.. on: 2015-04-29 03:13:15
No, sorry if I didn't make it more clear. Instead of doing:
1  
2  
3  
TiledMap map = new TmxMapLoader().load("tdmap1.tmx");
OrthogonalTiledMapRenderer renderer = new OrthogonalTiledMapRenderer(map,unitScale);
OrthographicCamera camera = new OrthographicCamera();


try making it

1  
2  
3  
map = new TmxMapLoader().load("tdmap1.tmx");
renderer = new OrthogonalTiledMapRenderer(map,unitScale);
camera = new OrthographicCamera();

because then you are using your class variables that are used in the render method.
5  Game Development / Newbie & Debugging Questions / Re: Having trouble with the screen class.. on: 2015-04-29 02:56:03
Looks like the problem is here:
1  
2  
OrthogonalTiledMapRenderer renderer = new OrthogonalTiledMapRenderer(map,unitScale);
OrthographicCamera camera = new OrthographicCamera();

You're creating a camera and map renderer that have a scope that is just that show method,and your camera and renderer in your screen class aren't being created, which is why they are still null, even after show().
6  Game Development / Newbie & Debugging Questions / Re: [libgdx] Resize game window and/or enable/disable fullscreen on-the-fly on: 2015-04-14 03:02:11
Use Gdx.graphics.setDisplayMode(int width, int height, boolean fullscreen)
7  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Animation + Delta Time? on: 2015-04-14 00:41:23
Also, just pointing out that when you say new Animation(2f, ...) your animation will change frames every two seconds, which is pretty slow (unless that's intentional). That number where your 2f is now is the time for each frame of the animation.
8  Game Development / Newbie & Debugging Questions / Re: Animated Mouse Cursor on: 2015-03-11 04:07:58
Yep, each frame of the animation would have to be separate. Then, I would make a Pixmap array and fill it with a couple cursor frames. Here, my array of Pixmaps is called frames.

1  
2  
3  
4  
5  
6  
... // Timer stuff

if(index == frames.length) // Reset the index if it reaches the end of the array
   index = 0;
Gdx.input.setCursorImage(frames[index++], #, #); // Set the cursor image to index then increment by 1
     
9  Game Development / Newbie & Debugging Questions / Re: Animated Mouse Cursor on: 2015-03-11 03:17:24
You could have a class that is sort of like the Animation class. You have a variable in there keeping track of time and when it reaches a certain amount of time, you would then change the cursor image by getting a Pixmap from an array of pixmaps, then start the timer over again. I would be happy to help you out and elaborate a little more as well.
10  Game Development / Newbie & Debugging Questions / Re: Trouble Implementing Simple Projectile into Slick2D on: 2015-01-27 20:21:22
Are you ever looping through the projectiles in order to render them?
11  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2014-12-23 19:48:50
I think I'll try and finish something. I started a top down shooter a little bit ago, so I already had some stuff such as movement, collision, and shooting done. This morning I came up with an idea for the gameplay and story, and made the art to create the first room. The only thing I didn't make was the player sprite. I should probably do more work on the gameplay and story and less on graphics right now  Roll Eyes



I'm making it with LibGDX and the lighting is with Box2DLights.
12  Game Development / Newbie & Debugging Questions / Re: Slick2D White Rectangle instead image!? on: 2014-11-30 20:31:06
Looking here at the docs, it says that all resource loading should be done in the init method. Since you were loading the images from the enter method, that's where it was going wrong.

http://slick.ninjacave.com/javadoc/org/newdawn/slick/state/GameState.html#enter(org.newdawn.slick.GameContainer, org.newdawn.slick.state.StateBasedGame)
13  Games Center / Archived Projects / Re: SJGL (Now on GitHub!) on: 2014-11-27 22:03:50
Just letting you know, the pills spawn outside of the little area.


14  Game Development / Newbie & Debugging Questions / Re: LibGDX ClassCastException on: 2014-11-22 20:11:53
I think that the level properties might automatically be set to be strings, so perhaps try making it
1  
Float.parseFloat(getLevel.getProperties().get("player spawn x"))
and the same thing for y;
15  Game Development / Newbie & Debugging Questions / Re: Saving only one value in preferences file - libgdx on: 2014-11-21 02:27:36
Just a little confused. Do you have sound and music stored in your preferences?  When the player turns the music/sound on or off, do you directly change the value you already have stored in the preferences? Thanks Smiley
16  Game Development / Game Play & Game Design / Re: Options menu? (2D games) on: 2014-11-03 03:46:40
If you didn't already know, LibGDX has a UI library built in: scene2d. It's pretty easy to use to add buttons, sliders, and more.

For managing different platforms, there are many different ways you can do it such as having a different option screen class for each platform, so my next idea is just one option of many. So you'll probably have a screen class called Options. When you show the options screen, you would do a check to see what platform the game is on with the method Gdx.app.getApplicationType() or whatever the method is.  Then you could have separate methods for creating the options screen for each platform, so: initDesktopOptions() and initAndroidOptions(). Then you could create the UI elements for each type in each of those methods.
17  Games Center / Featured Games / Re: [Slick2d] Retro-Pixel Castles > Now on Steam! < on: 2014-10-10 13:40:49
Awesome! Congrats Cheesy
18  Game Development / Newbie & Debugging Questions / Re: Box2D Circle works but not pentagon Polygon? on: 2014-10-09 13:07:41
Correct me if I'm wrong but doesn't Math.sin use radians? Instead of doing Math.sin(i * 72) would Math.sin(Math.toRadians(i * 72)) work?
19  Games Center / Contests / Re: Ludum Dare 30 (Connected Worlds) on: 2014-08-25 22:34:24
You linked the screen shot, not the game itself! And with a name like 'Dragon' how do you expect us to find you!? We want to play!
Oh gosh I didn't realize I posted a screenshot and not the actual link  Clueless  . Alright here it is. I will also update my original post http://www.ludumdare.com/compo/ludum-dare-30/?action=preview&uid=25675
20  Games Center / Contests / Re: Ludum Dare 30 (Connected Worlds) on: 2014-08-25 01:17:43
Going to play all of your games  Wink

I finished my entry as well:
http://www.ludumdare.com/compo/ludum-dare-30/?action=preview&uid=25675
I know I did better than last Ludum Dare with everything and had a lot of fun this time around!
21  Games Center / WIP games, tools & toy projects / Re: Real Turn - Android RPG with roguelike elements on: 2014-08-19 17:44:12
Looks really cool  Grin . I wish I had an Android device, but I'll just try it on my computer later.
22  Game Development / Newbie & Debugging Questions / Re: Libgdx, Box2D and a huge "block world" (destructible blocks!) on: 2014-08-19 02:16:49
So you call the drawmap method in the render class, so every frame. Any reason why you are creating a fixture every time?
23  Game Development / Newbie & Debugging Questions / Re: Libgdx Death animation on: 2014-08-04 14:56:20
Try doing this after you create the animation.
1  
deathAnimation.setPlayMode(PlayMode.NORMAL);


I'm not sure if this will draw the last frame once it's done. If it does, great, but if it doesn't, you could check to see if it's finished and then do what you want.
1  
deathAnimation.isAnimationFinished(stateTime);
24  Game Development / Newbie & Debugging Questions / Re: (LibGDX) Colorize grayscale sprite on: 2014-07-30 11:45:43
If you are using the Libgdx Sprite class, you can use the sprite.setColor method, just make sure you're rendering your sprite with the sprite.draw method.
25  Game Development / Newbie & Debugging Questions / [LibGDX]Box2dLights Rendering Issue on: 2014-01-14 04:25:20
Hiya,
So, I have a map like this:


Sometime I'm going to add in some stuff and I would like to add in some lights. I took a look at Box2dLights and set it up and it works great (Nice and simple), however I'm not able to do what I want to do. I would like to add in lights that will not affect the lighting anywhere on the scene except where the light is and where it extends to.

I tried moving the RayHandler updateAndRender method around my render method to try different rendering positions, but it didn't do anything to help with my problem. When I put it so that it renders the light after my player and map render methods, it looks good, but where the light it is the only place where there is light. Everywhere else is completely black, but I think that is how the light is supposed to work (not sure).

Sorry if this post was confusing at all. Let me know if you need any more information or if you would like me to restate something.

Thanks!
26  Game Development / Newbie & Debugging Questions / Re: Why isn't drawing a Sprite working? on: 2013-08-19 18:33:52
I played around with it for a little bit, and I found the issue, but didn't solve it.

Pretty much, the main game class sets the screen to MainMenu. MainMenu then runs its show method once then never runs its render method, and switches back to the main game class render method. Why is it doing this?

 I have no idea what to do here because I've tried copying and pasting code from another screen class I made for a different project, pasting it in, then changing all the names and everything, and it still doesn't work.

EDIT: I figured out the issue. I had to add super.render(); to the main game class. Ugh, I can't believe I forgot that, and was trying to figure out the problem for a couple hours now DX. I guess that's programming though Wink
27  Game Development / Newbie & Debugging Questions / Why isn't drawing a Sprite working? on: 2013-08-19 17:48:28
Hi everyone. I'm having an issue, and it's really frustrating because of how simple it is Tongue . Drawing a Sprite isn't working at all. I'm using LibGDX.

For example, with this code, when I draw the sprite, it is flashing really fast.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
@Override
   public void show() {
      batch = new SpriteBatch();

      texture = new Texture("ui/mainmenu.png");
      mainMenu = new Sprite(texture);
      mainMenu.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
     
      batch.begin();
      mainMenu.draw(batch);
      batch.end();
   }

   @Override
   public void render(float delta) {
      Gdx.gl.glClearColor(0, 0, 0, 1);
       Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
   }


but with this code, my sprite doesn't show up at all.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
   @Override
   public void show() {
      batch = new SpriteBatch();

      texture = new Texture("ui/mainmenu.png");
      mainMenu = new Sprite(texture);
      mainMenu.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
   }

   @Override
   public void render(float delta) {
      Gdx.gl.glClearColor(0, 0, 0, 1);
       Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
       
       batch.begin();
       mainMenu.draw(batch);
       batch.end();
   }


Thanks in advance Smiley
28  Game Development / Newbie & Debugging Questions / Re: Error When Loading TileMap - NumberFormatException on: 2013-06-18 22:30:10
I'll take a look at that. Thank you!
29  Game Development / Newbie & Debugging Questions / Error When Loading TileMap - NumberFormatException on: 2013-06-18 21:01:19
Hello!
I've been playing around and learning Slick2d lately, and I decided to do a Tile Map. However, when I try and load it, it gives me an error. First, this is the error:
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  
Tue Jun 18 14:58:40 MDT 2013 INFO:Slick Build #237
Tue Jun 18 14:58:40 MDT 2013 INFO:LWJGL Version: 2.9.0
Tue Jun 18 14:58:40 MDT 2013 INFO:OriginalDisplayMode: 1440 x 900 x 32 @60Hz
Tue Jun 18 14:58:40 MDT 2013 INFO:TargetDisplayMode: 960 x 600 x 0 @0Hz
Tue Jun 18 14:58:40 MDT 2013 INFO:Starting display 960x600
Tue Jun 18 14:58:40 MDT 2013 INFO:Use Java PNG Loader = true
Tue Jun 18 14:58:40 MDT 2013 INFO:Controllers not available
Tue Jun 18 14:58:40 MDT 2013 ERROR:For input string: ""
java.lang.NumberFormatException: For input string: ""
   at java.lang.NumberFormatException.forInputString(Unknown Source)
   at java.lang.Integer.parseInt(Unknown Source)
   at java.lang.Integer.parseInt(Unknown Source)
   at org.newdawn.slick.tiled.TiledMap$GroupObject.<init>(TiledMap.java:1079)
   at org.newdawn.slick.tiled.TiledMap$ObjectGroup.<init>(TiledMap.java:1033)
   at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:688)
   at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:106)
   at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:90)
   at com.dragon.Level1.init(Level1.java:21)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
   at com.dragon.Main.main(Main.java:29)
Tue Jun 18 14:58:40 MDT 2013 ERROR:Failed to parse tilemap
org.newdawn.slick.SlickException: Failed to parse tilemap
   at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:695)
   at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:106)
   at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:90)
   at com.dragon.Level1.init(Level1.java:21)
   at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
   at com.dragon.Main.main(Main.java:29)
Caused by: java.lang.NumberFormatException: For input string: ""
   at java.lang.NumberFormatException.forInputString(Unknown Source)
   at java.lang.Integer.parseInt(Unknown Source)
   at java.lang.Integer.parseInt(Unknown Source)
   at org.newdawn.slick.tiled.TiledMap$GroupObject.<init>(TiledMap.java:1079)
   at org.newdawn.slick.tiled.TiledMap$ObjectGroup.<init>(TiledMap.java:1033)
   at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:688)
   ... 7 more


Here is the class that is causing the problem:
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  
package com.dragon;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.tiled.TiledMap;

public class Level1 extends BasicGameState {
   int stateID  = 4;
   
   private TiledMap map;
   
   public Level1(int state) {
      stateID = state;
   }

   @Override
   public void init(GameContainer container, StateBasedGame game) throws SlickException {
      map = new TiledMap("/res/world/level.tmx"); //Error
   }

   @Override
   public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {

   }

   @Override
   public void update(GameContainer container, StateBasedGame game, int delta)   throws SlickException {
     
   }

   @Override
   public int getID() {
      return stateID;
   }

}


I know that it's the map = new TiledMap... line that's causing this because of the error message. When I comment that line out, the game works fine. Thanks!
30  Game Development / Newbie & Debugging Questions / Re: Where to go From Where I'm at? on: 2013-05-14 01:48:34
Cool, thank you  Grin
Pages: [1] 2
 
SHC (28 views)
2015-08-01 03:58:20

Jesse (20 views)
2015-07-29 04:35:27

Riven (40 views)
2015-07-27 16:38:00

Riven (21 views)
2015-07-27 15:35:20

Riven (24 views)
2015-07-27 12:26:13

Riven (14 views)
2015-07-27 12:23:39

BurntPizza (36 views)
2015-07-25 00:14:37

BurntPizza (46 views)
2015-07-24 22:06:39

BurntPizza (31 views)
2015-07-24 06:06:53

NoxInc (37 views)
2015-07-22 22:16:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21
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!