Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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 3
1  Game Development / Newbie & Debugging Questions / Re: My First Game on: 2014-05-04 10:24:09

1  
2  
3  
4  
5  
6  
7  
8  
9  
   public void update(float delta) {
      player.update(delta);
      for (int i = 0; i < wall.size(); i++) {
         wall.get(i).update(delta);
         if (wall.get(i).collides(player)) {
            player.stop();
         }
      }
   }


And the stop method within the player is:
1  
2  
3  
4  
5  
   public void stop() {
      velocity.x = 0;
      velocity.y = 0;
      System.out.println("x");
   }


The problem now is that once the player touches the wall, it go to the stop method and remain there forever even when I touch down other areas on the map to try to move away from the wall!
Any ideas?

Am i right that you call this Methode recursivly over and over again: wall.get(i).update(delta)?

Maybe you could post what wall.get(i).collides(player) does too, because i think the Error comes from there^^.
2  Game Development / Newbie & Debugging Questions / Re: My First Game on: 2014-05-02 07:19:45
This repository has helped me greatly when i was learning about tilemaps:
http://code.google.com/p/libgdx-users/wiki/TiledMaps

Maybe this here will help you too:
https://github.com/libgdx/libgdx/wiki/Tile-maps

Well i cannot tell you if you're on the "right" path. It is the right path if it fits for the purpose and helps you solving problems^^. Allways stick to stuff and mechanics you like, if you like to make tilemaps, make some^^. Afterwards you will know if it was the right way.
3  Game Development / Newbie & Debugging Questions / Re: Trouble working with ArrayList on: 2014-05-01 21:16:06
1  
2  
3  
4  
5  
for(ItemEntity p: Player.playerInventory){
     if(Player.playerInventory.get(0) != null)                //my problem is in this for statement somehow
    g.drawImage(p.getSprite(),50,50,this);
     if(Player.playerInventory.get(1) != null)               //if i take out this "if statment" than I'm able to display the 1st item fine.
       g.drawImage(p.getSprite(),100,100,this);}


Why would you check the playerInventory with get(), when your allready getting each ItemEntity with:
for(ItemEntity p : Player.playerInventory)
That would be my solution to looping through your inventory:

1  
2  
3  
4  
5  
6  
7  
8  
9  
int pX = 50;
int pY = 50;
for(ItemEntity p : Player.playerInventory()) {
    if(p != null) {
        g.drawImage(p.getSprite(),pX, pY, this);
        pX+=50;
        pY+=50;
    }
}


Your variables look wrong - I assume Player is an instance not a  class, so it should be named "player".

Or maybe Player is a class and he is accessing it in a static way^^.
4  Game Development / Newbie & Debugging Questions / Re: My First Game on: 2014-05-01 21:00:34
That is great help. I finally managed to load the map using the method you mentioned Cheesy

Now I want to ask about two things:

1. My future plan is to make the game online multi-player so I will need to initiate the maps and everything from a server and the players will be able to modify by adding or removing assets from the map. From your experience, should I keep the way I use for maps or should I start making tiled maps? If I should use tiled maps, can the .tmx file be modified and saved from the code?

2. Is there some tutorial I can use to implement an interaction between player and houses for example?

Thanks in advance.

1. As Drenius suggested, i would too recommend to stay singleplayer for a while, because the task to create a multiplayer game is not an easy one. Start small and create a great singleplayer game, maybe more than one, before considering going multiplayer.

2. What kind of interactions would you like to implement? Opening chests? Doors?
5  Game Development / Newbie & Debugging Questions / Re: My First Game on: 2014-04-30 09:54:47
1. Why don't you use an ArrayList? This way it would be expandable and you can add as many Houses/Huts as you want.
2. No. When using Lists/Arrays there is no way to update every element in the List/Array without looping through^^.
6  Game Development / Newbie & Debugging Questions / Re: Your opinion on my elephant pattern movement? on: 2013-08-18 15:58:28
Idk what game engine you're using, but with libgdx, you can just apply the color to the spriteBatch (or whatever batch you use) to draw with a different color setting. You just apply a bit more red and it will look more "reddish" Smiley.

About the elephant, you could load the "default" elephant when loading the game, and then just make copies of it when the player reaches a certain location.
7  Game Development / Newbie & Debugging Questions / Re: Libs ? on: 2013-08-18 15:14:57
If you're looking for an external library for game development, I recommend Slick2D to start off with. It's easy and simple to use, but it is a bit lacking for larger, more complex games.

