Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (569)
Games in Android Showcase (154)
games submitted by our members
Games in WIP (618)
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 ... 5
1  Game Development / Newbie & Debugging Questions / Re: 2D Perlin Noise Algorithm not working correctly on: 2015-01-07 13:13:32
This solution fixed the obvious issue thanks!

However now I'm, not so much an issue, but something weird where the values don't seem to cover the entire range between -1 and 1. Occasionally 1 in every about 36 attempts i will get one value bigger than 0.7 but other than that they are mostly between -0.5 and 0.5. This can be worked around it doesn't cause any major issue, but all other tutorials and images I've seen have values ranging all the way from -1 to 1!
2  Game Development / Newbie & Debugging Questions / Re: A little problem..... (Rendering) on: 2015-01-06 21:58:40
Ed's implementation would be much faster using a comparator to sort the list of entities before rendering instead like so (snipet from my game code):

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
      entities.sort(Entity.ySorter);
      for (Entity e : entities) {
         AABB b = e.getBoundsForRendering();
         if (b != null) {
            if (b.intersects(cam.getViewportBounds()))
               e.render();
         } else {
            e.render();
         }
      }


Entity.ySorter is as follows:

1  
2  
3  
4  
5  
6  
7  
   public static SortByY ySorter = new SortByY();
   
   public static class SortByY implements Comparator<Entity> {
      public int compare(Entity o1, Entity o2) {
         return (o1.getY() > o2.getY()) ? -1 : (o1.getY() < o2.getY()) ? 1 : 0;
      }
   }
3  Game Development / Newbie & Debugging Questions / 2D Perlin Noise Algorithm not working correctly on: 2015-01-06 21:55:48
So I'm trying to write my own perlin noise algorithm at the moment but I've been stuck with this one problem for a long time

Here is my result:



And here's my code (sorry it's a bit messy, I'm not using a proper vector class at the moment):

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  
private float dot(float x0, float y0, float x1, float y1) {
   return (x0 * x1) + (y0 * y1);
}

public float sample(float x, float y) {
   int gx0 = (int) Math.floor(x);
   int gy0 = (int) Math.floor(y);
   int gx1 = gx0 + 1;
   int gy1 = gy0 + 1;
   
   float dx0 = x - gx0;
   float dy0 = y - gy0;
   
   float dx1 = x - gx1;
   float dy1 = y - gy1;
   
   float w0 = dot(dx0, dy0, getVX(gx0, gy0), getVY(gx0, gy0));
   float w1 = dot(dx0, dy1, getVX(gx0, gy1), getVY(gx0, gy1));
   float w2 = dot(dx1, dy1, getVX(gx1, gy1), getVY(gx1, gy1));
   float w3 = dot(dx1, dy0, getVX(gx1, gy0), getVY(gx1, gy0));
   
   float sx = weigh(dx0);
   float sy = weigh(dy0);
   
   float a = lerp(sy, w0, w1);
   float b = lerp(sy, w2, w3);
   float h = lerp(sx, a, b);
   
   return h;
}

private float weigh(float x) {
   return 3 * (x * x) - 2 * (x * x * x);
}

private float lerp(float w, float a, float b) {
      return a + w * (b - a);
}


The functions getVX and getVY get the respective x and y components of the vectors at the grid points. I'm pretty sure this isn't an issue with random generation of the gradients on the grid points but I can post this code if it will help!

Thanks in advanced  Cheesy!
4  Game Development / Newbie & Debugging Questions / Re: OpenGL Color Blending on: 2014-12-30 09:22:04
I'm still failing to see how this makes a difference, as the color gets applied directly as a color offset to the texture as if it were written like this:

1  
2  
GL11.glColor4f(r, g, b, 1.0f);
GL11.glVertex2f(x, y);


The article you linked discusses the ordering of physical geometry in the scene whereas the light itself is just an applied color offset
5  Game Development / Newbie & Debugging Questions / Re: OpenGL Color Blending on: 2014-12-29 10:25:41
Quote
Is it a problem with one channel being not represented even slightly so it doesn't get shown? Instead of straight blue do something like vec3(0.02, 0.02, 1.0) and see what you get.

It seems that the closer the other channels get to 0, the less visible the lighting effect is on non-grey textures. I found when making light colour: (0.3f, 0.3f, 1.0f) in RGB, the light showed up somewhat, but the blue didn't seem to be blending with the green.

