Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 27 additions & 29 deletions data/images/tiles.strf
Original file line number Diff line number Diff line change
Expand Up @@ -2416,6 +2416,7 @@
(id 75)
(images "tiles/water/deprecated/water.png")
(water #t)
(shaded #t)
(deprecated #t)
)

Expand All @@ -2427,6 +2428,7 @@
"tiles/water/deprecated/waves-2.png"
)
(water #t)
(shaded #t)
(fps 10)
(deprecated #t)
)
Expand Down Expand Up @@ -2957,11 +2959,11 @@
175 176 177 178
)
(attributes
512 512 512 512
512 512 512 512
512 512 512 512
512 512 512 512
512 512 512 512
516 516 516 516
516 516 516 516
516 516 516 516
516 516 516 516
516 516 516 516
)
(images
"tiles/waterfall/trans-0.png"
Expand All @@ -2985,17 +2987,19 @@
"tiles/waterfall/foam-3.png"
)
(attributes
512 0 512
512 512 512
516 0 516
516 516 516
)
(water #t)
(shaded #t)
(fps 10)
)

(tile
(id 200)
(images "tiles/water/deprecated/water-trans.png")
(water #t)
(shaded #t)
(deprecated #t)
)

Expand All @@ -3007,6 +3011,7 @@
"tiles/water/deprecated/waves-trans-2.png"
)
(water #t)
(shaded #t)
(fps 10)
(deprecated #t)
)
Expand Down Expand Up @@ -3047,11 +3052,11 @@
275 276 277 278
)
(attributes
512 512 512 512
512 512 512 512
512 512 512 512
512 512 512 512
512 512 512 512
516 516 516 516
516 516 516 516
516 516 516 516
516 516 516 516
516 516 516 516
)
(images
"tiles/waterfall/deprecated/waterfall-0.png"
Expand Down Expand Up @@ -4896,25 +4901,17 @@
2019 2140 2141 2142
)
(attributes
512 512 512 512
516 516 516 516
)
(images
(surface (diffuse-texture (file "tiles/water/antarctic-1.png"))
(displacement-texture (file "tiles/water/antarctic-displacement.png")))
(surface (diffuse-texture (file "tiles/water/antarctic-2.png"))
(displacement-texture (file "tiles/water/antarctic-displacement.png")))
(surface (diffuse-texture (file "tiles/water/antarctic-3.png"))
(displacement-texture (file "tiles/water/antarctic-displacement.png")))
(surface (diffuse-texture (file "tiles/water/antarctic-4.png"))
(displacement-texture (file "tiles/water/antarctic-displacement.png")))
(surface (diffuse-texture (file "tiles/water/antarctic-5.png"))
(displacement-texture (file "tiles/water/antarctic-displacement.png")))
(surface (diffuse-texture (file "tiles/water/antarctic-6.png"))
(displacement-texture (file "tiles/water/antarctic-displacement.png")))
(surface (diffuse-texture (file "tiles/water/antarctic-7.png"))
(displacement-texture (file "tiles/water/antarctic-displacement.png")))
(surface (diffuse-texture (file "tiles/water/antarctic-8.png"))
(displacement-texture (file "tiles/water/antarctic-displacement.png")))
"tiles/water/antarctic-1.png"
"tiles/water/antarctic-2.png"
"tiles/water/antarctic-3.png"
"tiles/water/antarctic-4.png"
"tiles/water/antarctic-5.png"
"tiles/water/antarctic-6.png"
"tiles/water/antarctic-7.png"
"tiles/water/antarctic-8.png"
)
(fps 16)
)
Expand All @@ -4924,6 +4921,7 @@
(images
"tiles/water/antarctic.png")
(water #t)
(shaded #t)
)

(tiles
Expand Down
44 changes: 36 additions & 8 deletions data/shader/shader330.frag
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,26 @@ uniform bool is_displacement;

in vec4 diffuse_var;
in vec2 texcoord_var;
flat in uint attrs_var;

out vec4 fragColor;

const uint TATTR_SOLID = 0x0001u;
const uint TATTR_UNISOLID = 0x0002u;
const uint TATTR_SHADED = 0x0004u;
const uint TATTR_SLOPE = 0x0010u;
const uint TATTR_FIF = 0x0100u;
const uint TATTR_ICE = 0x0100u;
const uint TATTR_WATER = 0x0200u;
const uint TATTR_HURTS = 0x0400u;
const uint TATTR_FIRE = 0x0800u;
const uint TATTR_WALLJUMP = 0x1000u;

void main(void)
{
if (backbuffer == 0.0 || !is_displacement)
{
vec4 color = diffuse_var * texture(diffuse_texture, texcoord_var.st + (animate * game_time));
fragColor = color;
}
else if (is_displacement)
vec4 color = diffuse_var * texture(diffuse_texture, texcoord_var.st + (animate * game_time));

if (is_displacement)
{
vec4 pixel = texture(displacement_texture, texcoord_var.st + (displacement_animate * game_time));
vec2 displacement = (pixel.rg - vec2(0.5, 0.5)) * 255;
Expand All @@ -32,8 +41,27 @@ void main(void)
uv = vec2(uv.x, 1.0 - uv.y);
vec4 back_color = texture(framebuffer_texture, uv);

vec4 color = diffuse_var * texture(diffuse_texture, texcoord_var.st + (animate * game_time));
fragColor = vec4(mix(color.rgb, back_color.rgb, alpha), color.a);
vec4 newcolor = diffuse_var * texture(diffuse_texture, texcoord_var.st + (animate * game_time));
color = vec4(mix(newcolor.rgb, back_color.rgb, alpha), newcolor.a);
}

if ((attrs_var & TATTR_SHADED) == TATTR_SHADED &&
(attrs_var & TATTR_WATER) == TATTR_WATER &&
(attrs_var & TATTR_FIRE) != TATTR_FIRE) // Water (not lava)
{
vec2 uv = (fragcoord2uv * gl_FragCoord.xyw).xy;
uv.x = uv.x + 0.0006 * (sin(game_time + uv.y * (80)) + cos(game_time + uv.y * 30));
uv.y = 1.0 - uv.y + 0.003 * (cos(game_time + uv.y * 140));
vec4 back_color = texture(framebuffer_texture, uv);

if (backbuffer == 0.0)
fragColor = color;
else
fragColor = vec4(max(color.rgb, back_color.rgb), 1.0);
}
else if (backbuffer == 0.0 || !is_displacement)
{
fragColor = color;
}
}

Expand Down
3 changes: 3 additions & 0 deletions data/shader/shader330.vert
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
in vec2 texcoord;
in vec2 position;
in vec4 diffuse;
in uint attrs;

out vec2 texcoord_var;
out vec4 diffuse_var;
flat out uint attrs_var;

uniform mat3 modelviewprojection;

void main(void)
{
texcoord_var = texcoord;
diffuse_var = diffuse;
attrs_var = attrs;
gl_Position = vec4(vec3(position, 1) * modelviewprojection, 1.0);
}

Expand Down
15 changes: 8 additions & 7 deletions src/badguy/badguy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,12 @@ BadGuy::draw(DrawingContext& context)

Vector draw_offset = context.get_time_offset() * m_physic.get_velocity();
Vector draw_pos = get_pos() + draw_offset;
int layer = m_in_water ? -1 : m_layer;

if (m_state == STATE_INIT || m_state == STATE_INACTIVE)
{
if (Editor::is_active()) {
m_sprite->draw(context.color(), draw_pos, m_layer, m_flip);
m_sprite->draw(context.color(), draw_pos, layer, m_flip);
}
}
else
Expand All @@ -177,30 +178,30 @@ BadGuy::draw(DrawingContext& context)
{
context.push_transform();
context.set_flip(context.get_flip() ^ VERTICAL_FLIP);
m_sprite->draw(context.color(), draw_pos, m_layer, m_flip);
m_sprite->draw(context.color(), draw_pos, layer, m_flip);
context.pop_transform();
}
else
{
if (m_unfreeze_timer.started() && m_unfreeze_timer.get_timeleft() <= 1.f)
{
m_sprite->draw(context.color(), draw_pos + Vector(graphicsRandom.randf(-3, 3), 0.f), m_layer - 1, m_flip);
m_sprite->draw(context.color(), draw_pos + Vector(graphicsRandom.randf(-3, 3), 0.f), layer - 1, m_flip);
if (is_portable())
m_freezesprite->draw(context.color(), draw_pos + Vector(graphicsRandom.randf(-3, 3), 0.f), m_layer);
m_freezesprite->draw(context.color(), draw_pos + Vector(graphicsRandom.randf(-3, 3), 0.f), layer);
}
else
{
if (m_frozen && is_portable())
{
m_freezesprite->draw(context.color(), draw_pos, m_layer);
m_freezesprite->draw(context.color(), draw_pos, layer);
}

if (m_state != STATE_BURNING || m_firesprite->get_current_frame() < 5)
m_sprite->draw(context.color(), draw_pos, m_layer - (m_frozen ? 1 : 0), m_flip);
m_sprite->draw(context.color(), draw_pos, layer - (m_frozen ? 1 : 0), m_flip);
}

if (m_state == STATE_BURNING) {
m_firesprite->draw(context.color(), draw_pos, m_layer);
m_firesprite->draw(context.color(), draw_pos, layer);
}

if (m_glowing)
Expand Down
2 changes: 1 addition & 1 deletion src/object/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2286,7 +2286,7 @@ Player::draw(DrawingContext& context)
else if (m_dying)
m_sprite->draw(context.color(), draw_pos, Sector::get().get_foremost_opaque_layer() + 1);
else
m_sprite->draw(context.color(), draw_pos, LAYER_OBJECTS + 1);
m_sprite->draw(context.color(), draw_pos, m_no_water ? LAYER_OBJECTS + 1 : -1);

//TODO: Replace recoloring with proper costumes
Color power_color = (get_bonus() == BONUS_FIRE ? Color(1.f, 0.7f, 0.5f) :
Expand Down
5 changes: 4 additions & 1 deletion src/object/tilemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,8 @@ TileMap::draw(DrawingContext& context)

std::unordered_map<SurfacePtr,
std::tuple<std::vector<Rectf>,
std::vector<Rectf>>> batches;
std::vector<Rectf>,
std::vector<uint32_t>>> batches;

for (pos.x = start.x, tx = t_draw_rect.left; tx < t_draw_rect.right; pos.x += 32, ++tx) {
for (pos.y = start.y, ty = t_draw_rect.top; ty < t_draw_rect.bottom; pos.y += 32, ++ty) {
Expand Down Expand Up @@ -584,6 +585,7 @@ TileMap::draw(DrawingContext& context)
std::get<1>(batches[surface]).emplace_back(pos,
Sizef(static_cast<float>(surface->get_width()),
static_cast<float>(surface->get_height())));
std::get<2>(batches[surface]).emplace_back(tile.get_attributes());
}
}
}
Expand All @@ -597,6 +599,7 @@ TileMap::draw(DrawingContext& context)
canvas.draw_surface_batch(surface,
std::move(std::get<0>(it.second)),
std::move(std::get<1>(it.second)),
std::move(std::get<2>(it.second)),
m_current_tint, m_z_pos);
}
}
Expand Down
18 changes: 6 additions & 12 deletions src/supertux/tile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,13 @@ class Tile final
SOLID = 0x0001,
/** uni-directional solid tile */
UNISOLID = 0x0002,
/** a brick that can be destroyed by jumping under it */
BRICK = 0x0004, //Marked for removal, DO NOT USE!
/** the level should be finished when touching a goaltile.
* if data is 0 then the endsequence should be triggered, if data is 1
* then we can finish the level instantly.
*/
GOAL = 0x0008, //Marked for removal, DO NOT USE!
/** Is affected by shader */
SHADED = 0x0004,
/* 0x0008 reserved */
/** slope tile */
SLOPE = 0x0010,
/** Bonusbox, content is stored in \a data */
FULLBOX = 0x0020, //Marked for removal, DO NOT USE!
/** Tile is a coin */
COIN = 0x0040, //Marked for removal, DO NOT USE!
/* 0x0020 reserved */
/* 0x0040 reserved */

/* interesting flags (the following are passed to gameobjects) */
FIRST_INTERESTING_FLAG = 0x0100,
Expand All @@ -66,7 +60,7 @@ class Tile final
/** for lava: WATER, HURTS, FIRE */
FIRE = 0x0800,
/** a walljumping trigger tile */
WALLJUMP = 0x1000
WALLJUMP = 0x1000,
};

/** worldmap flags */
Expand Down
10 changes: 2 additions & 8 deletions src/supertux/tile_set_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ TileSetParser::parse_tile(const ReaderMapping& reader)
attributes |= Tile::SOLID;
if (reader.get("unisolid", value) && value)
attributes |= Tile::UNISOLID | Tile::SOLID;
if (reader.get("brick", value) && value)
attributes |= Tile::BRICK;
if (reader.get("shaded", value) && value)
attributes |= Tile::SHADED;
if (reader.get("ice", value) && value)
attributes |= Tile::ICE;
if (reader.get("water", value) && value)
Expand All @@ -251,12 +251,6 @@ TileSetParser::parse_tile(const ReaderMapping& reader)
attributes |= Tile::FIRE;
if (reader.get("walljump", value) && value)
attributes |= Tile::WALLJUMP;
if (reader.get("fullbox", value) && value)
attributes |= Tile::FULLBOX;
if (reader.get("coin", value) && value)
attributes |= Tile::COIN;
if (reader.get("goal", value) && value)
attributes |= Tile::GOAL;

uint32_t data = 0;

Expand Down
Loading
Loading