Java-Gaming.org Hi !
 Featured games (91) games approved by the League of Dukes Games in Showcase (757) Games in Android Showcase (229) games submitted by our members Games in WIP (844) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Show Posts Pages: [1] 2 3
 1 Games Center / Showcase / Re: Cold Contract - Procedurally generated game on: 2014-08-21 21:48:34 let me know if you have buyersI'm curious   anyway good work
 2 Game Development / Game Mechanics / Re: place or move solid on grids (heighmap) on: 2014-08-21 20:36:47 hallo basil_thanks for your help, but unfortunally it is not my problem  sorry if my english is not enough good and I have let you lost time try to find an alghortim i know how to calculate the height of the grid in one point moreover in the my grid structure I mantain also the normal of each vertex so i can obtain easily it and computate the slope pitch and yawmy problem is another, i will try to explane at the better that i canmy grid is based on trianglesi would like to place vehicles like a car and move it on the grid, the car is something that can be considered schematically as a boxa car has 4 wheels, I know exactly the coordinate of this 4 point (i can computate normal, heigth.. etcc in this point becouse i have all the info)and this are the 4 points that can enter in contact with the gridso I would like to find a way to calculate  the rotation that i have to apply to the center of gravity of the carif we considered the grid based on the x,y axis i need only to calculate the rotation by the x and y axis becouse they are the rotatio that place the wheels in contact with the grid becouse the z is used only to positionate the car in the direction of the movement  so my problem is to find a good idea to calculate the x and y angles considering that i have 4 point,i know also that 4 point of the wheels are not enought, immagine this scenario:-that the car is moving on a little hill (a sort of spike)-the 4 wheels are located in a point lower down that the the peak of the hillso the result is that when i will render the car, the wheels are correctly on the grid but may be part of the terrain (the grid)will be draw inside the carso if someone can suggest a better algorhitm, for example another idea could be to conside the 5 points,  adding the center of gravity of the car traslated at the level of the wheels as another point that has to be evaluated to computate the x and y angles rotationsor I can consider the 4 point of the wheel of the car, as two triangles (wheel ABC and wheel BCD), and use algorithms for intersections of the triangles to identify the intersections points, and based on the intersections point computate the x and y angles rotationsi never do something like this so i would like to know what is the best approach to achieve this kind of problems
 3 Game Development / Game Mechanics / place or move solid on grids (heighmap) on: 2014-08-19 09:27:00 hallo guysi have a highmap grid used to create a terrainnow i would like to move same solid over it, i mean following the irregularities of the terrainbefore to start the implementation i would like to see what are the possible implementationsmy understanding is that the relation in terms of size between the solid (the car) and the size of the tile in the grid is very importantto have a more realistic effect is better that the tiles of the grid are more little that the size of the solidto get the height of the map in a point i can add to terrain object a functionint height = terrain.getHeigth(Vector point)this function try to find the height of the closest vertex on the gridmy idea was to get the point of the 4 wheel of the car, identify the height of each single pointand find a way to calulate the 2 angles rotation by z and x  (if the grid is on x z plan)now this is the real question!, the algorithm to calculate the rotation aglesstill I don't know what is the algotihym that i have to apply to generate the two anglesmy idea was to computate angles in this way:angel rotation by z) angle between the front wheels and angle back wheels and get the max or the average angel rotation by x) angle between the left wheels and angle right wheels and get the max or the averagei can also verify if the angle is not over a limit and accept the movement, to avoid to have car that are able to go over the wallsi see different problem in this implementation, I mean in the resultimmagine that i'm calculating the z angle and the terrain for the point of view of the front wheel as a slope in the opposit direction of the back wheel same problme appear calculating the x angle if the slope of the right side is opposit of the left sideso i suppose that i'm using a worng alghoritm to computate the two rotation angles or may be i can not calculate the correct position with only 4 point but i nedd a 5th point that is the center of the solid
4  Game Development / Game Mechanics / Re: GRID with glInterleavedArrays and GL_TRIANGLE_STRIP on: 2014-08-07 23:29:50
no i'm not using the glDisplayList, i'm just calling the primitive for now during the display(GLAutoDrawable drawable)  phase

anyway, I finished just 5 minutes ago the implementation with the  the glDrawElements
actually i have the indexes in in arrays in indexdata[] becouse i'm using the GL_TRIANGLE_STRIP

