Java-Gaming.org
 Featured games (79) games approved by the League of Dukes Games in Showcase (498) games submitted by our members Games in WIP (422) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Show Posts Pages: [1] 2 3 ... 20
1  Game Development / Newbie & Debugging Questions / Re: Proper Way To Handle Gravity? on: 2013-12-06 09:37:48
arg sry, yes you are right I messed up, should have checked what I was writing.

The correct way of doing things with const acceleration is:
 1  2  3 `val oldVel = velocityvelocity += gravityAcc * dTimeposition += (oldVel + velocity) / 2 * dTime`

and found the old blog post I tried to remember the first time
http://lolengine.net/blog/2011/12/14/understanding-motion-in-games
 2 Discussions / General Discussions / Re: Java "Mods" on: 2013-12-04 19:41:32 BTW, I just learned about the Graal project. It's a subproject of OpenJDK and it is an interesting lib to have your own language run on the JVM. You parse your language and build up an AST with the Truffle lib of this project. After that you can run the AST and the Graal compiler which is already included in the latest JRE  will compile it to Java-Bytecode on the fly.Also, they have an example parser for Java so you can probably add your own syntax quite "easy".
3  Game Development / Newbie & Debugging Questions / Re: Proper Way To Handle Gravity? on: 2013-12-04 19:27:47
First of all, why uses something as abstract as "units" anyways if you want to convert to meters.

Now about your code, no it is not correct and yes you can just divide the gravity by 60, because thats is normal.

 1  2  3  4  5  6  7  8  9  10  11 `g = 9.81 m/s^2v (m/s)//you can not add a acceleration to an velocity so ...Vd = A * tdm/s = m/s^2 * sA: in your case gtd: your time deltaVd: is your velocity delta`

Also, the following formula is more correct for a constant acceleration like gravity:
 1  2 `val deltaVel = GRAVITY * timeDeltaentityVelocity = (2 * entityVelocity + deltaVel) / 2`
 4 Game Development / Newbie & Debugging Questions / Re: java.io.File bug in Linux? on: 2013-12-02 09:16:59 I don't know, but on my "linux" your code just works fine.
 5 Game Development / Newbie & Debugging Questions / Re: Theory of 2d per pixel lighting. on: 2013-12-01 12:21:40 You have to create a fbo first, there shouldbe many examples how to do this. Then bind a texture to it, which has the size of the screen or only half of it if you want to optimize. After thatbind the fbo as the render target.Collect all lights and either render them throughh a shader or as texturs (shape of the light cone as a grayscala image) to the fbo. So in the end this texture only holds the color of every light in it.As a last step just blend this texture over your normally rendered scene.
6  Game Development / Newbie & Debugging Questions / Re: Theory of 2d per pixel lighting. on: 2013-11-30 14:06:14
btw, using a framebuffer for lighting is probably better, because you can add more easily new light types(spot-lights, area lights) and scales way better with higher number of lights.

Why do they scale better you ask?
As your code shows, you would have to add more shader attributes/uniforms all the time if you want to support more lights. This would end in things like in the past where one would either have to restrict the number of lights per object or have to render the whole scene multiple times. This method describte by theAgent is a 2D version of deferred rendering and has the same benefits.

But..
coming back to your shader, just calculate the distance of the light per vertex and use the interpolated result in the fragment shader.

 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 `//vertexin vec2 position;uniform vec2 light_pos;out float dist_to_light;void main(){   dist_to_light = length(position- light_pos);//no need for your own computation, if you have a vec4 and vec3(why???) just do length(pos.xy - light.xy)   ...}//fragmentin float dist_to_light;uniform float max_light_distvoid main(){  float intensity = max(0, 1 - dist_to_light / max_light_dist);  float quad_intensity = intensity * intensity;//light has a quadratic falloff  ...}`

