Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (808)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (872)
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]
1  Games Center / WIP games, tools & toy projects / Re: CaveGear on: 2015-06-24 14:18:15
Code for Block Place and Break:
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  
// Blockchange
   public void change(World world, int x, int y) {
      float finalLight = 0;
      for (int ix = -1; ix <= 1; ix++) {
         for (int iy = -1; iy <= 1; iy++) {
            float dis = ix * ix + iy * iy;
            if (dis != 0) {
               float cur = 0;
               if (world.getBlock(x + ix, y + iy) != null) {
                  cur = world.getBlock(x + ix, y + iy).light;
               }
               if (dis == 2) {
                  cur -= 1.7f;
               } else {
                  cur -= 1.0f;
               }
               if (opaque) {
                  cur -= 1;
               }
               if (cur < 0)
                  cur = 0;
               if (cur > finalLight) {
                  finalLight = cur;
               }
            }
         }
      }
      if (finalLight != light) {
         light = finalLight;
         stepChange(world, x, y);
         if (Chunk.stepping)
            chunk.redolight = true;
      }
   }

Code for the method "Step Change"
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
   public void stepChange(World world, int x, int y) {
      if (world.getBlock(x - 1, y) != null)
         world.getBlock(x - 1, y).change(world, x - 1, y);
      if (world.getBlock(x, y - 1) != null)
         world.getBlock(x, y - 1).change(world, x, y - 1);
      if (world.getBlock(x + 1, y) != null)
         world.getBlock(x + 1, y).change(world, x + 1, y);
      if (world.getBlock(x, y + 1) != null)
         world.getBlock(x, y + 1).change(world, x, y + 1);
   }


And in the BlockAir it's different cause that's the only one affected by the WorldLight:
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  
@Override
      public void updateWorldLight(float delta, World world, int x, int y) {
         BlockBack bb = world.getBlockBack(x, y);
         if (bb == null) {
   
         } else if (bb.Type == 0) {
                  change(world, x, y);
         }
      }
   
      // Blockchange
      @Override
      public void change(World world, int x, int y) {
         boolean worldLight = true;
         float finalLight = 0;
         BlockBack bb = world.getBlockBack(x, y);
         if (bb == null) {
   
         } else if (bb.Type == 0) {
            if (world.worldLight != light) {
               finalLight = world.worldLight;
               worldLight = true;
            }
         }
         for (int ix = -1; ix <= 1; ix++) {
            for (int iy = -1; iy <= 1; iy++) {
               float dis = ix * ix + iy * iy;
               if (dis != 0) {
                  float cur = 0;
                  if (world.getBlock(x + ix, y + iy) != null) {
                     cur = world.getBlock(x + ix, y + iy).light;
                  }
                  // following calculations round the light shape
                  if (dis == 2) {
                     cur -= 1.7f;
                  } else {
                     cur -= 1.0f;
                  }
                  if (opaque) {
                     cur -= 1;
                  }
                  if (cur < 0)
                     cur = 0;
                  if (cur > finalLight) {
                     finalLight = cur;
                     worldLight = false;
                  }
               }
            }
         }
         if (finalLight != light) {
            light = finalLight;
            if (worldLight) {
               if (shouldChange(world, x, y)) {
                  stepChange(world, x, y);
                  if (Chunk.stepping)
                     chunk.redolight = true;
               }
            } else {
               stepChange(world, x, y);
               if (Chunk.stepping)
                  chunk.redolight = true;
            }
         }
      }
   
      public boolean shouldChange(World world, int x, int y) {
         for (int ix = -1; ix <= 1; ix++) {
            for (int iy = -1; iy <= 1; iy++) {
               float dis = ix * ix + iy * iy;
               if (dis != 0) {
                  if (world.getBlock(x + ix, y + iy) != null) {
                     if (world.getBlock(x + ix, y + iy).Type != 0) {
                        return true;
                     } else {
                        if (world.getBlockBack(x + ix, y + iy) != null) {
                           if (world.getBlockBack(x + ix, y + iy).Type != 0) {
                              return true;
                           }
                        } else {
                           return true;
                        }
                     }
                  }
               }
            }
         }
         return false;
      }