the result is incredible for my
i have incremented the frame rate of the 600%

 1  2  3  4  5 `      gl.glInterleavedArrays(GL_T2F_N3F_V3F, 0, modeldata);            for (int i = 0; i <  indexdata.length-1; i++) {               gl.glDrawElements(GL2.GL_TRIANGLE_STRIP, vertex.length*2, GL.GL_UNSIGNED_INT, indexdata[i]);      }`

This are the results of my test
with a grid of 634 x 355 = 225070 vertexs

1 version) using fixed pipeline functions GL_TRIANGLES i get 16 fps
2 version) using glDrawArrays  GL.GL_TRIANGLES  i get 10 fps
3 version) using fixed pipeline functions GL_TRIANGLE_STRIP i get 22 fps
4 version) using several glDrawElements  GL.GL_TRIANGLE_STRIP  i get 120 fps!!!!

my final modification now will by to change the glDrawElements   with the glMultyDrawElements
at this point i will make also a test with the glDisplayList

5  Game Development / Game Mechanics / Re: GRID with glInterleavedArrays and GL_TRIANGLE_STRIP on: 2014-08-07 20:10:17
ok guys thanks for the trick

first of all i create the alghortim for the triangle strip, I post it in case someone will found in future the same issue

what can i say that now that i running the highmap with the triangle strip it is faster that before
it increase the frames of 15-20 % for second

now i will try also with the glDrawArrays

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16 `      for(int y = 0; y < vertex[0].length-1; y++) {               gl.glBegin(GL2.GL_TRIANGLE_STRIP);         for (int x = 0; x < vertex.length-1; x++) {            gl.glTexCoord2f((x)/(float)(vertex.length-1), (y+1)/(float)(vertex[0].length-1));            gl.glNormal3d(normal[x][y+1].getX(), normal[x][y+1].getY(), normal[x][y+1].getZ());            gl.glVertex3d(vertex[x][y+1].getX(), vertex[x][y+1].getY(), vertex[x][y+1].getZ());            gl.glTexCoord2f((x)/(float)(vertex.length-1), (y)/(float)(vertex[0].length-1));                           gl.glNormal3d(normal[x][y].getX(), normal[x][y].getY(), normal[x][y].getZ());            gl.glVertex3d(vertex[x][y].getX(), vertex[x][y].getY(), vertex[x][y].getZ());                     }         gl.glEnd();      }`
6  Game Development / Game Mechanics / GRID with glInterleavedArrays and GL_TRIANGLE_STRIP on: 2014-08-06 22:14:31
Hallo guys

i have an highmap terrain generator and i would like to increase its preformance

my enigne in the beginning populate 3 bi-dimensional arrays

texture (x,y)
norma (x,y)
vertex (x,y)

inquerying the array by x and y i can get all the information of the vertex in the grid, becouse x and y is also the position of the vertex in the grid

in the beginnig i was using the GL_TRIANGLES to draw the grid and this is my algorithm

 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 `gl.glBegin(GL2.GL_TRIANGLES);      for (int x = 0; x < vertex.length-1; x++) {         for (int y = 0; y < vertex[0].length-1; y++) {            //triangle down            gl.glTexCoord2f(x/(float)(vertex.length-1), y/(float)(vertex[0].length-1));            gl.glNormal3d(normal[x][y].getX(),normal[x][y].getY(),normal[x][y].getZ());            gl.glVertex3d(vertex[x][y].getX(),vertex[x][y].getY(),vertex[x][y].getZ());            gl.glTexCoord2f((x+1)/(float)(vertex.length-1), y/(float)(vertex[0].length-1));            gl.glNormal3d(normal[x+1][y].getX(),normal[x+1][y].getY(),normal[x+1][y].getZ());                        gl.glVertex3d(vertex[x+1][y].getX(),vertex[x+1][y].getY(),vertex[x+1][y].getZ());            gl.glTexCoord2f((x+1)/(float)(vertex.length-1), (y+1)/(float)(vertex[0].length-1));            gl.glNormal3d(normal[x+1][y+1].getX(),normal[x+1][y+1].getY(),normal[x+1][y+1].getZ());                        gl.glVertex3d(vertex[x+1][y+1].getX(),vertex[x+1][y+1].getY(),vertex[x+1][y+1].getZ());            //triangle up            gl.glTexCoord2f(x/(float)(vertex.length-1), y/(float)(vertex[0].length-1));                        gl.glNormal3d(normal[x][y].getX(),normal[x][y].getY(),normal[x][y].getZ());                        gl.glVertex3d(vertex[x][y].getX(),vertex[x][y].getY(),vertex[x][y].getZ());            gl.glTexCoord2f((x+1)/(float)(vertex.length-1), (y+1)/(float)(vertex[0].length-1));            gl.glNormal3d(normal[x+1][y+1].getX(),normal[x+1][y+1].getY(),normal[x+1][y+1].getZ());                        gl.glVertex3d(vertex[x+1][y+1].getX(),vertex[x+1][y+1].getY(),vertex[x+1][y+1].getZ());            gl.glTexCoord2f(x/(float)(vertex.length-1), (y+1)/(float)(vertex[0].length-1));               gl.glNormal3d(normal[x][y+1].getX(),normal[x][y+1].getY(),normal[x][y+1].getZ());                        gl.glVertex3d(vertex[x][y+1].getX(),vertex[x][y+1].getY(),vertex[x][y+1].getZ());         }      }      gl.glEnd();`