also don't use cos/sin in your shader rotate with a uniform 2x2 matrix
 7 Game Development / Performance Tuning / Re: Loading a large map in server on: 2013-11-27 16:31:22 Then pls show us some code. What are your data-structures and how do you load the map, because when we say you just need one id + type per tile you should only need around 200mb
 8 Game Development / Newbie & Debugging Questions / Re: [LWJGL] Multiple textures on a VBO on: 2013-11-27 11:31:41 @opiop65 don't mix up vertex arrays and vertex array objects they are totally different things. VAOs are OpenGL objects like(texture, buffer ...) which safe the state of the used VBO. They are a OpenGL 3 feature, read it up if you like.
 9 Game Development / Newbie & Debugging Questions / Re: [LWJGL] Multiple textures on a VBO on: 2013-11-26 21:20:18 just split up the model.
 10 Game Development / Performance Tuning / Re: Loading a large map in server on: 2013-11-26 20:49:07 I don't know how big this map is, but most of the time the final data-structure isn't the problem. It may be that your parser creates too many temporary object which let the JVM explode.Anyway, did you try to just extend the Java heap size?(add -Xmx1024m as a start parameter to Java to set the heap to 1GB)
 11 Game Development / Performance Tuning / Re: Loading a large map in server on: 2013-11-26 18:12:51 In my opinion you did something horrible wrong, because I can't imagine a game world which would consume too much memory on the server (did you try to extend the Java heap?)
 12 Game Development / Newbie & Debugging Questions / Re: My Game have creative commons Resources ( images/audio) ,Can i still sell it? on: 2013-11-26 00:49:57 CodeHead, nobody is talking about open-source, this discussion is about copyright. Nobody cares about the source-code of the game, it is all about the end product(the compiled game).Quote from: CodeHead on 2013-11-25 23:49:31It's like saying a movie that had a coke can in the background of a b-roll scene was derivative of Coca~Cola.Yes this is actually the case and on top of that you would probably also infringe on some brand laws. There are of course always some copyright barriers like fair-use, but this doesn't change anything of the fact that it is an infringement in the first place.And yes you can call this crazy and unthinkable, but this is the world of copyright we are living in.
 13 Game Development / Newbie & Debugging Questions / Re: My Game have creative commons Resources ( images/audio) ,Can i still sell it? on: 2013-11-25 23:33:01 I don't think I can add anything to what I or nsigma already said without repeating myself. So to conclude:A game is a copyrightable work, so it is a derivative work of all other works it uses. The law doesn't care how you implement this(loading from a different folder whatever).
 14 Discussions / General Discussions / Re: Picking Techniques on: 2013-11-25 10:31:29 The thing is ray casting gets trivial when you include collision detection into your game, something probably every game has. Most of the time your physics-engine will handle this for you.
 15 Game Development / Newbie & Debugging Questions / Re: Back half of cube is being clipped (using geometry shader). on: 2013-11-25 01:43:29 use vec3 for the position and just a mat3 for the roation matrix. I guess your problem is that the w component of the corners is 0
 17 Game Development / Newbie & Debugging Questions / Re: My Game have creative commons Resources ( images/audio) ,Can i still sell it? on: 2013-11-24 10:03:16 first of all:I think it would be the easiest thing for you to just write all the authors and ask if they would license the work as CC-BY to you and if they don't want to agree try to negotiate something like you get x% and max y money after I sell it.@CodeHead &  jmguillemetteI'm pretty sure that this is not true. The thing is:Your compiled code is a copyrightable work.The Assets are worksThe game as a hole is a work (assets + work).It is the same as if you take 10 pics and photoshop them together, the result is your work, but all the copyright of the author of the 10 original works remain. You might say that you only copy the original work and don't change it, but you are integrating it into another work. It doesn't matter for the law how the end result comes to be (video displayed). And to back up my claim I looked up a court case in germany(remember that always the law of the country of the author counts) which states that the sole transformation of a work to another media type constitutes as a derivative work.only in GER
 19 Game Development / Newbie & Debugging Questions / Re: My Game have creative commons Resources ( images/audio) ,Can i still sell it? on: 2013-11-23 20:47:06 It seems that you only want to take and not give, so your only options are public domain and licenses which allow you to do anything like CC without SA.
 20 Game Development / Newbie & Debugging Questions / Re: My Game have creative commons Resources ( images/audio) ,Can i still sell it? on: 2013-11-23 15:55:01 Yes you have to share your game under the same license. This means that you can of course still sell your game, but everybody else can do the same.You could perhaps write the author and ask if they give you permission to use their work under another license or agreement.
