Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (701)
Games in Android Showcase (203)
games submitted by our members
Games in WIP (774)
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 ... 29
1  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-11-18 18:01:39
Had a mock interview for oxford today , here is a fun little question how many consecutive zeros are there at the end of 2016!?
2  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-10-20 09:38:18
I sold all my gun skins in Counter Strike for just over $1000
Turned out to be a profitable investment.
I have only one question:
And how many money you spend on keys to unlock them? Wink
Depends on how long it took , a KWH of power is an extremely cheap amount of power only a few cents , most computers run at less than a KWH often at a third of that so I would assume he would have made atleast $500 profit with power costs included.  This of course makes it a better short term investment than bit coin
3  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-10-18 09:56:53
As for a fast way to deal with ln, I guess you could try the usual series lnx ~ x-1 - 0.5(x-1)(x-1) + 0.33(x-1)(x-1)(x-1) - ... and shorten it to the smallest number of terms that would still produce acceptable results..

Just be warned that this will only produce a 'valid' approximation for about 0 < x < 2.

Edit: Since
(plnp)^2 / p
and
(plnp)^2
should both be calculated per light (correct, or am I thinking of this variable wrong?), this optimization matters less than the optimization of the equation
y=s/(x^2+t)
where
s=(plnp)^2
and
t=(plnp)^2/p
.

Ps: also not gonna use latex sorry not sorry
Genius coder I forgot this was only happening once per light  Roll Eyes , i'll fix that.  The divisions cannot be optimised easily as that equation cannot be simplified much further than it already is however by precalculating p and lnp then using them when neccessary it can be made much faster.
4  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-10-17 18:29:56
Updated my algorithm a little bit , gives a nicer result with light regions getting larger on the darker colours. with range being defined as plnp + p.
This produces the nice result shown below.

It would be nice to make this faster , as lighting calculations don't need to be exact is there any decent and rapid approximation to ln p , of course p^2 ln p can be approximated but the only implementations I have found don't have much explanation.
5  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-10-15 14:58:36
Updated my lighting system to produce a nice inverse square type spread , came up with this equation to model it where k is the range of the light and p is the power. This functions so that it doesn't require a square root calculation and that y<1 when x = k.
6  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-10-11 21:27:14
UCAS for Oxbridge is so damn early.
I wasn't planning to apply until about 3 weeks before , really was quite pressured. Have to sit the MAT in a few weeks aswell , that is going to be interesting...
7  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-10-10 20:28:14
Sent off my UCAS application to oxford to study mathematics.
8  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-09-13 19:21:57
I got depressed a bit.

http://xkcd.com/1732
I think the fact people still don't believe this is insane , it's obviously getting worse and population increase plays a huge role! Us java developers need to get into gear to make games that stop people from wanting to have more children so that we can save the environment!
9  Game Development / Newbie & Debugging Questions / Re: Level Design And "Level Data" file formats on: 2016-09-06 15:43:11
Here is how I do this , initially I setup an enum storing each obj/tile type with names and sprite positions along with an ID for it. Advantages of this? an object can have the same function and interaction however it will have a different appearance and can have a different name , this can of course be expanded for other things like bounds.
For instance my enum class looks like this :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
public enum tileid {
   SPACE(new space(),"aaa"),
   METAL_WALL(new metal_wall(),"a"),
   METAL_FLOOR(new metal_floor(),"b");
   public tile type;
   public String id;
   tileid(tile t,String letter){
      type = t;
      id = letter;
   }
}


