Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (528)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (594)
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: Why does the Basic Java Hex Editor I made freeze on files around 2MB size and up on: 2010-10-11 07:01:39

I don't use AWT, but looks like your loading the data in the main GUI thread.  This generally is very bad in most GUIs.

In SWT I would throw the load function to a new thread and async output to a progress window/bar.
2  Game Development / Newbie & Debugging Questions / Re: How to create a simple encoder and decoder? on: 2010-10-07 11:36:49

You might want to take a look at this for ideas:
http://www.flamewind.com/programs.html

It's a conversation editor for a NWN 2.  It outputs to XML.

I don't know the structure of your program, but you might be able to use that to create all the text via a nice GUI program.  Save it in XML and that is half your battle right there.

The other half would be writing an XML reader to pull in the data to your game.
3  Discussions / General Discussions / Re: Getting started and actually getting something done. on: 2010-10-05 08:37:32
If you want to develop for Win, Mac, Linux; then I would suggestion Slick 2D with TWL.

That gets you a nice game engine and nice GUI/theme-able interface.
Those in themselves will save you tons of time.

On top of that there are some nice network lib and data manglers out there.
Reuse when you can will help speed development, specially working by yourself.
4  Discussions / Suggestions / Re: Shared code on: 2010-10-05 08:36:10
I'm up for it, but instead of posting to forum, would a semi-open source control system work?  Everyone could just upload what they wanted under their username.  Or even shared ftp server.
5  Discussions / Suggestions / Re: Shared code on: 2010-10-04 23:46:01
Same here. I have a ton of code and don't mind sharing it.  I don't know how much of an audience a bunch of half finished games with poor graphics would have though. Smiley  Most smaller games would probably be easier to just code up ones self then digging though someone elses mush.

6  Java Game APIs & Engines / Android / Game Engines? on: 2010-10-04 16:47:04

Any good 2d game engines for Android?  Something like Slick 2D would be optimal.

7  Discussions / Jobs and Resumes / Re: Hiring for small job. on: 2010-09-30 22:27:50


ok, thanks guys.  I guess this thread can be closed.  I go back to reading up on opengl.
8  Discussions / Jobs and Resumes / Re: Hiring for small job. on: 2010-09-30 22:11:37
That is possibly the most pathologically worst way of achieving this result without actually writing it in Ruby! See Riven's answer. Basically: allocate a direct ByteBuffer to hold the raw pixel data. Poke directly into that. Every frame, call glTexImage2D() to upload your data to OpenGL. Draw a single quad. Rinse, repeat.

Cas Smiley

Any examples/tutorials of that?  Like I said, I suck at opengl.
9  Discussions / Jobs and Resumes / Re: Hiring for small job. on: 2010-09-30 22:07:31


Sorry, but I don't understand how this helps.  My bottle neck is in rendering, not in access or manipulating the data.
The vast majority of time is spent in GL11.glVertex
10  Discussions / Jobs and Resumes / Re: Hiring for small job. on: 2010-09-30 21:57:00
here is what I got:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
GL11.glBegin(SGL.GL_QUADS);

      for (int x = 0; x < width / pixelSize; x++) {
         for (int y = 0; y < height / pixelSize; y++) {
         
            int x1=x*pixelSize;
            int y1=y*pixelSize;
            GL11.glVertex2f(x1, y1);
            GL11.glVertex2f(x1 + pixelSize, y1);
            GL11.glVertex2f(x1 + pixelSize, y1 + pixelSize);
            GL11.glVertex2f(x1, y1 + pixelSize);
         }
      }

GL11.glEnd();


roughly 97% of the time it's bound by the GL11.glVertex2f functions.
I'm drawing direct to screen.

I hoping that it would be faster to generate a texture off that data then just throw up the entire texture. 
Rendering 1 texture to screen should be tons faster then all those calls.

The bottleneck will move to generation of the texture.  Which if fine.  That is only updating it, not rendering it and can always be throttled.



11  Discussions / Jobs and Resumes / Re: Hiring for small job. on: 2010-09-30 21:17:31
Same goes for OpenGL.

