Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (428)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
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: Advanced BufferedImage manipulation in pure Java on: 2013-12-17 15:39:11
hello man

this is some of my code to make operation on images at run time in pure java it can help you

it help you to make this kind of operation on the images BRIGHTEN and TRANSPARENCY using lookup tables

use it is very easy just create the object and run a method

1  
2  
3  
4  
5  
BufferedImage myImmage = ....
BufferedImage effectImmage = null; //image altered by the effect

BrightenEffect effect = new BrightenEffect();
effectImmage  = effect.filterImage(myImmage,200,150,1,1); //BRIGHTEN effect on R and G channel






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  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
package it.game.image.effect;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.LookupOp;
import java.awt.image.LookupTable;
import java.awt.image.ShortLookupTable;

public class BrightenEffect{

   short[] noChange;         //used to channel that don't change see the hapha channel
  short[] saturation;         //used to channel that don't change see the hapha channel  
  short[] unsaturation;      //used to channel that don't change see the hapha channel  

   public BrightenEffect(){
      noChange = calculateArrayNoChange();
      saturation = calculateArrayByCostant((short) 255);
      unsaturation = calculateArrayByCostant((short)0);
   }

   public BufferedImage copyImage(BufferedImage image){
      BufferedImage sourceBI = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
      Graphics2D g = (Graphics2D) sourceBI.getGraphics();
      g.drawImage(image, 0, 0, null);
      return sourceBI;
   }
   
   protected short[] calculateArrayByPercentage(double percentage) {
     
      if(percentage == 0) //COLOR_UNSATURATION
        return unsaturation;
      if(percentage == 1) //COLOR_ORIGINAL
        return noChange;      
      if(percentage == 255) //COLOR_SATURATION
        return saturation;
     
      short[] array = new short[256];
      short value;
      for (int i = 0; i < array.length; i++) {
         value = (short) (i*percentage);
         if(value> 255){
            value = 255;
         }
         if(value< 0){
            value = 0;
         }
         array[i] = value;
      }
      return array;
   }      

   private short[] calculateArrayNoChange() {
      short[] array = new short[256];
      for(int i=0; i < 256; i++) {
         array[i] = (short) i;
      }
      return array;
   }  
   
   private short[] calculateArrayByCostant(short constant) {
      short[] array = new short[256];
      for(int i=0; i < 256; i++) {
         array[i] = constant;
      }
      return array;
   }  



   /**
    * create a copy of the image changing the saturation on the 3 base color
    * the values of the color RChannel,GChannel,BChannel must be a value between 0 and 255
    * is possible to change also the transparency of the image changing the alphaChannel
    *
    * if the value of a  channel is 1 no change are done to that color
    *
    * so call the function with the the value (image,1,1,1,1) return an image identical to the original
    * so call the function with the value (image,1,0,0,1) return an image using the original red channel active and removing the other channels
    * so call the function with the value (image,255,0,0,1) return an image completely red
     * so call the function with the value (image,1,1,1,0.1) return an image transparent  
    *
    * etc....
    *
    *
    * @param image
    * @param RChannel
    * @param GChannel
    * @param BChannel
    * @return
    * @throws Exception
    */

   public BufferedImage filterImage(BufferedImage image, double RChannel, double GChannel, double BChannel,double alphaChannel) throws Exception {

      if(RChannel == 1 && GChannel == 1 && BChannel == 1)
         return image;
     
      BufferedImage source = copyImage(image);
     
      short[] R = calculateArrayByPercentage(RChannel);
      short[] G = calculateArrayByPercentage(GChannel);
      short[] B = calculateArrayByPercentage(BChannel);
      short[] A = calculateArrayByPercentage(alphaChannel);        
         
      short[][] table;
   
      table = new short[4][];
      table[0] = R;         //RED
     table[1] = G;         //GREEN
     table[2] = B;         //BLUE
     table[3] = A;    //ALPHA
 
      LookupTable lkTable = new ShortLookupTable(0, table);
      LookupOp operation = new LookupOp(lkTable, null);

      return operation.filter(source, null);
   }      

}










