diff options
Diffstat (limited to 'src/crepe/api')
| -rw-r--r-- | src/crepe/api/Animator.cpp | 1 | ||||
| -rw-r--r-- | src/crepe/api/Animator.h | 32 | ||||
| -rw-r--r-- | src/crepe/api/LoopManager.cpp | 6 | ||||
| -rw-r--r-- | src/crepe/api/Sprite.cpp | 5 | ||||
| -rw-r--r-- | src/crepe/api/Sprite.h | 8 | 
5 files changed, 33 insertions, 19 deletions
| diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index 45f67f6..7fe49ee 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -18,7 +18,6 @@ Animator::Animator(game_object_id_t id, Sprite & ss, int row, int col, int col_a  	this->spritesheet.mask.w /= row;  	this->spritesheet.mask.x = 0;  	this->spritesheet.mask.y = col_animator * this->spritesheet.mask.h; -	this->active = false;  	// need to do this for to get the aspect ratio for a single clipping in the spritesheet  	this->spritesheet.aspect_ratio diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h index 6c506aa..ede450a 100644 --- a/src/crepe/api/Animator.h +++ b/src/crepe/api/Animator.h @@ -18,11 +18,6 @@ class SDLContext;  class Animator : public Component {  public: -	//TODO: need to implement this -	void loop(); -	void stop(); - -public:  	/**  	 * \brief Constructs an Animator object that will control animations for a sprite sheet.  	 * @@ -57,15 +52,32 @@ private:  	//! The current row being animated.  	int curr_row = 0; -	//TODO: Is this necessary? -	//int fps; +	//! should the animation loop +	bool looping = false; + +	//! starting frame for cycling +	int cycle_start = 0; + +	//! end frame for cycling (-1 --> use last frame) +	int cycle_end = -1; + +	//! frames per second for animation +	int fps = 1; + +	int offset_x = 0; + +public: +	void loop() { this->looping = true; } +	void play() {this->active = true;} +	void pause() {this->active = false;} +	void stop() {this->active = false; this->curr_col = 0; this->curr_row = 0;} +	void set_fps(int fps) {this->fps = fps;} +	void set_cycle_range(int start, int end) {this->cycle_start = start, this->cycle_end = end;} +	void set_anim(int col) {this->curr_row = 0; this->curr_col = col; }  private:  	//! AnimatorSystem adjust the private member parameters of Animator;  	friend class AnimatorSystem; - -	//! SDLContext reads the Animator member var's -	friend class SDLContext;  };  } // namespace crepe  // diff --git a/src/crepe/api/LoopManager.cpp b/src/crepe/api/LoopManager.cpp index 7edf4d1..88ca704 100644 --- a/src/crepe/api/LoopManager.cpp +++ b/src/crepe/api/LoopManager.cpp @@ -58,6 +58,7 @@ void LoopManager::setup() {  	this->game_running = true;  	LoopTimer::get_instance().start();  	LoopTimer::get_instance().set_fps(200); +	this->scene_manager.load_next_scene();  }  void LoopManager::render() { @@ -66,4 +67,7 @@ void LoopManager::render() {  	}  } -void LoopManager::update() { LoopTimer & timer = LoopTimer::get_instance(); } +void LoopManager::update() {  +	LoopTimer & timer = LoopTimer::get_instance();  +	this->get_system<AnimatorSystem>().update(); +} diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp index 1d57b53..29e415f 100644 --- a/src/crepe/api/Sprite.cpp +++ b/src/crepe/api/Sprite.cpp @@ -6,19 +6,20 @@  #include "Component.h"  #include "Sprite.h"  #include "Texture.h" +#include "types.h"  using namespace std;  using namespace crepe;  Sprite::Sprite(game_object_id_t id, Texture & image, const Color & color, -			   const FlipSettings & flip, int sort_layer, int order_layer, float height) +			   const FlipSettings & flip, int sort_layer, int order_layer, const vec2 & size)  	: Component(id),  	  color(color),  	  flip(flip),  	  sprite_image(std::move(image)),  	  sorting_in_layer(sort_layer),  	  order_in_layer(order_layer), -	  height(height) { +	  size(size) {  	dbg_trace(); diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h index 7d9c14b..f04f70c 100644 --- a/src/crepe/api/Sprite.h +++ b/src/crepe/api/Sprite.h @@ -1,11 +1,10 @@  #pragma once -#include <cstdint> -  #include "../Component.h"  #include "Color.h"  #include "Texture.h" +#include "types.h"  namespace crepe { @@ -41,7 +40,7 @@ public:  	 * \param height the height of the image in game units  	 */  	Sprite(game_object_id_t id, Texture & image, const Color & color, -		   const FlipSettings & flip, int sort_layer, int order_layer, float height); +		   const FlipSettings & flip, int sort_layer, int order_layer, const vec2 & size);  	/**  	 * \brief Destroys the Sprite instance. @@ -62,8 +61,7 @@ public:  	//! Order within the sorting layer  	const int order_in_layer; -	//! height in world units -	const float height; +	vec2 size;  	/**  	 * \aspect_ratio ratio of the img so that scaling will not become weird |