Quote
What order do you draw your objects on to the screen? I suspect you have an issue here

Depending on the order you draw things in the source and destination colors will be different

I render all of the tiles on the map, then the entities. But I don't see why this should make a difference.

Quote
Looks correct. Are you sure your glow/light texture isn't being hidden by the depth test?

There is no texture for a light, it is simply represented as a color offset to the original texture of the tile.
6  Game Development / Newbie & Debugging Questions / Re: OpenGL Color Blending on: 2014-12-28 18:31:20
1  
2  
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);


Is this the wrong one?
7  Game Development / Newbie & Debugging Questions / OpenGL Color Blending on: 2014-12-28 16:56:47
So I've almost finished my tile based colored lighting system for my game, but I'm having an issue when using the color blending.

To set the RGB levels for each tile, I use the following code which is based off my own 'Buffer Object' class:

('bo' is an instance of the buffer object class)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
bo.bindImage(i);
bo.setDepth(Tile.yPosToDepth(y) - 1.0f); //This line is not important to this issue (At least I don't think it is!)
bo.setRGB(r0, g0, b0);
bo.setUV(txmax, tymin);
bo.addVertex(x + tileSize, y + tileSize);
bo.setRGB(r1, g1, b1);
bo.setUV(txmin, tymin);
bo.addVertex(x, y + tileSize);
bo.setRGB(r3, g3, b3);
bo.setUV(txmin, tymax);
bo.addVertex(x, y);
bo.setRGB(r2, g2, b2);
bo.setUV(txmax, tymax);
bo.addVertex(x + tileSize, y);


This gets compiled exactly as you'd expect it to into a VBO. However the colour blending is not working properly when I use textures as shown in this image:



As you can see, the blue only shows up on the grey texture, not on the green.
However when I replace all my tiles with white textures I get the following result:



So the colour blending is working correctly!??!

Please note that green and blue lights are working completely fine, it just seems to be an issue with the blue channel.

Here are my texture loading parameters if it is of any help:

1  
2  
3  
4  
5  
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER,GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER,GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, b);


Also note, that GL_BLEND is enabled, in the images, the player's shirt is green but that is still blending correctly and the random squares are rain, so just ignore them!

Thanks in advance!  Cheesy
8  Games Center / Showcase / [LD29] Cave Runner - A multi monitor game on: 2014-04-29 18:56:44
I created this game in 72 hours with a friend for the Ludum Dare game jam!



So, the idea to use more than one monitor was ambitious and has severe bugs on some multi monitor machines!
As far as I'm aware, the game works fine on all single monitor setups however.