I thought it was a good way to learn and get me started.
Slick2D is deprecated and I have a real problem with people telling newbies to use It. Why even learn It? So what if its easy. Easy is not always better.

I agree, using deprecated libs just because they are "easy" is not recommended. By the way libGDX isn't that much harder is is also well maintained and can be used even for complex games Smiley.
8  Game Development / Newbie & Debugging Questions / Re: [SOLVED][LibGDX] Problem with removing and creating Bodies on: 2013-08-17 18:14:37
I just found the solution to this problem. As allways it was pretty obvious but the error was not  Tongue.

Previously i just flagged my entities for destruction and then iterated over them to destroy the bodies. This worked fine but the Problem was with the creation of the bodies (obviously doing that when the world was stepping).

The solution was, that i now add my entities to a list when they need to be created/destroyed. I create them before the step happens, and destroy them after the step finished.

1  
2  
3  
createEntities();
world.step();
destroyEntities();


It was kinda hard to find the solution, as it's only mentioned with 1 sentence at the end here: http://www.iforce2d.net/b2dtut/removing-bodies

"By the way, although this topic has focused on removing bodies since that is the most common case to cause problems, the creation of new bodies, and the creation and removal of fixtures must be dealt with in the same way."
9  Discussions / General Discussions / Re: Generating random sprites on: 2013-08-16 20:04:47
I'd say you're missing a few layers of useful abstraction. In particular a separate ball object and a rough entity system which is just a fancy term of "a list of sprites" basically. Also you should separate some of your logic into their own functions, your game loop for instance.

I'd say the OP would need some more basic java, because that is what you learn when learning the basics of the language...
10  Game Development / Newbie & Debugging Questions / Re: [LibGdx]Doesn´t understand Camera + Noob Questions on: 2013-08-16 17:19:03
Hmm okay, I haven´t known OrthogonalTiledMapRenderer yet, but I am also not able to use it, it just doesn´t find the package??? I have even no maps package.

Well then you are using an old version of libGDX. You should redownload it (if possible the latest nightly).

If you use an OrthogonalCamera you should also use the OrthogonalTiledMapRenderer. Maybe thats where your issues come from...

Edit: I just read through the docs and it seems TileMapRenderer does not exist anymore Smiley
11  Discussions / General Discussions / Re: Generating random sprites on: 2013-08-16 17:13:21
The only thing I want to point out in your code so that the OP understands is that
1  
xCoords[]
is actually the array of balls. Sorry but it seemed like a very vague and not related name for an array of balls!

Thanks for pointing that out, i changed it Smiley.
12  Discussions / General Discussions / Re: Generating random sprites on: 2013-08-16 13:18:02
Maybe someone of the dukes could move this post to the right forum? Smiley

I allready answered your questions. But it seems you kinda lack some java basics. Maybe you should start with that before trying to write games.

Here is an example for creating a random amount of balls with random x-coordinates:

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  
public class FallingBallTest {

      private int[] balls; // Array of x values for the various balls
     private int y;
      private int width;
      public boolean running = false;

      public FallingBallTest() {
            JFrame f = new JFrame("Falling Ball Test");
            f.add(this);
            f.setSize(500, 500);
            f.setResizable(false);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            width = this.getWidth();
            Random rand = new Random();
            balls = new int[rand.nextInt(10)];
            for(int i = 0; i < xCoords.length; i++)
            balls[i] = rand.nextInt(width);
            this.startGame();
      }

      public void startGame() {
            running = true;
            while(running) {
                  this.update();
                  this.repaint();
            }
      }

      public void update() {
            y++
      }

      public void paintComponent(Graphics g) {
            super.paint(g);
            Graphics2D g2d = (Graphics2D) g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2d.setColor(Color.black);
            for(int x : balls) {
                  g2d.fillOval(x, y, 30, 30);
            }
      }

      public void main(String[] args) {
            new FallingBallTest();
      }
}


I give no guarantee that it actually works, was just scribbling it here before i have to go Smiley.
13  Game Development / Newbie & Debugging Questions / Re: Skip frames on: 2013-08-16 12:55:48
So lets say your delta time is about 0.01 seconds. It means you're moving your object about 0.25 pixels every frame and that means (with a framerate of about 60 fps) you move your objects 15 pixels every second. If you check for collisions every frame, there should be no problem at all.