2  Java Game APIs & Engines / Java Sound & OpenAL / Re: Exporting Jar with OpenAL on: 2013-12-17 15:06:35
I figured it out, don't mind me. But I still wonder why some sounds don't play... Oddly enough they were my two background sounds. They were perfectly fine in Eclipse but when I exported the Jar they stopped playing. Does OpenAL have a size limit? Because the one file I was trying to play was 14 MB. The other file was only 4 MB, so I don't think that's the issue.

regarding this point if it works in eclipse it works outside eclipse, i mean if size limit exist, exist inside and outside!
so again i ask you an important question, what you mean for
" I exported the Jar " ?
can you explain how i structured your deployment version of your project in the way that may be will be more easy help you to find a solution and explain why it is not working outside eclipse?

did you try to start the project with command line?
do you have the same behavior?



Another problem I found was that sounds wouldn't play exactly when I called them to start, which really annoyed me. For instance, when the player dropped to a certain health level I call on a heartbeat sound to start playing. It doesn't play until I pause the game though, and then stops when I unpause it. I had other sounds playing at the other time, so maybe that was the issue? Either way its kind of annoying that a sound library just doesn't work as its supposed to...

this instead is related to another issue,
from you description look like that the thread that manage the sound start only when the thread that manage the game is stopped
may be in this case try to attach code to understand whats is happening
(anyway for this other question may be is better to create a different thread in the forum)



3  Java Game APIs & Engines / Java Sound & OpenAL / Re: Exporting Jar with OpenAL on: 2013-12-16 18:36:34
Class loader issue my friend

dont' blame on OpneAL

all the issue is related to this line of code
GameSound.class.getResourceAsStream("sound" + File.separatorChar + path);

question what is the class loader that load the class GameSound?
for sure is not the same where is loaded the resource "sound" + File.separatorChar + path

it works in eclipse because it load all the resources of the project in the same classpath

and what you mean to export the jar?
are you executing the main class with command line?
if you will run the class by command line and will add with option -cp or -classpath all the jar, it will works

this is an example
java -cp ../lib/application.jar;../other.jar;../config com.x.y.z.MainClass

./config is a folder if you wont to add file as images configuration file wave file etc directly in file system withtou bind in a jar

i suppose that you create an executable jar correct?

another important point is the definition of the resource name that is different if call in the
getResourceAsStream in the ClassLoader or Class

this is the correct sintax (look the char / based on object that call the method getResourceAsStream)
ClassLoader.getResourceAsStream("some/pkg/resource.properties");
Class.getResourceAsStream ("/some/pkg/resource.properties");







4  Game Development / Game Play & Game Design / Re: scroll through a 3D world on: 2013-12-15 18:34:18
A method I use for rendering  is basically raycast lighting but done to render the image when it hits , its not as efficient as some other methods though.

word is a long rectangle, this solution can introduce a strong cost in computation
i'm looking for a smart pattern, already know and implemented



5  Game Development / Game Play & Game Design / scroll through a 3D world on: 2013-12-15 16:05:49
Hallo guys

i have to decide what is the best way to render my 3D world game

this is my situation and my related question

SITUATION
I'm implementing a sort of space shooter game but instead to have a classic side scrolling the ship
is rendered look at the ship from back.
the style is similar to Air Strike 3D (http://www.youtube.com/watch?v=zHkARvzsrMU)

so in my head the word is like a long rectangle and the ship (and the camera) is moving from one site to the other site of the rectangle until the rectangle is finish

WORD REPRESENTATION
now my idea is to:
describe the word by configurations file (properties or xml) that represent the word as a grid in the way that i can easily customize different levels
so the word is a grid of element that has a specific x and y (conditioned by the grid position) and z coordinate
enemy are initialized in a specific x,y coordinate in the grid
other elements are initialized in a specific x,y coordinate in the grid

now my question:

what is the best way in this kind of games to render the word in terms of performance?
1)I can render all the word in one shot compile it in a glList and use it every loop
2) find a valid algorithm to segment the word based on camera view and decide what element draw, but in this way every loop i have a computation to decide what cells draws
3) other solution?

for example in a games of fly simulation what is the algorithmic /strategy that the developer use usually?

thanks




 


















6  Discussions / General Discussions / Re: How long were you programming with Java before you made your first game? on: 2013-09-04 19:01:58
mainly this depend from you and not from the programming language

i mean is more easy learn a new language for people that already know at good level a language
more complex if you are learning for the first time a programming language

