From:
bool CBasicItem::VertCollide(float &Ny,float &Vy){ std::vector V; CRect R=CRect(int(X),int(Ny),W,H); Map.Collides(R,V); Items[1].Collides(this,R,V); for(size_t I=0;I { if(V.Layer==ltFore) { if(Vy<0) Ny=float(V.Rect.Y+V.Rect.H); else Ny=float(V.Rect.Y-H); Vy=0; return true; } if(V.Layer==ltMid) { if(int(Y)+H-1.Rect.Y) { if(Vy<0) Ny=float(V.Rect.Y+V.Rect.H); else Ny=float(V.Rect.Y-H); Vy=0; return true; } } } return false;}
to
bool CBasicItem::VertCollide(float &Ny,float &Vy){ std::vector V; CRect R=CRect(int(X),int(Ny),W,H); Map.Collides(R,V); Items[1].Collides(this,R,V); for(size_t I=0;I { if(V.Layer==ltFore || (V.Layer==ltMid && int(Y)+H-1.Rect.Y)) { if(Vy<0) Ny=float(V.Rect.Y+V.Rect.H); else Ny=float(V.Rect.Y-H); Vy=0; return true; } } return false;}
It's actually a good idea to post tricky code in this journal. I find it really handy to read through it at work when away from my compiler.
I also need to improve the code that adds map blocks to the collision vector. I've realised that at the moment it is sampling every point in a grid across and down the rectangle, whereas it only actually needs to sample along the edges.
Both pretty minor stuff really, but I thought if I posted them, that would remind me to do it when I get in.
Out on the razz with some work colleagues tonight so don't expect to get much done, but I should have time to do the above before I get too merry. The second change is going to involve firing up C++ Builder and actually visually plotting the sample points in a TImage to make sure it works before porting the sampling code back into VS I reckon.
[EDIT] Sorted both above issues. Perhaps getting slightly too tipsy to think about any other major changes till tomorrow but the edge tracing algothingy seems to work pretty well.
Are you using texture atlases for you app? I just noticed that my engine is very similar to yours - almost everything is a sprite (quad), and that gets shoved into a dynamic VB once per frame and rendered. Texture atlases (texture sheets as they're know in my engine) let me render (usually) all sprites in a single DrawPrimitive call.
Also, using the GDI fonts aren't that difficult to do either, my engine draws glyphs to a DIB section, then copies that to a texture, and uses vertex alpha to render coloured quads as a text string.
It saves having the fonts pre-generated, and lets you use unicode easily (If that's any use). But it means textured fonts are a bit limited...
Pictures and Pictures + some code