so to increase the performance i move all the data in a FloatBuffer but still i using the same algorithm to popoluate it
so means that i populate the FloatBuffer  with GL_TRIANGLES

 1  2 `      gl.glInterleavedArrays(GL_T2F_N3F_V3F, 0, modeldata);      gl.glDrawArrays(GL.GL_TRIANGLES, 0, modeldataElements);`

the floatBuffer generate is very big, its size is

 1  2 `int length = maxX*maxY;   //total vertexmodeldata = FloatBuffer.allocate(length*(6*(2 texture cordinate)+6*(3 normal cordinate)+6*(3 vertex cordinate)));`

for a grid of 100 x 100 i have = 100 x 100 x 48 = 480.000  elements
actually in my games im using grid of 100 x 800 = 3.840.000 elements

the result in terms of performance is not increased,
and with my big surprise for big grid the fixed pipiline call are faster that the use of the  glDrawArrays

so now I would like to use the GL_TRIANGLE_STRIP, because in this way i can reduce the size of the FloatBuffer and may be in this way i can increase the performace

that mean that i have to find a different algorithm to populate the FloatBuffer

is there someone of u that populate a grid with GL_TRIANGLE_STRIP and the data stored in 3 arrray like this one?
texture (x,y)
norma (x,y)
vertex (x,y)

7  Game Development / Newbie & Debugging Questions / Re: StateMachine, Java Generics issue on: 2014-07-29 15:48:46
If i understand exactly what u mean

you completely reverting the relationship between the state and the state machine
this is way it can not work

you want generalize the concept of State ad specialize it for T object that has to maintain 3 internal state!!!
previous, actual, next
it is a relation that has not sense in Object Oriented Programming

may be this is the implementation that you was looking for?

this is the interface Manageable that is implemented by objects that have a state

 1  2  3  4  5  6  7 `public interface Manageable{      State getDefaultState();      State getCurrentState();      State getPreviousState();   }`

this the interface of your state machine
 1  2  3  4  5  6  7  8  9  10  11  12 `public interface StateMachine {          void enter(T object);          void execute(T object);          void exit(T object);   }`

now you can manage a specify State Machine for each kind of object

 1 `public interface StateMachine `

and StateMachine can access to all the 3 state variables for the manage object

State getDefaultState();
State getCurrentState();
State getPreviousState();

obviously Player has to implement the interface Manageable

now your internal method of the state machine can become

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23 `public void changeState(T managed) {      /* If the StateMachine is locked, can't change State */      if (isLocked)         return;      /*       * If the newState is the same as the currentState, no point in       * continuing       */      if (managed.getNewState == managed.getCurrentState)         return;      /* Set the previous state to the current state */      managed.setPreviousState = managed.setCurrentState;      /* If the current state is not null, we call its exit method */      if (managed.getCurrentState != null)         exit(managed);      /* Set the current state to the new state */      managed.SetCurrentState = managed.getNewState;      /* If the current state is not null, enter it */      if (managed.getCurrentState != null)               enter(managed);   }`

i have also a final advice

move the 3 methods:  enter execute exit
in the interface Manageable

so each specific implementation (like player) know what to do when its state chagne

and mantain in the stateMachine interface only the method changeState
remove the generics for the state machine and define the method
public void changeState(T managed)
as
public void changeState(Managed managed)