anyway
basically in java in the beginning (and only in the beginning) is more easy that C for example for the memory management (in java memory is managed automatically)
but basically in C in the beginning  (and only in the beginning) is more easy that java write the code interaction (in C there aren't object but only procedure)
both this language have their complexity in different areas

This are just 2 stupid examples, it is not a comparation between the java and C
and they are true until you write application like, calculator or hello word or something like this

but when you start to use really a language doesn't exist easy programming language



7  Game Development / Newbie & Debugging Questions / Re: Entity collision on: 2013-09-04 18:39:08
you can continue to work also with this logic
also the intersection function is ok that mean that this two rectangles intersect in same point
and you are shore 100%

the problem is after:
understand where, in what side, they intersect so that you can decide where you can move

the chance can be four

A over B
    ___
   |     |
   | A  |
   |___|
   |     |
   | B  |
   |___|

this case is when min Y A < max Y B
come move X = true
come move Y = false

A under B
    ___
   |     |
   | B  |
   |___|
   |     |
   | A  |
   |___|

this case is when max Y A > max Y B
come move X = true
come move Y = false

A before B
    _______
   |     |     |
   | A  |  B |
   |___|__ |
  
this case is when max X A > min X B
come move X = false
come move Y = true

A after B
    _______
   |     |     |
   | B  |  A |
   |___|__ |
  
this case is when min X A < max X B
come move X = false
come move Y = true


now
the 2 case
A over B  
A under B
are checked inside the new function blockY

the 2 case
A before B  
A after B
are checked inside the new function blockX


i hope is cleare
also my hash art Smiley

8  Game Development / Newbie & Debugging Questions / Re: Entity collision on: 2013-09-04 18:10:13
if i undestand what you mean

you want to move for example in y if it is not block also if x is block, right?
in this case you can modify easily your code like this


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
 public void CollisionManager(int delta) {
      int x0 = (int)(pos.x + (vel.x * delta));
      int y0 = (int)(pos.y + (vel.y * delta));
      int x1 = (int)(pos.x + width + (vel.x * delta));
      int y1 = (int)(pos.y + height + (vel.y * delta));
     
      List<Entity> entities = world.getEntities(x0, y0, x1, y1);
      for(int i = 0; i < entities.size(); i++){
         Entity e = entities.get(i);
         if(this == e) continue;
            this.touchedBy(e);
           
            if(this.blocksX(e)){
               canPassX = false;
            }
            if(this.blocksY(e)){
               canPassY = false;
            }
         }
     
   }



and in the move code function

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
 public void move(float xa, float ya, int delta){
   CollisionManager(delta);
      if(canPassX){
         pos.x += xa * delta;
      }
      if(canPassY){
         pos.y += ya * delta;
      }

   }


that mean that you have to modify your function block and split in 2 function
one to verify if block X and another to verify if block Y
so you need also to boolean variables to instead that one
canPassX
canPassY



9  Discussions / Suggestions / Re: Liking on: 2013-09-03 18:52:00
What if we could "like" a post and then sort the posts in the thread by likes? (or maybe call it "Agree" or "Disagree").

and if I like something that you don't like?
10  Java Game APIs & Engines / OpenGL Development / Calculate Texture coordinate in a 3d terrain grid done with GL_TRIANGLE_STRIP on: 2013-07-29 19:47:06


Hi guys
i have create my simple terrain generator that calculate vertex and normal

vertex are all at same distance the only difference consist in the height that is generated random

this is my algorithm

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
   private void drawPlan(Vertex[][] vertex, Vector[][] normals, GL2 gl) {

      for(int z = 0; z < zSubdivision-1; z++) {
         gl.glBegin(GL2.GL_TRIANGLE_STRIP);
         for(int x = 0; x < xSubdivision ; x++) {
            gl.glNormal3f(normals[x][z].x, normals[x][z].y, normals[x][z].z);
            gl.glVertex3f(vertex[x][z].x, vertex[x][z].y, vertex[x][z].z);                
            gl.glNormal3f(normals[x][z+1].x, normals[x][z+1].y, normals[x][z+1].z);
            gl.glVertex3f(vertex[x][z+1].x, vertex[x][z+1].y, vertex[x][z+1].z);                                  
         }
         gl.glEnd();
      }
   }



now i would like to add texture and calculate correctly the coordinate of my texture
is there already a know algorithm that calculate for plan draw with triangles the texture coordinate?

i suppose that the a texture must enter correctly in 8 triangles draw as hire bottom and so repeated for all the group of 8 trinagles
1  
2  
3  
4  
5  
x--x--x
| / | / |
x--x--x
| / | / |
x--x--x  


but because the triangle strip is calculated by a double cycle that consider only z and z+1 for each strip
i have to calculate texture coordinate for first half of image in the first cycle and after second half in the second cycle and repeat
 
is this right any advice ?
there is a better way to do it?
thanks





11  Game Development / Newbie & Debugging Questions / Re: load wavefront obj in jogl on: 2013-07-19 10:41:04
man, thanks for your answer but is not what i'm aspect
i'm able alone to make a simple Google search as all the human bean with fingers internet and keyboard Smiley

I will try to be more specific

1)guys is there someone of you that use same libraries to load and render obj wavefront file

