1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
/*
** ClanLib SDK
** Copyright (c) 1997-2005 The ClanLib Team
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any damages
** arising from the use of this software.
**
** Permission is granted to anyone to use this software for any purpose,
** including commercial applications, and to alter it and redistribute it
** freely, subject to the following restrictions:
**
** 1. The origin of this software must not be misrepresented; you must not
** claim that you wrote the original software. If you use this software
** in a product, an acknowledgment in the product documentation would be
** appreciated but is not required.
** 2. Altered source versions must be plainly marked as such, and must not be
** misrepresented as being the original software.
** 3. This notice may not be removed or altered from any source distribution.
**
** Note: Some of the libraries ClanLib may link to may have additional
** requirements or restrictions.
**
** File Author(s):
**
** Magnus Norddahl
** (if your name is missing here, please add it)
*/
#include "Display/display_precomp.h"
#include "API/Core/System/system.h"
#include "sprite_generic.h"
/////////////////////////////////////////////////////////////////////////////
// CL_Sprite_Generic construction:
CL_Sprite_Generic::CL_Sprite_Generic() :
angle(0.0f),
angle_pitch(0.0f),
angle_yaw(0.0f),
base_angle(0.0f),
scale_x(1.0f),
scale_y(1.0f),
red(1.0f),
green(1.0f),
blue(1.0f),
alpha(1.0f),
blend_src (blend_src_alpha),
blend_dest (blend_one_minus_src_alpha),
blendfunc_src_alpha (blend_src_alpha),
blendfunc_dest_alpha(blend_one_minus_src_alpha),
translation_hotspot(0,0),
rotation_hotspot(0,0),
translation_origin(origin_top_left),
rotation_origin(origin_center),
current_frame(0),
delta_frame(1),
update_time(0),
last_time(0),
id(0),
finished(false),
looping(false),
play_loop(true),
play_backward(false),
play_pingpong(false),
show_on_finish(CL_Sprite::show_blank)
{
}
CL_Sprite_Generic::~CL_Sprite_Generic()
{
}
/////////////////////////////////////////////////////////////////////////////
// CL_Sprite_Generic attributes:
CL_Sprite_Generic::SpriteFrame *CL_Sprite_Generic::get_frame(unsigned int index)
{
if(index >= 0 && index < frames.size())
return &frames[index];
else
return NULL;
}
/////////////////////////////////////////////////////////////////////////////
// CL_Sprite_Generic operations:
CL_Sprite_Generic &CL_Sprite_Generic::operator =(const CL_Sprite_Generic ©)
{
angle = copy.angle;
angle_pitch = copy.angle_pitch;
angle_yaw = copy.angle_yaw;
base_angle = copy.base_angle;
scale_x = copy.scale_x;
scale_y = copy.scale_y;
red = copy.red;
green = copy.green;
blue = copy.blue;
alpha = copy.alpha;
blend_src = copy.blend_src;
blend_dest = copy.blend_dest;
blendfunc_src_alpha = copy.blendfunc_src_alpha;
blendfunc_dest_alpha = copy.blendfunc_dest_alpha;
translation_hotspot = copy.translation_hotspot;
rotation_hotspot = copy.rotation_hotspot;
translation_origin = copy.translation_origin;
rotation_origin = copy.rotation_origin;
current_frame = copy.current_frame;
delta_frame = copy.delta_frame;
update_time = copy.update_time;
last_time = copy.last_time;
id = copy.id;
finished = copy.finished;
looping = copy.looping;
play_loop = copy.play_loop;
play_backward = copy.play_backward;
play_pingpong = copy.play_pingpong;
show_on_finish = copy.show_on_finish;
frames = copy.frames;
return *this;
}
float CL_Sprite_Generic::calc_time_elapsed()
{
// Calculate amount of time since last frame
float new_time = (float)CL_System::get_time();
if(last_time == 0)
last_time = new_time;
float delta_time = (new_time - last_time) / 1000.0f;
last_time = new_time;
return delta_time;
}
/////////////////////////////////////////////////////////////////////////////
// CL_Sprite_Generic implementation:
|