;; Small Tux arms
(name "small-tux-arms")
(action
- (name "walk")
+ (name "walk-right")
(fps 15.0)
(x-offset 5)
(y-offset 14)
"shared/smalltux/arms-walk-7.png"))
(action
- (name "stand")
+ (name "walk-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 14)
+ (mirror-action "walk-right"))
+
+ (action
+ (name "stand-right")
(fps 15.0)
(x-offset 5)
(y-offset 14)
(images "shared/smalltux/arms-walk-5.png"))
(action
- (name "jump")
+ (name "stand-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 14)
+ (mirror-action "stand-right"))
+
+ (action
+ (name "jump-right")
(fps 15.0)
(x-offset 5)
(y-offset 14)
(images "shared/smalltux/arms-jump-0.png"))
(action
- (name "skid")
+ (name "jump-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 14)
+ (mirror-action "jump-right"))
+
+ (action
+ (name "skid-right")
(x-offset 6)
(y-offset 15)
(images "shared/smalltux/arms-skid-0.png"))
(action
- (name "kick")
+ (name "skid-left")
+ (fps 15.0)
+ (x-offset 6)
+ (y-offset 15)
+ (mirror-action "skid-right"))
+
+ (action
+ (name "kick-right")
(x-offset 5)
(y-offset 14)
(images "shared/smalltux/arms-kick-0.png"))
+ (action
+ (name "kick-left")
+ (x-offset 5)
+ (y-offset 14)
+ (mirror-action "kick-right"))
+
; Grabbing is arms specific!
(action
- (name "grab")
+ (name "grab-right")
(x-offset 5)
(y-offset 14)
(images "shared/bigtux/arms-grab-0.png")))
+ (action
+ (name "grab-left")
+ (x-offset 5)
+ (y-offset 14)
+ (mirror-action "grab-right"))
+
;; Small Tux Body
(sprite
(name "small-tux-body")
(action
- (name "walk")
+ (name "walk-right")
(fps 15.0)
(x-offset 5)
(y-offset 14)
"shared/smalltux/body-walk-7.png"))
(action
- (name "stand")
+ (name "walk-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 14)
+ (mirror-action "walk-right"))
+
+ (action
+ (name "stand-right")
(fps 15.0)
(x-offset 5)
(y-offset 14)
(images "shared/smalltux/body-walk-5.png"))
(action
- (name "jump")
+ (name "stand-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 14)
+ (mirror-action "stand-right"))
+
+ (action
+ (name "jump-right")
(fps 15.0)
(x-offset 5)
(y-offset 14)
(images "shared/smalltux/body-jump-0.png"))
(action
- (name "skid")
+ (name "jump-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 14)
+ (mirror-action "jump-right"))
+
+ (action
+ (name "skid-right")
(x-offset 6)
(y-offset 15)
(images "shared/smalltux/body-skid-0.png"))
(action
- (name "kick")
+ (name "skid-left")
+ (x-offset 6)
+ (y-offset 15)
+ (mirror-action "skid-right"))
+
+ (action
+ (name "kick-right")
(x-offset 5)
(y-offset 14)
(images "shared/smalltux/body-kick-0.png")))
+ (action
+ (name "kick-left")
+ (x-offset 5)
+ (y-offset 14)
+ (mirror-action "kick-right"))
+
; End of Small Tux sprite
; Big Tux (no power) sprite
(name "big-tux-arms")
(action
- (name "walk")
+ (name "walk-right")
(fps 15.0)
(x-offset 5)
(y-offset 32)
"shared/bigtux/arms-walk-5.png"))
(action
- (name "stand")
+ (name "walk-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 14)
+ (mirror-action "walk-right"))
+
+ (action
+ (name "stand-right")
(fps 15.0)
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/arms-stand-0.png"))
(action
- (name "jump")
+ (name "stand-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "stand-right"))
+
+ (action
+ (name "jump-right")
(fps 15.0)
(x-offset 5)
(y-offset 30)
(images "shared/bigtux/arms-jump-0.png"))
(action
- (name "skid")
+ (name "jump-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 30)
+ (mirror-action "jump-right"))
+
+ (action
+ (name "skid-right")
(x-offset 6)
(y-offset 31)
(images "shared/bigtux/arms-skid-0.png"))
(action
- (name "kick")
+ (name "skid-left")
+ (fps 15.0)
+ (x-offset 6)
+ (y-offset 31)
+ (mirror-action "skid-right"))
+
+ (action
+ (name "kick-right")
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/arms-stand-0.png"))
(action
- (name "buttjump")
+ (name "kick-left")
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "kick-right"))
+
+ (action
+ (name "buttjump-right")
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/arms-stand-0.png"))
+ (action
+ (name "buttjump-left")
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "buttjump-right"))
+
; Grabbing is arms specific!
(action
- (name "grab")
+ (name "grab-right")
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/arms-grab-0.png"))
(action
- (name "duck+grab")
+ (name "grab-left")
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "grab-right"))
+
+ (action
+ (name "duck+grab-right")
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/arms-duck+grab-0.png")))
+ (action
+ (name "duck+grab-left")
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "grab-right"))
+
;; Big Tux Head
(sprite
(name "big-tux-head")
(action
- (name "walk")
+ (name "walk-right")
(fps 15.0)
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/head-stand-0.png"))
(action
- (name "stand")
+ (name "walk-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "walk-right"))
+
+ (action
+ (name "stand-right")
(fps 15.0)
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/head-stand-0.png"))
(action
- (name "jump")
+ (name "stand-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "stand-right"))
+
+ (action
+ (name "jump-right")
(fps 15.0)
(x-offset 5)
(y-offset 30)
(images "shared/bigtux/head-stand-0.png"))
(action
- (name "duck")
+ (name "jump-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 30)
+ (mirror-action "jump-right"))
+
+ (action
+ (name "duck-right")
(fps 15.0)
(x-offset 5)
(y-offset 30)
(images "shared/bigtux/head-duck-0.png"))
(action
- (name "skid")
+ (name "duck-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 30)
+ (mirror-action "duck-right"))
+
+ (action
+ (name "skid-right")
(x-offset 6)
(y-offset 31)
(images "shared/bigtux/head-skid-0.png"))
(action
- (name "kick")
+ (name "skid-left")
+ (fps 15.0)
+ (x-offset 6)
+ (y-offset 31)
+ (mirror-action "skid-right"))
+
+ (action
+ (name "kick-right")
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/head-stand-0.png"))
(action
- (name "buttjump")
+ (name "kick-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "kick-right"))
+
+ (action
+ (name "buttjump-right")
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/head-stand-0.png"))
(action
- (name "idle")
+ (name "buttjump-left")
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "buttjump-right"))
+
+ (action
+ (name "idle-right")
(fps 1.0)
(x-offset 6)
(y-offset 31)
"shared/bigtux/head-idle-blink-1.png")))
+ (action
+ (name "idle-left")
+ (fps 1.0)
+ (x-offset 6)
+ (y-offset 31)
+ (mirror-action "idle-right"))
+
;; Big Tux Body
(sprite
(name "big-tux-body")
(action
- (name "walk")
+ (name "walk-right")
(fps 15.0)
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/body-stand-0.png"))
(action
- (name "stand")
+ (name "walk-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "walk-right"))
+
+ (action
+ (name "stand-right")
(fps 15.0)
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/body-stand-0.png"))
(action
- (name "jump")
+ (name "stand-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "stand-right"))
+
+ (action
+ (name "jump-right")
(fps 15.0)
(x-offset 5)
(y-offset 30)
(images "shared/bigtux/body-stand-0.png"))
(action
- (name "duck")
+ (name "jump-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 30)
+ (mirror-action "jump-right"))
+
+ (action
+ (name "duck-right")
(fps 15.0)
(x-offset 5)
(y-offset 30)
(images "shared/bigtux/body-duck-0.png"))
(action
- (name "skid")
+ (name "duck-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 30)
+ (mirror-action "duck-right"))
+
+ (action
+ (name "skid-right")
(x-offset 6)
(y-offset 31)
(images "shared/bigtux/body-skid-0.png"))
(action
- (name "kick")
+ (name "skid-left")
+ (fps 15.0)
+ (x-offset 6)
+ (y-offset 31)
+ (mirror-action "skid-right"))
+
+ (action
+ (name "kick-right")
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/body-stand-0.png"))
(action
- (name "buttjump")
+ (name "kick-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "kick-right"))
+
+ (action
+ (name "buttjump-right")
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/body-stand-0.png")))
+ (action
+ (name "buttjump-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "buttjump-right"))
+
;; Big Tux Feet
(sprite
(name "big-tux-feet")
(action
- (name "walk")
+ (name "walk-right")
(fps 15.0)
(x-offset 5)
(y-offset 32)
"shared/bigtux/feet-walk-5.png"))
(action
- (name "stand")
+ (name "walk-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "walk-right"))
+
+ (action
+ (name "stand-right")
(fps 15.0)
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/feet-stand-0.png"))
(action
- (name "jump")
+ (name "stand-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "stand-right"))
+
+ (action
+ (name "jump-right")
(fps 15.0)
(x-offset 5)
(y-offset 30)
(images "shared/bigtux/feet-jump-0.png"))
(action
- (name "duck")
+ (name "jump-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 30)
+ (mirror-action "jump-right"))
+
+ (action
+ (name "duck-right")
(fps 15.0)
(x-offset 5)
(y-offset 30)
(images "shared/bigtux/feet-duck-0.png"))
(action
- (name "skid")
+ (name "duck-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 30)
+ (mirror-action "duck-right"))
+
+ (action
+ (name "skid-right")
(x-offset 6)
(y-offset 31)
(images "shared/bigtux/feet-skid-0.png"))
(action
- (name "kick")
+ (name "skid-left")
+ (x-offset 6)
+ (y-offset 31)
+ (mirror-action "skid-right"))
+
+ (action
+ (name "kick-right")
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/feet-kick-0.png"))
(action
- (name "buttjump")
+ (name "kick-left")
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "kick-right"))
+
+ (action
+ (name "buttjump-right")
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/feet-buttjump-0.png")))
+ (action
+ (name "buttjump-left")
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "buttjump-right"))
+
; End of Big Tux (no power) sprite
; Big Fire Tux sprite
(sprite
(name "big-fire-tux-head")
(action
- (name "walk")
+ (name "walk-right")
(fps 15.0)
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/head-fire-stand-0.png"))
(action
- (name "stand")
+ (name "walk-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "walk-right"))
+
+ (action
+ (name "stand-right")
(fps 15.0)
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/head-fire-stand-0.png"))
(action
- (name "jump")
+ (name "stand-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "stand-right"))
+
+ (action
+ (name "jump-right")
(fps 15.0)
(x-offset 5)
(y-offset 30)
(images "shared/bigtux/head-fire-stand-0.png"))
(action
- (name "duck")
+ (name "jump-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 30)
+ (mirror-action "jump-right"))
+
+ (action
+ (name "duck-right")
(fps 15.0)
(x-offset 5)
(y-offset 30)
(images "shared/bigtux/head-fire-stand-0.png"))
(action
- (name "skid")
+ (name "duck-left")
+ (fps 15.0)
+ (x-offset 5)
+ (y-offset 30)
+ (mirror-action "duck-right"))
+
+ (action
+ (name "skid-right")
(x-offset 6)
(y-offset 31)
(images "shared/bigtux/head-skid-0.png"))
(action
- (name "kick")
+ (name "skid-left")
+ (x-offset 6)
+ (y-offset 31)
+ (mirror-action "skid-right"))
+
+ (action
+ (name "kick-right")
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/head-fire-stand-0.png"))
(action
- (name "buttjump")
+ (name "kick-left")
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "kick-right"))
+
+ (action
+ (name "buttjump-right")
(x-offset 5)
(y-offset 32)
(images "shared/bigtux/head-fire-stand-0.png"))
(action
- (name "idle")
+ (name "buttjump-left")
+ (x-offset 5)
+ (y-offset 32)
+ (mirror-action "buttjump-right"))
+
+ (action
+ (name "idle-right")
(fps 1.0)
(x-offset 6)
(y-offset 31)
(images "shared/bigtux/head-idle-blink-0.png"
"shared/bigtux/head-idle-blink-1.png")))
+ (action
+ (name "idle-left")
+ (fps 1.0)
+ (x-offset 6)
+ (y-offset 31)
+ (mirror-action "idle-right"))
+
; End of Big Fire Tux sprite
lispreader.read_int("z-order", action->z_order);
lispreader.read_float("fps", action->fps);
- std::vector<std::string> images;
- if(!lispreader.read_string_vector("images", images))
- Termination::abort("Sprite contains no images: ", action->name.c_str());
-
- for(std::vector<std::string>::size_type i = 0; i < images.size(); i++)
- {
- action->surfaces.push_back(
- new Surface(datadir + "/images/" + images[i], true));
- }
-
- // TODO: add a top filter entry
+ /* TODO: add a top filter entry */
std::vector <int> mask_color;
lispreader.read_int_vector("apply-mask", mask_color);
if(mask_color.size() == 4)
}
}
+ action->mirror = false;
+ std::string mirror_action;
+ lispreader.read_string("mirror-action", mirror_action);
+ if(!mirror_action.empty())
+ {
+ action->mirror = true;
+ Action* act_tmp = get_action(mirror_action);
+ if(act_tmp == NULL)
+ std::cerr << "Warning: Could not mirror action. Action not found\n"
+ "Mirror actions must be defined after the real one!\n";
+ else
+ action->surfaces = act_tmp->surfaces;
+ }
+
+ // Load images
+ if(!action->mirror)
+ {
+ std::vector<std::string> images;
+ if(!lispreader.read_string_vector("images", images))
+ Termination::abort("Sprite contains no images: ", action->name.c_str());
+
+ for(std::vector<std::string>::size_type i = 0; i < images.size(); i++)
+ {
+ action->surfaces.push_back(
+ new Surface(datadir + "/images/" + images[i], true));
+ }
+ }
actions[action->name] = action;
}
action = i->second;
}
+Sprite::Action*
+Sprite::get_action(std::string act)
+{
+Actions::iterator i = actions.find(act);
+if(i == actions.end())
+ {
+ std::cerr << "Warning: Action '" << act << "' not found on Sprite '" << name << "'\n";
+ return NULL;
+ }
+return i->second;
+}
+
void
Sprite::start_animation(int loops)
{
/* Set Tux sprite action */
if (duck && size != SMALL)
- tux_body->set_action("duck");
+ {
+ if(dir == LEFT)
+ tux_body->set_action("duck-left");
+ else // dir == RIGHT
+ tux_body->set_action("duck-right");
+ }
else if (skidding_timer.started())
- tux_body->set_action("skid");
+ {
+ if(dir == LEFT)
+ tux_body->set_action("skid-left");
+ else // dir == RIGHT
+ tux_body->set_action("skid-right");
+ }
else if (kick_timer.started())
- tux_body->set_action("kick");
+ {
+ if(dir == LEFT)
+ tux_body->set_action("kick-left");
+ else // dir == RIGHT
+ tux_body->set_action("kick-right");
+ }
else if (butt_jump)
- tux_body->set_action("buttjump");
+ {
+ if(dir == LEFT)
+ tux_body->set_action("buttjump-left");
+ else // dir == RIGHT
+ tux_body->set_action("buttjump-right");
+ }
else if (physic.get_velocity_y() != 0)
- tux_body->set_action("jump");
+ {
+ if(dir == LEFT)
+ tux_body->set_action("jump-left");
+ else // dir == RIGHT
+ tux_body->set_action("jump-right");
+ }
else
{
if (fabsf(physic.get_velocity_x()) < 1.0f) // standing
{
- tux_body->set_action("stand");
+ if(dir == LEFT)
+ tux_body->set_action("stand-left");
+ else // dir == RIGHT
+ tux_body->set_action("stand-right");
}
else // moving
{
- tux_body->set_action("walk");
+ if(dir == LEFT)
+ tux_body->set_action("walk-left");
+ else // dir == RIGHT
+ tux_body->set_action("walk-right");
}
}
{
if(size == BIG)
{
- tux_body->head->set_action("idle");
+ if(dir == LEFT)
+ tux_body->head->set_action("idle-left");
+ else // dir == RIGHT
+ tux_body->set_action("idle-right");
+
tux_body->head->start_animation(1);
}
shooting_timer.check())
{
if (duck)
- tux_body->arms->set_action("duck+grab");
+ {
+ if(dir == LEFT)
+ tux_body->arms->set_action("duck+grab");
+ else // dir == RIGHT
+ tux_body->set_action("duck-right");
+ }
else
- tux_body->arms->set_action("grab");
+ {
+ if(dir == LEFT)
+ tux_body->arms->set_action("grab");
+ else // dir == RIGHT
+ tux_body->set_action("duck-right");
+ }
}
/* Draw Tux */