diff --git a/source/enemy/npcpath.cpp b/source/enemy/npcpath.cpp new file mode 100644 index 000000000..b93903da1 --- /dev/null +++ b/source/enemy/npcpath.cpp @@ -0,0 +1,45 @@ +/*========================================================================= + + npcpath.cpp + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2000 Climax Development Ltd + +===========================================================================*/ + +bool CNpcWaypoint::isPointNear( DVECTOR testPos ) +{ + s32 xDistSqr, yDistSqr; + + xDistSqr = testPos.vx - this->pos.vx; + xDistSqr *= xDistSqr; + + yDistSqr = testPos.vy - this->pos.vy; + yDistSqr *= yDistSqr; + + if ( xDistSqr + yDistSqr < 100 ) + { + return( true ); + } + else + { + return( false ); + } +} + +void CNpcPath::addWaypoint( DVECTOR newPos ) +{ + if ( waypointCount < NPC_MAX_WAYPOINTS ) + { + waypoint[waypointCount] = newPos; + waypointCount++; + } +} + + void setPathType( NPC_PATH_TYPE newPathType ); + bool incPath(); +bool CNpcPath::incPath \ No newline at end of file diff --git a/source/enemy/npcpath.h b/source/enemy/npcpath.h new file mode 100644 index 000000000..08ac5ccf2 --- /dev/null +++ b/source/enemy/npcpath.h @@ -0,0 +1,46 @@ +/*========================================================================= + + npcpath.h + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2000 Climax Development Ltd + +===========================================================================*/ + +class CNpcWaypoint +{ +public: + DVECTOR pos; + + bool isPointNear( DVECTOR testPos ); +}; + +enum NPC_PATH_TYPE +{ + SINGLE_USE_PATH = 0, + REPEATING_PATH = 1, + PONG_PATH = 2, +}; + +class CNpcPath +{ + enum + { + NPC_MAX_WAYPOINTS = 4, + }; + +private: + CNpcWaypoint waypoint[NPC_MAX_WAYPOINTS]; + NPC_PATH_TYPE pathType; + u8 currentWaypoint; + u8 waypointCount; + +public: + void addWaypoint( DVECTOR newPos ); + void setPathType( NPC_PATH_TYPE newPathType ); + bool incPath(); +}; \ No newline at end of file