So, again, what's the algorithm like? What are you calculating?

Have an object that stores/renders a texture, store it and update/render it any way you want as longs as it's fast.  Have an external method that allows modifying/getting of that data.   How the values that are passed into the modifying function are generated shouldn't matter.  Just assume it's random data.

Yea, assume that it'll call the modify function on one or more random x/y pair to set it to a random color.  The update and render functions will be called atleast 60 times per second.  From your objects point of view, there is no way it'll be able to assume any patterns on the data coming in.  The only thing it could reliably assume is that x/y will be in a valid range and color will be a valid color value (in whatever way you wish to store that data).

An example:

Create texture 800x600, set all pixels to black.

setPixel(100,200 red) is called.
The texture is updated().  It's all black, except pixel x=100/y=200 is red.
texture is rendered() and displayed to the user

setPixel(200,100, blue) is called.
The texture is updated().  It's all black, except pixel x=100/y=200 is red, pixel x=200/y=100 is blue
texture is rendered() and displayed to the user

setPixel(100,200 black)
setPixel(200,100, black)
The texture is updated().  It's all black again.
texture is rendered() and displayed to the user.
12  Discussions / Jobs and Resumes / Re: Hiring for small job. on: 2010-09-30 20:53:15

The more I think of it, the cuda/opencl is probably more than needed.  Standard opengl hopefully will be fast enough.
13  Discussions / Jobs and Resumes / Re: Hiring for small job. on: 2010-09-30 19:34:57
Sure.  In terms of budget, I don't know.  Was looking for an estimate for whoever was doing in.

In terms of what needs to be done, I need to update the screen per pixel.
See this: http://www.powerengine2a.com/images/screenshot_290.png
What I'm doing now is pretty slow.

From what I've read:
a pretty standard  way to do this is to create a Frame Buffer Object, Rendering that to a Texture "offline" then display the texture.
Another much faster is to use a pixel shader or cuda to do all the manipulation on the GPU.
or third unknown option, like I said in my first post; I'm willing to defer to the expert on whatever he thinks would work best.

In terms of performance I'm looking for at least 60 fps at 1024x768 on moderate hardware.

In terms of deliverable, I'm looking for a "screen" class that has an easy way to set pixels like setPixel(x,y,color), can render texture resolution independent of display (ie. internally use a 1024x768 texture for speed, but display it was 1280x800 [or whatever the set resolution is] either scaled or centered).  Should also have some sort of update/render methods were it does its work.  That way I can control how much updates it gets.  If it starts lagging, I can start skipping updates and still render the last good texture generated; then resume updating once it catches back up.  Or manually call an update after a setPixel.
14  Discussions / Jobs and Resumes / Hiring for small job. on: 2010-09-30 11:12:58
Looking for someone that is good with OpenGL/lwjgl.  Java of course Smiley
If you know CUDA (jcuda) that much the better, but not required.

It should hopefully be pretty straightforward for someone experienced. 
All 2d and will probably be dealing with Frame Buffer Objects and Textures but will defer to your expertise on best way to implement it.

I can pay via paypal or check in USD.

Email if intrested: dimecoin@gmail.com
15  Game Development / Performance Tuning / Re: Fastest way to set every pixel? on: 2010-09-29 19:58:31
well, i knocked up a simple program which fills pixels of a 1024x768 image using a buffered image and on my atom net book it achieves 68 fps so on higher spec machines it should do better. what is your target frame rate?

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  
import java.awt.Graphics2D;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;

import javax.swing.JFrame;

final public class a extends JFrame
{
   private static final int SCREEN_WIDTH = 1024;                     // Screen Width
   private static final int SCREEN_HEIGHT = 768;                     // Screen Height
   private static final int WIDTH_MUL_HEIGHT_MINUS_ONE=SCREEN_WIDTH*SCREEN_HEIGHT-1;
   
    final public static  void main( String[] a) throws Exception
    {
         new a();
    }
       