If the chunk.redoLight has its value set to true it will refresh the VBO rendered for the light.
the update worldlight method only gets called when the WorldLight value changes.
I'm stuck :p

I don't think that's quite readable but well :/
2  Games Center / WIP games, tools & toy projects / Re: CaveGear on: 2015-06-24 12:06:00
I'm currently Stuck with the lighting that is determined by the day time, updating the VBOs that are affected all at once freezes the screen visibly for under 1 second :/
3  Games Center / WIP games, tools & toy projects / Re: CaveGear on: 2015-06-24 08:08:18
actually i started it like 10 days ago, but I've recoded it a multiple times before, copied some stuff froom there and restarted.

are VAO faster than VBOs? Tongue
4  Games Center / WIP games, tools & toy projects / Re: CaveGear on: 2015-06-24 05:26:09
I'm currently using VBOs for the Chunks and Intermediate Mode for everything else (will change that)

There's a Story in the main post here that will introduce to the game, like why your character is there etc. but other than the atm not, I'll be working on that later i guess
5  Games Center / WIP games, tools & toy projects / Re: CaveGear on: 2015-06-18 20:07:43
Ingame Chat added Smiley shows up to 7 messages currently

Day/Night Cycle improved, Sun and Moon now show up in the back, and some clouds passing by Cheesy

+ I switched from Intermediate Mode rendering to VBO rendering (only in the chunks), from 30 FPS to 1300  Cool
have to reimplement the light next (so it shows above entities, it makes no sense that entities are always in their true color)
6  Games Center / WIP games, tools & toy projects / CaveGear on: 2015-06-15 20:06:41


So this is my first Project on here, it's called CaveGear Smiley