2)related to the libraries that you used, what is the experience that you had using this libraries?
high value functionality?
back side?
limitation?

thanks

12  Game Development / Newbie & Debugging Questions / load wavefront obj in jogl on: 2013-07-17 08:13:20
Hi guys
do you know same good library that can load and render obj wavefront file using jogl?
thanks

13  Java Game APIs & Engines / OpenGL Development / Re: JOGL and glNormal performance on: 2013-03-02 18:46:25
yes with the display list it is always faster that without


but if a test
display list and optimized version, it is less faster that
display list with original version that has more call of glNormal

this is the point that is not clear


14  Java Game APIs & Engines / OpenGL Development / Re: JOGL and glNormal performance on: 2013-03-02 18:37:37
hi theagentd , thanks for the answer but for mistake i post only half of my question so i modified it and in meanwhile you was answering to my half post!!! Smiley
i hope that now you can read and answer reading the complete question
thanks

Using the float version of glNormal (glNormal3f()) should be a bit faster, but you want really good performance you should look into display lists or VBOs. Your data seems to be static, so you should be able to generate your geometry and store it in a display list or VBO, and use glTranslatef() to position your objects when rendering.
15  Java Game APIs & Engines / OpenGL Development / JOGL and glNormal performance on: 2013-03-02 18:04:37
hi guys

i would like to understand more in deep how works jogl so that i can use the correct chose during my implementation.
during one of my exercise i find out a strange behavior that can change the performance of the program that i wrote.

this is the question
look at this code, that i use to draw a surface flat divided in square

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
   private void flatSurface(GL2 gl,int size,int sizeUnit) {

      gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_SPECULAR, new float[]{0.2f, 0.2f, 0.2f, 1f},0);
      gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT, new float[]{0.1f, 0.1f, 0.1f, 1f},0);
      gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_DIFFUSE,new float[]{0.6f, 0.6f, 0.5f, 1f},0 );

      gl.glPushMatrix();
      gl.glTranslated(-size/2, 1, -size/2);

      for (float x = size; x >= 0; x=x-sizeUnit) {
         gl.glBegin(GL2.GL_QUAD_STRIP);
         gl.glNormal3d(0, 1, 0);
         for (float z = size; z >= 0; z=z-sizeUnit) {
            gl.glVertex3f(x, 0,z);
            gl.glVertex3f(x+sizeUnit, 0,z);            
         }
         gl.glEnd();      
      }
      gl.glPopMatrix();
   }


I just read that if the glNormal is called one time instead that repeat for each vertex performance are better.
Becouse there are less call to GL system.
i did the test and in my program the fps are increased

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
//optimized versione
gl.glNormal3d(0, 1, 0);
for (float z = size; z >= 0; z=z-sizeUnit) {
   gl.glVertex3f(x, 0,z);
   gl.glVertex3f(x+sizeUnit, 0,z);            
}

//original version
for (float z = size; z >= 0; z=z-sizeUnit) {
   gl.glVertex3f(x, 0,z);
   gl.glNormal3d(0, 1, 0);
   gl.glVertex3f(x+sizeUnit, 0,z);            
   gl.glNormal3d(0, 1, 0);
}


after that i studied the display list and moved the firs function in a display list to increase more the performance
1  
2  
3  
4  
      superficieList = gl.glGenLists(1);
      gl.glNewList(superficieList, GL2.GL_COMPILE);
      flatSurface(gl,dimensione,dimensioneUnita);  
      gl.glEndList();


