http://members.chello.at/ennemoser/tloz%20the%20tower%204.01.627.rar
(newest build! I had to remake it!- so some old features are gone atm )
here is a screenshot:
http://members.chello.at/ennemoser/consolv4.jpg
Here is it! :) If you guys get strange errors, then please tell me what's in the logfile! :)
delta_x and delta_y
// this way ? 0o.. :3const float delta_x = player_x - monster_x;const float delta_y = player_y - monster_y;if( delta_x > 0 ){ face = Right;}else if( delta_x < 0 ){ face = Left;}if( delta_y > 0 ){ face = Down;}else if( delta_y < 0 ){ face = Up;}// HMM.. :)
it works fine if the monster moves up or down.. but still the same bug if it moves right or left! :/ well.. :p
when should I compare delta_x and y? help please!
same bug:
bool CMonster::think( SDL_Surface* screen, boost::shared_ptr<CMap> map_col, const int scroll_x, const int scroll_y, const float dTime, const float player_x, const float player_y, const int player_w, const int player_h ){ velx = 0.0f; vely = 0.0f; int tilecoord; if( foundPlayerX( player_x ) == true ) { if( player_x > x ) { velx = (dTime*m_speed); } else if( player_x < x ) { velx = -(dTime*m_speed); } else velx = 0.0000f; if(velx > 0) { if( collision_ver(x+w, y, tilecoord, velx, map_col)) { x = tilecoord*21 -w-1; } else { x += velx; } } else if(velx < 0) { if(collision_ver(x+velx, y, tilecoord, velx, map_col)) { x = (tilecoord+1)*21 +1; } else { x += velx; } } const float delta_x = player_x - x; if( delta_x > 0 ) { face = Right; } else if( delta_x < 0 ) { face = Left; } } if( foundPlayerY( player_y ) == true ) { if( player_y > y ) { vely = (dTime*m_speed); } else if( player_y < y ) { vely = -(dTime*m_speed); } else { vely = 0.0000f; } if(vely < 0) { if( collision_hor( x, y+vely, tilecoord, map_col )) { y = (tilecoord+1)*21 +1; } else { y += vely; } } else if( vely > 0 ) { if( collision_hor(x, y+vely+h, tilecoord, map_col) ) { y = tilecoord*21 -h-1; } else { y += vely; } } // change face const float delta_y = player_y - y; if( delta_y > 0 ) { face = Down; } else if( delta_y < 0 ) { face = Up; } } draw( screen, scroll_x, scroll_y ); return false;}
[Edited by - rakoon2 on September 2, 2004 9:22:53 AM]