Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (690)
Games in Android Showcase (200)
games submitted by our members
Games in WIP (764)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 ... 6 7 [8] 9 10
 71 
 on: 2016-09-23 04:55:58 
Started by orange451 - Last post by orange451
Today's update:
  • All player movement variables (from the console) are checked on the server-side as well. So, you can not use reflection to change them.
  • A server with "g_cheats" set to 1 will allow any player variable to be changed
  • Fixed memory leak between map loading.
  • Fixed issues with lag compensation
  • Created "autoexec" file. If there is a file called autoexec.cfg in the games directory, when the game starts it will read this file and put each line into the console. This is useful for having specific console commands run on startup (will work for server too)
  • Added a little more detail to the Mainstreet map
  • Fixed an issue with the server teleporting players (spawning). This also fixes an incorrect "rubberbanding" when you lag.
  • Added texture size setting to options menu
  • Fixed a display issue with the scoreboard
  • Fixed JVM crash

The server-sided variable check does not prevent against hacking. It only prevents users from changing some specific player movement variables via reflection ( gravity, acceleration, friction, run speed, noclip, third person, ect )

 72 
 on: 2016-09-23 02:01:41 
Started by BurntPizza - Last post by ra4king
I prefer my
unsigned long long triple double short char
572 bytes only thankyouverymuch.

 73 
 on: 2016-09-23 00:15:41 
Started by BurntPizza - Last post by theagentd
me vs. unsigned long long int - 1:0

\o/

Did you know that an
unsigned long long triple double short char
can be between 1 and 573.5 bytes depending on the hardware?

 74 
 on: 2016-09-23 00:10:34 
Started by theagentd - Last post by theagentd
GPUs often use smaller floats than 32 bits to avoid having to use a full 4 bytes per color channel. There are a number of common formats on GPUs, with 16-bit floats being the most common, but 10 and 11 bit formats are fairly common too. See this page for more info: https://www.opengl.org/wiki/Small_Float_Formats

There's no native support for <32-bit floats in Java, but it can be really useful to be able to work with smaller float values. Here are some use case examples:
 - You can store vertex attributes as 16-bit floats, especially normals and many other attributes that don't need a full 32-bit float to save a lot of space.
 - You can create 16-bit float texture data, or even R11F_G11F_B10F texture data offline and save it to a file without an OpenGL context, or something similar.
 - You can avoid some wasted memory bandwidth by reading back a 16-bit float texture in its native format and doing the unpacking on the CPU, although the driver may be faster at converting to 32-bit than my code...
 - Generally save memory when writing float binary data to files, as you can choose exactly how many bits to use for the exponent, the mantissa and even if you need a sign bit at all.


Storytime, the code is at the bottom =P
I first wrote a function to convert a 32-bit float to 16-bit floats and then back again using the Wikipedia specification, but then I realized that there are other float formats out there, so I decided to rework it a bit. I instead made two generic converter functions that take in a double value and converts it to a certain number of exponent and mantissa bits, with the sign being optional. Additionally, this also allowed me to test the system by using my functions to convert from 64-bit floats to 32-bit floats and compare that to a simple cast. So now I have a generic function that can handle any number of bits <=32, with a varying size mantissa and exponent for whatever needs you have.

Features
 - Denormals handled correctly for all bit counts.
 - Infinity/NaN preserved.
 - Clamps negative values to zero if the output value has no sign.
 - Values too big for the small format are rounded to infinity.
 - Values too small for the small format are rounded to 0.
 - Positive/negative zeroes preserved.
 - No dependencies.
 - Static functions for everything.
 - Shortcut methods for halfs, 11-bit and 10 bit floats.
 - Good performance (~50-100 million conversions per second).
 

Accuracy test
From my tests, converting doubles to 32-bit floats using my conversion function (and back again) provides 100% identical result as when doing a simple double-->float cast in Java (and back again). This test consisted of converting 18 253 611 008 random double bits to floats and back again, with 100% identical result to just casting. This should mean that the conversion is 100% accurate for 16-bit values as well, but this is harder to test.


Comments and suggestions are welcome.



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  
public class FloatConversion {

   private static final int DOUBLE_EXPONENT_BITS = 11;
   private static final long DOUBLE_EXPONENT_MASK = (1L << DOUBLE_EXPONENT_BITS) - 1;
   private static final long DOUBLE_EXPONENT_BIAS = 1023;
   
   private static final long DOUBLE_MANTISSA_MASK = (1L << 52) - 1;
   
