Show Posts
|
|
Pages: [1]
|
|
1
|
Game Development / Game Mechanics / Re: Efficient entity system?
|
on: 2012-06-15 19: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 18: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 17: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 
|
|
|
|
|
4
|
Game Development / Game Mechanics / Tile Management
|
on: 2012-06-15 17: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  .
|
|
|
|
|
6
|
Java Game APIs & Engines / OpenGL Development / [Solved] Lighting problem
|
on: 2011-12-06 21: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); double tileDistance = p1.distance((double) t.getX(), (double) t.getY()); tileDistance /= Tile.SIZE; if (tileDistance > lightDistance) continue; float light = lightDistance; light -= tileDistance; light /= 10; light += Engine.getMap().getLightModifier(); 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 21: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 20: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_GameI 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: 
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|