function intro()
{
DisplayEffect.sixteen_to_nine();
- PENNY.set_animation("stand");
+ PENNY.set_action("stand");
Text.set_centered(true);
Text.set_text(translate("SuperTux\nMilestone 2"));
Text.fade_in(2);
wait(4);
Text.fade_out(1);
-}
\ No newline at end of file
+}
(init-script "
Text.set_text(translate(\"The Crazy Nolok Dance\"));
Text.fade_in(2);
-TUX.set_animation(\"jump\");
+TUX.set_action(\"jump\");
wait(4);
Text.fade_out(1);
wait(1);
tuxjumps--;
wait(0.5);
if(PENNY.get_animation() == \"stand\") {
- PENNY.set_animation(\"throw\");
+ PENNY.set_action(\"throw\");
} else if(PENNY.get_animation() == \"throw\") {
- PENNY.set_animation(\"jump\");
+ PENNY.set_action(\"jump\");
} else if(PENNY.get_animation() == \"jump\") {
- PENNY.set_animation(\"dead\");
+ PENNY.set_action(\"dead\");
} else {
Sound.play(\"sounds/grow.wav\");
- PENNY.set_animation(\"stand\");
+ PENNY.set_action(\"stand\");
PENNY.set_velocity(0, 900);
}
}
--- /dev/null
+function intro()
+{
+ SUPERTUX.set_action("stand-right");
+ Tux.deactivate();
+ Tux.set_visible(false);
+ DisplayEffect.sixteen_to_nine(0);
+ DisplayEffect.fade_in(2);
+ wait(2);
+
+ Text.set_text(translate("Tux and Penny were out having a\n nice picnic on the\nice fields of Antarctica."));
+ Text.fade_in(1);
+// TODO play some tux sounds...
+ wait(1);
+
+ Sound.play("speech/tux_rap.ogg");
+ wait(5);
+ Text.fade_out(1);
+ wait(15);
+
+ Text.set_text(translate("Then suddenly..."));
+ Text.fade_in(1);
+
+// let's shake the bush...
+ // Sound.play("sounds/rustle.wav");
+ local bushx = BUSH.get_pos_x();
+ local bushy = BUSH.get_pos_y();
+ for(local i = 0; i < 20; ++i) {
+ BUSH.set_pos(bushx + rand() % 6 - 3, bushy);
+ wait(0.1);
+ }
+ Text.fade_out(1);
+
+// NOLOK jumps out of the bush
+ wait(0.5);
+ print("jump");
+ NOLOK.set_velocity(70, 600);
+
+ wait(1)
+ NOLOK.set_velocity(-120, 700);
+ wait(2);
+
+// nolok casts his spell...
+ NOLOK.set_action("throw");
+ // TODO we really need fade to white here and some thunder sound...
+ DisplayEffect.fade_out(0.3);
+ wait(0.3);
+ DisplayEffect.fade_in(0);
+ wait(0.3);
+ DisplayEffect.fade_out(0.5);
+ wait(0.5);
+ DisplayEffect.fade_in(0);
+ wait(0.4);
+ DisplayEffect.fade_out(0.2);
+ wait(2.5);
+ NOLOK.set_visible(false);
+ PENNY.set_visible(false);
+ DisplayEffect.fade_in(1);
+ wait(1);
+
+ Text.set_text("Oh No!\nPenny has been captured");
+ Text.fade_in(1);
+ wait(3);
+ Text.fade_out(1);
+
+ Text.set_text("Tux has to rescue her");
+ Text.fade_in(1);
+ wait(5);
+
+// fade out
+ DisplayEffect.fade_out(2);
+ wait(2);
+ Level.finish();
+}
--- /dev/null
+;; Generated by Flexlay Editor
+(supertux-level
+ (version 2)
+ (name (_ "Intro"))
+ (author "Development Team")
+ (sector
+ (name "main")
+ (init-script "intro()")
+ (gravity 10.000000)
+ (tilemap
+ (layer "background")
+ (solid #f)
+ (speed 1.000000)
+ (width 25)
+ (height 20)
+ (tiles
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343 1343
+ 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342
+ 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342
+ 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342
+ 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342
+ 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342
+ 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342
+ 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342
+ 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342
+ 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342
+ ))
+ (tilemap
+ (layer "interactive")
+ (solid #t)
+ (speed 1.000000)
+ (width 25)
+ (height 20)
+ (tiles
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 122 209 209 123 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 124 210 210 125 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 124 210 210 125 0 0 0 0 0 0 0 0 0
+ 0 0 122 123 0 0 0 0 0 0 0 0 124 210 210 125 0 0 0 0 0 0 0 0 0
+ 0 0 124 125 0 0 0 0 0 0 0 0 124 210 210 125 0 0 122 123 0 0 0 0 0
+ 0 0 124 125 0 0 0 0 0 0 0 0 124 210 210 125 0 0 124 125 0 0 0 0 0
+ 0 0 1345 1344 0 0 0 0 0 0 0 0 1345 1346 1346 1344 0 0 1345 1344 0 0 0 0 0
+ 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342 1342
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ ))
+ (tilemap
+ (layer "foreground")
+ (solid #f)
+ (speed 1.000000)
+ (width 25)
+ (height 20)
+ (tiles
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 1350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ ))
+ (camera
+ (mode "normal")
+ )
+
+ (background
+ (image "semi_arctic.jpg")
+ (speed 0.500000)
+ )
+ (spawnpoint (name "main") (x 320) (y 416))
+ (particles-snow
+ )
+ (scriptedobject
+ (x 286) (y 443)
+ (name "PENNY")
+ (sprite "images/creatures/penny/penny.sprite")
+ (layer 100)
+ (visible #t)
+ (physic-enabled #f)
+ (solid #f)
+ )
+ (scriptedobject
+ (x 492) (y 440)
+ (name "NOLOK")
+ (sprite "images/creatures/nolok/nolok.sprite")
+ (layer 100)
+ (visible #t)
+ (physic-enabled #t)
+ (solid #f)
+ )
+ (scriptedobject
+ (x 465) (y 390)
+ (name "BUSH")
+ (sprite "images/tiles/doodads/iceshrub.sprite")
+ (layer 105)
+ (visible #t)
+ (physic-enabled #f)
+ (solid #f)
+ )
+ (scriptedobject
+ (x 187) (y 442)
+ (name "SUPERTUX")
+ (sprite "images/creatures/tux_big/tux.sprite")
+ (layer 100)
+ (visible #t)
+ (physic-enabled #t)
+ (solid #f)
+ )
+ )
+ )
+
+;; EOF ;;
add_key(KEY_BRASS);
add_key(KEY_IRON);
Tux.deactivate();
- DisplayEffect.sixteen_to_nine();
+ DisplayEffect.sixteen_to_nine(2);
Text.set_text(translate("---Insert Cutscene Here---"));
Tux.walk(100);
Text.fade_in(2);
}
ALuint
-SoundManager::load_file_into_buffer(const std::string& filename)
+SoundManager::load_file_into_buffer(SoundFile* file)
{
- // open sound file
- std::auto_ptr<SoundFile> file (load_sound_file(filename));
-
- ALenum format = get_sample_format(file.get());
+ ALenum format = get_sample_format(file);
ALuint buffer;
alGenBuffers(1, &buffer);
check_al_error("Couldn't create audio buffer: ");
if(i != buffers.end()) {
buffer = i->second;
} else {
- buffer = load_file_into_buffer(filename);
- buffers.insert(std::make_pair(filename, buffer));
+ // Load sound file
+ std::auto_ptr<SoundFile> file (load_sound_file(filename));
+
+ if(file->size < 100000) {
+ buffer = load_file_into_buffer(file.get());
+ buffers.insert(std::make_pair(filename, buffer));
+ } else {
+ StreamSoundSource* source = new StreamSoundSource();
+ source->set_sound_file(file.release());
+ return source;
+ }
}
SoundSource* source = new SoundSource();
return;
lastticks = current_ticks;
- // check for finished sound sources
+ // update and check for finished sound sources
for(SoundSources::iterator i = sources.begin(); i != sources.end(); ) {
SoundSource* source = *i;
+
+ source->update();
+
if(!source->playing()) {
delete source;
i = sources.erase(i);
friend class SoundSource;
friend class StreamSoundSource;
- static ALuint load_file_into_buffer(const std::string& filename);
+ static ALuint load_file_into_buffer(SoundFile* file);
static ALenum get_sample_format(SoundFile* file);
void print_openal_version();
}
void
+SoundSource::update()
+{
+}
+
+void
SoundSource::set_looping(bool looping)
{
alSourcei(source, AL_LOOPING, looping ? AL_TRUE : AL_FALSE);
void stop();
bool playing();
+ virtual void update();
+
void set_looping(bool looping);
/// Set volume (0.0 is silent, 1.0 is normal)
void set_gain(float gain);
ALint queued;
alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
for(size_t i = 0; i < STREAMFRAGMENTS - queued; ++i) {
- fillBufferAndQueue(buffers[i]);
+ if(fillBufferAndQueue(buffers[i]) == false)
+ break;
}
}
alSourceUnqueueBuffers(source, 1, &buffer);
SoundManager::check_al_error("Couldn't unqueu audio buffer: ");
- fillBufferAndQueue(buffer);
+ if(fillBufferAndQueue(buffer) == false)
+ break;
}
if(!playing()) {
- if(processed == 0)
+ if(processed == 0 || !looping)
return;
// we might have to restart the source if we had a buffer underrun
play();
}
-#ifdef DEBUG
- ALint queued;
- alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
- assert(queued == (ALint) STREAMFRAGMENTS);
-#endif
-
if(fade_state == FadingOn) {
Uint32 ticks = SDL_GetTicks();
float time = (ticks - fade_start_ticks) / 1000.0;
this->fade_start_ticks = SDL_GetTicks();
}
-void
+bool
StreamSoundSource::fillBufferAndQueue(ALuint buffer)
{
// fill buffer
do {
bytesread += file->read(bufferdata + bytesread,
STREAMFRAGMENTSIZE - bytesread);
+ // end of sound file
if(bytesread < STREAMFRAGMENTSIZE) {
- file->reset();
+ if(looping)
+ file->reset();
+ else
+ break;
}
} while(bytesread < STREAMFRAGMENTSIZE);
-
- ALenum format = SoundManager::get_sample_format(file);
- alBufferData(buffer, format, bufferdata, STREAMFRAGMENTSIZE, file->rate);
- delete[] bufferdata;
- SoundManager::check_al_error("Couldn't refill audio buffer: ");
-
- alSourceQueueBuffers(source, 1, &buffer);
- SoundManager::check_al_error("Couldn't queue audio buffer: ");
+
+ if(bytesread > 0) {
+ ALenum format = SoundManager::get_sample_format(file);
+ alBufferData(buffer, format, bufferdata, bytesread, file->rate);
+ delete[] bufferdata;
+ SoundManager::check_al_error("Couldn't refill audio buffer: ");
+
+ alSourceQueueBuffers(source, 1, &buffer);
+ SoundManager::check_al_error("Couldn't queue audio buffer: ");
+ }
+
+ // return false if there aren't more buffers to fill
+ return bytesread >= STREAMFRAGMENTSIZE;
}
+
void set_fading(FadeState state, float fadetime);
FadeState get_fade_state() const
{
- return fade_state;
+ return fade_state;
}
void update();
+
+ void set_looping(bool looping)
+ {
+ this->looping = looping;
+ }
+ bool get_looping() const
+ {
+ return looping;
+ }
private:
static const size_t STREAMBUFFERSIZE = 1024 * 500;
static const size_t STREAMFRAGMENTSIZE
= STREAMBUFFERSIZE / STREAMFRAGMENTS;
- void fillBufferAndQueue(ALuint buffer);
+ bool fillBufferAndQueue(ALuint buffer);
SoundFile* file;
ALuint buffers[STREAMFRAGMENTS];
FadeState fade_state;
Uint32 fade_start_ticks;
float fade_time;
+ bool looping;
};
#endif
#include "video/drawing_context.hpp"
#include "main.hpp"
+static const float BORDER_SIZE = 75;
+
DisplayEffect::DisplayEffect()
- : type(NO_FADE), fadetime(0), fading(0), black(false)
+ : screen_fade(NO_FADE), screen_fadetime(0), screen_fading(0),
+ border_fade(NO_FADE), border_fadetime(0), border_size(0),
+ black(false), borders(false)
{
- border_size = 0;
- borders_fading = false;
- borders_active = false;
}
DisplayEffect::~DisplayEffect()
void
DisplayEffect::update(float elapsed_time)
{
- if (borders_fading) {
- if (border_size < 75) border_size += 1.5;
- else borders_active = true;
- }
- else if (borders_active) {
- if (border_size > 0) border_size -= 1.5;
- else borders_active = false;
- }
- switch(type) {
+ switch(screen_fade) {
case NO_FADE:
- return;
+ break;
case FADE_IN:
- fading -= elapsed_time;
- if(fading < 0) {
- type = NO_FADE;
+ screen_fading -= elapsed_time;
+ if(screen_fading < 0) {
+ screen_fade = NO_FADE;
}
break;
case FADE_OUT:
- fading -= elapsed_time;
- if(fading < 0) {
- type = NO_FADE;
+ screen_fading -= elapsed_time;
+ if(screen_fading < 0) {
+ screen_fade = NO_FADE;
black = true;
}
break;
default:
assert(false);
}
+
+ switch(border_fade) {
+ case NO_FADE:
+ break;
+ case FADE_IN:
+ border_fading -= elapsed_time;
+ if(border_fading < 0) {
+ border_fade = NO_FADE;
+ }
+ border_size = border_fading / border_fading * BORDER_SIZE;
+ break;
+ case FADE_OUT:
+ border_fading -= elapsed_time;
+ if(border_fading < 0) {
+ borders = false;
+ border_fade = NO_FADE;
+ }
+ border_size = (border_fadetime - border_fading)
+ / border_fadetime * BORDER_SIZE;
+ break;
+ default:
+ assert(false);
+ }
}
void
context.push_transform();
context.set_translation(Vector(0, 0));
- if(black || type != NO_FADE) {
+ if(black || screen_fade != NO_FADE) {
float alpha;
if(black) {
alpha = 1.0f;
} else {
- switch(type) {
+ switch(screen_fade) {
case FADE_IN:
- alpha = fading / fadetime;
+ alpha = screen_fading / screen_fadetime;
break;
case FADE_OUT:
- alpha = (fadetime-fading) / fadetime;
+ alpha = (screen_fadetime - screen_fading) / screen_fadetime;
break;
default:
alpha = 0;
Color(0, 0, 0, alpha), LAYER_GUI-10);
}
- if (borders_fading || borders_active) {
+ if (borders) {
context.draw_filled_rect(Vector(0, 0), Vector(SCREEN_WIDTH, border_size),
Color(0, 0, 0, 1.0f), LAYER_GUI-10);
context.draw_filled_rect(Vector(0, SCREEN_HEIGHT - border_size), Vector(SCREEN_WIDTH, border_size),
DisplayEffect::fade_out(float fadetime)
{
black = false;
- this->fadetime = fadetime;
- fading = fadetime;
- type = FADE_OUT;
+ screen_fadetime = fadetime;
+ screen_fading = fadetime;
+ screen_fade = FADE_OUT;
}
void
DisplayEffect::fade_in(float fadetime)
{
black = false;
- this->fadetime = fadetime;
- fading = fadetime;
- type = FADE_IN;
+ this->screen_fadetime = fadetime;
+ screen_fading = fadetime;
+ screen_fade = FADE_IN;
}
void
}
void
-DisplayEffect::sixteen_to_nine()
+DisplayEffect::sixteen_to_nine(float fadetime)
{
- borders_fading = true;
+ if(fadetime == 0) {
+ borders = true;
+ border_size = BORDER_SIZE;
+ } else {
+ borders = true;
+ border_size = 0;
+ border_fade = FADE_IN;
+ border_fadetime = fadetime;
+ border_fading = border_fadetime;
+ }
}
void
-DisplayEffect::four_to_three()
+DisplayEffect::four_to_three(float fadetime)
{
- borders_fading = false;
+ if(fadetime == 0) {
+ borders = false;
+ } else {
+ border_size = BORDER_SIZE;
+ border_fade = FADE_OUT;
+ border_fadetime = fadetime;
+ border_fading = border_fadetime;
+ }
}
void fade_in(float fadetime);
void set_black(bool enabled);
bool is_black();
- void sixteen_to_nine();
- void four_to_three();
+ void sixteen_to_nine(float fadetime);
+ void four_to_three(float fadetime);
private:
enum FadeType {
NO_FADE, FADE_IN, FADE_OUT
};
- FadeType type;
- float fadetime;
- float fading;
- bool black;
- bool borders_fading;
- bool borders_active;
+ FadeType screen_fade;
+ float screen_fadetime;
+ float screen_fading;
+ FadeType border_fade;
+ float border_fadetime;
+ float border_fading;
float border_size;
+
+ bool black;
+ bool borders;
};
#endif
}
void
+Player::set_visible(bool visible)
+{
+ this->visible = visible;
+}
+
+bool
+Player::get_visible()
+{
+ return visible;
+}
+
+void
Player::kick()
{
kick_timer.start(KICK_TIME);
void
Player::draw(DrawingContext& context)
{
+ if(!visible)
+ return;
+
TuxBodyParts* tux_body;
if (player_status->bonus == GROWUP_BONUS)
bool is_dead() const
{ return dead; }
bool is_big();
+
+ void set_visible(bool visible);
+ bool get_visible();
private:
void handle_input();
void deactivate();
void walk(float speed);
+ bool visible;
+
Portable* grabbed_object;
Sprite* smalltux_gameover;
}
void
-ScriptedObject::set_animation(const std::string& animation)
+ScriptedObject::set_action(const std::string& animation)
{
sprite->set_action(animation);
}
std::string
-ScriptedObject::get_animation()
+ScriptedObject::get_action()
{
return sprite->get_action_name();
}
// --- Scripting Interface stuff ---
- void set_animation(const std::string& animation);
- std::string get_animation();
+ void set_action(const std::string& animation);
+ std::string get_action();
void move(float x, float y);
void set_pos(float x, float y);
/// check if display is set to black
virtual bool is_black() = 0;
/// set black borders for cutscenes
- virtual void sixteen_to_nine() = 0;
+ virtual void sixteen_to_nine(float fadetime) = 0;
/// deactivate borders
- virtual void four_to_three() = 0;
+ virtual void four_to_three(float fadetime) = 0;
// fade display until just a small visible circle is left
// (like what happens in some cartoons at the end)
* Make Tux walk
*/
virtual void walk(float speed) = 0;
+ /**
+ * Set player visible or not visible
+ */
+ virtual void set_visible(bool visible) = 0;
+ /**
+ * returns true if the player is currently visible (that is he was not set
+ * inivisible by the set_visible method)
+ */
+ virtual bool get_visible() = 0;
};
}
{}
#endif
- virtual void set_animation(const std::string& animation) = 0;
- virtual std::string get_animation() = 0;
+ virtual void set_action(const std::string& animation) = 0;
+ virtual std::string get_action() = 0;
virtual void move(float x, float y) = 0;
virtual void set_pos(float x, float y) = 0;
{
Scripting::DisplayEffect* _this;
sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
+ float arg0;
+ sq_getfloat(v, 2, &arg0);
- _this->sixteen_to_nine();
+ _this->sixteen_to_nine(arg0);
return 0;
}
{
Scripting::DisplayEffect* _this;
sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
+ float arg0;
+ sq_getfloat(v, 2, &arg0);
- _this->four_to_three();
+ _this->four_to_three(arg0);
return 0;
}
return 0;
}
-static int ScriptedObject_set_animation_wrapper(HSQUIRRELVM v)
+static int ScriptedObject_set_action_wrapper(HSQUIRRELVM v)
{
Scripting::ScriptedObject* _this;
sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
const char* arg0;
sq_getstring(v, 2, &arg0);
- _this->set_animation(arg0);
+ _this->set_action(arg0);
return 0;
}
-static int ScriptedObject_get_animation_wrapper(HSQUIRRELVM v)
+static int ScriptedObject_get_action_wrapper(HSQUIRRELVM v)
{
Scripting::ScriptedObject* _this;
sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
- std::string return_value = _this->get_animation();
+ std::string return_value = _this->get_action();
sq_pushstring(v, return_value.c_str(), return_value.size());
return 1;
return 0;
}
+static int Player_set_visible_wrapper(HSQUIRRELVM v)
+{
+ Scripting::Player* _this;
+ sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
+ SQBool arg0;
+ sq_getbool(v, 2, &arg0);
+
+ _this->set_visible(arg0);
+
+ return 0;
+}
+
+static int Player_get_visible_wrapper(HSQUIRRELVM v)
+{
+ Scripting::Player* _this;
+ sq_getinstanceup(v, 1, (SQUserPointer*) &_this, 0);
+
+ bool return_value = _this->get_visible();
+
+ sq_pushbool(v, return_value);
+ return 1;
+}
+
static int display_text_file_wrapper(HSQUIRRELVM v)
{
const char* arg0;
msg << "Couldn't create new class 'ScriptedObject'";
throw SquirrelError(v, msg.str());
}
- sq_pushstring(v, "set_animation", -1);
- sq_newclosure(v, &ScriptedObject_set_animation_wrapper, 0);
+ sq_pushstring(v, "set_action", -1);
+ sq_newclosure(v, &ScriptedObject_set_action_wrapper, 0);
if(SQ_FAILED(sq_createslot(v, -3))) {
std::ostringstream msg;
- msg << "Couldn't register function'set_animation'";
+ msg << "Couldn't register function'set_action'";
throw SquirrelError(v, msg.str());
}
- sq_pushstring(v, "get_animation", -1);
- sq_newclosure(v, &ScriptedObject_get_animation_wrapper, 0);
+ sq_pushstring(v, "get_action", -1);
+ sq_newclosure(v, &ScriptedObject_get_action_wrapper, 0);
if(SQ_FAILED(sq_createslot(v, -3))) {
std::ostringstream msg;
- msg << "Couldn't register function'get_animation'";
+ msg << "Couldn't register function'get_action'";
throw SquirrelError(v, msg.str());
}
throw SquirrelError(v, msg.str());
}
+ sq_pushstring(v, "set_visible", -1);
+ sq_newclosure(v, &Player_set_visible_wrapper, 0);
+ if(SQ_FAILED(sq_createslot(v, -3))) {
+ std::ostringstream msg;
+ msg << "Couldn't register function'set_visible'";
+ throw SquirrelError(v, msg.str());
+ }
+
+ sq_pushstring(v, "get_visible", -1);
+ sq_newclosure(v, &Player_get_visible_wrapper, 0);
+ if(SQ_FAILED(sq_createslot(v, -3))) {
+ std::ostringstream msg;
+ msg << "Couldn't register function'get_visible'";
+ throw SquirrelError(v, msg.str());
+ }
+
if(SQ_FAILED(sq_createslot(v, -3))) {
std::ostringstream msg;
msg << "Couldn't register class'Player'";
: gravity(10), player(0), solids(0), camera(0),
currentmusic(LEVEL_MUSIC)
{
- song_title = "chipdisko.ogg";
player = new Player(player_status);
add_object(player);