12.07.2015 Views

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

Implementation of a Peer-to-Peer Multiplayer Game with ... - DVS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

AvatarAn abstract representation <strong>of</strong> an avatar, either belonging <strong>to</strong> the local or a remote player, is provided bythe interface Avatar. The interface defines the basic methods for avatar positioning, which are mostlyequivalent <strong>to</strong> the equally named Entity methods:const vec<strong>to</strong>r3df& getPosition() const Returns the avatar’s current position.const vec<strong>to</strong>r3df& getRotation() const Returns the avatar’s current rotation.const vec<strong>to</strong>r3df& getDestPosition() const Returns the avatar’s destination position (if absolutemovement) or direction (if relative movement).const vec<strong>to</strong>r3df& getDestRotation() const Returns the avatar’s destination rotation (if absolutemovement) or direction (if relative movement).const s32 getPosSpeed() const Returns the avatar’s current translational speed (units/sec).const s32 getRotSpeed() const Returns the avatar’s current rotary speed.const bool movementIsAbsolute() const Returns whether the current destination is absolute (true)or relative (false).void setPosition(const vec<strong>to</strong>r3df& pos) Sets the avatar’s position and s<strong>to</strong>ps its movement.void setRotation(const vec<strong>to</strong>r3df& rot) Sets the avatar’s rotation and s<strong>to</strong>ps its rotation.void moveTo(const vec<strong>to</strong>r3df& pos, s32 speed = -1) Moves the avatar <strong>to</strong> the (absolute) positionpos <strong>with</strong> the given speed (units/sec). The default speed <strong>of</strong> -1 means immediate positioning. UnlikesetPosition(), this method does not affect the position before the next animation step.void moveBy(const vec<strong>to</strong>r3df& direction, s32 speed = -1) Moves the avatar in the given direction<strong>with</strong> the given speed (units/sec if the length <strong>of</strong> direction is 1). Movement will continue until explicitlys<strong>to</strong>pped. Also, the direction vec<strong>to</strong>r is cumulative. Subsequent calls <strong>to</strong> this method will addthe direction vec<strong>to</strong>r; use setPosition() <strong>to</strong> s<strong>to</strong>p the movement.void rotateTo(const vec<strong>to</strong>r3df& rot, s32 speed = -1) Rotates the avatar <strong>to</strong> the (absolute) rotationrot <strong>with</strong> the given speed (units/sec). The default speed <strong>of</strong> -1 means immediate rotation.Unlike setRotation(), movements this method does not affect the rotation before the next animationstep.void rotateBy(const vec<strong>to</strong>r3df& angles, s32 speed = -1) Rotates the avatar <strong>with</strong> the given anglesat the given speed. Rotation will continue until explicitly s<strong>to</strong>pped. Also, the angles vec<strong>to</strong>r is cumulative.Subsequent calls <strong>to</strong> this method will add the angles vec<strong>to</strong>r; use setRotation() <strong>to</strong> s<strong>to</strong>p therotation.irr::s32 getId() Returns the object id which is unique <strong>with</strong>in the application. Note that this valuedoes not identify the player across nodes.SpaceshipThe Spaceship class integrates the Avatar interface <strong>with</strong> Entity, connecting Avatar methods <strong>to</strong> Entity’sfunctionality (see figure 4.3). Furthermore, it is responsible for the spaceship 3D model.From the point <strong>of</strong> view <strong>of</strong> the Irrlicht component, Spaceship is an Entity, thus encapsulating a scenenode and being animated. From the point <strong>of</strong> view <strong>of</strong> the game core, it is primarily seen through the52 4.1 <strong>Game</strong> Architecture

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!