so now performance are increased more but with big surprise i noted that:
with the display list i can increase more the performance if in the function that draw the surface i use the old code!!!
1  
2  
3  
4  
5  
6  
7  
//original version
for (float z = size; z >= 0; z=z-sizeUnit) {
   gl.glVertex3f(x, 0,z);
   gl.glNormal3d(0, 1, 0);
   gl.glVertex3f(x+sizeUnit, 0,z);            
   gl.glNormal3d(0, 1, 0);
}


this has not sense for me and my knowledge can not help my to undestand why.
can u help me to understand this beaviour? Huh



16  Java Game APIs & Engines / OpenGL Development / display list with solid sphere in error on: 2013-03-01 13:36:24
hi guys

I'm trying to understand how use the display list and i have create a very easy code just to draw a sphere

this is my code in the init

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
public void init(GLAutoDrawable drawable) {

                ............
                ............

      sp = gl.glGenLists(1);
      gl.glNewList(sp, GL2.GL_COMPILE);
      glut.glutSolidSphere (0.4, 16, 16);
      gl.glEndList();
}



bat during the execution of glut.glutSolidSphere (0.4, 16, 16); i take this exception

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  
Exception in thread "Timer-0" java.lang.RuntimeException: java.lang.NullPointerException
   at jogamp.common.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58)
   at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103)
   at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:206)
   at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172)
   at javax.media.opengl.Threading.invoke(Threading.java:191)
   at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:428)
   at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:74)
   at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:142)
   at com.jogamp.opengl.util.FPSAnimator$1.run(FPSAnimator.java:128)
   at java.util.TimerThread.mainLoop(Timer.java:512)
   at java.util.TimerThread.run(Timer.java:462)
Caused by: java.lang.NullPointerException
   at it.spaghettisource.cap6.exn6p3.init(exn6p3.java:78)
   at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:201)
   at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:222)
   at javax.media.opengl.awt.GLCanvas$6.run(GLCanvas.java:926)
   at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:521)
   at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:462)
   at javax.media.opengl.awt.GLCanvas$9.run(GLCanvas.java:964)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:646)
   at java.awt.EventQueue.access$000(EventQueue.java:84)
   at java.awt.EventQueue$1.run(EventQueue.java:607)
   at java.awt.EventQueue$1.run(EventQueue.java:605)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:616)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


can i use the glut function in the display list?
or i have to activate same flag that i forgot?

thanks

17  Java Game APIs & Engines / OpenGL Development / make a Porting: Java2D to JOGL on: 2013-01-31 17:54:03
hi guys

i have a game implemented completely in Java2D,
i would like now study jogl and make a complete porting,

my game is a side scrolling shooter.
it is mainly based on  direct draw of the images using the primitive of java2D --> Graphics2D.drawImage
The engine is provided of functionality to modify color and transparent and rotation of the images,
finally i have final effect over the final image create drawing directly over it that allow my to make effect like darkness (used for example in the transition between the level etc..), send storm, rain etc....

now studding same tutorial of jogl I undestood that is completely based on a 3D concepts.
So to create a flat 2D word i have to:
A) create a 3D word with the  Z coordinate constant and use the Orthographic Projection
B) to print an image create a rectangle/square and load the image as a texture over it

is there another approach "more 2D" that this one, or this is the correct path that i have to follow to reach my target?
thanks guys


 
18  Game Development / Newbie & Debugging Questions / Re: How do play a midi file? on: 2013-01-20 19:02:43
hi man this is the easy answer to your question, pure java no other libs
hire i'm using the old applet lib, you can run wiht JVM 1.1 until JVM 1.7

mcdonald.mid is an old midi file, susbtitute with your

if u what to use pure java but you need something little more complex, you have to use JSA (java sound api)

JSA this is the official doc
http://docs.oracle.com/javase/tutorial/sound/index.html

this is a complex demo for ORACLE that will show to use the power of JSA
http://www.oracle.com/technetwork/java/index-139508.html


remeber you have to create a separate a thread to run the music in loop

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public class McDonald {

 public static void main(String[] args){
     AudioClip mcdClip =  Applet.newAudioClip( McDonald.class.getClassLoader().getResource("mcdonald.mid") );
     mcdClip.play();        
     // mcdClip.loop(); //if u what loop  
   
     while(true){
        System.out.println("manage music in a separate thread not in the main thread like this");
     }
  }
}


