Re: Sphere SFML v0.75alpha
Reply #133 –
Update:
I just added person talking. It's strange, so Sphere doesn't rely on it's internal input handler for talking. It must rely on the map engine itself to handle keypresses, otherwise you can do stuff while still in a talk script. Also there was a weird issue when drawing the map. Since I'm using the gpu for the camera (fast offsetting), I have to reset the camera so it draws things normally to screen (where (0, 0) is true (0, 0)), anyways I thought it would be simple to implement talking but there were a ot of little design things that got in the way - all corrected now. 
It's remarkably confusing at times exactly how the map engine operates! But I'm glad to emulate it thus far. For example, the talk distance while in pixels is not the actual talk distance. Sphere must add the distance from a sprites origin to their base on top of the distance. This allows a distance of 8 (smaller than the distances between bases) to work. Most Sphere sprites usually have a base of 16x16, if two entities bump into each other with bases of that size - Sphere's default talk distance of 8 would not work, but yet it does. That's because of the base distance it adds on top of that distance. The code for something like that (for those curious) is something like this:
Line[] pBase = person.GetBounds();
int w = (int)(pBase[0].End.X - pBase[0].Start.X);
int h = (int)(pBase[1].End.Y - pBase[1].Start.Y);
float dx = person.Position.X - compare.Position.X;
float dy = person.Position.Y - compare.Position.Y;
double a = Math.Atan2(dy, dx);
dx -= (float)(Math.Cos(a) * w/2);
dy -= (float)(Math.Sin(a) * h/2);
if ((int)Math.Sqrt(dx * dx + dy * dy) <= _talk_dist)
return person.Name;