It's a mixture of Minecraft, Terraria, Starbound and Magicite, so basically a 2D Sidescroll Sandbox game with the Goal to survive. Enemies will have much more HP than the Players, potions will be very rare and there is no Health Regen at all. You'll start off with 3 Hearts and the amount can only be increased by Weapons/Armor with Vitality as a stat. There are other Stats such as Dextertity (Increasing accuracy of your Bow) Strength (Increases your Sword's damage) Inteligence (Increases Magic damage) and Defense (Decreases Damage taken).

Story:
You (and your friends, multiplayer is fully implemented) crashed with your Spaceship on a planet without oxygen, your Ship is completly destroyed and you don't have the technology to fix it. The only working parts you could get out of the wreck are an Oxygen Compressor and a Crafting Station. each of you has an Oxygen Flask that holds air for only one minute equipped and that's about all you have. You quickly realise that you don't have any chance of getting away from this planet, so you decided to build a base and explore the planet which surprises you with magical weapons, strange ores and deadly creatures.

Features:
✔ - Day Night Cycle
✔ - Build and Break blocks
✔ - Lighting (Reimplementing)
✔ - Multiplayer
✔ - Menu
✔ - Inventory System
✔ - Infinite Terrain generation
✔ - Seed depending maps with Caves
✔ - Player Animations
✔ - Ingame Chat

Todo:
✘ - Crafting System
✘ - Monsters
✘ - Liquids
✘ - More Ores/Stonetypes/Materials
✘ - Bosses
✘ - Health, Oxygen, Mana and Hunger bars
✘ - Character Customization
✘ - Stat system on weapons

(After Implementing and Testing some more Stuff I'll release a Demo)

And now some Videos about the current look of the game:

Animated Menu:
<a href="http://www.youtube.com/v/lyN4Rb6sZ7Q?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/lyN4Rb6sZ7Q?version=3&amp;hl=en_US&amp;start=</a>

Day-Night Cycle:
<a href="http://www.youtube.com/v/XodplMMKgvc?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/XodplMMKgvc?version=3&amp;hl=en_US&amp;start=</a>

Build/Break and Inventory:
<a href="http://www.youtube.com/v/CXLHClXaQHs?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/CXLHClXaQHs?version=3&amp;hl=en_US&amp;start=</a>
7  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-06-14 19:06:47
Designed the Gui for my Game, the Gui change is animated and the code to add a new Gui is really short Smiley

The text in the lower field is random upon Start

8  Discussions / Business and Project Management Discussions / Re: New Team! T.H.E.Tritonn looking for Members on: 2015-06-14 16:40:34
Send you an e-mail Smiley
9  Game Development / Newbie & Debugging Questions / Re: How Do I Expand My Game? on: 2015-06-14 12:18:43
Well, you posted it in the "Java Gaming Wiki" section, if you look at the other entries there, they're all written by wiki Duke, i think it's an account that functions as a wiki system
10  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-06-12 20:04:17
Some Art, Some Animations and a lot of Client-Server Code Smiley

Click to Play
11  Game Development / Newbie & Debugging Questions / Re: Weird if Statement/System.out behavior on: 2015-06-12 12:35:43
figured out time was a long and the delta value that gets added a float, without the Misc.log it's running under 1ms per update which keeps the long to 0 and with the Misc.log it's a bit above 1ms  Cranky wow

changed the time variable to be a float as well
12  Game Development / Newbie & Debugging Questions / Re: Weird if Statement/System.out behavior on: 2015-06-12 12:27:05
alright, gonna do that  Roll Eyes
13  Game Development / Newbie & Debugging Questions / [Solved] Weird if Statement/System.out behavior on: 2015-06-12 11:41:40
1  
2  
3  
4  
Misc.log("Update");
if (time >= 1000) {
   Misc.log("Time");
}

where Misc has this function:
1  
2  
3  
4  
public static void log(String msg) {
   Date date = new Date();
   System.out.println("[" + new Timestamp(date.getTime()) + "] " + msg);
}


Time is a float that increses with my delta time (which is calculated in millieseconds) so after one second it should pass into the if state as well (it's in my game loop)

I tested it with outputs to see what in my code isn't working.

with both Misc.log(); calls arround the if statement both get called, however if I remove the Misc.log("Update"); it doesn't ever output "Time" in my console, nothing else changed, why is this and how can i fix it? :/
Without both the code inside that if() doesn'T get called either
14  Game Development / Networking & Multiplayer / [Solved] KryoNet Auto Pinging (KeepAlive) on: 2015-06-10 07:06:19
In my program KryoNet sends Pings itself way too often, about 50 times per ms (!) i printed them to the console with timestamps.
That's way too often, can I somehow reduce the amount?
1  
2  
      con.setKeepAliveTCP(1000);
      con.setTimeout(1000);

didn't change anything (called in the Serverlistener receive code) and i couldn't find a method in the server object itself.
couldn't find anything through google either :c

edit: I called con.updateReturnTripTime() in my received method, so it just sends the Ping messages arround, fixed Cheesy
15  Game Development / Newbie & Debugging Questions / Re: Textured Greedy Mesh on: 2015-04-09 17:50:05
that solved the problem, thx Smiley
16  Game Development / Newbie & Debugging Questions / Re: Textured Greedy Mesh on: 2015-04-09 15:37:57
I use this in my texture init code:

      
1  
2  
3  
4  
      GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S,GL11.GL_REPEAT);
      GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T,GL11.GL_REPEAT);
      GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER,GL11.GL_NEAREST);
      GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER,GL11.GL_LINEAR_MIPMAP_LINEAR);


edit: using png decoder
17  Game Development / Newbie & Debugging Questions / Re: Textured Greedy Mesh on: 2015-04-09 15:09:20
okey, but the problem with the lines is still there? :C
18  Game Development / Newbie & Debugging Questions / Re: Textured Greedy Mesh on: 2015-04-09 15:02:23
well, my first try at GLSL i don't know that i can directly multiply vectors etc.  Shocked
19  Game Development / Newbie & Debugging Questions / Re: Textured Greedy Mesh on: 2015-04-09 13:31:15
i decided to go with the shaders (how difficult can that be?) since i don't know how to use texture2darsays or how to implement them in VBOs.

Frag 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  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
varying vec3 vertNormal;
varying vec4 vertColor;
varying vec4 viewSpace;
uniform sampler2D tex;