19  Game Development / Game Play & Game Design / Re: Penny-Arcade's Show: Extra Credits on: 2013-01-19 22:36:47
my wife will kill me

look like my story...    Cry
I understand you man...

   
20  Games Center / WIP games, tools & toy projects / Re: Tiger Supply - Java2D space scrolling shoter - my first demo on: 2013-01-11 01:54:34
no any comment... sob....
very sad
21  Games Center / WIP games, tools & toy projects / Tiger Supply - Java2D space scrolling shoter - my first demo on: 2013-01-10 00:50:55
Hi guys

this is my first game, finally!!!! (yet demo version  Clueless )

To create a game was been always one of my dream when i start to make develop.
Actually i do business software professionally since 10 year, so this year i decided to let my (kid) dream become true

this is only my you tube demo
<a href="http://www.youtube.com/v/Wg6lgxjf0jI?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/Wg6lgxjf0jI?version=3&amp;hl=en_US&amp;start=</a>

images and graphic is copy from the www just to take same images and give a shape to it.

it is very basic, i would like to improve it, specially graphically, but unfortunately i'm not a graphic design and my capabilities in this field are very bad
if you want to give any commend bad a good will be appreciated also because this mean that someone is look this video  Cheesy

thanks to all of you, specially to all the answer that i received in this forum that help me to solve problem and find new solutions

another question: how to add image to the topic in the showcases?

22  Java Game APIs & Engines / Java 2D / Re: Experimenting with realtime raytracing in Java2D on: 2013-01-10 00:36:25
for my works

fantastic!!!!

congratulation good job
23  Game Development / Game Play & Game Design / Re: Initial Sprite Location on: 2013-01-09 14:46:43
I work with more tiled map layer

i use different tiled map based on different scope, this give you a flexibility to manage this stuff separate also in the code
instead to have a bundle of code that have to think of all, you ave different pieces for specific scope

1 tile for background
1 tile for solid items
1 tile for enemy
.....
.....
.....
1 tile for final grafica effect


and if you manage all this logic with the pattern chain and the pattern command together,
you can introduce every time more layer with little effort

 

24  Java Game APIs & Engines / Java 2D / Re: Experimenting with realtime raytracing in Java2D on: 2013-01-09 14:38:09
wow, go haead and let us to know how i going!!!!!   Wink
25  Game Development / Game Mechanics / Re: Entity update and render optimization in 2D map on: 2013-01-09 14:34:34
so generic question, impossible help you in this way

are you able to identify the slow part of your application?

divide et impera:
analyze your software
identify part that are slow
verify the possible solution (this can be question to be inserted in the forum)

26  Games Center / Archived Projects / Re: Space Mission: Asteroids!! on: 2013-01-08 20:31:05
desotry the asteroid create more little asteroid some time  Tongue
27  Java Game APIs & Engines / Java 2D / Re: OpenGL VM flag degrade performance on Java2D??? on: 2013-01-08 00:55:20
Next thanks to you
regarding the optimization i want to answer to all your idea just to share our knowledge

firs of all
The chose of the JPanel happen for one specific reason the method JPanel.createImage(pWidth, pHeight)
hire the official link to java doc http://docs.oracle.com/javase/6/docs/api/java/awt/Component.html#createImage(java.awt.image.ImageProducer)
this method must be called each time in the cycle, because it manage automatically for you the double buffering strategy
increasing the performance, so for this reason this object is used by double buffering i can not reuse the same object clearing the immage

never tried to do it by canvas, is there a specific method to do it automatically? the old AWT expose something to do it? if exsist let me know i want to try it


Quote
Ok, then you apply a set of affineTransforms, right?, so you create an intermediate BufferedImage called "filtered" with all the changes. Do you tried directly to draw the image to dbg without creating that "filtered" image?

this part of the code is already optimized, the solution applied is this:
every image transformed in the chain of effect is stored in a repository  keeping with it information of the kind of transformation performed over it, so every time that  on a image is required to execute same effect, first of all I look in the repository if that image with that kind of transformation already exists in this case this image is get and reused, other ways a new image with effect is created and saved in the repository.
this make in my case a huge increasing of the performance and aloud to me to work on image modification on the fly
but the back side of this solution is the memory used to store images in the repository