You're gamelogic happens every frame, so you cannot "limit" it to the frames. That means every time something is drawn, the gamelogic is calculated before. Also you're logic doesn't "skip" frames, as your frames don't skip frames. if you halt your gameLoop because of fps limitation (thread.sleep()), no logic will be done, but also no rendering will be done.

Another case would be, if you would use a seperate thread for your gamelogic. But i don't think thats the case here.
14  Game Development / Newbie & Debugging Questions / Re: Skip frames on: 2013-08-16 12:33:05
I thought ur loop was really weird...

The loop wasn't that bad, and doesn't cause framelags. And where does he do actions based on frames? He updates the game using the delta time (as everybody should do) Smiley.

An advice to both of you:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
/* Works but isn't very nice nor very capable of 
 * beeing used in a "serious" game because it will just loop infinitely. */

while(true) {
...
}

/* This one is quite better, because you can control the condition better.
 * If you choose to quit your game and maybe move back to a menuscreen
 * you could stop with running = false: */

while(running) {
...
}
15  Discussions / General Discussions / Re: Generating random sprites on: 2013-08-16 12:27:58
1. This is kind of the wrong forum to post this kind of question.

2. You have to create a loop if you want more balls to fall down.

3. You have to randomly set the x-coordinate using maybe the java.util.Random class.

And last but not least: You don't begin a question with a bunch of code. Maybe next time start with a little introduction on what you try to accomplish...
16  Game Development / Newbie & Debugging Questions / Re: Skip frames on: 2013-08-16 12:17:49
What exactly are you doing inside world.update() (i think thats your global "gamelogic update" method)? Also are you using any libraries or pure java2d? A bit of code of screen.repaint() and world.update() would be very helpfull.

Also this:

1  
try{ Thread.sleep(1); }catch(Exception e){}


won't cause any noticable change to the current behavior, as you set the thread to sleep for just 1 millisecond.
17  Game Development / Newbie & Debugging Questions / Re: Moving from Command prompt to a gui. advice? on: 2013-08-16 08:14:01
I think you are going the wrong way. I think what you want is something like a HUD inside a game. Swing components are not suitable for that. I also don't know why you would remove and add actionListeners continuously. You just would check game states in your actionPerformed method if you would need to change the functionallity of a button.

Also your code suggests that you are quite a beginner in java programming. I would recommend you to get a little bit more familiar with java before even considering making games.
18  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Decals and Models on: 2013-08-16 07:54:50
I don't know much about libGDX's 3D API but some things were strange about your code.

  • First you don't use your decalBatch anywhere in your render method, or are you using it elsewhere?
  • Why are you ordering the Models you would like to draw?
  • What are you doing with the renderingOrder object?

Maybe i just need more context to fully understand what you're doing, but you can also take a look at this (If you have not allready done that):

Using the libgdx 3D API

Edit: I think i found something. Your depthBuffer is maybe not correctly initialised. You should use values between -1 and 1, als specified here: http://www.opengl.org/sdk/docs/man/xhtml/glDepthRange.xml. Most of the time you can set the depthBuffer like that:

1  
Gdx.gl.glDepthRangef(0f, 1.0f); //0 beeing the near plane and 1 beeing the far plane
19  Game Development / Newbie & Debugging Questions / Re: [LibGdx] Can't render tiled map on: 2013-08-15 20:02:26
Just download the latest nightly from the libgdx website and add it to your build path in eclipse. Just the way you did it when you started with this build Smiley.
20  Game Development / Newbie & Debugging Questions / Re: [LibGdx] Can't render tiled map on: 2013-08-15 19:33:05
I'm using the latest stable build. It's LibGdx - 0.9.8

That might be the Problem. You should switch to the nightly builds because as Stein102 posted, the new map API is not yet in stable.
21  Game Development / Newbie & Debugging Questions / [SOLVED][LibGDX] Problem with removing and creating Bodies on: 2013-08-15 18:14:43
I really didn't find any suitable solution on the web for my particular problem.

I'm creating a game with LibGDX and run into problems when i try to create bodies. The Problem occurs quite randomly and i can't track it down properly, but it seems it is only occuring when i create an Item from my Item class.

This is the error message:

http://pastebin.com/Qy0qaKBr

and this is the logfile created:

http://pastebin.com/jz6Tr6u5