    a() throws Exception
    {

         Graphics2D g;
      final BufferedImage image= new BufferedImage(SCREEN_WIDTH,SCREEN_HEIGHT,BufferedImage.TYPE_INT_RGB);
     
/****************************************************************************************************************
 * Initalize Screen
 */

      // the buffer strategey used for the video double buffer
      BufferStrategy strategy;
       
      setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
      show();
     
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
      createBufferStrategy(2);
      strategy = getBufferStrategy();
     
       int frameCount=0;
      long threashold=System.currentTimeMillis();
      long time;
      int i;
     
      int[] pixelData=((DataBufferInt)image.getRaster().getDataBuffer()).getData();

      /****************************************************************************************************************
       * Game Loop
       */

      do
      {      
         time=System.currentTimeMillis();   // the current timestamp
         frameCount++;
          if(time>threashold)
          {
             setTitle(""+frameCount);
             frameCount=0;
             threashold=time+1000-(time-threashold);
          }
         
          for (i=WIDTH_MUL_HEIGHT_MINUS_ONE;i>=0;i--)
          {
             pixelData[i]=(i)&0xFFFFFF;
          }
         
         
         
           // Get hold of a graphics context for the accelerated surface
           g = (Graphics2D) strategy.getDrawGraphics();
         g.drawImage(image,0,0,null);
         
          strategy.show();
     
      //    // give some cpu time to other processes
          Thread.yield();
      } while (true);
         
    }
   
}
   



Thanks, but I'm using Slick 2d; so would need to convert from AWT BufferedImage to Image:http://slick.cokeandcode.com/javadoc/org/newdawn/slick/Image.html

I'm assuming that would take a performance hit converting it every frame.
16  Game Development / Performance Tuning / Re: Fastest way to set every pixel? on: 2010-09-29 08:09:49
Probably just getting the pixels from the BufferedImage, modifying it, then drawing the image should be fastest.
Or you can go overboard and write a GPU shader that does this with OpenGL/OpenCL, it would be extremely fast but also hard to write.

I think that is what I want.  I'ved tried images and rects already, but pretty slow.
Any newbie articles to get started on shaders?


17  Game Development / Performance Tuning / Fastest way to set every pixel? on: 2010-09-28 09:54:19
I have a game board, let's say 1024x768.  Kind of like the game of life, but every cell will be it's own color.

What's the fastest way to do this?  I tried it though Slick 2d, but assuming there is probably some over head there.
I don't know OpenGL, so hopefully someone can guide me?

I've tried drawing fillRect and using an image (byte) buffer (ImageData.getImage() - involves lots of creating/destroying of an Image object)
I did it on different workstations, one has a way better CPU and the other has way better GPU.
It seems filling quads is heavy on the GPU and creating an image/byte buffer kills the cpu/memory.

Doing in direct in lwjgl will give better performance?  What would be a good approach and can someone point me in the right direction?

18  Game Development / Shared Code / Re: Particle editor on: 2010-09-24 22:08:54
oh, that looks nice
19  Discussions / Business and Project Management Discussions / Re: Good news for Java mobile devs? on: 2010-09-22 22:32:30
Well I hope to see J2ME learn from Android and improve it or see JavaFX on phones. There is also the Java market which I hope would help.
Windows mobile 7 started from scratch to get back into the race against android and iPhone, so why can't anyone else?

Myself I still like to see able writing one application for windows/android/symbian.

I wish they would just create a Java Apps store.  Any user from any system, Desktop (win,linux,mac), Mobile, web, etc could download an app and be assured that it works on their platform.  For developers, they would have one place to push and it'd work on all platforms.  This of course assumes that you have a reasonable and working environment on each platform, which we really don't.  I don't buy this "write once, run everywhere" nonsense.

20  Discussions / General Discussions / Re: JavaFX is *officially* dead! on: 2010-09-21 19:50:48
I went to javaforum a couple of months ago. Some oracle devs explained (or rather tried to impress us) with the grand future of java. Smiley
One of the key things they pressed lots and lots and lots was javaFX. Larry was determined to see javaFX a success. And as the sales guy said: "what Larry wants, he usually gets".
Even when filtering with my bullshit filter, it seems that javaFX will get real attention with oracle.

