Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (707)
Games in Android Showcase (207)
games submitted by our members
Games in WIP (781)
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  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [artemis-odb] When does it init Systems? on: 2016-10-14 00:13:01
You're getting a null-pointer exception because you try and use the mapSystem in the MapRenderSystem's constructor. You want to override the initialize() method from the BaseSystem class, which gets called after the system injections.
2  Game Development / Newbie & Debugging Questions / Re: Libgdx + box2d - Rotating around a point on: 2016-06-29 05:48:42
Could we maybe see a snippet of your code? It would be useful to see what you have, maybe we can build off that. I was looking at the docs and I saw a couple things with RevoluteJointDef. I'm assuming you've tried this, but I would set the motorSpeed to whatever speed you want, and then the maxMotorTorque to a large value so that it can accelerate to that motorSpeed quickly.
3  Game Development / Newbie & Debugging Questions / Re: Libgdx + box2d - Rotating around a point on: 2016-06-29 01:17:53
Are you talking about the position in the orbit? It is dependent on the current rotation, I guess, but it wouldn't be hard to write some code to have the object rotate to a certain angle in the orbit.

edit: actually, the rotation of the orbiting object would be off, this method would work if sravia wanted to just have the object circle around, but if sravia wanted to set it to a certain angle in the orbit then it wouldn't work.
4  Game Development / Newbie & Debugging Questions / Re: Libgdx + box2d - Rotating around a point on: 2016-06-29 00:42:24
Not sure exactly what rotation you are referring to, but the object in the center can have a rotation without it affecting the orbiting object.
5  Game Development / Newbie & Debugging Questions / Re: Libgdx + box2d - Rotating around a point on: 2016-06-28 22:51:11
Hydroque's method is definitely a valid option, but there is also another option using physics, which IMO is a good option since box2d is a physics engine, but either will work. The upside to this is that you aren't risking messing up the physics simulation by manually editing positions.

So you have this diagram here, a box rotating at a distance r (center to center) from an object with velocity v and has a constant speed.

Now imagine the orbiting box is attached to the center object by a string. In order for that box to keep rotating around the center, the string needs to apply a force to it.
We know
However the acceleration here is centripetal acceleration because it is an object rotating at a constant radius and constant speed around an object.
Centripetal acceleration is
so we can plug that in to the original equation
In order to keep the box rotating around the center object, you need to apply a force which is equal to
on the center of the orbiting object towards the center position. However you also have to make sure it has an initial velocity, otherwise it would just fall in to the center object. That initial velocity is just v and it needs to be tangent to the orbiting circle. For example, if the box starts on top, the velocity needs to be v in the positive or negative x direction.

Now if you want to have the object always facing the center: think of the moon. The same side of the moon always faces the Earth. This is because it takes the moon the same time to orbit around the Earth as it does for the moon to complete one full rotation.
The time it takes (in seconds) for the object to complete one rotation around the center is called the period (which is noted as T). The equation is:
Now we can find the angular velocity so that the object always faces the center. The angular velocity is measured in radians per second. The object needs to rotate one full rotation, in the time it takes to travel once around the orbit. So, since we need to travel 2 PI radians in T seconds, we can find the angular velocity by using the equation:
which conveniently ends up being
So to have the object always face the center, you need to set its angular velocity to be v/r and have its initial rotation be facing the object.

I wrote out the code for this and it is working, so if you decide to take this approach and run in to trouble I can gladly help you out.
6  Game Development / Game Mechanics / Re: LibGDX Screen to World coordinates on: 2015-08-28 03:05:41
camera.unproject returns the updated Vector3 so you need to save that value:
Vector2 clickPos = new Vector2(x, camera.viewportHeight - y);
Vector3 worldCoordinates = camera.unproject(new Vector3(clickPos, 0));

or you could also do this and then the updated coordinates will be stored in the original Vector3:
Vector3 clickPos = new Vector3(x, camera.viewportHeight - y, 0);
7  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
8  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:


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:

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

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:

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!
9  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.
10  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:
TiledMap map = new TmxMapLoader().load("tdmap1.tmx");
OrthogonalTiledMapRenderer renderer = new OrthogonalTiledMapRenderer(map,unitScale);
OrthographicCamera camera = new OrthographicCamera();

try making it

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.
11  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:
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().
12  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 width, int height, boolean fullscreen)
13  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.
14  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.

... // 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
15  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.
16  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?
17  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.
18  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., org.newdawn.slick.state.StateBasedGame)
19  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.

20  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
Float.parseFloat(getLevel.getProperties().get("player spawn x"))
and the same thing for y;
21  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
22  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 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.
23  Games Center / Featured Games / Re: [Slick2d] Retro-Pixel Castles > Now on Steam! < on: 2014-10-10 13:40:49
Awesome! Congrats Cheesy
24  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?
25  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
26  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:
I know I did better than last Ludum Dare with everything and had a lot of fun this time around!
27  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.
28  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?
29  Game Development / Newbie & Debugging Questions / Re: Libgdx Death animation on: 2014-08-04 14:56:20
Try doing this after you create the animation.

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.
30  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.
Pages: [1] 2
Galdo (368 views)
2017-01-12 13:44:09

Archive (524 views)
2017-01-02 05:31:41

0AndrewShepherd0 (993 views)
2016-12-16 03:58:39

0AndrewShepherd0 (922 views)
2016-12-15 21:50:57

Lunch (1056 views)
2016-12-06 16:01:40

ral0r2 (1288 views)
2016-11-23 16:08:26

ClaasJG (1385 views)
2016-11-10 17:36:32

CoffeeChemist (1384 views)
2016-11-05 00:46:53

jay4842 (1468 views)
2016-11-01 19:04:52

theagentd (1243 views)
2016-10-24 17:51:53
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 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‑
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!