21  Game Development / Performance Tuning / Re: what is faster? on: 2013-11-22 01:35:17
here did some fixes/changes:
 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  119  120  121  122  123  124  125  126  127  128  129  130  131  132  133  134  135  136  137  138  139  140  141  142  143  144  145  146  147  148  149  150  151  152  153  154  155  156  157  158  159  160  161  162  163  164  165  166  167  168  169  170  171  172  173  174  175  176  177  178  179  180  181  182  183  184  185  186  187  188  189  190  191  192  193  194  195  196  197  198 `public class Physics extends ROGameObject{    public Random r = new Random();              @Override    public void update()    {            }    //check if two objcts collide    public boolean checkCollisions(ROGameObject go1, ROGameObject go2)    {        Rectangle r1 = new Rectangle((int)go1.getx(),(int)go1.gety(),(int)go1.getxsize(),(int)go1.getysize());        Rectangle r2 = new Rectangle((int)go2.getx(),(int)go2.gety(),(int)go2.getxsize(),(int)go2.getysize());                return r1.intersects(r2);    }      +    //use Math.abs(...)   -    public int removenegative(int value)-    {-        if (value < 0)-        {-            return (value*-1);-        }-        return value;             -    }                //function checks if a value is between minimum and maximum value    public float floatbetweenfunction(float minvalue, float midvalue, float maxvalue)    {       -        if (minvalue < midvalue && midvalue < maxvalue)-        {-            return (midvalue);-        }        if (midvalue <= minvalue )                   {                return (minvalue);        }+        else if (midvalue >= maxvalue )                   {                return (maxvalue);        }+   else             return (midvalue);+   //but why not use Math.max(Math.min(maxvalue, midvalue), minvalue);    }    +    //no need see above-    public int intbetweenfunction(int minvalue, int midvalue, int maxvalue)-    {       -        ...-    }            //returns a random number between minvalue and maxvalue    public int RandomInt(int minvalue, int maxvalue)    {                  return (minvalue + (int)(Math.random() * ((maxvalue - minvalue) + 1)));       }    +   //never use for Strings for math, pls...    public String Randombit()    {        ...    }   +    //same as aboth    public char flipbit(char bit)    {   ...    }    +   //why?    public String flipbitstring(String newstring)    {     ...    }    +    //Math.max(...)    public int MaxInt(int value1, int value2)    {         }            public static double PytagorasInt(int value1, int value2)    {    +   //no need to convert to double, I would say counter productive. If you should convert to long        double nvalue1 = (double)value1;        double nvalue2 = (double)value2;                double int1 = (nvalue1*nvalue1) + (nvalue2*nvalue2);                return Math.sqrt(int1);       }            public char inttoletter(int newint)    {    +   if(newint < 0 && newint > 33)+      return 'A';+   else if(newint < 26)+      return (char)(newint + 'A');+   else+      return (char)(newint - 26 + 'a');            }    public float lettertofloat(char letter)    {+   return lettertoint(letter) / 33f;                   }            //number between -1 and 1    public float lettertofloat2(char letter,float tresholdfactor)    {+   return tresholdfactor * (-1 + lettertofloat(letter));                  }                public int lettertoint(char letter)    {+   if(letter >= 'A' && letter <= 'Z')+      return letter - 'A';+   else if(letter >= 'a' && letter <= 'h')+      return letter - 'h';+   else+      return 0;                  }                public char letterup(char letter)    {+   if((letter >= 'A' && letter < 'Z') || (letter >= 'a' && letter < 'h'))+      return letter + 1;+   else if(letter == 'Z')+      return 'a';+   else if(letter == 'h')+      return 'h';+   else+      return letter;                      }        public char letterdown(char letter)    {+   if((letter > 'A' && letter <= 'Z') || (letter > 'a' && letter <= 'h'))+      return letter - 1;+   else if(letter == 'a')+      return 'Z';+   else if(letter == 'A')+      return 'A';+   else+      return letter;       }         public char letterrandom(char letter)    {+   if((letter >= 'A' && letter <= 'Z') || (letter >= 'a' && letter <= 'h')){+           return inttoletter(RandomInt(0, 33));+   }            return(letter);    }            public char letterinvert(char letter)    {+   if((letter >= 'A' && letter <= 'Z') || (letter >= 'a' && letter <= 'h')){+           return inttoletter( 33 - lettertoint(letter) );+   }            return(letter);                   }            public String inverseletter(String prestring,int lettertoinverse)    {+        String first = prestring.substring(0, lettertoinverse - 1);+        String last = prestring.substring(lettertoinverse + 1, prestring.length());+        return first + letterinvert(prestring.charAt(lettertoinverse)) + last;    }                  public String insertsubstring(String originalstring,String insertstring,int indexstart,int indexend)    {        String substring1 = originalstring.subString(0, indexstart);        String substring3= originalstring.subString(indexenx, originalstring.length());        -        for(int j = 0; j<(insertstringlength) ;j++)// wtf-        {        -            substring2 += insertstring.charAt(j);-        }                             +        return substring1 + insertstring2 + substring3;    }        public String removesubstring(String originalstring,String insertstring,int indexstart,int indexend)    {        //also with substring    }    }`
 22 Game Development / Performance Tuning / Re: what is faster? on: 2013-11-22 00:58:53 Also...your methods tell me that you are quite new to programming and Java. You duplicate a lot of code which is either present already in the standard library or doing stuff which is extremely unperformant or code size.
 23 Discussions / General Discussions / Re: Developing on mobile phones and tablets on: 2013-11-20 10:26:46 just saying, there is a 65'' Android tablet out there
 24 Game Development / Newbie & Debugging Questions / Re: Inconsistent IndexOutOfBounds Exceptions on: 2013-11-16 01:58:00 also the code is wrong, because everytime you delete a projectile you skip the next
 25 Discussions / General Discussions / Re: Java's built in Scripting engine on: 2013-11-15 21:28:04 what about recursion, is that included(not only tailrec)?
 26 Discussions / General Discussions / Re: Java's built in Scripting engine on: 2013-11-15 20:36:13 Am I the only one thinking about the halting problem here? Or does it not apply, because we don't want to prove anything and only set restrictions?
