Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  Game Development / Game Mechanics / Re: Efficient entity system? on: 2012-06-15 17:04:33
As opposed to an entity system which forces you to branch of entities which could have similar properties, a component based entity system allows an entity to implements certain functionality instead of everything above in the hierarchichal ladder.

for example a monster could implement this functionality: attackable, interactable, living.
instead of just branching down through: entity>living>attackable>monster etcetera.
2  Game Development / Game Mechanics / Re: Tile Management on: 2012-06-15 16:00:12
idea 3 is sort of what i'm working off now, and idea 4 could work for some primitive tiles but i'm looking for a bit more functionality, e.g. tiles will interact with the player.
3  Game Development / Game Mechanics / Re: Tile Management on: 2012-06-15 15:54:36
that idea of having a tiletype and each tile having a reference to a tiletype is EXACTLY how i have it atm, named the same, exactly the same code and everything lmao. Thanks and I'll probably go from this and work out the kinks as they arrive but if anybody has any better ideas hit me up Smiley
4  Game Development / Game Mechanics / Tile Management on: 2012-06-15 15:17:45
Hey, i'm in the early process of writing a side-scrolling tile based game, and i have been trying to figure out which is the best way of caching tiles.

Idea 1:
I would store an instance of a tile class such as grass for every tile in the game (sounds very costly), this allows each tile to have its own unique properties (still being a subset of grass ofcourse).

Idea 2:
I would store the id of every tile in the game, and use a tile lookup table to retrieve a singleton instance of that tile, this option seems to be more fitting however then each tile of the same type must be the same globally, and couldn't have different properties to other grass tiles.

Which idea would be the most viable, and if you have a better idea, please feel free to share it Smiley.
5  Java Game APIs & Engines / OpenGL Development / Re: Lighting problem on: 2011-12-09 21:30:15
<3!

Thanks alot for the info!
6  Java Game APIs & Engines / OpenGL Development / [Solved] Lighting problem on: 2011-12-06 20:33:10
I've been working on my per-tile lighting system, currently it is very simple and supports coloured lighting.

PROBLEM 1:
I started to notice that lighting wouldn't work for random tiles, here is an example:



At first i thought it was a problem in my tiling system, however if i disabled lighting the tiles were fine.

Here is my lighting code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
   public void updateLightValues() {
      for (Tile t : Engine.getMap().getVisibleTiles()) {
         Point p1 = new Point((int) x, (int) y);//Player coordinates
        double tileDistance = p1.distance((double) t.getX(), (double) t.getY());//the distance from the player to the tile
        tileDistance /= Tile.SIZE;//tiles are 16x16 therefore this is the amount of tiles between the player and the tile.
        if (tileDistance > lightDistance) continue;//if the distance is further than the light source's max distance, skip this tile.
        float light = lightDistance;//the initial light value (alpha value)
        light -= tileDistance;
         light /= 10;
         light += Engine.getMap().getLightModifier();//currently getlightmodifier() returns 0.
        if (light < 0) light = 0;
         if (light > 1) light = 1;

         float a = light + t.getLightValue() * (1 - light);
         float r = ((red * a) + (t.getLightRed() * t.getLightValue())) / a;
         float g = ((green * a) + (t.getLightGreen() * t.getLightValue())) / a;
         float b = ((blue * a) + (t.getLightBlue() * t.getLightValue())) / a;
         t.setLightValues(r, g, b, a);
      }
   }


That method is called every tick and will update light values around the light source.
Note that a light is represented by a LightSource, and the lightsource class holds all variables including this method.

PROBLEM 2:
My second problem is with the colour blending. It seems that a light source will blend into another light source, however the light source it's blending into won't be counter-blended, producing a weird blend like this:



Thankyou for your time.
7  Java Game APIs & Engines / OpenGL Development / Re: Alpha blending problem on: 2011-11-26 20:03:11
yes, positive, i even loaded 2 textures just to check if that was the problem.

EDIT: I checked if the image had an alpha channel in the texture loader and it says it doesn't, however photoshop/gimp/image viewser all say it does.

EDIT2: Problem solved, textureloader loads the image as an image icon due to 'signed code' and then paints it onto a bufferedimage which has a predefined rgb not argb color space.
8  Java Game APIs & Engines / OpenGL Development / [Solved] Alpha blending problem on: 2011-11-26 19:46:25
Hey, i'm quite new to lwjgl/opengl however i've been writing games in java2d for quite awhile now. So anyways, this is my problem:

I've been trying to get alpha blending to work for the past 2 days, i've searched endlessly and tried a million different solutions, and i have a weird feeling it's a very stupid mistake on my behalf, the texture i'm rendering are simply black where it should be transparent.

NOTE: To load and store texture data i'm using the texture class and loader used here: http://lwjgl.org/wiki/index.php?title=Space_Invaders_Example_Game
I have checked the textureloader class and it does load textures with RGBA. Also i tried setting the blend mode to (gl_one, gl_one) and i can see that it does infact blend with that mode.


Here is my gl init code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
   public void initGL() {
      Engine.debug("Initialising OpenGL");
     
      GL11.glMatrixMode(GL11.GL_PROJECTION);
      GL11.glLoadIdentity();
      GL11.glOrtho(0, WIDTH, HEIGHT, 0, -1, 1);
      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glLoadIdentity();
      GL11.glViewport(0, 0, WIDTH, HEIGHT);
     
      GL11.glDisable(GL11.GL_DEPTH_TEST);
      GL11.glEnable(GL11.GL_TEXTURE_2D);
      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
      GL11.glEnable(GL11.GL_BLEND);
     
      Engine.debug("OpenGL Initialised!");
   }


and here is my rendering code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
public void drawTexture(Texture texture, int x, int y, int width, int height) {
      GL11.glPushMatrix();
     
      texture.bind();
     
      GL11.glTranslatef(x, y, 0);
      GL11.glBegin(GL11.GL_QUADS);
     
      GL11.glTexCoord2f(0, 0);
      GL11.glVertex2f(0, 0);
     
      GL11.glTexCoord2f(0, texture.getHeight());
      GL11.glVertex2f(0, height);
     
      GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
      GL11.glVertex2f(width, height);
     
      GL11.glTexCoord2f(texture.getWidth(), 0);
      GL11.glVertex2f(width, 0);
     
      GL11.glEnd();
      GL11.glPopMatrix();
   }


And finally, here is a screenshot of how it looks:

Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (22 views)
2014-09-19 03:14:18

Dwinin (35 views)
2014-09-12 09:08:26

Norakomi (63 views)
2014-09-10 13:57:51

TehJavaDev (90 views)
2014-09-10 06:39:09

Tekkerue (44 views)
2014-09-09 02:24:56

mitcheeb (65 views)
2014-09-08 06:06:29

BurntPizza (48 views)
2014-09-07 01:13:42

Longarmx (35 views)
2014-09-07 01:12:14

Longarmx (40 views)
2014-09-07 01:11:22

Longarmx (37 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59: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!