Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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: Get all text from System.out on: 2014-01-07 22:21:57
You can try this, have served me fine for over a year.
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  
public class SplitPrintStream extends PrintStream {
   private PrintStream second;
   
   public SplitPrintStream(PrintStream main, PrintStream second) {
      super(main);
      this.second = second;
   }
   
   @Override
   public void close() {
      super.close();
      if (second != null)
         second.close();
   }
   
   @Override
   public void flush() {
      super.flush();
      if (second != null)
         second.flush();
   }
   
   @Override
   public void write(byte[] buf, int off, int len) {
      super.write(buf, off, len);
      if (second != null)
         second.write(buf, off, len);
   }
   
   @Override
   public void write(int b) {
      super.write(b);
      if (second != null)
         second.write(b);
   }
   
   @Override
   public void write(byte[] b) throws IOException {
      super.write(b);
      if (second != null)
         second.write(b);
   }
}

Simply pass it System.out and the printstream for your log file or wherever else, you want to sent the console output(I use it to read console output, from my play testers via network.),
then replace System.out with the new SplitPrintStream using System.setOut().
2  Game Development / Newbie & Debugging Questions / Re: lwjgl fullscreen cpu load problem on: 2014-01-05 20:05:46
I have 331.82 driver and tried out your code, and I was able to reproduce the issue.
after a bit of messing around I discovered that, it would seem like enabling vsync, is what causing the issue, at least for me.
3  Game Development / Newbie & Debugging Questions / Re: lwjgl fullscreen cpu load problem on: 2014-01-05 19:32:32
Try this,
Verify that Display.getDesktopDisplayMode().getFrequency(); returns a positive number, like 60.
otherwise set refreshrate to 60 manually.
also make sure vsync actually gets enabled, check that you haven't enforced vsync to stay off, in nvidia control panel.
4  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Issue with LWJGL Space Inaders Example on: 2013-11-08 23:17:55
Hi gmmaster, you are getting that error, because you are not running your own main method.

The slick library contains numerous example programs, each with its own main method.

At the time you first attempted to run your code, you may not have had focus on the editor or may have had another class open, so eclipse couldn't find a main method.
This makes it search the build path for a main method, and it finds all those inside Slick and sorts them alphabetically, and picks the first (it may have shown a dialog too).
So you are actually running AlphaMapTest.java, it says that in the stack trace too, and as another feature of eclipse it remembers which file you ran last, so it keeps running that when you click the run button.

A simple solution is to open your own class in the editor, right click in the editor, and run it from there, this it should remember too, so doing it once should be enough.
5  Game Development / Newbie & Debugging Questions / Re: some Garbage Collection and LWJGL memory managment questions on: 2013-09-01 14:41:23
Answer 1.
Yes it does create a memory leak, but depending on how often you do this, it should not really be to much a problem.
Still you shouldn't do it, its better to just reuse the old buffer id, by uploading new data, such as with a vbo, you just call glbuffer with the new data.
Otherwise you should at least remove them, using the appropriate gl remove calls, before letting go of the id, because the GC wont save you here.

Answer 2.
Null'ing the buffer wont make the GC any faster, buffers are like any other java objects flagged "to be removed" when there are no more references to it, however if you still need the object that holds the buffer for a while, just not the buffer itself, you should null the buffer, so that the GC may clean up the buffer, without having to wait.

Answer 3.
Generally the OS will handle that for you, but you should still clean up after yourself, its better to do so, rather than rely on somebody else to do it, i'd say not doing it is like having the main method throw an exception, because you are to lazy to catch it yourself in a try...catch block.
6  Game Development / Newbie & Debugging Questions / Re: Texture coordinate problem with GLSL on: 2013-03-21 16:28:18
Next time you should really make sure to clean it up before posting.

Thats why i thought you were using the fixed-function pipeline.
7  Game Development / Newbie & Debugging Questions / Re: Texture coordinate problem with GLSL on: 2013-03-21 15:24:09
Looks like you aren't enabling and setting the texture coordinate attributes correctly.

you need these.
glTexCoordPointer
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
8  Game Development / Game Mechanics / Re: Getting array of all surrounding mobs on: 2013-02-03 00:57:50
Try replacing that return statement with a break statement.
9  Java Game APIs & Engines / OpenGL Development / Re: Two squares/cubes (basic question OpenGL 3.x LWJGL) on: 2013-01-27 13:40:51
You only have the vertices and colors for a single cube.
Ideally you could just draw the single cube twice and adjust its location with the model matrix.