   public static long doubleToSmallFloat(double d, boolean hasSign, int exponentBits, int mantissaBits){
     
      long bits = Double.doubleToRawLongBits(d);
     
      long s = -(bits >>> 63);
      long e = ((bits >>> 52) & DOUBLE_EXPONENT_MASK) - DOUBLE_EXPONENT_BIAS;
      long m = bits & DOUBLE_MANTISSA_MASK;
      int exponentBias = (1 << (exponentBits-1)) - 1;
     
      if(!hasSign && d < 0){
         //Handle negative NaN and clamp negative numbers when we don't have an output sign
         if(e == 1024 && m != 0){
            return (((1 << exponentBits) - 1) << mantissaBits) | 1; //Negative NaN
         }else{
            return 0; //negative value, clamp to 0.
         }
      }
     
     
     
      long sign = s;
      long exponent = 0;
      long mantissa = 0;
     
     
     

     
      if(e <= -exponentBias){

         double abs = Double.longBitsToDouble(bits & 0x7FFFFFFFFFFFFFFFL);
         
         //Value is too small, calculate an optimal denormal value.
         exponent = 0;
         
         int denormalExponent = exponentBias + mantissaBits - 1;
         double multiplier = Double.longBitsToDouble((denormalExponent + DOUBLE_EXPONENT_BIAS) << 52);
         
         //Odd-even rounding
         mantissa = (long)Math.rint(abs * multiplier);
         
      }else if(e <= exponentBias){
         
         //A value in the normal range of this format. We can convert the exponent and mantissa
         //directly by changing the exponent bias and dropping the extra mantissa bits (with correct
         //rounding to minimize the error).
         
         exponent = e + exponentBias;
         
         int shift = 52 - mantissaBits;
         long mantissaBase = m >> shift;
         long rounding = (m >> (shift-1)) & 1;
         mantissa = mantissaBase + rounding;

         //Again, if we overflow the mantissa due to rounding to 1024, we want to round the result to
         //up to infinity (exponent 31, mantissa 0). Through a stroke of luck, the code below
         //is not actually needed due to how the mantissa bits overflow into the exponent bits,
         //but it's here for clarity.
         //exponent += mantissa >> 10;
         //mantissa &= 0x3FF;
         
      }else{
         
         //We have 3 cases here:
         // 1. exponent = 128 and mantissa != 0 ---> NaN
         // 2. exponent = 128 and mantissa == 0 ---> Infinity
         // 3. value is to big for a small-float---> Infinity
         //So, if the value isn't NaN we want infinity.
         exponent = (1 << exponentBits) - 1;
         if(e == 1024 && m != 0){
            mantissa = 1; //NaN
         }else{
            mantissa = 0; //infinity
         }
      }
     
      if(hasSign){
         return (sign << (mantissaBits + exponentBits)) + (exponent << mantissaBits) + mantissa;
      }else{
         return (exponent << mantissaBits) + mantissa;
      }
     
   }
   
   public static double smallFloatToDouble(long f, boolean hasSign, int exponentBits, int mantissaBits){

      int exponentBias = (1 << (exponentBits-1)) - 1;

      long s = hasSign ? -(f >> (exponentBits + mantissaBits)) : 0;
      long e = ((f >>> mantissaBits) & ((1 << exponentBits) - 1)) - exponentBias;
      long m = f & ((1 << mantissaBits) - 1);

      long sign = s;
      long exponent = 0;
      long mantissa = 0;

      if(e <= -exponentBias){
         
         //We have a float denormal value. Cheat a bit with the calculation...

         int denormalExponent = exponentBias + mantissaBits - 1;
         double multiplier = Double.longBitsToDouble((DOUBLE_EXPONENT_BIAS - denormalExponent) << 52);
         
         return (1 - (sign << 1)) * (m * multiplier);

      }else if(e <= exponentBias){
         
         //We have a normal value that can be directly converted by just changing the exponent
         //bias and shifting the mantissa.
         
         exponent = e + DOUBLE_EXPONENT_BIAS;
         int shift = 52 - mantissaBits;
         mantissa = m << shift;
      }else{
         
         //We either have infinity or NaN, depending on if the mantissa is zero or non-zero.
         exponent = 2047;
         if(m == 0){
            mantissa = 0; //infinity
         }else{
            mantissa = 1; //NaN
         }
      }
     
      return Double.longBitsToDouble(((sign << 63) | (exponent << 52) | mantissa));
   }
   
   //Half floats
   
   public static short floatToHalf(float f){
      return (short) doubleToSmallFloat(f, true, 5, 10);
   }
   
   public static float halfToFloat(short h){
      return (float) smallFloatToDouble(h, true, 5, 10);
   }
   
   public static short doubleToHalf(double d){
      return (short) doubleToSmallFloat(d, true, 5, 10);
   }
   
   public static double halfToDouble(short h){
      return smallFloatToDouble(h, true, 5, 10);
   }
   
   
   //OpenGL 11-bit floats
   
