Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 08 Mar 2004
Offline Last Active Today, 10:51 AM

Posts I've Made

In Topic: 2D Plain/layer Shift Game Play Mechanics

26 July 2016 - 11:03 AM

Unfortunate timing of me reading this post.. I need to stop killing the end of my day with this forum :)


Ive never used melonJS, but from looking at the homepage, it mentions 'Multiple layers with parallax scrolling' I also see mentions of z sorting


This would suggest there is someway to set up multiple layers - ie one layer for each map, and even if there was a restriction on how many tilemaps you could load - you could always store the background map in the first half of the array, and the background map in the second half. Obviously not the most ideal solution, but something that may work as a quick suggestion


It might just be easier to use another one of the engines you have mentioned - but just thought id mention the above if you felt like melonJS is something you like, as to not prematurely drop it

In Topic: 2D Plain/layer Shift Game Play Mechanics

25 July 2016 - 11:03 AM



This just looks like there are two tilemaps at play, so using one for a forground, and one for a background.





player_position_forgroundX = player_postionX / 20;

player_position_backgroundX = player_postionX / 40;


player_position_forgroundY = player_postionY / 10;

player_position_backgroundY = player_postionY / 20;


and when the witch occurs you are just using a smaller image / scaled image, and display it on the toggled map.


This is an overly basic explanation, as im just finished work now and about to run out the door :)

In Topic: Generate terrain once given the heightmap

28 June 2016 - 01:18 AM

The pixelation is probably to do with your texture setup, have a look here at the section describing GL_NEAREAST and GL_LINEAR http://learnopengl.com/#!Getting-started/Textures ( or just at the whole site in general, its a great resource :) )


edit: fixed link

edit: edit: didnt fix link

In Topic: Generate terrain once given the heightmap

27 June 2016 - 10:25 AM



It can be hard to tell if your calculations are a bit off (cant do them in my head :) ) or what affect the 'up' value is having against your z value. But id find something like the following a little easier, altough not tested


      float scale = 10.f;
      float height = (float)img.data[i] / 255.0f;
      for( int z = 0; z < img.height; z++ )
          for( int x = 0; z < img.width; x++ )
            model->vertices.push_back(glm::vec3(  x    * scale, height * scale,  z    * scale ));
            model->vertices.push_back(glm::vec3( (x+1) * scale, height * scale,  z    * scale ));
            model->vertices.push_back(glm::vec3( (x+1) * scale, height * scale, (z+1) * scale ));
            model->vertices.push_back(glm::vec3(  x    * scale, height * scale,  z    * scale ));
            model->vertices.push_back(glm::vec3(  x    * scale, height * scale, (z+1) * scale ));
            model->vertices.push_back(glm::vec3( (z+1) * scale, height * scale, (z+1) * scale ));


As for ruling out problems with your own, try slap glPolygonMode( GL_FRONT, GL_LINE ); above your rendering, and it will display it as a wiremesh - you should then atleast see how your triangles look beneath the surface.


Maybe just try drawing it all using points first - get the calculations correct - and then move onto triangles when you are happy. you can make the point size bigger using glPointSize(5.f);


Sorry i cant help anymore at the minute, but keep at it!

In Topic: How the 'perspective division' should be done?

11 January 2016 - 09:46 AM

Just wanted to add in some links that may be useful, all tough not exactly relevant to SDL, I found this to be an easy to follow description of the perspective divide http://learnopengl.com/#!Getting-started/Coordinate-Systems , and if you wish to delve into the maths a bit more, the following is worth a look, https://unspecified.wordpress.com/2012/06/21/calculating-the-gluperspective-matrix-and-other-opengl-matrix-maths/ . As said above, it looks like your error is dividing by z, which is the wrong value and probably producing some bizare results based solely on where the items are placed on the scene.