void main(){
   if(viewSpace.z==0){
      vec4 texel = texture2D(tex,gl_TexCoord[0].st);
      texel.r=texel.r*vertColor.r;
      texel.g=texel.g*vertColor.g;
      texel.b=texel.b*vertColor.b;
      texel.a=texel.a*vertColor.a;
      gl_FragColor = texel;
   }else{
      float x = gl_TexCoord[0].s*32-mod(gl_TexCoord[0].s*32,1);
      float y = gl_TexCoord[0].t*32-mod(gl_TexCoord[0].t*32,1);
      float fx = gl_TexCoord[0].s*32-x;
      float fy = gl_TexCoord[0].t*32-y;
      float tx = mod(fx*viewSpace.z,1);
      if(tx<=0.001){tx=0.001;}
      if(tx>=0.999){tx=0.999;}
      float ty = mod(fy*viewSpace.z,1);
      if(ty<=0.001){ty=0.001;}
      if(ty>=0.999){ty=0.999;}
      float finalx = (x+tx)/32;
      float finaly = (y+ty)/32;
      vec2 modded = vec2(finalx,finaly);
      vec4 texel = texture2D(tex,modded);
      texel.r=texel.r*vertColor.r;
      texel.g=texel.g*vertColor.g;
      texel.b=texel.b*vertColor.b;
      texel.a=texel.a*vertColor.a;
      gl_FragColor = texel;
      }
   }  
}


Vert Shader:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
varying vec3 vertNormal;
varying vec4 vertColor;
varying vec4 viewSpace;

void main(){
   gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex;
   vertNormal = normalize(gl_NormalMatrix * gl_Normal);
   vertColor = gl_Color;
   viewSpace = gl_Vertex;
   gl_TexCoord[0] = gl_MultiTexCoord0;
}


the result:


Some blue lines between (I could understand that for rounding issues or something)
and some brown/yellowish gradient which makes no sense for me (the texture doesn't have this kind of gradient next to the grey texture)

in the vertex shader the 0.001 and 0.999 are there so the tex coordinates never belong to a nearby texture, i don't understand where the problem lies Undecided

Edit: I use the z coordinate to see how often the tile has to be repeated in the current face (1= normal, 2= it's a 2x2 quad, 4= it's a 4x4 quad)
20  Game Development / Newbie & Debugging Questions / Textured Greedy Mesh - Solved on: 2015-04-08 15:52:09
I'm working on a Sandbox game at the moment and wanted to improve the rendering of the Chunks.
I started to work myself into greedy meshing and not long after that I implemented it and it works fine now, the problem i have is: the faces don't all have the size of one Tile anymore, there's faces that have 2x2 Tiles meshed into one and if i put the texture on it, well obviously it stretches to fill the whole area. I want to display it so that it repeats the texture so it looks like it looked before. this wouldn't be a problem if the Tiles are all different textures ( i could just make the texcoord from 0 to 2 instead of from 0 to 1) but i have them all together in a spritesheet and no idea how i can repeat one part of it on a face.
I've read that i could write a fragment shader that uses modulo operations but i didn't want to implement shaders for now, so is there any other option for this?
21  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-04-03 16:58:07
Added an earth texture in the background to Blox.

[...]

Also solved z-fighting and lighting issues now.

The platform where the red Block is standing on looks a bit weird on the left side no?
22  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-03-29 19:51:49
Started a project called "CaveGear" (My first project ever) and drew some art for it Smiley
I will post in WIP when there's a playable version Smiley
The Color of the shirt, the hair and the shoes are defined through the program itself and not in the textures so the character is customizable (there even are 4 different Hair styles for now)

Pages: [1]
 
mercenarius (4 views)
2020-06-04 19:26:01

mercenarius (2 views)
2020-06-04 19:13:43

Riven (850 views)
2019-09-04 15:33:17

hadezbladez (5834 views)
2018-11-16 13:46:03

hadezbladez (2635 views)
2018-11-16 13:41:33

hadezbladez (6251 views)
2018-11-16 13:35:35

hadezbladez (1504 views)
2018-11-16 13:32:03

EgonOlsen (4739 views)
2018-06-10 19:43:48

EgonOlsen (5797 views)
2018-06-10 19:43:44

EgonOlsen (3282 views)
2018-06-10 19:43:20
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
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!