   public static short floatToF11(float f){
      return (short) doubleToSmallFloat(f, false, 5, 6);
   }
   
   public static float f11ToFloat(short f){
      return (float) smallFloatToDouble(f, false, 5, 6);
   }
   
   public static short doubleToF11(double f){
      return (short) doubleToSmallFloat(f, false, 5, 6);
   }
   
   public static double f11ToDouble(short f){
      return smallFloatToDouble(f, false, 5, 6);
   }
   
   
   //OpenGL 10-bit floats.
   
   public static short floatToF10(float f){
      return (short) doubleToSmallFloat(f, false, 5, 5);
   }
   
   public static float f10ToFloat(short f){
      return (float) smallFloatToDouble(f, false, 5, 5);
   }
   
   public static short doubleToF10(double f){
      return (short) doubleToSmallFloat(f, false, 5, 5);
   }
   
   public static double f10ToDouble(short f){
      return smallFloatToDouble(f, false, 5, 5);
   }
}

 75 
 on: 2016-09-22 21:01:07 
Started by Paradox123 - Last post by Paradox123

Hi Again!

Today I come with my new game, Sort And Sequence.





This is a puzzle which provides you two modes to play.
1º - You have to sort the numbers given to you before you run out of time.
2º - You have to calculate the numbers given to you as fast as you can.

Its a very simple game, but you can have some fun times alone or with your friends.

Well, if you like don't forget to share and evaluate.

Link: https://play.google.com/store/apps/details?id=com.sortandsequence.android

P.S: If you find any bugs, or anything that you find worth sharing, please tell me.


 76 
 on: 2016-09-22 20:06:01 
Started by dylanignis - Last post by dylanignis
Hey everyone,

I'll cut right to the chase - I've always been an avid gamer and enjoyed my fair share of programming, but what struck me truly as what I wanted, it was a good few years back, the second I laid my eyes on Ludum Dare time lapses, Notch programming his games at some 300wpm, looking at game developers making whatever they wanted whenever they wanted just really, really fascinated me. Ever since then I've wanted but one thing - to be able to just develop my own games, and have so much fun doing it, to the standard that I know what I'm doing meaning that the only limitation for me would have to be my imagination. From that day I've always been taking in as much as possible from wherever I can, and I have gotten to the skill level where I can successfully bang out a quick window, game loop, tiles, sprites, all with the sort of ChernoProject style of code. However - if I wan't to make anything more, I have to go searching on the internet and watching many tutorials to get any further - well, at least properly.. I've made plenty of games however they are often incredibly inefficiently programmed with only a few classes, all jam-packed with thousands of lines of code.

So, I guess my question is, how exactly do I make 'proper' games, what are the mandatory rules and restrictions for programming, and what is the theory behind it all? By this I mean, what is the process of level systems, artificial intelligence, how to implement sfx, proper cut-scenes and animations - all the things that one would be expected to know before diving right in and making games?

Thanks a lot for any feedback - all is appreciated.
Sorry for the essay..
Thanks again,
Dylan.
 Grin

 77 
 on: 2016-09-22 19:49:31 
Started by BurntPizza - Last post by J0
unsigned long long?

 78 
 on: 2016-09-22 19:12:58 
Started by BurntPizza - Last post by basil_
me vs. unsigned long long int - 1:0

\o/

 79 
 on: 2016-09-22 18:12:54 
Started by BurntPizza - Last post by Roquen
Today IBM announced open sourcing their JDK.

 80 
 on: 2016-09-22 17:44:07 
Started by comrad_gremlin - Last post by comrad_gremlin
Eh, the follow function was kind of mobile oriented, but if you are using it on PC: sure Smiley Fixed the jittering today.

Here's the full list of fixes:
- New enemy plane: seeker, follows the player around
- Five new missions
- Fixed jittering in touch follow / joystick mode
- Bonuses are going to spawn closer to you (and mostly in your way)
- Guaranteed to drop health bonus for every 1000 score now

Click to Play

Latest Version Here: http://coldwild.com/flyer

Pages: 1 ... 6 7 [8] 9 10
 
xTheGamerPlayz (11 views)
2016-09-26 21:26:27

Wave Propagation (220 views)
2016-09-20 13:29:55

steveyg90 (333 views)
2016-09-15 20:41:23

steveyg90 (333 views)
2016-09-15 20:13:52

steveyg90 (371 views)
2016-09-14 14:44:42

steveyg90 (398 views)
2016-09-14 14:42:13

theagentd (429 views)
2016-09-12 16:57:14

theagentd (364 views)
2016-09-12 14:18:31

theagentd (295 views)
2016-09-12 14:14:46

Nihilhis (727 views)
2016-09-01 13:36:54
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21
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!