put a list of Managed in the state machine
in this way you will have only one state machine that is able to manage all the kind of objects

still the state machine can call the 3 method becouse it is managin object of type Manageable
so inside the method changeState can call
managed.exit()
managed.enter()
managed.executed()

 8 Game Development / Networking & Multiplayer / Re: Moving from a String based approach? on: 2014-07-29 15:27:57 if your implementation is a serve centricwhere each client will keep a connection whit the server, you can chose a standard interchange protocolfor example you can use CORBA or SOAPthis protocols keep you far for the real technical issues connection, serialization, deserialziationwhat you have to do in your code is just create the data that will be transferthere are several implementation for both the protocols in JAVA or C#, and in case you can integate easily also whit other languages if u need in future
 9 Games Center / WIP games, tools & toy projects / Re: MoreSpaceInvaders on: 2014-07-29 15:15:58 yes the atmosphere generated was niceso it is just a circle of withe triangles and another circle of interpolated triangle from white to blackvery simple and the result is very nice! instead how did you obtain the effect of the shields around the enemies?
 10 Games Center / WIP games, tools & toy projects / Re: MoreSpaceInvaders on: 2014-07-28 18:42:37 Drenius the game si very nicea Technical questionhow do you draw the planet so bright?is it a circle with a white circle texture and  the blend active or samething else?
 11 Game Development / Shared Code / Re: XML Reader Classes on: 2014-07-27 23:44:22 JAXP (SAX and DOM) is a very old model for parser the J2EE official parser now is JAXB and it is moved to JDK since version 1.6no more need to write any rows of code to parse an XMLJAXB create beans that have a relation with the xml and load automaticaly the xml populating for you the beanor can automatically serialize the bean in xml in case you need to save datawhat you need is just an xsd that describre the xml, that is allso you can also use a run time to save information in caseand it is standard Javareference oracle documentationhttp://www.oracle.com/technetwork/articles/javase/index-140168.html
 12 Game Development / Game Mechanics / bright sphere bullet: for space ship shooter on: 2014-07-26 16:59:41 Hallo guysI'm try to understand what is the best way to fit a nice effect on the bullet of my gamethe game is a 3D ship shooter i would like that the basic bullets are a sort of bright sphere, with the center white  and going far from the center it become blue I mean with a sort of tail that lost the color from white to blueIn the beginning I was thinking to create a flat square that with the billboarding was alway in the direction of the cameraand add to it a texture wiht the shape of a sphere I have also created a simple particle engine to create more square one over the other that was moving from the center in the original direction of the bulletso using then GL_BLEND function the sum of the color was white in the center and in the same time i was thinking that apply also this particles a sort of tail effect was created I created it and the result was no so amazing has i was thinking,do u have any other idea to implement this kind of effect?also what is the best shape that as to be drow in the texture to create this effect
