(supertux-music
(file "leveldone.ogg")
- (loop-begin 0.653061224489796) ;sample no. 28800
- (loop-at 5.514739229024940) ;sample no. 243200
)
#include "supertux/sector.hpp"
namespace{
- static const float WALK_SPEED = 100;
+ static const float CAPTAIN_WALK_SPEED = 100;
static const float BOARDING_SPEED = 200;
}
CaptainSnowball::collision_solid(const CollisionHit& hit)
{
if (is_active() && (walk_speed == BOARDING_SPEED)) {
- walk_speed = WALK_SPEED;
+ walk_speed = CAPTAIN_WALK_SPEED;
physic.set_velocity_x(dir == LEFT ? -walk_speed : walk_speed);
}
WalkingBadguy::collision_solid(hit);
#include "supertux/object_factory.hpp"
#include "util/reader.hpp"
-static const std::string SOUNDFILE = "sounds/flame.wav";
+static const std::string FLAME_SOUND = "sounds/flame.wav";
Flame::Flame(const Reader& reader) :
BadGuy(reader, "images/creatures/flame/flame.sprite", LAYER_FLOATINGOBJECTS),
bbox.set_pos(Vector(start_position.x + cos(angle) * radius,
start_position.y + sin(angle) * radius));
countMe = false;
- sound_manager->preload(SOUNDFILE);
+ sound_manager->preload(FLAME_SOUND);
set_colgroup_active(COLGROUP_TOUCHABLE);
}
void
Flame::activate()
{
- sound_source.reset(sound_manager->create_sound_source(SOUNDFILE));
+ sound_source.reset(sound_manager->create_sound_source(FLAME_SOUND));
sound_source->set_position(get_pos());
sound_source->set_looping(true);
sound_source->set_gain(2.0);
#include <math.h>
-static const float IDLE_TIME = 0.2f; /**< time to wait before and after throwing */
+static const float MOLE_WAIT_TIME = 0.2f; /**< time to wait before and after throwing */
static const float THROW_TIME = 4.6f; /**< time to spend throwing */
static const float THROW_INTERVAL = 1; /**< time between two thrown rocks */
static const float THROW_VELOCITY = 400; /**< initial velocity of thrown rocks */
case PRE_THROWING:
sprite->set_action("idle");
set_colgroup_active(COLGROUP_DISABLED);
- timer.start(IDLE_TIME);
+ timer.start(MOLE_WAIT_TIME);
break;
case THROWING:
sprite->set_action("idle");
case POST_THROWING:
sprite->set_action("idle");
set_colgroup_active(COLGROUP_DISABLED);
- timer.start(IDLE_TIME);
+ timer.start(MOLE_WAIT_TIME);
break;
case PEEKING:
sprite->set_action("peeking", 1);
#include "supertux/object_factory.hpp"
namespace {
-const float VERTICAL_SPEED = -450; /**< y-speed when jumping */
-const float HORIZONTAL_SPEED = 220; /**< x-speed when jumping */
const float MIN_RECOVER_TIME = 0.1f; /**< minimum time to stand still before starting a (new) jump */
const float MAX_RECOVER_TIME = 1.0f; /**< maximum time to stand still before starting a (new) jump */
-static const std::string HOP_SOUND = "sounds/hop.ogg";
+static const std::string SKULLYHOP_SOUND = "sounds/hop.ogg";
}
SkullyHop::SkullyHop(const Reader& reader) :
recover_timer(),
state()
{
- sound_manager->preload( HOP_SOUND );
+ sound_manager->preload( SKULLYHOP_SOUND );
}
SkullyHop::SkullyHop(const Vector& pos, Direction d) :
recover_timer(),
state()
{
- sound_manager->preload( HOP_SOUND );
+ sound_manager->preload( SKULLYHOP_SOUND );
}
void
} else
if (newState == JUMPING) {
sprite->set_action(dir == LEFT ? "jumping-left" : "jumping-right");
+const float HORIZONTAL_SPEED = 220; /**< x-speed when jumping */
physic.set_velocity_x(dir == LEFT ? -HORIZONTAL_SPEED : HORIZONTAL_SPEED);
+const float VERTICAL_SPEED = -450; /**< y-speed when jumping */
physic.set_velocity_y(VERTICAL_SPEED);
- sound_manager->play( HOP_SOUND, get_pos());
+ sound_manager->play( SKULLYHOP_SOUND, get_pos());
}
state = newState;
#include "supertux/object_factory.hpp"
static const float FLYTIME = 1.2f;
-static const float FLYSPEED = -100.0f;
+static const float MOVE_SPEED = -100.0f;
SpiderMite::SpiderMite(const Reader& reader) :
BadGuy(reader, "images/creatures/spidermite/spidermite.sprite"),
{
sprite->set_action(dir == LEFT ? "left" : "right");
mode = FLY_UP;
- physic.set_velocity_y(FLYSPEED);
+ physic.set_velocity_y(MOVE_SPEED);
timer.start(FLYTIME/2);
}
if(timer.check()) {
if(mode == FLY_UP) {
mode = FLY_DOWN;
- physic.set_velocity_y(-FLYSPEED);
+ physic.set_velocity_y(-MOVE_SPEED);
} else if(mode == FLY_DOWN) {
mode = FLY_UP;
- physic.set_velocity_y(FLYSPEED);
+ physic.set_velocity_y(MOVE_SPEED);
}
timer.start(FLYTIME);
}
static const int SHAKE_RANGE_X = 40;
static const float SHAKE_TIME = .8f;
-static const float SQUISH_TIME = 2;
static const float SHAKE_RANGE_Y = 400;
Stalactite::Stalactite(const Reader& lisp) :
physic.enable_gravity(true);
set_colgroup_active(COLGROUP_MOVING);
}
- } else if(state == STALACTITE_FALLING || state == STALACTITE_SQUISHED) {
+ } else if(state == STALACTITE_FALLING) {
movement = physic.get_movement(elapsed_time);
- if(state == STALACTITE_SQUISHED && timer.check())
- remove_me();
}
}
Stalactite::squish()
{
state = STALACTITE_SQUISHED;
- set_colgroup_active(COLGROUP_MOVING_ONLY_STATIC);
- sprite->set_action("squished");
- if(!timer.started())
- timer.start(SQUISH_TIME);
+ physic.enable_gravity(true);
+ physic.set_velocity_x(0);
+ physic.set_velocity_y(0);
+ set_state(STATE_SQUISHED);
+ set_group(COLGROUP_MOVING_ONLY_STATIC);
+ run_dead_script();
}
void
#include <math.h>
-static const float WALKSPEED = 120;
+static const float STUMPY_SPEED = 120;
static const float INVINCIBLE_TIME = 1;
Stumpy::Stumpy(const Reader& reader) :
mystate(STATE_NORMAL),
invincible_timer()
{
- walk_speed = WALKSPEED;
+ walk_speed = STUMPY_SPEED;
max_drop_height = 16;
sound_manager->preload("sounds/mr_treehit.ogg");
}
mystate(STATE_INVINCIBLE),
invincible_timer()
{
- walk_speed = WALKSPEED;
+ walk_speed = STUMPY_SPEED;
max_drop_height = 16;
sound_manager->preload("sounds/mr_treehit.ogg");
invincible_timer.start(INVINCIBLE_TIME);
namespace {
const float VERTICAL_SPEED = -450; /**< y-speed when jumping */
const float HORIZONTAL_SPEED = 320; /**< x-speed when jumping */
-const float RECOVER_TIME = 0.5; /**< time to stand still before starting a (new) jump */
+const float TOAD_RECOVER_TIME = 0.5; /**< time to stand still before starting a (new) jump */
static const std::string HOP_SOUND = "sounds/hop.ogg";
}
physic.set_velocity_y(0);
sprite->set_action(dir == LEFT ? "idle-left" : "idle-right");
- recover_timer.start(RECOVER_TIME);
+ recover_timer.start(TOAD_RECOVER_TIME);
} else
if (newState == JUMPING) {
sprite->set_action(dir == LEFT ? "jumping-left" : "jumping-right");
#include <math.h>
-static const float WALKSPEED = 100;
static const float JUMP_ON_SPEED_Y = -400;
static const float JUMP_OFF_SPEED_Y = -500;
static const std::string LAND_ON_TOTEM_SOUND = "sounds/totem.ogg";
Totem::initialize()
{
if (!carried_by) {
+static const float WALKSPEED = 100;
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
sprite->set_action(dir == LEFT ? "walking-left" : "walking-right");
return;
#include <math.h>
-static const std::string SOUNDFILE = "sounds/willowisp.wav";
+static const std::string TREEWILLOSOUND = "sounds/willowisp.wav";
static const float SUCKSPEED = 25;
TreeWillOWisp::TreeWillOWisp(GhostTree* tree, const Vector& pos,
tree(tree),
suck_target()
{
- sound_manager->preload(SOUNDFILE);
+ sound_manager->preload(TREEWILLOSOUND);
this->radius = radius;
this->angle = 0;
void
TreeWillOWisp::activate()
{
- sound_source.reset(sound_manager->create_sound_source(SOUNDFILE));
+ sound_source.reset(sound_manager->create_sound_source(TREEWILLOSOUND));
sound_source->set_position(get_pos());
sound_source->set_looping(true);
sound_source->set_gain(2.0);
return;
std::cout << "Expose me '" << name << "'\n";
- scripting::WillOWisp* interface = static_cast<scripting::WillOWisp*> (this);
- expose_object(vm, table_idx, interface, name);
+ scripting::WillOWisp* _this = static_cast<scripting::WillOWisp*> (this);
+ expose_object(vm, table_idx, _this, name);
}
void
const float SAFE_TIME = .5; /**< the time we are safe when tux just hit us */
const int INITIAL_HITPOINTS = 3; /**< number of hits we can take */
-const float SQUISH_TIME = 5;
+const float YETI_SQUISH_TIME = 5;
}
Yeti::Yeti(const Reader& reader) :
physic.set_velocity_y(0);
state = SQUISHED;
- state_timer.start(SQUISH_TIME);
+ state_timer.start(YETI_SQUISH_TIME);
set_colgroup_active(COLGROUP_MOVING_ONLY_STATIC);
sprite->set_action("dead");
#include "supertux/object_factory.hpp"
-static const float SHAKE_TIME = .8f;
+static const float YT_SHAKE_TIME = .8f;
YetiStalactite::YetiStalactite(const Reader& lisp)
: Stalactite(lisp)
void
YetiStalactite::start_shaking()
{
- timer.start(SHAKE_TIME);
+ timer.start(YT_SHAKE_TIME);
state = STALACTITE_SHAKING;
}
void
AmbientSound::expose(HSQUIRRELVM vm, SQInteger table_idx)
{
- scripting::AmbientSound* interface = static_cast<scripting::AmbientSound*> (this);
- expose_object(vm, table_idx, interface, name, false);
+ scripting::AmbientSound* _this = static_cast<scripting::AmbientSound*> (this);
+ expose_object(vm, table_idx, _this, name, false);
}
void
Camera::expose(HSQUIRRELVM vm, SQInteger table_idx)
{
if(name.empty()) return;
- scripting::Camera* interface = new scripting::Camera(this);
- expose_object(vm, table_idx, interface, name, true);
+ scripting::Camera* _this = new scripting::Camera(this);
+ expose_object(vm, table_idx, _this, name, true);
}
void
mode = SCROLLTO;
}
-static const float EPSILON = .00001f;
+static const float CAMERA_EPSILON = .00001f;
static const float MAX_SPEED_Y = 140;
void
last_player_pos = player_pos;
// check that we don't have division by zero later
- if(elapsed_time < EPSILON)
+ if(elapsed_time < CAMERA_EPSILON)
return;
/****** Vertical Scrolling part ******/
float upperend = SCREEN_HEIGHT * config.edge_x;
float lowerend = SCREEN_HEIGHT * (1 - config.edge_x);
- if (player_delta.y < -EPSILON) {
+ if (player_delta.y < -CAMERA_EPSILON) {
// walking left
lookahead_pos.y -= player_delta.y * config.dynamic_speed_sm;
if(lookahead_pos.y > lowerend) {
lookahead_pos.y = lowerend;
}
- } else if (player_delta.y > EPSILON) {
+ } else if (player_delta.y > CAMERA_EPSILON) {
// walking right
lookahead_pos.y -= player_delta.y * config.dynamic_speed_sm;
if(lookahead_pos.y < upperend) {
// Find out direction in which the player moves
LookaheadMode walkDirection;
- if (player_delta.x < -EPSILON) walkDirection = LOOKAHEAD_LEFT;
- else if (player_delta.x > EPSILON) walkDirection = LOOKAHEAD_RIGHT;
+ if (player_delta.x < -CAMERA_EPSILON) walkDirection = LOOKAHEAD_LEFT;
+ else if (player_delta.x > CAMERA_EPSILON) walkDirection = LOOKAHEAD_RIGHT;
else if (player->dir == ::LEFT) walkDirection = LOOKAHEAD_LEFT;
else walkDirection = LOOKAHEAD_RIGHT;
float LEFTEND = SCREEN_WIDTH * config.edge_x;
float RIGHTEND = SCREEN_WIDTH * (1 - config.edge_x);
- if (player_delta.x < -EPSILON) {
+ if (player_delta.x < -CAMERA_EPSILON) {
// walking left
lookahead_pos.x -= player_delta.x * config.dynamic_speed_sm;
if(lookahead_pos.x > RIGHTEND) {
lookahead_pos.x = RIGHTEND;
}
- } else if (player_delta.x > EPSILON) {
+ } else if (player_delta.x > CAMERA_EPSILON) {
// walking right
lookahead_pos.x -= player_delta.x * config.dynamic_speed_sm;
if(lookahead_pos.x < LEFTEND) {
Candle::expose(HSQUIRRELVM vm, SQInteger table_idx)
{
if (name.empty()) return;
- scripting::Candle* interface = new scripting::Candle(this);
- expose_object(vm, table_idx, interface, name, true);
+ scripting::Candle* _this = new scripting::Candle(this);
+ expose_object(vm, table_idx, _this, name, true);
}
void
LevelTime::expose(HSQUIRRELVM vm, SQInteger table_idx)
{
if (name.empty()) return;
- scripting::LevelTime* interface = new scripting::LevelTime(this);
- expose_object(vm, table_idx, interface, name, true);
+ scripting::LevelTime* _this = new scripting::LevelTime(this);
+ expose_object(vm, table_idx, _this, name, true);
}
void
Platform::expose(HSQUIRRELVM vm, SQInteger table_idx)
{
if (name.empty()) return;
- scripting::Platform* interface = new scripting::Platform(this);
- expose_object(vm, table_idx, interface, name, true);
+ scripting::Platform* _this = new scripting::Platform(this);
+ expose_object(vm, table_idx, _this, name, true);
}
void
#include "object/star.hpp"
static const float INITIALJUMP = -400;
-static const float SPEED = 150;
-static const float JUMPSPEED = -300;
+static const float STAR_SPEED = 150;
+static const float JUMPSTAR_SPEED = -300;
Star::Star(const Vector& pos, Direction direction) :
MovingSprite(pos, "images/powerups/star/star.sprite", LAYER_OBJECTS, COLGROUP_MOVING),
physic()
{
- physic.set_velocity((direction == LEFT) ? -SPEED : SPEED, INITIALJUMP);
+ physic.set_velocity((direction == LEFT) ? -STAR_SPEED : STAR_SPEED, INITIALJUMP);
}
void
Star::collision_solid(const CollisionHit& hit)
{
if(hit.bottom) {
- physic.set_velocity_y(JUMPSPEED);
+ physic.set_velocity_y(JUMPSTAR_SPEED);
} else if(hit.top) {
physic.set_velocity_y(0);
} else if(hit.left || hit.right) {
Thunderstorm::expose(HSQUIRRELVM vm, SQInteger table_idx)
{
if (name == "") return;
- scripting::Thunderstorm* interface = new scripting::Thunderstorm(this);
- expose_object(vm, table_idx, interface, name, true);
+ scripting::Thunderstorm* _this = new scripting::Thunderstorm(this);
+ expose_object(vm, table_idx, _this, name, true);
}
void
TileMap::expose(HSQUIRRELVM vm, SQInteger table_idx)
{
if (name.empty()) return;
- scripting::TileMap* interface = new scripting::TileMap(this);
- expose_object(vm, table_idx, interface, name, true);
+ scripting::TileMap* _this = new scripting::TileMap(this);
+ expose_object(vm, table_idx, _this, name, true);
}
void
if (name == "")
return;
- scripting::Wind* interface = new scripting::Wind(this);
- expose_object(vm, table_idx, interface, name, true);
+ scripting::Wind* _this = new scripting::Wind(this);
+ expose_object(vm, table_idx, _this, name, true);
}
void
g_screen_manager->push_screen(new GameSession(filename, GameSession::current()->get_player_status()));
}
-static SQInteger squirrel_read_char(SQUserPointer file)
-{
- std::istream* in = reinterpret_cast<std::istream*> (file);
- char c = in->get();
- if(in->eof())
- return 0;
-
- return c;
-}
-
void import(HSQUIRRELVM vm, const std::string& filename)
{
IFileStream in(filename);
printf("--------------------------------------------------------------\n");
}
-static SQInteger squirrel_read_char(SQUserPointer file)
+SQInteger squirrel_read_char(SQUserPointer file)
{
std::istream* in = reinterpret_cast<std::istream*> (file);
char c = in->get();
std::string squirrel2string(HSQUIRRELVM vm, SQInteger i);
void print_squirrel_stack(HSQUIRRELVM vm);
+SQInteger squirrel_read_char(SQUserPointer file);
+
HSQOBJECT create_thread(HSQUIRRELVM vm);
SQObject vm_to_object(HSQUIRRELVM vm);
HSQUIRRELVM object_to_vm(HSQOBJECT object);
+// SuperTux
+// Copyright (C) 2009 qMax
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "gui/menu.hpp"
+#include "object/floating_text.hpp"
+#include "object/level_time.hpp"
+#include "object/text_object.hpp"
+#include "supertux/levelintro.hpp"
+#include "supertux/player_status.hpp"
+#include "supertux/statistics.hpp"
+#include "supertux/textscroller.hpp"
+#include "trigger/climbable.hpp"
+#include "trigger/secretarea_trigger.hpp"
#include "video/color.hpp"
+#include "worldmap/worldmap.hpp"
+
+Color LevelIntro::header_color(1.0,1.0,0.6);
+Color LevelIntro::author_color(1.0,1.0,1.0);
+Color LevelIntro::stat_hdr_color(0.2,0.5,1.0);
+Color LevelIntro::stat_color(1.0,1.0,1.0);
+
+Color Statistics::header_color(1.0,1.0,1.0);
+Color Statistics::text_color(1.0,1.0,0.6);
+
+Color Menu::default_color(1.0,1.0,1.0);
+Color Menu::active_color(0.2,0.5,1.0);
+Color Menu::inactive_color(0.5,0.5,0.5);
+Color Menu::label_color(0.0,1.0,1.0);
+Color Menu::field_color(1.0,1.0,0.6);
+
+Color PlayerStatus::text_color(1.0,1.0,0.6);
+
+Color TextObject::default_color(1.0,1.0,1.0);
+
+Color FloatingText::text_color(1.0,1.0,0.6);
+
+Color LevelTime::text_color(1.0,1.0,0.6);
+
+Color SecretAreaTrigger::text_color(1.0,1.0,0.6);
+
+Color Climbable::text_color(1.0,1.0,0.6);
+
+Color worldmap::WorldMap::level_title_color(1.0,1.0,1.0);
+Color worldmap::WorldMap::message_color(1.0,1.0,0.6);
+Color worldmap::WorldMap::teleporter_message_color(1.0,1.0,1.0);
-namespace LevelIntro {
-Color header_color(1.0,1.0,0.6);
-Color author_color(1.0,1.0,1.0);
-Color stat_hdr_color(0.2,0.5,1.0);
-Color stat_color(1.0,1.0,1.0);
-}
-
-namespace Statistics {
-Color header_color(1.0,1.0,1.0);
-Color text_color(1.0,1.0,0.6);
-}
-
-namespace Menu {
-Color default_color(1.0,1.0,1.0);
-Color active_color(0.2,0.5,1.0);
-Color inactive_color(0.5,0.5,0.5);
-Color label_color(0.0,1.0,1.0);
-Color field_color(1.0,1.0,0.6);
-}
-
-namespace PlayerStatus {
-Color text_color(1.0,1.0,0.6);
-}
-
-namespace TextObject {
-Color default_color(1.0,1.0,1.0);
-}
-
-namespace FloatingText {
-Color text_color(1.0,1.0,0.6);
-}
-
-namespace LevelTime {
-Color text_color(1.0,1.0,0.6);
-}
-
-namespace SecretAreaTrigger {
-Color text_color(1.0,1.0,0.6);
-}
-
-namespace Climbable {
-Color text_color(1.0,1.0,0.6);
-}
-
-namespace worldmap {
-namespace WorldMap {
-Color level_title_color(1.0,1.0,1.0);
-Color message_color(1.0,1.0,0.6);
-Color teleporter_message_color(1.0,1.0,1.0);
-}}
-
-namespace TextScroller {
-Color small_color(1.0,1.0,1.0);
-Color heading_color(1.0,1.0,0.6);
-Color reference_color(0.2,0.6,1.0);
-Color normal_color(1.0,1.0,1.0);
-}
+Color TextScroller::small_color(1.0,1.0,1.0);
+Color TextScroller::heading_color(1.0,1.0,0.6);
+Color TextScroller::reference_color(0.2,0.6,1.0);
+Color TextScroller::normal_color(1.0,1.0,1.0);
/* EOF */
void
Sector::try_expose(GameObject* object)
{
- ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
- if(interface != NULL) {
+ ScriptInterface* object_ = dynamic_cast<ScriptInterface*> (object);
+ if(object_ != NULL) {
HSQUIRRELVM vm = scripting::global_vm;
sq_pushobject(vm, sector_table);
- interface->expose(vm, -1);
+ object_->expose(vm, -1);
sq_pop(vm, 1);
}
}
{
HSQUIRRELVM vm = scripting::global_vm;
sq_pushobject(vm, sector_table);
- scripting::SSector* interface = static_cast<scripting::SSector*> (this);
- expose_object(vm, -1, interface, "settings", false);
+ scripting::SSector* this_ = static_cast<scripting::SSector*> (this);
+ expose_object(vm, -1, this_, "settings", false);
sq_pop(vm, 1);
}
void
Sector::try_unexpose(GameObject* object)
{
- ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
- if(interface != NULL) {
+ ScriptInterface* object_ = dynamic_cast<ScriptInterface*> (object);
+ if(object_ != NULL) {
HSQUIRRELVM vm = scripting::global_vm;
SQInteger oldtop = sq_gettop(vm);
sq_pushobject(vm, sector_table);
try {
- interface->unexpose(vm, -1);
+ object_->unexpose(vm, -1);
} catch(std::exception& e) {
log_warning << "Couldn't unregister object: " << e.what() << std::endl;
}
#include "video/texture_manager.hpp"
#include "video/video_systems.hpp"
-static inline int next_po2(int val)
-{
- int result = 1;
- while(result < val)
- result *= 2;
-
- return result;
-}
-
DrawingContext::DrawingContext() :
renderer(0),
lightmap(0),
class Renderer;
class Lightmap;
+inline int next_po2(int val)
+{
+ int result = 1;
+ while(result < val)
+ result *= 2;
+
+ return result;
+}
+
/**
* This class provides functions for drawing things on screen. It also
* maintains a stack of transforms that are applied to graphics.
// some constants for predefined layer values
enum {
+ // Image/gradient backgrounds (should cover entire screen)
LAYER_BACKGROUND0 = -300,
+ // Particle backgrounds
LAYER_BACKGROUND1 = -200,
+ // Tilemap backgrounds
LAYER_BACKGROUNDTILES = -100,
+ // Solid tilemaps
LAYER_TILES = 0,
+ // Ordinary objects
LAYER_OBJECTS = 50,
+ // Objects that pass through walls
LAYER_FLOATINGOBJECTS = 150,
+ //
LAYER_FOREGROUNDTILES = 200,
+ //
LAYER_FOREGROUND0 = 300,
+ //
LAYER_FOREGROUND1 = 400,
+ // Hitpoints, time, coins, etc.
LAYER_HUD = 500,
+ // Menus, mouse, console etc.
LAYER_GUI = 600
};
#include "video/drawing_request.hpp"
#include "video/font.hpp"
#include "video/gl/gl_surface_data.hpp"
+#include "video/gl/gl_renderer.hpp"
#include "video/gl/gl_texture.hpp"
#include "video/glutil.hpp"
#include "video/lightmap.hpp"
#include "video/surface.hpp"
#include "video/texture_manager.hpp"
-namespace {
-
-inline void intern_draw(float left, float top, float right, float bottom,
- float uv_left, float uv_top,
- float uv_right, float uv_bottom,
- float angle, float alpha,
- const Color& color,
- const Blend& blend,
- DrawingEffect effect)
-{
- if(effect & HORIZONTAL_FLIP)
- std::swap(uv_left, uv_right);
-
- if(effect & VERTICAL_FLIP)
- std::swap(uv_top, uv_bottom);
-
- // unrotated blit
- glBlendFunc(blend.sfactor, blend.dfactor);
- glColor4f(color.red, color.green, color.blue, color.alpha * alpha);
-
- if (angle == 0.0f) {
- float vertices[] = {
- left, top,
- right, top,
- right, bottom,
- left, bottom,
- };
- glVertexPointer(2, GL_FLOAT, 0, vertices);
-
- float uvs[] = {
- uv_left, uv_top,
- uv_right, uv_top,
- uv_right, uv_bottom,
- uv_left, uv_bottom,
- };
- glTexCoordPointer(2, GL_FLOAT, 0, uvs);
-
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- } else {
- // rotated blit
- float center_x = (left + right) / 2;
- float center_y = (top + bottom) / 2;
-
- float sa = sinf(angle/180.0f*M_PI);
- float ca = cosf(angle/180.0f*M_PI);
-
- left -= center_x;
- right -= center_x;
-
- top -= center_y;
- bottom -= center_y;
-
- float vertices[] = {
- left*ca - top*sa + center_x, left*sa + top*ca + center_y,
- right*ca - top*sa + center_x, right*sa + top*ca + center_y,
- right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y,
- left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y
- };
- glVertexPointer(2, GL_FLOAT, 0, vertices);
-
- float uvs[] = {
- uv_left, uv_top,
- uv_right, uv_top,
- uv_right, uv_bottom,
- uv_left, uv_bottom,
- };
- glTexCoordPointer(2, GL_FLOAT, 0, uvs);
-
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- }
-
- // FIXME: find a better way to restore the blend mode
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-}
-
-static inline int next_po2(int val)
-{
- int result = 1;
- while(result < val)
- result *= 2;
-
- return result;
-}
-
-} // namespace
-
GLLightmap::GLLightmap() :
screen(),
lightmap(),
#include <iomanip>
#include <iostream>
-#include <math.h>
#include <physfs.h>
#include "supertux/gameconfig.hpp"
# define glOrtho glOrthof
#endif
-namespace {
-
-inline void intern_draw(float left, float top, float right, float bottom,
- float uv_left, float uv_top,
- float uv_right, float uv_bottom,
- float angle, float alpha,
- const Color& color,
- const Blend& blend,
- DrawingEffect effect)
-{
- if(effect & HORIZONTAL_FLIP)
- std::swap(uv_left, uv_right);
-
- if(effect & VERTICAL_FLIP)
- std::swap(uv_top, uv_bottom);
-
- glBlendFunc(blend.sfactor, blend.dfactor);
- glColor4f(color.red, color.green, color.blue, color.alpha * alpha);
-
- // unrotated blit
- if (angle == 0.0f) {
- float vertices[] = {
- left, top,
- right, top,
- right, bottom,
- left, bottom,
- };
- glVertexPointer(2, GL_FLOAT, 0, vertices);
-
- float uvs[] = {
- uv_left, uv_top,
- uv_right, uv_top,
- uv_right, uv_bottom,
- uv_left, uv_bottom,
- };
- glTexCoordPointer(2, GL_FLOAT, 0, uvs);
-
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- } else {
- // rotated blit
- float center_x = (left + right) / 2;
- float center_y = (top + bottom) / 2;
-
- float sa = sinf(angle/180.0f*M_PI);
- float ca = cosf(angle/180.0f*M_PI);
-
- left -= center_x;
- right -= center_x;
-
- top -= center_y;
- bottom -= center_y;
-
- float vertices[] = {
- left*ca - top*sa + center_x, left*sa + top*ca + center_y,
- right*ca - top*sa + center_x, right*sa + top*ca + center_y,
- right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y,
- left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y
- };
- glVertexPointer(2, GL_FLOAT, 0, vertices);
-
- float uvs[] = {
- uv_left, uv_top,
- uv_right, uv_top,
- uv_right, uv_bottom,
- uv_left, uv_bottom,
- };
- glTexCoordPointer(2, GL_FLOAT, 0, uvs);
-
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- }
-
- // FIXME: find a better way to restore the blend mode
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-}
-
-} // namespace
-
GLRenderer::GLRenderer() :
desktop_size(-1, -1),
screen_size(-1, -1),
#define HEADER_SUPERTUX_VIDEO_GL_RENDERER_HPP
#include "math/size.hpp"
+#include "video/drawing_request.hpp"
#include "video/renderer.hpp"
+#include <math.h>
+
+namespace {
+
+inline void intern_draw(float left, float top, float right, float bottom,
+ float uv_left, float uv_top,
+ float uv_right, float uv_bottom,
+ float angle, float alpha,
+ const Color& color,
+ const Blend& blend,
+ DrawingEffect effect)
+{
+ if(effect & HORIZONTAL_FLIP)
+ std::swap(uv_left, uv_right);
+
+ if(effect & VERTICAL_FLIP)
+ std::swap(uv_top, uv_bottom);
+
+ glBlendFunc(blend.sfactor, blend.dfactor);
+ glColor4f(color.red, color.green, color.blue, color.alpha * alpha);
+
+ // unrotated blit
+ if (angle == 0.0f) {
+ float vertices[] = {
+ left, top,
+ right, top,
+ right, bottom,
+ left, bottom,
+ };
+ glVertexPointer(2, GL_FLOAT, 0, vertices);
+
+ float uvs[] = {
+ uv_left, uv_top,
+ uv_right, uv_top,
+ uv_right, uv_bottom,
+ uv_left, uv_bottom,
+ };
+ glTexCoordPointer(2, GL_FLOAT, 0, uvs);
+
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ } else {
+ // rotated blit
+ float center_x = (left + right) / 2;
+ float center_y = (top + bottom) / 2;
+
+ float sa = sinf(angle/180.0f*M_PI);
+ float ca = cosf(angle/180.0f*M_PI);
+
+ left -= center_x;
+ right -= center_x;
+
+ top -= center_y;
+ bottom -= center_y;
+
+ float vertices[] = {
+ left*ca - top*sa + center_x, left*sa + top*ca + center_y,
+ right*ca - top*sa + center_x, right*sa + top*ca + center_y,
+ right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y,
+ left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y
+ };
+ glVertexPointer(2, GL_FLOAT, 0, vertices);
+
+ float uvs[] = {
+ uv_left, uv_top,
+ uv_right, uv_top,
+ uv_right, uv_bottom,
+ uv_left, uv_bottom,
+ };
+ glTexCoordPointer(2, GL_FLOAT, 0, uvs);
+
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ }
+
+ // FIXME: find a better way to restore the blend mode
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+}
+
+} // namespace
+
+
+
class GLRenderer : public Renderer
{
private:
void
WorldMap::try_expose(GameObject* object)
{
- ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
- if(interface != NULL) {
+ ScriptInterface* object_ = dynamic_cast<ScriptInterface*> (object);
+ if(object_ != NULL) {
HSQUIRRELVM vm = scripting::global_vm;
sq_pushobject(vm, worldmap_table);
- interface->expose(vm, -1);
+ object_->expose(vm, -1);
sq_pop(vm, 1);
}
}
void
WorldMap::try_unexpose(GameObject* object)
{
- ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
- if(interface != NULL) {
+ ScriptInterface* object_ = dynamic_cast<ScriptInterface*> (object);
+ if(object_ != NULL) {
HSQUIRRELVM vm = scripting::global_vm;
SQInteger oldtop = sq_gettop(vm);
sq_pushobject(vm, worldmap_table);
try {
- interface->unexpose(vm, -1);
+ object_->unexpose(vm, -1);
} catch(std::exception& e) {
log_warning << "Couldn't unregister object: " << e.what() << std::endl;
}