Jump to content

  • Log In with Google      Sign In   
  • Create Account

Wrathnut

Member Since 02 Feb 2000
Offline Last Active Oct 17 2014 03:27 PM

Posts I've Made

In Topic: collision detection, 2d platformer

21 March 2014 - 02:02 PM

The above solutions are the common ones used. If your objects are moving extremely fast you might want to consider casting a ray from the 4 corners of your bounding box from the old position to the corresponding corner in the new position. The collision ray with the smallest magnitude (if any)  is where you will need to resolve your collision and impart any forces on the colliding objects.


In Topic: AI Visibility test in 2D

22 August 2013 - 10:10 AM

Actually your suggestion seems quite sound. Using an AAB that completely encompasses your AI's FOV could be done for a quick check to see if the player could be in the enemy AI's FOV. Then perform a raycast from the enemy to the player to determine if the player is actually in the line of sight of the enemy. Raycasting can be done using DDA. Which is pretty quick if you are only casting one ray.

 

I am not sure about your layer concept. If you mean the upper halfof the screen is a different layer vs the lower half. Then the same grid or matrix you use for collision detection is the same one you cast your ray into.


In Topic: C++ Help

18 March 2013 - 08:29 PM

Serapth I actually did look into using maps when I was first designing my systems apparently I didn't look hard enough at maps. I am genuinely surprised that it doesn't get slower as the list gets larger I will have to look into it a bit more.

 

And Thank you EwClay for the example.


In Topic: C++ Help

18 March 2013 - 03:03 PM

I might beg to differ a bit. But it is only a minor quible. My system has the flexibility to look up versus name or ID and as simple name value pair isn't quite what I desire. I am comparing several things in my search not just a name. That and I am not particlulary fond of the syntax for iterators. But that is preference as far as I am concerned.

 

If it works and gives you the performance you need then use it.  A map or a vector is just the vehicle to get the job done.

 

BitMaster answered the question as to why it was not working I was just showing him how he can use his current system by just comparing a string value.

 

I would like to ask how my imlementation is more error prone. I am assuming you meant to say, "There are two reasons for this, first the map will simplify your code and as a result make it less error prone and easier to maintain."

 

I am not try to start an argument but I am always trying to learn new things or techniques.


In Topic: C++ Help

18 March 2013 - 11:07 AM

For my C++/SDL 2d game I am doing the same sort of thing where I have a manager that keeps a vector list of gracphics objects and can render them according to an ID or a string name. For you to compare string values you have to do a

.compare(value)==0

 

I store an name, ID and an image type in my graphics object. The ID or name are referencing the owner of the image. The type refers to a standard image type. This can easily be associated with an animation list so that current images from a running animation can be pulled from the library.

 

Here is one of my routines for rendering images

 

void gFXManager::renderImage(SDL_Surface *screen, string name, int type, int x, int y){
	
	for(int i=0; i < this->gFXList.size(); i++){
		if(this->gFXList[i]->getName().compare(name)==0 && this->gFXList[i]->getType()==type){
			//Render the image to the surface
			this->gFXList[i]->drawImage(screen, x, y);
			break;
		}
	}
}

PARTNERS