13  Game Development / Newbie & Debugging Questions / Re: Advanced BufferedImage manipulation in pure Java on: 2013-12-17 14: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 effectBrightenEffect 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);   }      }`

 14 Java Game APIs & Engines / Java Sound & OpenAL / Re: Exporting Jar with OpenAL on: 2013-12-17 14:06:35 Quote from: opiop65 on 2013-12-16 21:26:39I 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?Quote from: opiop65 on 2013-12-16 21:26:39Another 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 stoppedmay 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)
 15 Java Game APIs & Engines / Java Sound & OpenAL / Re: Exporting Jar with OpenAL on: 2013-12-16 17:36:34 Class loader issue my frienddont' blame on OpneAL all the issue is related to this line of codeGameSound.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 + pathit works in eclipse because it load all the resources of the project in the same classpathand 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 worksthis is an examplejava -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 jari 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 Classthis 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");
 16 Game Development / Game Play & Game Design / Re: scroll through a 3D world on: 2013-12-15 17:34:18 Quote from: lcass on 2013-12-15 17:14:35A 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 computationi'm looking for a smart pattern, already know and implemented
 17 Game Development / Game Play & Game Design / scroll through a 3D world on: 2013-12-15 15:05:49 Hallo guysi have to decide what is the best way to render my 3D world gamethis is my situation and my related questionSITUATIONI'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 finishWORD REPRESENTATIONnow 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 coordinateenemy 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 loop2) 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 draws3) other solution?for example in a games of fly simulation what is the algorithmic /strategy that the developer use usually?thanks
 18 Discussions / General Discussions / Re: How long were you programming with Java before you made your first game? on: 2013-09-04 17:01:58 mainly this depend from you and not from the programming languagei mean is more easy learn a new language for people that already know at good level a languagemore complex if you are learning for the first time a programming languageanywaybasically 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 areasThis are just 2 stupid examples, it is not a comparation between the java and Cand they are true until you write application like, calculator or hello word or something like thisbut when you start to use really a language doesn't exist easy programming language
 19 Game Development / Newbie & Debugging Questions / Re: Entity collision on: 2013-09-04 16:39:08 you can continue to work also with this logicalso the intersection function is ok that mean that this two rectangles intersect in same pointand you are shore 100% the problem is after: understand where, in what side, they intersect so that you can decide where you can movethe chance can be fourA over B    ___   |     |   | A  |   |___|   |     |   | B  |   |___|this case is when min Y A < max Y Bcome move X = truecome move Y = falseA under B    ___   |     |   | B  |   |___|   |     |   | A  |   |___|this case is when max Y A > max Y Bcome move X = truecome move Y = falseA before B    _______   |     |     |   | A  |  B |   |___|__ |   this case is when max X A > min X Bcome move X = falsecome move Y = trueA after B    _______   |     |     |   | B  |  A |   |___|__ |   this case is when min X A < max X Bcome move X = falsecome move Y = truenow the 2 case A over B  A under B are checked inside the new function blockYthe 2 case A before B  A after B are checked inside the new function blockXi hope is cleare also my hash art
20  Game Development / Newbie & Debugging Questions / Re: Entity collision on: 2013-09-04 16: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 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

 21 Discussions / Suggestions / Re: Liking on: 2013-09-03 16:52:00 Quote from: ClickerMonkey on 2013-09-03 16:38:47What 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?
22  Java Game APIs & Engines / OpenGL Development / Calculate Texture coordinate in a 3d terrain grid done with GL_TRIANGLE_STRIP on: 2013-07-29 17: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

 23 Game Development / Newbie & Debugging Questions / Re: load wavefront obj in jogl on: 2013-07-19 08:41:04 man, thanks for your answer but is not what i'm aspecti'm able alone to make a simple Google search as all the human bean with fingers internet and keyboard I will try to be more specific1)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
 24 Game Development / Newbie & Debugging Questions / load wavefront obj in jogl on: 2013-07-17 06:13:20 Hi guysdo you know same good library that can load and render obj wavefront file using jogl?thanks
 25 Java Game APIs & Engines / OpenGL Development / Re: JOGL and glNormal performance on: 2013-03-02 17:46:25 yes with the display list it is always faster that withoutbut if a test display list and optimized version, it is less faster thatdisplay list with original version that has more call of glNormalthis is the point that is not clear
 26 Java Game APIs & Engines / OpenGL Development / Re: JOGL and glNormal performance on: 2013-03-02 17: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!!! i hope that now you can read and answer reading the complete questionthanks Quote from: theagentd on 2013-03-02 17:29:30Using 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.
27  Java Game APIs & Engines / OpenGL Development / JOGL and glNormal performance on: 2013-03-02 17: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 versionegl.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 versionfor (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 versionfor (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?

28  Java Game APIs & Engines / OpenGL Development / display list with solid sphere in error on: 2013-03-01 12: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

 29 Java Game APIs & Engines / OpenGL Development / make a Porting: Java2D to JOGL on: 2013-01-31 16:54:03 hi guysi 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.drawImageThe 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 ProjectionB) to print an image create a rectangle/square and load the image as a texture over itis 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
30  Game Development / Newbie & Debugging Questions / Re: How do play a midi file? on: 2013-01-20 18: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");     }  }}`

 Pages: [1] 2 3
 EgonOlsen (45 views) 2018-06-10 19:43:48 EgonOlsen (27 views) 2018-06-10 19:43:44 EgonOlsen (47 views) 2018-06-10 19:43:20 DesertCoockie (210 views) 2018-05-13 18:23:11 nelsongames (127 views) 2018-04-24 18:15:36 nelsongames (126 views) 2018-04-24 18:14:32 ivj94 (867 views) 2018-03-24 14:47:39 ivj94 (128 views) 2018-03-24 14:46:31 ivj94 (779 views) 2018-03-24 14:43:53 Solater (143 views) 2018-03-17 05:04:08
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 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