As i read on some resources it seems like this error is caused when destroying a body while iterating over the bodylist. As i do not destroy bodies when this error happens its seems rather odd. Also i never figured out why the OpenAL library is involved here, as i don't use any sounds yet...
22  Game Development / Newbie & Debugging Questions / Re: Bullet Directional Shooting Images [Need Help] on: 2013-08-15 17:31:04
Ok then you need to create a separat AffineTransform like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
// You create an identity transform (this should never change):
AffineTransform identity = new AffineTransform();
// You create another transform (used for rotating):
AffineTransform at= new AffineTransform();
// set the transform for rotating to the identity (do this with every bullet):
at.setTransform(identity)
// rotate your image:
at.rotate(angle);
// Draw your image:
g2d.drawImage(image, at, this);


The AffineTransform class is quite complicated and i don't even understand it fully, but that would maybe do the trick Smiley.

Edit: changed the code because it won't do anything else than my code posted before xD
23  Game Development / Newbie & Debugging Questions / Re: Having an issue loading text files on: 2013-08-15 17:22:05
Is the res folder still in the build-path? if yes, try to remove it, paste it into your source-folder again and try it with the given advices.
24  Game Development / Newbie & Debugging Questions / Re: Bullet Directional Shooting Images [Need Help] on: 2013-08-15 17:03:08
Why change the image? You can also rotate it by the angle you just calculated. If you use pure Java2D you could do something like that:

1  
2  
3  
AffineTransform at = new AffineTransform();
at.rotate(angle);
g2d.transform(at);
25  Game Development / Newbie & Debugging Questions / Re: Having an issue loading text files on: 2013-08-15 16:46:43
Seems like you're not getting the classLoader from an instantiated object in which case the "getClassLoader()" will return null iirc. Try changing that to:

1  
 return Assets.class.getResourceAsStream("/" + name);


http://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html

The nullPointerException suggests that the InputStream is null. In the Constructor of the InputStreamReader's superclass Reader you will find this:

1  
2  
3  
if (lock == null) {
      throw new NullPointerException();
}


lock is in that case the InputStream Object created from getResourceAsStream(). This is what getResourceAsStream() returns:

1  
2  
3  
4  
5  
6  
7  
8  
public InputStream getResourceAsStream(String name) {
      URL url = getResource(name);
      try {
            return url != null ? url.openStream() : null;
      } catch (IOException e) {
            return null;
      }
}


So your URL is definetely null. This (as we all know) only happens if your path is not valid.
26  Game Development / Newbie & Debugging Questions / Re: Having an issue loading text files on: 2013-08-15 15:06:56
It seems like your resource just cannot be found by the InputStream. You have to check if the packages are properly named. Also if you have copied SHC's code you should check, if youre resources are located in a package called res.<YourResourcePackage>:

1  
2  
3  
4  
public InputStream getInputStream(String name)
{
    return getClass().getClassLoader().getResourceAsStream("res/" + name);
}

27  Discussions / General Discussions / Re: latest "immersive" game technology on: 2013-08-13 08:10:10
Science-fiction has arrived! Prepare yourselfs! Cheesy

I allways wonder how fast this industry paces... Its unbelievable that about 20 years ago we played stuff like commander keen and secret of monkey island and now we don't even need a screen anymore :O
28  Game Development / Newbie & Debugging Questions / Re: How to structure 2D RPG? on: 2013-08-13 07:45:25
I have allways used an entity-component-system. Even the famous Unity3D Engine uses this system, so i think it will be a good decision to stick with it Smiley. Its relatively easy to maintain and makes the code look more structured. Of course others will maybe say something else, but thats my personal opinion Smiley. You of course should choose which suits you best. A List of desing patterns in game developing can be found here:

Useful pesign patterns in game development
29  Game Development / Newbie & Debugging Questions / Re: [LibGdx]Doesn´t understand Camera + Noob Questions on: 2013-08-11 20:10:26
Well i think the problem is, that the TiledMapRenderer (OrthogonalTiledMapRenderer or any of the 4 available Smiley) needs to be set to the right camera projection like that:

1  
renderer.setView(camera


If you allready do that, it would be helpfull to me, if you could post more code of your rendering process, otherwise its just guessing what goes wrong...
30  Game Development / Newbie & Debugging Questions / Re: Arrow Ballistic + Collision issue + Pos Issue + Slow Method? on: 2013-08-10 21:13:42
It would be good to know at wich frame rate your update() happens. Do you calculate delta time between the updates? If yes you could use the delta value to calculate the distance the arrow flew after the last update. Then you could check for collisions based on the distance. Or do i get you completely wrong? xD
Pages: [1] 2 3
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

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

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

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

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

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

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

BurntPizza (49 views)
2014-08-09 21:09:32
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!