instead regarding this fact (davedes please don't take it personally, but i have to write this)
Quote
General consensus is: if you need reliable performance, Java2D is the wrong choice
the fact that exist technologies that are better of the Java2D is something that also the kids know,
so if i use this specific section of the forum called Java2D, and not OpenGL Development may be ther is a reason what u think?
http://www.java-gaming.org/boards/java-2d/15/view.html

if i can get 1 euro for all the guys that write in this forum,
Quote
General consensus is: if you need reliable performance, Java2D is the wrong choice
i will become one of the most reach person in the word (ok i will open a topic for this  Grin)
 
regarding the real discussion of this topic,
Quote
Setting flags like that always screams to me
me too!!!

i want to try to set the variable J2D_D3D_NO_HWCHECK=true and try to activate the direct3D. i will let to know how it works

28  Discussions / General Discussions / Re: Java launchers on: 2013-01-07 13:25:22
Also Eclypse allow to you to create an executable multy platform

hire is the link how to use and configure

http://wadeawalker.wordpress.com/2010/10/24/tutorial-creating-native-binary-executables-for-multi-platform-java-apps-with-opengl-and-eclipse-rcp/

29  Java Game APIs & Engines / Java 2D / Re: OpenGL VM flag degrade performance on Java2D??? on: 2013-01-07 11:30:37
the output in the console is almost nothing, so modifying it din't recognize any effect

i'm working on my laptop and the graphics card is integrated on it:
Intel(R) HD Graphics Family

testing this card with the OpenGl Extensions viewer 3.0 i'm able to support with this card operation
openGL 2.2
30  Java Game APIs & Engines / Java 2D / OpenGL VM flag degrade performance on Java2D??? on: 2013-01-07 10:51:20
Quote
And without the "OpenGL" VM flag?

my situation was to have a game implemented without the flag for the OpenGL.
my framework (done in java2D) is completely based on the BufferedImageOp to draw on the fly effect!

how my frameworks works is this just create to any cycle the next immage and then the the drawable:

1  
2  
dbImage = JPanel.createImage(pWidth, pHeight); // create the double buffer immage
dbg = (Graphics2D) dbImage.getGraphics();


after that it is pass to the rendering that are 2D sprite based on the bufferedImmage
internalRenderGame(dbg);

any sprite before to be render on the dbg ( that i s the Graphics2D) is passed to a chain of effect that execute specific effect implemented as BufferedImageOp brightness, and transparence or affine trasfomration for scale and rotation

1  
2  
3  
//filtersToApplyare all the filter ot use: can be any, one of this or all -->brightness, transparence,scale and rotation
BufferedImage filtered = EffectManager.getInstance().chain(filtersToApply,image, position, size, color);
dbg.drawImage(filtered, (int)(position.getPosX() - filtered.getWidth()/2), (int)(position.getPosY() - size.getHeigh()/2), null);



in the end finally draw the final immage with all the sprite and background painted over
1  
2  
g = (Graphics2D) gamePanel.getGraphics();
g.drawImage(doFinalEffect(dbImage), 0, 0,pWidth,pHeight, null);

but before is possible to pass the final image (that is the immage with the background and all the sprites) again to a chain of effect (that is implemented has before as BufferedImageOp  brightness to make obscuration of all the immage)



ALL this story to explane that it is very easy nothing complex, and when i have activated the "OpenGL" VM flag -Dsun.java2d.opengl=True, my application is start to be very slow!!! it become a disaster, lost 30% of the frames!!!!
i would like to understand why, or at list to understand how to analyze
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.

xsi3rr4x (79 views)
2014-04-15 18:08:23

BurntPizza (71 views)
2014-04-15 03:46:01

UprightPath (82 views)
2014-04-14 17:39:50

UprightPath (66 views)
2014-04-14 17:35:47

Porlus (82 views)
2014-04-14 15:48:38

tom_mai78101 (106 views)
2014-04-10 04:04:31

BurntPizza (166 views)
2014-04-08 23:06:04

tom_mai78101 (262 views)
2014-04-05 13:34:39

trollwarrior1 (212 views)
2014-04-04 12:06:45

CJLetsGame (221 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!