For loading the world it stores a list of all the ID's next to their corresponding obj/tile and then iterate through a string which stores all the map data and create this.
Here is the code for loading/saving the map:
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  
public void save_world(){
      String output = "";
      int x;
      int y;
      for(y = height - 1;y >= 0;y--){
         String x_output = "";
         for(x = 0;x < width ;x++){
            String y_output = "";
            tile t = world[x][y];
            if(t == null){
               y_output = "aaa";
            }
            else{
               obj[] objs = t.get_items();
               y_output = get_tile_id(t);
               for(obj o : objs){
                  y_output += "#";
                  y_output += get_obj_id(o);
               }
            }
            if(x != width - 1 ){
               y_output += ",";
            }
            x_output += y_output;
         }
         x_output += ";";
         output += x_output;
      }
      System.out.println(output);//the actual map
     
   }
   public void build_world(){
      String file = map_file.gettext("./src/com/maps/map1");
      String[] rows = file.split(";");
      int x = 0;
      int y = height - 1;
      for(String row : rows){
         x = 0;
         String[] columns = row.split(",");
         for(String column : columns){
            String[] point_data = column.split("#");
            boolean tile = false;
            for(String data : point_data){
               if(!tile){
                  tile = true;
                  tile t = getnew(tileset.get(data));
                  if(t == null){
                     t = new space(new Vertex2d(x,y));
                     
                  }else{
                     t.init(new Vertex2d(x,y));
                  }
                  add_tile(t);
                  continue;
               }
               obj o = getnewobj(objset.get(data));
               if(o == null){
                  continue;
               }
               o.init(oh,new Vertex2d(x,y));
               add_obj(o);
            }
            x++;
         }
         y --;
      }
      for(x = 0; x < width;x++){
         for(y= 0;y < height;y++){
            if(world[x][y] == null){
               add_tile(new space(new Vertex2d(x,y)));
            }
         }
      }
      clear_paused_lights();
      update();
   }

So how does this work? Lets start with loading the world first , the code initially iterates through the input string and splits it into individual coordinates (each tile/obj has exact world coordinates) with rows being defined by ; and each individual index being split by , . This also stores items and it does so by splitting them from the tiles with #.

For example a world that is 4 by 4 with tile a on the top row and tile b the rest of the map with each alternating index storing an item with ID c would look like this :
1  
a#c,a,a#c,a;b#c,b,b#c,b;b#c,b,b#c,b;b#c,b,b#c,b;

It's quick it's dirty but it does the job and doesn't require serializable.
10  Discussions / Miscellaneous Topics / Re: HTML/CSS Is Gross on: 2016-08-30 23:36:25
"I'm gonna make my own HTML , with black jack ... and hookers!" - Hydroque 2016
11  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-08-24 22:44:05
Got my new renderer working and my god it is so much simpler to use , GUI's and stuff are still a *bit* of a challenge requiring a seperate set of buffer storage. It would be great to know how people usually handle modular layering.
12  Game Development / Newbie & Debugging Questions / Re: LWJGL 3 rendering issues on: 2016-08-23 22:33:13
Discovered I hadn't enabled the GLFW contexts , seems to have fixed it. Thanks SHC for the tutorial.
13  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-08-23 21:32:53
Started rewriting my entire graphics engine , to be perfectly honest the previous one was pretty shoddy now looking at it...
It is so much better to have tried, and learned from the process, than done nothing at all.
And then try again and fail because you can't write GLSL XD.
14  Game Development / Newbie & Debugging Questions / Re: LWJGL 3 rendering issues on: 2016-08-23 21:14:50
I am forcibly setting the colour of the shape within my frag shader. Here they are.
vertex
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  
attribute vec2 position;
attribute vec2 texin;
uniform vec2 transform;
uniform vec2 dimension;
vec2 convertback(vec2 data){
float tx = data.x * dimension.x;
float ty = data.y * dimension.y;
vec2 stage1 = vec2(tx,ty);
tx = stage1.x + dimension.x;
ty = stage1.y + dimension.y;
return vec2(tx,ty);
}
vec2 convertto(vec2 data){
float tx = data.x ;
float ty = data.y;
vec2 stage1 = vec2(tx - dimension.x,ty - dimension.y);
vec2 stage2 = vec2((stage1.x )/dimension.x,(stage1.y )/dimension.y);
return stage2;
}
void main(){
   
   vec4 offset = vec4((position.x+transform.x),(position.y+transform.y),1,1);
   gl_Position = offset;


}

frag
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
uniform sampler2D bgl_RenderedTexture;