Hopefully Oracle focuses on the "last inch".

Java is a great platform, specially the VM!  Getting it to the end user is a pain.

Applet would be great in theory; apps embedded int he browser! Look at flash, that works out well. 
But something about the last inch, mainly the user experience with applets - just isn't/wasn't there.
If they could get applets running like flash they would dominate the flash market.  Most any one would rather write for the Java VM then for adobes yucky one.
With a good deployment of the VM you could write in most anything: java,  javascript, jpython, jruby, etc.  That would attract a lot of developers.

It's not that flash is better, it ain't.  The only reason it "won" is because it had a better user experience in terms of deployment.
If Oracle was to focus on that (Sun sure didn't) then they might have something.




21  Game Development / Newbie & Debugging Questions / Re: [2D] Lights and Shadows on: 2010-09-18 17:42:08

Thanks for  explaining that, but I'm not even familiar with that terminology.
22  Game Development / Newbie & Debugging Questions / [2D] Lights and Shadows on: 2010-09-18 07:01:20

Anyone have an articles/tutorials on top down lights/shadows?

This engine looks really nice:
http://sourceforge.net/project/screenshots.php?group_id=303720&ssid=128010
http://www.asantee.net/ethanon/

I don't even understand the basic concepts of this.   How are lights/shadows handled in games, specifically 2d.
23  Game Development / Newbie & Debugging Questions / Re: Design Question on: 2010-09-15 18:40:20
hence why i said go and look at this *in practice*. Real code just doesn't map to simplistic "this is the best way to do it".  Its also just coding something up is a good idea. Working code is better than a non working "perfect" design... that once you start implementing you realize is useless for your particular problem.

Have any open source examples of largish Java games that are code "right"?
24  Discussions / General Discussions / Re: Google AI contest about to start. on: 2010-09-12 19:20:45
Investment Strategy

I was thinking a simple pricing model might work.  Anyone see any flaws with this?
The theory is, if you make better investments then the other bot, you'll out grow him.

The cost would be how many ships it takes to capture.
The distance would also factor into cost some how.  Everything being equal you would want a closer planet (since you could capture it fewer turns).

The value of a planet would be it's growth.

All those are known and pretty solid maths.  The last input would be probability.  The probability of the enemy attacking the planet.  Everything else being equal you want one that is less likely to be attacked (since it'll  reduce your return and/or even lose your investment). 

One way to do that is calculate all the above in reverse order for him.  The better investment it is for him, the more likely he'll attack it.

At the end of the day it's the most ships that wins, not most planets.

Parasite Strategy

Another one I was thinking of is using a "Parasite " strategy.  Any planet he attacks, you attack.  He uses maximize resources to capture a planet, you use minim resources.

For example, if a neutral planet is at 50 and he sends 55 ships to capture it, the planet is left with 5 enemy ships.  You send 10 ships and capture it out from under him.
He spend all those ships to capture it, but you plucked it from him for very cheap.  This would work if the bot wasn't aggressive.  If he attacked you directly it'd probably fail.

25  Game Development / Newbie & Debugging Questions / Re: Camera class in top view on: 2010-09-12 19:03:46
In my update():

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
   screenWidth = gc.getWidth();
      screenHeight = gc.getHeight();
     
           
      if (followPlayer) {
         playerTileOffsetX = player.getTileOffset().x;
         playerTileOffsetY = player.getTileOffset().y;
         playerX = screenWidth/2- player.getCordPosition().x-16 - playerTileOffsetX;
         playerY = screenHeight/2 - player.getCordPosition().y-16 - playerTileOffsetY;
      }


in render (I use slick)

1  
2  
3  
4  
5  
6  
   defaultBackground.draw(0,0, gc.getWidth(), gc.getHeight());
     
      // If we're following player
      if (followPlayer) {
         g.translate(playerX, playerY);
      }




PlayerTileOffsetXY doesn't matter.  It's just player offset in pixels from tiles.  This lets it "smooth scroll" 1 pixel at a time instead of jumping 32 (it gets jerky if you jump to many pixels to quick).

Translate just shifts to screen: http://slick.cokeandcode.com/javadoc/org/newdawn/slick/Graphics.html#translate%28float,%20float%29


Then on top of the above, I just draw player in center of screen.  Non translated.

26  Discussions / General Discussions / Re: Google AI contest about to start. on: 2010-09-11 18:15:46
I was actually thinking it might be fun to make a Q-Learner or Neural Network AI for this, train it for a few days, then see how well that does. The only challenge then is figuring out how to represent the game within reasonable state space or fitness equation, but Galcon is simple enough that I think you could manage. Although there is a limit on how long you can take to do moves, there is no limit on the amount of memory you need (a large state space for Q-Learner would need probably like 10mb of RAM all on its own, at least), nor the amount of crap you store on the hard disk (store the "winning" state space on disk so it can be loaded up properly). You could also do a genetic algorithm along the same lines.

Hmmmm.... now I'm getting intrigued.

You can't write to disk though.  So all your training would have to be against offline bots and don't know if that would be a good sample?
27  Discussions / General Discussions / Re: Google AI contest about to start. on: 2010-09-11 18:03:23
I signed up.  Not a chance I'll do any good though.

Anyone else in?

Code base seems kind of weird.  Anyone get it working in eclipse?  It runs in a very awkward manner.
Also the GUI is slow and doesn't update till after the match.  Wish they would of did that a little better. 

How are you guys getting output for debugging/checking?  Printing to system out or writing to file are both no-noes.
man this thing is awkward to deal with.
28  Game Development / Newbie & Debugging Questions / Re: Camera class in top view on: 2010-09-10 21:56:24
> I might be slow, and it is late. Why do you divide by two?

To get the center point.

If you have a piece of paper that is 10 inches wide, if you fold it in half (that is divide by 2) you get the center point of paper.
Same with screen width, but measured in pixels.

Also depends on how you draw sprites.  When I draw them at x and y it draws 0,0 of the sprites at that location.
If that is the case, you have to divide your sprite image by 2 to get center of image.  If not, your sprite won't be true center, it'll be off by a bit.

What coordinate system are you using?  Either pixels or tiles (like a tiled map) will work with this.
Not sure what other type of cord system you'd be using other than one of those?
29  Game Development / Newbie & Debugging Questions / Re: Camera class in top view on: 2010-09-10 21:06:55
I have a Camera class that basically:

Divides screenwidth /2 and subtracts the player position (minutes half of players sprite width) and move screen by that.
Same with height.

A concrete example.  If screen is 640 wide and player is at 300 and player is 32 pixels wide.
640/2 = 320 [screen width /2] - 300 [player [pos] = 20 - 16 [sprite width /2] =4

that means I shift the map over by 4 pixels.

Basically, whatever the player is, the camera is centered on him.  If he moves left 32 pixels, the camera follows him over 32 pixels.

Or another way to look at it, the player is always perfectly centered in middle of the screen and map moves under him.

I like this approach because it isn't dependent on resolution.  The higher the resolution just means the player sees more of the map.
Maps can be as big or small as you like.
30  Discussions / General Discussions / Re: Threaded javac? on: 2010-09-10 06:43:53

SSDs are pretty fast and pretty darn safe.
I have one at home and it Eclipse flies compared to what I have at work (even though work has better CPU and more memory).
Pages: [1] 2
 

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

The first screenshot will be displayed as a thumbnail.

PocketCrafter7 (14 views)
2014-11-28 16:25:35

PocketCrafter7 (10 views)
2014-11-28 16:25:09

PocketCrafter7 (11 views)
2014-11-28 16:24:29

toopeicgaming1999 (77 views)
2014-11-26 15:22:04

toopeicgaming1999 (67 views)
2014-11-26 15:20:36

toopeicgaming1999 (17 views)
2014-11-26 15:20:08

SHC (30 views)
2014-11-25 12:00:59

SHC (28 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (28 views)
2014-11-24 19:59:16
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!