Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 28 Jun 2012
Offline Last Active Feb 04 2013 03:14 PM

Posts I've Made

In Topic: Using tiles for more than just maps?

29 August 2012 - 07:35 AM

its not a good idea to keep a copy of the sprite that each tile represent instead you want to keep just a index of the tiles, what you should do its create a class that works like an atlas and load all the sprites once so you keep just 1 copy of the img, also its not a good idea to test collision against all the currents tiles in the map.

for example if you are going to make the map SIZEX and SIZEY and lets say that you have N tiles images stored in an class call obj.

the class obj could load all the imgs and keep them in a vector or an array for example.

vector<obj> images;

the map is an array of for example short map[SIZEX*SIZEY];

each slot of the array will represent an index to the atlas images array,

lets say that the first tile is grass ID 0 second dirt ID 1 and stone ID 2

the map should be {0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,2,2,2,1,1,1,0,0...

at the moment of rendering the map you will just get the current index in the map and get the image from the atlas with that index.

regarding collision as a said not a good idea to test all the map

read this topic, i alrdy posted something related to collision


In Topic: Smooth player movements?

28 August 2012 - 02:57 PM

yes you can animate a sprite and interpolate each frame as an animation, and move using delta time.

this link is for c++ but you can get the idea http://www.programmersheaven.com/2/time-fps


currentpos += dir*deltatime;

In Topic: Making Chunks load?

27 August 2012 - 09:19 AM


this site has many implementations of LODs algorithms

In Topic: C++: problem erasing vector items

23 August 2012 - 03:09 PM

try something like this, havent t

std::vector<int> somevalues;
std::vector<int> somevaluesTocheck;
bool status = false;

for(int i = 0 ; i < (int)somevaluesTocheck.size() ; i++){

     status = false;

	 for(int j = 0; j < (int)somevalues.size(); j++){

		  if(somevaluesTocheck[i] == somevalues[j]){

			   status = true;



		  somevaluesTocheck.erase(somevaluesTocheck.begin() + i);

In Topic: Raycasting

23 August 2012 - 01:42 PM

I think you should try with ray / plane collision , for example an Axis Aligned box or a OOB

the idea is to cast a ray from the eye or from a click point and check if the ray intersect the plane

a ray is defined by

P= Ro + (Rd*t)

Ro = camera eye for example
Rd = ray dir;
t = distance or time

and a plane (P - Po). n = 0

n = plane normal

(Ro + Rd.t - Po).n = 0
Rd.t.n + (Ro - Po).n = 0

t = (Po - Ro)n / Rd.n

If the line starts outside the plane and is parallel to the plane, there is no intersection. In this case, the above denominator will be zero and the numerator will be non-zero. If the line starts inside the plane and is parallel to the plane, the line intersects the plane everywhere. In this case, both the numerator and denominator above will be zero. In all other cases, the line intersects the plane once and t represents the intersection as the distance along the line from Ro