void main(){
   vec4 tex = texture2D(bgl_RenderedTexture,vecdata);
    if(tex.rgb == vec3(1.0,0,1.0)){
         discard;
    }
    else{
    gl_FragColor = vec4(1.0,0,1.0,1);
    }
   
   
  }
   
   


I'll show the GLFW init code along with the full render code.


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
public void create_display(int width, int height, String name, int framerate) {

      GLFW.glfwInit();
      core.window = GLFW.glfwCreateWindow(width, height,
            name, 0, 0);
      this.width = width;
      this.height = height;
      GLFW.glfwMakeContextCurrent(core.window);
      GLFW.glfwSwapInterval(1);
      GLFW.glfwShowWindow(core.window);
      GL.createCapabilities();
      vbo_core = new CoreVBO();
      GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
      GL11.glEnable(GL11.GL_BLEND);
      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

   }


1  
2  
3  
4  
5  
6  
public void render() {
      core.graphics.render();
      for(int i = 0; i < render_methods.size();i++){//manual rendering , must be done through the graphics handler
         render_methods.get(i).call();
      }
   }
15  Game Development / Newbie & Debugging Questions / LWJGL 3 rendering issues on: 2016-08-23 18:47:09
I'm probably being an absolute idiot here ( as usual ) , i'm trying to render a simple shape in my new graphics engine and while the window is shown no image is shown on the screen. Below is the relative code.

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  
public void render() {
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
      int index = 0;
      for(index = 0; index < buffer_objects.size();index++){
         BufferObject render_object = buffer_objects.get(index);
         vbo_core.bind_shader();
         GL11.glEnable(GL11.GL_BLEND);
         GL11.glBindTexture(GL11.GL_TEXTURE_2D, render_object.texture.id);
         GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, render_object.vertex_id);
         GL20.glEnableVertexAttribArray(vbo_core.locationattribvertex);
         GL20.glEnableVertexAttribArray(vbo_core.locationattribtex);
         GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER,render_object.vertex_id);
         GL20.glVertexAttribPointer(vbo_core.locationattribvertex, 2,
               GL11.GL_FLOAT, false, 0, 0);
         GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, render_object.texture_id);
         GL20.glVertexAttribPointer(vbo_core.locationattribtex, 2,
               GL11.GL_FLOAT, false, 0, 0);
         // Draw the textured rectangle
         GL20.glUniform2f(vbo_core.locationdimension, width, height);
         GL20.glUniform2f(vbo_core.locationtransform, render_object.translation.x,
               render_object.translation.y);
         GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, render_object.vert_count);
         
         GL20.glDisableVertexAttribArray(vbo_core.locationattribvertex);
         GL20.glDisableVertexAttribArray(vbo_core.locationattribtex);

         GL11.glEnable(GL11.GL_BLEND);
         vbo_core.un_bind_shader();
      }
     
   }

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
public int create_buffer(int size , Vertex2d[] data,Texture t){
      int index = create_buffer(size,t);
      BufferObject buffer = buffer_objects.get(index);
      for(Vertex2d vertex :data){
         buffer.verticies.put(vertex.x);
         buffer.textures.put(vertex.u);
         buffer.verticies.put(vertex.y);
         buffer.textures.put(vertex.v);
         buffer.vert_count+=2;
      }
      buffer_objects.set(index,buffer);
      buffer.flip();
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, buffer.vertex_id);
      GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer.verticies, GL15.GL_STREAM_DRAW);
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, buffer.texture_id);
      GL15.glBufferData(GL15.GL_ARRAY_BUFFER,   buffer.textures, GL15.GL_STREAM_DRAW);
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
      return index;
   }