Edit: Oh didn't see you weren't using matrices, maybe you should consider using some.
10  Java Game APIs & Engines / OpenGL Development / Re: Two squares/cubes (basic question OpenGL 3.x LWJGL) on: 2013-01-27 12:51:43
Not quite, now you tell it to draw the same square twice.

Think of the vertices as if they are on a numbered list, the first 4 vertices in your vertices array are those of the first square.
The next 4 vertices are those of your second square.

So your indices should look something like this.
1  
2  
3  
4  
5  
6  
7  
byte[] indices = {
            0, 1, 2,
            2, 3, 0,
           
            4, 5, 6,
            6, 7, 4,
      };

The indices simply tell the gpu which of the vertices you have sent it, it should draw, and what order to draw them in.
The advantage of this approach is that you don't need to send the same vertex several times to join multiple triangles together.
As an example you only sent 4 vertices for each of the squares, but you need 6 to make a square by combining two triangles, but two of them is already on the same location.
11  Java Game APIs & Engines / OpenGL Development / Re: Two squares/cubes (basic question OpenGL 3.x LWJGL) on: 2013-01-27 12:20:36
You need to add the other squares indices to your indices array.
The indices tells your vboi which of the vertices it should draw and what order to draw them in.
12  Game Development / Newbie & Debugging Questions / Re: Nullpointer exception at render on: 2012-12-17 23:52:31
getSprites()?
In the code you posted before currentFrame isn't being instantiated either.

Edit: by the way, you really should check your code an extra time before posting more of these NullPointerException errors, because they are often easy enough to spot,
make sure you have a clear idea where your variables is instantiated.
13  Game Development / Newbie & Debugging Questions / Re: Nullpointer exception at render on: 2012-12-17 22:30:43
It doesn't look like you are ever creating that SpriteBatch object, so the variable just hold a null value.
14  Game Development / Newbie & Debugging Questions / Re: Image height on: 2012-11-30 17:43:05
Any errors?
Just the wrong output?
What do you code look like?

Edit: lost the post, this one answered.
15  Game Development / Newbie & Debugging Questions / Re: Image height on: 2012-11-30 17:40:27
image.getHeight();
16  Game Development / Newbie & Debugging Questions / Re: Cube decided not to participate. on: 2012-10-18 16:27:32
The viewport is set automatically to whatever the display resolution is set to when created.
but you set the resolution after creating the window, so you had to set it manually.
17  Game Development / Newbie & Debugging Questions / Re: Cube decided not to participate. on: 2012-10-17 16:12:46
try doing glViewport(0, 0, 800, 600); right after creating the display.
18  Game Development / Newbie & Debugging Questions / Re: Tile-based game help! on: 2012-10-13 23:34:06
There is nothing there that requires it to be static, but you made the field static, so the it has to be called statically when you draw it.

On the line g.drawImage(Tiles.tileImg, Level.thex, Level.they);
remove "Tiles."
and remove the static modifier on the field "tileImg".
19  Game Development / Newbie & Debugging Questions / Re: Tile-based game help! on: 2012-10-13 23:18:57
Seems tileImg in Tiles is static, so it is replaced for "all" your tiles, every time a new tiles is created.
if I read your map creation code correctly, that means they all use "res/twat.png".
20  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Slick2D diagonal line artifacts on: 2012-09-05 10:14:43
Looks like the effect that happens when you enable anti-alias on the Graphics object.
If you are, try disabling it before drawing images.
21  Game Development / Newbie & Debugging Questions / Re: Basic Java2D rendering problem on: 2012-09-05 08:33:44
Switch
1  
2  
      frame.pack();
      frame.setResizable(false);

so it says
1  
2  
      frame.setResizable(false);
      frame.pack();
22  Game Development / Newbie & Debugging Questions / Re: Slick2D Two Input Questions and More on: 2012-06-20 18:00:46
Override keyPressed(int key, char c) in BasicGameState or BasicGame.