If you have issues with the game and you really are desperate to play (which you shouldn't be as the level design was VERY poor  Grin) you can unplug or disable one of your monitors to just play on one.

Ultimately the game was buggy, unfinished, unpolished and game play wise underwhelming, but I am pleased with our attempt to innovate and try something new!

I'd love to hear what you think of this concept!

Ludum Dare Page
9  Game Development / Newbie & Debugging Questions / Bitmasking with multiple tiles on: 2014-04-16 14:31:47
Just took a look at this really great article post from angryfishstudios: http://www.angryfishstudios.com/2011/04/adventures-in-bitmasking/

My question is, what is the best away to achieve this effect if I had more than 2 types of tiles that all needed to connect into eachother. Would I have to draw out every single possible combination of tiles?

Thanks!
10  Game Development / Newbie & Debugging Questions / Re: New book : Fundamental 2D Game Programming With Java on: 2014-04-15 16:38:00
Would be interested to take a look in this one. Look a bit on the expensive side for me at the moment though :S

By the looks of the preview it uses the default Java2D library but all it boasts in its description is :

Quote
application programming, full-screen games, input handling, matrix transformations, basic physics, intersection testing, collision detection, and much more

Unless the 'much more' really is much more, this doesn't really seem all that worth it. These are the kind of relatively basic things you can find and probably learn more about from internet tutorials and forums
11  Games Center / WIP games, tools & toy projects / Re: Square World on: 2014-02-21 21:06:07
No it is not his code. I just learn how to create a game like that and i create my own. The texture of character is from his tutorial but in version 0.2.0 i will change it

Sounds a bit suspicious if you ask me, you should really just make your own art assets, I mean, these aren't exactly that hard to make o0
12  Game Development / Newbie & Debugging Questions / Re: Random Sprites Showing on: 2014-02-19 12:06:49
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public class User {

    private Code code;

    public static Code getCode() {
        return code;
    }

    public static void main(String[] args) {
        User gibbo3771 = new User();
        System.out.println(gibbo3771.getCode().toString())
    }
}

I get a nullpointerexception.  Emo

Ontop of what trollwarrior suggested, you never actually instantiate the code variable, it should look more like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public class User {

    private Code code = new Code();

    public static Code getCode() {
        return code;
    }

    public static void main(String[] args) {
        User gibbo3771 = new User();
        System.out.println(gibbo3771.getCode().toString())
    }
}
13  Game Development / Newbie & Debugging Questions / Re: Trying to set up a class hierarchy on: 2014-02-18 11:44:21
Maybe try using an init() method to instantiate those variables instead of the constructor like this :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
public class Player extends Entity {
   Texture texture;
   FixtureDef fixtureDef;
   BodyDef bodyDef;
   CircleShape shape;

   public Player(SpriteBatch spriteBatch, World world, float WORLD_TO_BOX, float BOX_TO_WORLD) {
      super();
      //Planned to define texture, fixtureDef, bodyDef and shape and set their attributes here
      super.init(texture, spriteBatch, world, fixtureDef, bodyDef, shape, WORLD_TO_BOX,
            BOX_TO_WORLD);
      // TODO Auto-generated constructor stub
   }

}
14  Game Development / Newbie & Debugging Questions / Re: 2D layering in OpenGL on: 2014-02-13 21:23:45
I suppose you're right, 100 fps is more than enough to run a game on. I'm just concerned about adding more entities to the screen and that slowing down the game even further
15  Game Development / Newbie & Debugging Questions / Re: 2D layering in OpenGL on: 2014-02-13 21:05:34
Realistically speaking, 50 - 30 fps is not really anywhere near good enough for a 2d game  Undecided
16  Game Development / Newbie & Debugging Questions / Re: 2D layering in OpenGL on: 2014-02-13 19:58:17
I think however, although 100 fps is manageable at the moment, in future, the efficiency of that rendering won't be good enough
17  Game Development / Newbie & Debugging Questions / Re: [Math/Geometry/Mesh-Generation] Planetary Surface on: 2014-02-13 18:46:32
So you're struggling to map the points on your noise graph to a 3D mesh?
18  Game Development / Newbie & Debugging Questions / Re: [LIBGDX] skinning a cube with multiple textures on: 2014-02-13 18:43:32
Could we get a full view of your code?
19  Game Development / Newbie & Debugging Questions / Re: 2D layering in OpenGL on: 2014-02-13 18:35:31
I appreciate creating 10 layers would be easy but...

As I mentioned, I need to render each individual body part of each entity on the correct layer which means with a large amounts of entities i need a more dynamic range of layers so instead of having layers 1, 2, 3, 4 etc. I have an each individual z value for each object
20  Game Development / Newbie & Debugging Questions / Re: [Math/Geometry/Mesh-Generation] Planetary Surface on: 2014-02-13 18:33:02
I don't quite understand what you're saying here. Why do you need to generate points in between the 4 edge points in the first place?
21  Game Development / Newbie & Debugging Questions / Re: 2D layering in OpenGL on: 2014-02-13 18:07:46
Hi appreciate your response and I do realize how absurd it really is to use one VBO for each tile  Grin

I appreciate you said you weren't following this thread but the main issue I'm having, is in a large VBO there is no easy way of layering it with other objects outside the VBO.

For example, usually I would write the code like this without VBOs

1  
2  
3  
4  
5  
6  
7  
8  
      for (int y = chunkH - 1; y >= 0; y--) {
         for (int x = chunkW - 1; x >= 0; x--) {
            //render tiles at coordinate
         }
         for (int x = chunkW - 1; x >= 0; x--) {
            //render entites in tiles at coordinate
         }
      }


This meant that all entities were rendered on top of the necessary tiles and behind the tiles that they shouldn't be in front of.

The issue with a big VBO for each chunk of tiles, is that I can't correctly render the entities layered with the tiles.

By my reckoning the only real way to make this work properly is to enable depth testing and use z values the layer things but this is difficult due to a number of issues:
  • Each tile needs to be rendered on a different z value
  • Each entity needs to rendered on a different z value
  • Each entity is made up of multiple body parts so those body parts will also need to be layered correctly and rendered on different z values
  • I also need to have GUI objects rendered on certain layers, but on top of the main world
22  Game Development / Newbie & Debugging Questions / Re: 2D layering in OpenGL on: 2014-02-13 17:44:19
Having switched to immediate mode, I've dropped from around 150fps to 100fps. It would seem in this case an individual VBO for each tile is the most viable option here.

I think, as layering only takes place on the y axis, I will give each row of tiles its own VBO to be rendered on as this seems the most efficient

EDIT

Upon reflection, a depth based management system does seems like a lot of work here but after a bit of thinking, I reckon i might give this a go, giving gui elements and world elements there own individual depth layers
23  Game Development / Newbie & Debugging Questions / Re: 2D layering in OpenGL on: 2014-02-13 17:16:53
Ok thanks  Cheesy

I will try implementing this now and will report back on how I get on
24  Game Development / Newbie & Debugging Questions / Re: 2D layering in OpenGL on: 2014-02-13 07:53:24
Surely generating a vbo for each individually tile is still quicker though?
25  Game Development / Newbie & Debugging Questions / Re: 2D layering in OpenGL on: 2014-02-12 21:24:09
By some vague calculations i reckon i need to render around 4096 at once though  Undecided.

This is really gonna bug me. I will think while I sleep tonight and see if I come up with anything.

Certainly and interesting problem though
26  Game Development / Newbie & Debugging Questions / Re: 2D layering in OpenGL on: 2014-02-12 21:16:52
The project that I'm working on is a tile based RPG game.

I'm not very confident using a shader at the moment, mainly cause i suck at GLSL, but also I would like to emulate some sort of layering system that's reminiscent of the whole 'last rendered is on top' feature.

Effectively I guess what I'm asking is, whats the fastest way to render out a 16 * 16 area of tiles without rendering them all in the same VBO
27  Game Development / Newbie & Debugging Questions / Re: 2D layering in OpenGL on: 2014-02-12 20:55:32
Any ideas on how to manage this system?

I triad incrementing a global z value by 0.0001 so that every time i rendered on object it would be put slightly in front all of the other objects but this doesn't really work as the VBOs are generated once and then have to be fully recompiled to change their z value
28  Game Development / Newbie & Debugging Questions / Re: 2D layering in OpenGL on: 2014-02-12 20:17:33
That was the original plan, but managing all the z values got very messy :S
29  Game Development / Newbie & Debugging Questions / Re: 2D layering in OpenGL on: 2014-02-12 19:16:14
The reason why I switched them to rendering them individually because I needed the entities within the tiles the be rendered on top of each tile, but not rendered on top of the tiles below the entity so the layering is correct. I'm sorry if I'm being to vague I'm really bad at explaining things  Tongue.

If you really want the code i can try and paste it but it is a very long chunk of code with a lot of additional variables and functions not to do with this topic
30  Game Development / Newbie & Debugging Questions / Re: 2D layering in OpenGL on: 2014-02-12 18:00:35
Each tile is a quad with a texture applied to it. Before I had this depth issue, I was adding each chunk (16 * 16) of tiles to one large buffer object, but now I need to render a row of tiles and all of the entities in that row of tiles which will mean making 16 buffer objects for each row in the chunk which seems very inefficient and has caused large frame drops. The entities in that tile usually are made up of around 6 VBO's themselves as each individual part of the entity needs to be manipulated
Pages: [1] 2 3 ... 5
 
Riven (23 views)
2015-04-16 10:48:47

Duke0200 (36 views)
2015-04-16 01:59:01

Fairy Tailz (27 views)
2015-04-14 20:13:12

Riven (29 views)
2015-04-12 21:36:37

bus hotdog (46 views)
2015-04-10 02:39:32

CopyableCougar4 (47 views)
2015-04-10 00:51:04

BurntPizza (46 views)
2015-04-06 22:06:58

ags1 (51 views)
2015-04-02 10:58:48

Riven (49 views)
2015-04-01 18:27:05

ags1 (66 views)
2015-03-31 10:55:12
How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27
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!