Any help an obvious error pointing out would be helpful.
16  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-08-22 21:31:18
Started rewriting my entire graphics engine , to be perfectly honest the previous one was pretty shoddy now looking at it. For the things I wanted to do it had too much overhead and required lots of micromanagement by the above programs. I have designed my new one to be much simpler to use with the core graphics handler class dealing directly with the openGL side of things and the renderer class dealing with with the graphics handler , interactions between world objects and the conversion of world coordinates to screen coordinates all with minimal input from the higher level classes. It has limitations in that it will only render squares ( tile based game so it doesn't make too much difference to the total function ) , the renderer can handle a maximum number of objects before it just starts declining them however this will always be precalculated by the world so that if it does happen something has probably gone wrong. All of the graphics handler is extendable up to the limit of the system though so it should work just fine for that , it's also made so that all my previous code will not require too much modification and if anything should become a lot simpler than previous especially in terms of memory efficiency which was my previous issue.

The graphics handler is the only class that will deal with floatbuffers and because of this memory leaks will hopefully be non existant , this class also directly deal with all of the vbo's and because of this no other classes are required to have a cleanup method.
17  Game Development / Newbie & Debugging Questions / Re: Floatbuffer memory leak on: 2016-08-21 20:19:19
Tries to fix memory leak , ends up rewriting entire graphics engine  Grin
18  Game Development / Newbie & Debugging Questions / Re: Floatbuffer memory leak on: 2016-08-21 15:22:16
I couldn't really find any tutorials on linking stacks with lwjgl and if anyone has any please let me know.

Not sure what you're looking for exactly. It's very simple:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
// Method 1: Explicit malloc/free, useful for "big" buffers and custom lifecycles 
FloatBuffer buffer = memAllocFloat(100);
// ..use buffer..
memFree(buffer); // buffer goes away (doesn't have to be in the same method)

// Method 2: Stack allocation, useful for "small" buffers, local-only
try ( MemoryStack stack = stackPush() ) {
   FloatBuffer buffer = stack.mallocFloat(100);
   // ..use buffer..
} // buffer goes away


Ahh thanks , so just entirely ignore BufferUtils and do it manually. I'll work on my method first and then implement this with it.
19  Game Development / Newbie & Debugging Questions / Re: Floatbuffer memory leak on: 2016-08-21 11:58:47
I think the method i'm going to go for instead is to still use floatbuffers however entirely leave them to the few VBO's I have and instead modify actual vertex data and pass it down to the VBOs. This basically means recoding the graphics engine but it isn't that bad , I couldn't really find any tutorials on linking stacks with lwjgl and if anyone has any please let me know.
20  Game Development / Newbie & Debugging Questions / Re: Floatbuffer memory leak on: 2016-08-21 10:06:38
Stacks seem perfect for this role , it's strange that these aren't really mentioned in any of the default LWJGL tutorials as it's really useful. Thanks for the links i'll implement them soon.
21  Game Development / Newbie & Debugging Questions / Floatbuffer memory leak on: 2016-08-21 00:27:54
So i've been trying to fix memory leaks within my code and it seems the cause of the entire issue is BufferUtils.createFloatBuffer(); when this is called it creates a float buffer and appears to leave it in memory , my test of just having a for loop call that ended up hogging memory. Is there a method of deleting the floatbuffer once it's purpose has been served as it's at the core of my code.
22  Game Development / Newbie & Debugging Questions / Re: Reference handler thread lag issues on: 2016-08-19 22:24:14
Hmm I found the problem , turns out my legacy code was creating 6 unnecessary float buffers all of monstrous size in a rather high traffic section of code which was basically bottle necking the entire code.
23  Game Development / Newbie & Debugging Questions / Reference handler thread lag issues on: 2016-08-19 22:19:07
So I'm working on a game with an open world esq environment and it currently is a bit of a memory whore which I'm working on however after running a memory check on the code I find that the memory is pretty well contained other than the graphics methods and yet I still get lag spikes, after investigating I found that the reference handler thread would spike up every now and again and seems to be the cause of the lag.

What causes this thread to actually spike up , I understand it's to do with the garbage collector so would reducing my use of throwaway objects for arguments (eg some_function(new Vertex(x,y))) help with this problem?
24  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-08-19 20:58:20
Searched for a memory leak within my code , turns out there are two sources one being in the core of the graphics system and the other being in a poorly implemented lighting handler , talking about gigabytes here that killed my computer when I tried to run it.
25  Game Development / Newbie & Debugging Questions / Re: multiple VBO transparency on: 2016-08-13 11:02:36
If this is not even possible then please let me know.
26  Game Development / Newbie & Debugging Questions / multiple VBO transparency on: 2016-08-11 19:04:02
So currently I have an overlay VBO object and a world VBO object , overlay is rendered after the world and I would like the overlay object to blend with the world object based on the alpha value. I know this can be done with a single VBO but that would mean rewriting the majority of my VBO code.
27  Game Development / Game Mechanics / Re: [java] Rapid trigonometric calculations on: 2016-04-19 19:41:24
See this link: http://www.java-gaming.org/topics/extremely-fast-sine-cosine/36469/view.html
Feel free to compare it against those implementations.

Thank you so much for that , I have copied over some of the methods and benchmarked against them , here are the results.

1  
2  
3  
4  
5  
6  
7  
[0]   Valcalc.defcos!..........   6.33ns
[1]   Valcalc.defsin...........   6.33ns
[2]   Valcalc.deftan........!..........   6.34ns
[3]   Valcalc.devsin..!..........   51.7ns
[4]   Valcalc.kappasin..........   5.37ns
[5]   Valcalc.lcasssin..........   5.70ns
[6]   Valcalc.lcasssincostan.........!....!..........   5.69ns


The reason I found that Devmaster's method was so slow was due to the use of modulo which if used for different angles would be pretty slow.
Compared to the others mine held up quite well , it is quite clear that it is more efficient to calculate all three methods at the same time as shown by both my methods having almost identical times even though one produces three values. Naturally Kappa's wins because it was built to be as fast as possible with errors being allowed , it would be great for an explanation of how it works as it seems magical like the inverse square root calculation.

All values above use PI/6 as the input value which is pre calculated in order to effect the results as minimally as possible.
28  Game Development / Game Mechanics / [java] Rapid trigonometric calculations on: 2016-04-19 18:45:35
I was fairly bored earlier and decided to try to write a fast algorithm to calculate all the basic trig functions with optimizations made to their calculations due to similarities with their Taylor series.
Compared to functions such as the built in sin and cos it generally takes longer than each individual function but is faster that sin and cos performed at the same time and much faster than sin cos and tan calculated , I haven't compared it to more assembly based ones such as fsincos so I'm not really sure about that.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
public double[] sincostan(double theta){
      int accuracy = 10;
      double sin = theta;
      double cos = 1;
      double exponential = theta;
      double factorial = 1;
      double even = -1;
      double increment = 2;
      for(int i = 1; i < accuracy; i++){
         exponential *=theta;
         factorial *= (increment);
         cos += (even/factorial) * exponential;
         increment ++;
         exponential *=theta;
         factorial *= (increment);
         sin += (even/factorial) * exponential;
         increment ++;
         even*=-1;
      }
      double tan = sin/cos;
      return new double[]{sin,cos,tan};
   }


It's simple enough to use , give a number of iterations as the accuracy variable (10 tends to give you the maximum accuracy when using doubles) and input theta as the angle in radians. If there are any improvements or comparisons please let me know!
29  Discussions / General Discussions / Re: Virtual machine ID on: 2015-07-23 15:52:58
For instance , on a piece of software called BYOND you are able to request a computer ID that returns an Integer of something like 384756237. This stays the same for the computer unlike the IP.
30  Discussions / General Discussions / Virtual machine ID on: 2015-07-23 13:40:58
This is more of a random question. Does a virtual machine running on a computer have a different ID number than the computer it's running on?
Pages: [1] 2 3 ... 29
 
ral0r2 (194 views)
2016-11-23 16:08:26

ClaasJG (334 views)
2016-11-10 17:36:32

CoffeeChemist (428 views)
2016-11-05 00:46:53

jay4842 (479 views)
2016-11-01 19:04:52

theagentd (490 views)
2016-10-24 17:51:53

theagentd (478 views)
2016-10-24 17:50:08

theagentd (436 views)
2016-10-24 17:43:15

CommanderKeith (434 views)
2016-10-22 15:22:05

Roquen (407 views)
2016-10-22 01:57:43

Roquen (303 views)
2016-10-17 12:09:13
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!