Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 02 Mar 2011
Offline Last Active Feb 13 2013 12:05 AM

Topics I've Started

How to use git in a mutli-user environment,

25 December 2012 - 11:14 PM

Hello everyone and Merry Christmas,


Me and a friend have started working on some stuff together and we've decided to use git as our version control system. We keep running into issues with fast-forward errors. We're both working in one branch (master) and we often commit and push at the same time.


I'm wondering how we should best make use of egit on eclipse to try and avoid these issues. We're hosting on bitbucket if that helps. Should we both work in local branches then merge them before pushing or something like that?


There is very little information from what I can see on this (maybe I'm just wording it wrong in Google  and I would really appreciate some really in depth articles that describe it well, plus if they have a focus on egit as well that would be awesome, but it's by no means necessary.


Any help would be greatly appreciated. Thanks!

error with seperated matrices and GLSL

01 September 2012 - 06:57 AM


I recently started playing around with OpenGL on C++ and after getting some of the basics, a simple GLSL implementation. I tried to add very slight random noise to some simple shaded polygons, where the colors are described at the vertices (I don't know the proper name for this) in a pyramid.

I made it use FragCoord to get it coords to calculate the noise value, but this uses screen pixels and so the noise would stay the same no matter the prospective you're looking at the model from. I followed the description of a better method described in the top answer here, but this doesn't seem to be working. I can't move the shape around and it's stuck at z=0. I can't change any camera perspectives. I think this may be an error in my GLSL as I'm totally new to it and it's quite alien to me.

Here's an image of my problem. The first is what it's meant to look like (without the noise) the second what it looks like:
Posted Image

Posted Image

Here is my code:

varying vec4 verpos;
float rand2d(vec2 x){
	uint n = floatBitsToUint(x.y * 214013.0 + x.x * 2531011.0);
	n = n * (n * n * 15731u + 789221u);
	n = (n >> 9u) | 0x3F800000u;

	return (2.0 - uintBitsToFloat(n));
float rand3d(vec3 x){
	uint n = floatBitsToUint(x.y * 214013.0 + x.x * 2531011.0 + x.z * 27644437.0);
	n = n * (n * n * 15731u + 789221u);
	n = (n >> 9u) | 0x3F800000u;

	return (2.0 - uintBitsToFloat(n));
void main(void)
vec4 outColor = gl_Color;
outColor *= ((0.2 * rand3d(vec3(verpos.x, verpos.y, verpos.z)) + 0.9);
outColor.w = 1.0;
gl_FragColor = outColor;

uniform mat4 view_matrix;
uniform mat4 model_matrix;

varying vec4 verpos;
void main(){
verpos = model_matrix * gl_Vertex;
gl_FontColor = gl_Color;
gl_Position = gl_ProjectionMatrix * view_matrix * model_matrix * gl_Vertex;

and my render method where I separate my matrices:
void App::render(){
start = SDL_GetTicks();
//Clear the matrices and pixel/depth buffer(s)
//Create model matrix and pass to shader
glTranslatef(x, y, -6.0f);//Modify the world matrix
GLfloat model_matrix_array[16];
glGetFloatv(GL_MODELVIEW_MATRIX, model_matrix_array);
glUniformMatrix4fv(model_matrix, 1, GL_FALSE, model_matrix_array);
//Create view matrix and pass to shader
glRotatef(roty, 1.0f, 0.0f, 0.0f);//Modify the view matrix
glRotatef(rotx, 0.0f, 1.0f, 0.0f);//Modify the view matrix
GLfloat view_matrix_array[16];
glGetFloatv(GL_MODELVIEW_MATRIX, view_matrix_array);
glUniformMatrix4fv(view_matrix, 1, GL_FALSE, view_matrix_array);

  glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
  glVertex3f(0.0f, 0.0f, 1.0f);
  glColor4f(0.0f, 1.0f, 0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);
  glColor4f(1.0f, 0.0f, 0.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);
  glColor4f(1.0f, 1.0f, 0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
  glColor4f(0.0f, 1.0f, 1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
  glColor4f(0.0f, 1.0f, 0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);
  glColor4f(0.0f, 1.0f, 0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);
  glColor4f(1.0f, 0.0f, 0.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);
  glColor4f(1.0f, 1.0f, 0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
  glColor4f(0.0f, 1.0f, 1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
current = SDL_GetTicks();

I'm sorry that this is such a big post but I really hope it doesn't put people off and that someone can help me. I would really appreciate it.


Perlin noise and procedural generation

19 January 2012 - 03:34 AM

I've recently been working on a 2d RPG adventure game in Java. I have world loading among other things and I want to use procedural generation for the landscape of the game world.

I have had no previous experience with procedural generation so this was quite a learning curve for me and I feel I have done fairly well. I finally managed to make a Perlin noise demo with help from this article here and I'm fairly happy of the result (that demo uses a persistence of 1 and 8 octaves).

Here is the code for my Perlin noise. It's very fast to generate compared to some of the other algorithms I've tried. Im using a linear interpolate method because I don't notice the difference between a cos one except for the fact that linear is MUCH quicker...

double[][] genWhiteNoise(){
  Random random = new Random(seed);
  double[][] noise = new double[width][height];

  for(int x  = 0; x < width; x++){
   for(int y = 0; y < height; y++){
	noise[x][y] = random.nextDouble() % 1;

  return noise;

double[][] generateSmoothNoise(double[][] baseNoise, int octave){
  double[][] smoothNoise = new double[width][height];

  int samplePeriod = 1 << octave;
  double sampleFrequency = 1.0f / samplePeriod;

  for(int x  = 0; x <  width; x++){
   int sample_x0 = (x / samplePeriod) * samplePeriod;
   int sample_x1 = (sample_x0 + samplePeriod) % width;
   double horizontal_blend = (x  - sample_x0) * sampleFrequency;
   for(int y = 0; y < height; y++){
	int sample_y0 = (y / samplePeriod) * samplePeriod;
	int sample_y1 = (sample_y0 + samplePeriod) % height;
	double vertical_blend = (y - sample_y0) * sampleFrequency;
	double top = interpolate(baseNoise[sample_x0][sample_y0], baseNoise[sample_x1][sample_y0], horizontal_blend);
	double bottom = interpolate(baseNoise[sample_x0][sample_y1], baseNoise[sample_x1][sample_y1], horizontal_blend);
	smoothNoise[x][y] = interpolate(top, bottom, vertical_blend);

  return smoothNoise;

double[][] perlinNoise(double[][] baseNoise, int octaveCount){
  double[][][] smoothNoise = new double[octaveCount][][];

  for(int i = 0; i < octaveCount; i++){
   smoothNoise[i] = generateSmoothNoise(baseNoise, i);

  double[][] perlinNoise = new double[width][height];
  double amplitude = 1.0;
  double totalAmplitude = 0.0d;

  for(int octave = octaveCount - 1; octave >= 0; octave--){
   amplitude *= persistance;
   totalAmplitude += amplitude;
   for(int x = 0; x < width; x++){
	for(int y = 0; y < height; y++){
	 perlinNoise[x][y] += smoothNoise[octave][x][y] * amplitude;

  for(int x = 0; x < width; x++){
   for(int y = 0; y < height; y++){
	perlinNoise[x][y] /= totalAmplitude;

  return perlinNoise;

First off, can someone please tell me if the noise I have generated if suitable for random world generation or if it's not, can they give me some tips and/or links to good examples.

and second, can someone please tell me a good place to start for turning that Perlin noise into a game world. I am using a tile based system and i plan on having mountains, sand dunes, forests and cities (they wont be randomly generated but they will have a random location in the world based on some placement parameters).

Any help would be very much appreciated.

Export JAR using slick with Eclipse

11 December 2011 - 10:12 PM

Hello Everyone.

I've just started working on a new project and I was just checking the export as Jar to make sure that it works. It's a good thing that I did because for some reason I cant get Eclipse to properly export my project.

Im using slick2d which is stored in a folder in my root project directory. (this also contains lwjgl.jar and all the win 64x natives)

I have tried playing round with a few setting in the export as jar option and I have also tried export as runnable jar.

When I export as 'jar', when I try to open the jar it says "Could not find the main class: com.thecreeperlawyer.enginedemo.EngineDemo. Program will exit.". I have looked into the jar with winrar and the manifest seems to say the right thing (from my limited knowledge of manifests) and I can also find "com\thecreeperlawyer\enginedemo\EngineDemo.class".

When I export as 'runnable jar', when I open it nothing happens.

Could someone please tell me, or provide a thorough tutorial on how to properly export a slick2D/LWJGL project from Eclipse.

Also if anyone could provide (if the tutorial doesn't) the best way to export the libs (slick2d.jar, LWJGL.jar and the natives) that would be very much appreciated.


Java Null Pointer Exception

31 October 2011 - 10:57 PM


I'm currently working a a 2D dungeon crawler game. I have a tile based system with a Tile class. This contains a whole heap of public static Tile. The problem is, when I try to access these from anywhere, I get a Null pointer Exception. I don't how i get this though since I quite clearly instatiate the variables. Heres the code

public static Tile backgroundRock;
	public static Tile bars;
	public static Tile dirt;
	public static Tile grass;
	public static Tile grill;
	public static Tile platform;
	public static Tile rock;
	public static Tile shaft;
	public static Tile table;
	public static Tile water;
		bars = new TileBars(0, 0, 0x404040);
		dirt = new TileDirt(1, 1, 0x7F3300);
		grass = new TileGrass(2, 2, 0x267F00);
		grill = new TileGrill(3, 3, 0x3F2F2F);
		rock = new TileRock(4, 4, 0x808080);
		shaft = new TileShaft(5, 5, 0xFFD800);
		table = new TileTable(6, 6, 0xFF4300);
		water = new TileWater(7, 7, 0x0094FF);
		platform = new TilePlatform(8, 8, 0x423300);
		backgroundRock = new TileBackRock(9, 9, 0xFFFCF4);

Please help, is there something I'm missing...