the c parameter is similar to calling KeyEvent.getKeyChar() and the key parameter is similar to calling KeyEvent.getKeyCode()
23  Game Development / Newbie & Debugging Questions / Re: Platformer Gravity, the Camera and Graphical Flicker... on: 2012-04-20 15:59:11
Casting to int on rendering, is likely the best way to do it and shouldn't cause any errors.

This problem often pops up on the slick forum, and most of the time casting to int on render, is the first thing people will tell you to do.
But sometimes making an invisible 1 pixel frame around the image works too, but in your case I'd recommend casting.
24  Game Development / Newbie & Debugging Questions / Re: Serialize Image on: 2012-02-05 17:11:55
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
   
   public void nullifyImages(){
      uSelImage = null;
      uNorImage = null;
      uActiveImage = null;
   }
   
   public void loadImages() throws SlickException{
      uSelImage = new Image(uSelImageDest);
      uNorImage = new Image(uNorImageDest);
      uActiveImage = new Image(uActiveImageDest);
   }


Try putting these in your unit class.
Call nullifyImages() on you object just before out.writeObject(object) and call loadImages() just after loading in.readObject().

If your program still need the object after saving you can either.
1. pass the images to somewhere else, where you can retrieve them from, before you nullify the fields.
2. reload them with loadImages() after saving.
25  Game Development / Newbie & Debugging Questions / Re: Serialize Image on: 2012-02-05 16:36:08
Do you actually need to save the images into a file?

Otherwise you could simply save the Image paths, then set your image fields to null before saving the file, and then after loading the file, load the images based on the path you saved.
26  Game Development / Newbie & Debugging Questions / Re: Memory leak(?) and inefficient buffering problem on: 2012-02-01 22:17:39
I didn't mean to say it "did", i meant it could cause performance problems if the program would start spamming exceptions, which in turn could cause memory leak, but thanks for correcting me, wasn't really sure about what impact exceptions had on memory.
27  Game Development / Newbie & Debugging Questions / Re: Memory leak(?) and inefficient buffering problem on: 2012-02-01 22:05:01
Looking at your code i don't see anything obvious that would cause memory leak, but i do have a few criticisms. Wink

The first one, and possibly causing the memory leak, is that you silence exceptions, i see you do this a few times.
Try not to silence exceptions, because if your program is throwing a lot of silenced exceptions, it could easily cause all sorts of performance problems, and try to use specific exceptions that you know could be thrown rather than the standard Exception.

The second one, try to add more comments or arrange you code based on functionality, to make it easier to read, because large walls of code is tend to be hard to read, and limits the amount of people who would post here.

As for your drawing algorithm, it looks fine, i don't know how much of an improvement it is as i have little experience with it, but you could try using bufferstrategy rather than a bufferedimage its supposed to be faster.
28  Game Development / Newbie & Debugging Questions / Re: Slick2ds entity engine on: 2012-01-16 12:19:52
I don't recall slick 2D having an entity manager, only some of its extensions that have and a few tutorials that explains how to make one.

My advise, make your own, it will be alot easier to understand whats going on, than using someone else's system.

My idea's:
For your crowd manager(npc-director), make it an entity, and make all the npc's entities too, have the npc-director create and remove npc's first thing per loop, maybe using an npc pool, npc-director could assign them behaviors too.
Then have the npc's control what they do on their own.

This is what i would do based on your description.
But its up to you, to decide how it should work. Wink
29  Game Development / Game Play & Game Design / Re: Game Graphics Style Opinions on: 2012-01-15 22:03:32
For looks, i'd clearly say the sketched one.
When i compare the screenshots, i look at the tile-based and think "why? another one of those." but when i look at the sketched one i think "This seems interesting, wanna see more."

But for control, i'd say that the tile-based might be easiest for the player to understand and interact with, when using click and drag, while the sketched one would be better of with a different control system such as point and click.

My conclusion would be, pick the sketched one, it have the best "feel".
30  Game Development / Newbie & Debugging Questions / Re: Creating a simple Game Menu / Screens? on: 2012-01-12 14:47:51
Sounds like you would want to use a statemachine for the different screens.
As example, create a mainmenu state that shows the buttons for each option.
The gameplay, highscores and credits would go in states of their own.
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.

Longarmx (39 views)
2014-10-17 03:59:02

Norakomi (30 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (57 views)
2014-10-14 00:39:48

TehJavaDev (58 views)
2014-10-14 00:35:47

TehJavaDev (48 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!