Effect.fade_in(2);
Camera.scroll_to(0, 945, 15);
wait(3);
- Text.set_text("Somewhere at the shores\nof Antarctica...");
+ Text.set_text(translate ("Somewhere at the shores\nof Antarctica..."));
Text.fade_in(2);
wait(3);
Text.fade_out(2);
wait(10);
SUPERTUX.set_velocity(50,0);
Camera.scroll_to(3100, 945, 18);
- wait(10);
+ wait(6);
logo.set_anchor_point(ANCHOR_TOP);
- logo.set_pos(0, 90);
+ logo.set_pos(0, -120);
logo.set_visible(true);
- wait(5);
- logo.set_visible(false);
+ logo.fade_in(2);
+ logo_in();
wait(6);
+ logo.fade_out(2);
+ wait(2);
+ logo.set_visible(false);
+ wait(5.3);
//begin conversation and Tux rap
SUPERTUX.set_velocity(0,0);
wait(0.3);
}
+function logo_in()
+{
+ local i;
+ for(local i = -120; i <= 90; i+=2) {
+ logo.set_pos(0, i);
+ wait(0.01);
+ }
+}
#include "lisp/lisp.hpp"
#include "floating_image.hpp"
+
FloatingImage::FloatingImage(const std::string& spritefile)
- : layer(LAYER_FOREGROUND1 + 1), visible(false), anchor(ANCHOR_MIDDLE)
+ : layer(LAYER_FOREGROUND1 + 1), visible(false), anchor(ANCHOR_MIDDLE), fading(0), fadetime(0)
{
sprite.reset(sprite_manager->create(spritefile));
}
void
FloatingImage::update(float elapsed_time)
{
- (void) elapsed_time;
+ if(fading > 0) {
+ fading -= elapsed_time;
+ if(fading <= 0) {
+ fading = 0;
+ visible = true;
+ }
+ } else if(fading < 0) {
+ fading += elapsed_time;
+ if(fading >= 0) {
+ fading = 0;
+ visible = false;
+ }
+ }
+
+// (void) elapsed_time;
}
void
}
void
-FloatingImage::draw(DrawingContext& context)
+FloatingImage::fade_in(float fadetime)
{
- if(!visible)
- return;
+ this->fadetime = fadetime;
+ fading = fadetime;
+}
+void
+FloatingImage::fade_out(float fadetime)
+{
+ this->fadetime = fadetime;
+ fading = -fadetime;
+}
+
+
+void
+FloatingImage::draw(DrawingContext& context)
+{
context.push_transform();
context.set_translation(Vector(0, 0));
+ if(fading > 0) {
+ context.set_alpha((fadetime-fading) / fadetime);
+ } else if(fading < 0) {
+ context.set_alpha(-fading / fadetime);
+ } else if(!visible) {
+ context.pop_transform();
+ return;
+ }
+
Vector spos = pos + get_anchor_pos(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT),
sprite->get_width(), sprite->get_height(), anchor);
void set_action(const std::string& action);
std::string get_action();
+
+ void fade_in(float fadetime);
+ void fade_out(float fadetime);
void update(float elapsed_time);
void draw(DrawingContext& context);
bool visible;
AnchorPoint anchor;
Vector pos;
+ float fading;
+ float fadetime;
};
#endif
return floating_image->get_action();
}
+void
+FloatingImage::fade_in(float fadetime)
+{
+ floating_image->fade_in(fadetime);
+}
+
+void
+FloatingImage::fade_out(float fadetime)
+{
+ floating_image->fade_out(fadetime);
+}
+
+
}
bool get_visible();
void set_action(const std::string& action);
std::string get_action();
+ void fade_in(float fadetime);
+ void fade_out(float fadetime);
#ifndef SCRIPTING_API
private:
}
+static SQInteger FloatingImage_fade_in_wrapper(HSQUIRRELVM vm)
+{
+ SQUserPointer data;
+ if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0))) {
+ sq_throwerror(vm, _SC("'fade_in' called without instance"));
+ return SQ_ERROR;
+ }
+ Scripting::FloatingImage* _this = reinterpret_cast<Scripting::FloatingImage*> (data);
+ SQFloat arg0;
+ if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) {
+ sq_throwerror(vm, _SC("Argument 1 not a float"));
+ return SQ_ERROR;
+ }
+
+ try {
+ _this->fade_in(static_cast<float> (arg0));
+
+ return 0;
+
+ } catch(std::exception& e) {
+ sq_throwerror(vm, e.what());
+ return SQ_ERROR;
+ } catch(...) {
+ sq_throwerror(vm, _SC("Unexpected exception while executing function 'fade_in'"));
+ return SQ_ERROR;
+ }
+
+}
+
+static SQInteger FloatingImage_fade_out_wrapper(HSQUIRRELVM vm)
+{
+ SQUserPointer data;
+ if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0))) {
+ sq_throwerror(vm, _SC("'fade_out' called without instance"));
+ return SQ_ERROR;
+ }
+ Scripting::FloatingImage* _this = reinterpret_cast<Scripting::FloatingImage*> (data);
+ SQFloat arg0;
+ if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) {
+ sq_throwerror(vm, _SC("Argument 1 not a float"));
+ return SQ_ERROR;
+ }
+
+ try {
+ _this->fade_out(static_cast<float> (arg0));
+
+ return 0;
+
+ } catch(std::exception& e) {
+ sq_throwerror(vm, e.what());
+ return SQ_ERROR;
+ } catch(...) {
+ sq_throwerror(vm, _SC("Unexpected exception while executing function 'fade_out'"));
+ return SQ_ERROR;
+ }
+
+}
+
static SQInteger Platform_release_hook(SQUserPointer ptr, SQInteger )
{
Scripting::Platform* _this = reinterpret_cast<Scripting::Platform*> (ptr);
throw SquirrelError(v, "Couldn't register function 'get_action'");
}
+ sq_pushstring(v, "fade_in", -1);
+ sq_newclosure(v, &FloatingImage_fade_in_wrapper, 0);
+ if(SQ_FAILED(sq_createslot(v, -3))) {
+ throw SquirrelError(v, "Couldn't register function 'fade_in'");
+ }
+
+ sq_pushstring(v, "fade_out", -1);
+ sq_newclosure(v, &FloatingImage_fade_out_wrapper, 0);
+ if(SQ_FAILED(sq_createslot(v, -3))) {
+ throw SquirrelError(v, "Couldn't register function 'fade_out'");
+ }
+
if(SQ_FAILED(sq_createslot(v, -3))) {
throw SquirrelError(v, "Couldn't register class 'FloatingImage'");
}