// Copyright (c) 2014 Alex Diener. All rights reserved. #ifndef __PlayerModel_H__ #define __PlayerModel_H__ #ifdef __cplusplus extern "C" { #endif typedef struct PlayerModel PlayerModel; #include "gamemath/Vector2f.h" #include "gamemath/Vector2i.h" #include "stemobject/StemObject.h" #include "watertowerclassic/LevelModel.h" #define PLAYER_WIDTH 8 #define PLAYER_HEIGHT 16 #define PLAYER_MAX_WALK_SPEED 1.5f #define PLAYER_JUMP_VELOCITY -4.25f #define PLAYER_MAX_FALL_SPEED 7.75f #define PLAYER_INITIAL_LIVES 3 #define PLAYER_MAX_LIVES 10 #define PLAYER_BREATH_DURATION 900 enum PlayerAnimationState { animStateStandFront, animStateStandBack, animStateStandLeft, animStateStandRight, animStateClimb1, animStateClimb2, animStateClimb3, animStateClimb4, animStateRunLeft1, animStateRunLeft2, animStateRunLeft3, animStateRunLeft4, animStateRunRight1, animStateRunRight2, animStateRunRight3, animStateRunRight4, animStateJumpLeft, animStateJumpRight, animStateJumpFront, animStateJumpBack }; enum PlayerAbstractAnimationState { abstAnimStand, abstAnimRunLeft, abstAnimRunRight, abstAnimClimb, abstAnimJump, abstAnimStandFront, abstAnimStandBack }; #define PlayerModel_structContents(self_type) \ StemObject_structContents(self_type) \ \ Vector2i tileLocation; \ Vector2f pixelLocation; \ float hVel; \ float vVel; \ struct LevelBlock * standingOn; \ bool underwater; \ char ladderIntention; \ char jumpIntention; \ bool onLadder; \ long airLeft; \ short numberOfKeys; \ short numberOfPoints; \ long totalPoints; \ short numberOfLives; \ char animationState; \ long animationCounter; \ int opacity; \ bool fadingIn; \ LevelModel * levelModel; \ \ void (* update)(self_type * self); \ void (* startMovingLeft)(self_type * self); \ void (* startMovingRight)(self_type * self); \ void (* startMovingDown)(self_type * self); \ void (* startMovingUp)(self_type * self); \ void (* stopMovingLeft)(self_type * self); \ void (* stopMovingRight)(self_type * self); \ void (* stopMovingDown)(self_type * self); \ void (* stopMovingUp)(self_type * self); \ void (* jump)(self_type * self); \ void (* action)(self_type * self); \ void (* setAnimationState)(self_type * self, enum PlayerAbstractAnimationState abstractState); \ const char * (* getSpriteName)(self_type * self); stemobject_struct_definition(PlayerModel) PlayerModel * PlayerModel_create(LevelModel * levelModel); bool PlayerModel_init(PlayerModel * self, LevelModel * levelModel); void PlayerModel_dispose(PlayerModel * self); void PlayerModel_update(PlayerModel * self); void PlayerModel_startMovingLeft(PlayerModel * self); void PlayerModel_startMovingRight(PlayerModel * self); void PlayerModel_startMovingDown(PlayerModel * self); void PlayerModel_startMovingUp(PlayerModel * self); void PlayerModel_stopMovingLeft(PlayerModel * self); void PlayerModel_stopMovingRight(PlayerModel * self); void PlayerModel_stopMovingDown(PlayerModel * self); void PlayerModel_stopMovingUp(PlayerModel * self); void PlayerModel_jump(PlayerModel * self); void PlayerModel_action(PlayerModel * self); void PlayerModel_setAnimationState(PlayerModel * self, enum PlayerAbstractAnimationState abstractState); const char * PlayerModel_getSpriteName(PlayerModel * self); #ifdef __cplusplus } #endif #endif