27  Java Game APIs & Engines / OpenGL Development / Re: LWJGL openGL - set new position of vertex array on: 2013-11-14 23:49:42
write a factory method which generates a mesh from a Cube?
 1  2  3  4  5 `class Mesh{  static Mesh from(Cube c);  static Mesh from(Sphere s, float tesselation);  ...}`
 28 Discussions / General Discussions / Re: AMD has revealed an API that gives developers direct access to GPUs using ... on: 2013-11-14 23:46:24 Do you know how one programs the GPU with Mantel, GLSL or something new?What is with all the low level rasterization stuff(stencil, depth, blending ...) just a copy from OpenGL or something new?
 29 Java Game APIs & Engines / OpenGL Development / Re: LWJGL openGL - set new position of vertex array on: 2013-11-14 19:08:59 You do not use your render data for collision detection. You have two data sets one for rendering and one for collision. In most cases the data you need for collision is much simpler. i.e. let's say that you use 1000 triangles to render a sphere, but to calculate the collision you just need the center position and the radius.In more complex games you have a simplified collision mesh. Say you have a nice detailed 3D character with some thousand triangles, you collision mesh would just be a collection of some basic shapes. The head would be a sphere the arms and legs a some boxes and so on.You can even use different collision meshes for different tasks. For example ego-shooters use a simple box to check the collision of a player with the world and a more detailed one (aka hit-boxes) to detect hits.
30  Game Development / Newbie & Debugging Questions / Re: Removing An Event Broadcaster From Within A Listener on: 2013-11-13 13:46:28
you can make the removal safe by iterating backwards with an index over the listener collection. So instead of:
 1  2 `for(Animation a: animations){ a.process(); }`

do:
 1  2  3  4 `for(int i=a.length - 1; i >= 0; i--){  animations.get(i).process();}`

 Pages: [1] 2 3 ... 20
 Add your game by posting it in the WIP section, or publish it in Showcase. The first screenshot will be displayed as a thumbnail.
 Phased (20 views) 2013-12-07 10:06:59 wessles (50 views) 2013-11-28 23:37:31 wreed12345 (59 views) 2013-11-23 17:42:34 Damocles (105 views) 2013-11-15 12:23:59 StumpyStrust (83 views) 2013-11-14 14:42:32 StumpyStrust (78 views) 2013-11-14 14:41:43 EliwoodL (90 views) 2013-11-11 10:52:42 EliwoodL (85 views) 2013-11-11 10:52:33 EliwoodL (85 views) 2013-11-11 10:51:49 Samdy (105 views) 2013-11-07 10:06:49
 opiop65 24x wessles 15x Spasi 15x CodeHead 12x Groboclown 12x theagentd 12x HeroesGraveDev 11x SHC 11x Roquen 10x Nate 9x Riven 8x ctomni231 8x doppler 7x saucymeatman 7x Danny02 6x Luffaren 6x
 HotSpot Intrinsicsby Roquen2013-11-25 17:44:34How do I start Java Game Development?by Nate2013-11-18 18:35:15Concurrencyby Roquen2013-11-08 22:39:59Concurrencyby Roquen2013-11-08 20:43:31Concurrencyby Roquen2013-11-08 15:31:17Concurrencyby Roquen2013-11-08 15:20:42Concurrencyby Roquen2013-11-08 15:00:50Resources for learning software design.2013-10-17 16:25:24