Skip to content
Draft
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
23 changes: 21 additions & 2 deletions data/images/objects/candle/candle-light-1.sprite
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
(supertux-sprite
(action
(name "default")
(images "candle-light-1.png")
(surfaces
(surface
(diffuse-texture
(file "candle-light-1.png")
)
(circle
(radius 140)
)
)
)
(images )
(hitbox 260 280 256 256)
)
(action
(name "white")
(images "candle-light-white-1.png")
(surfaces
(surface
(diffuse-texture
(file "candle-light-white-1.png")
)
(circle
(radius 140)
)
)
)
(hitbox 260 280 256 256)
)
)
22 changes: 20 additions & 2 deletions data/images/objects/candle/candle-light-2.sprite
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
(supertux-sprite
(action
(name "default")
(images "candle-light-2.png")
(surfaces
(surface
(diffuse-texture
(file "candle-light-2.png")
)
(circle
(radius 140)
)
)
)
(hitbox 260 280 256 256)
)
(action
(name "white")
(images "candle-light-white-2.png")
(surfaces
(surface
(diffuse-texture
(file "candle-light-white-2.png")
)
(circle
(radius 140)
)
)
)
(hitbox 260 280 256 256)
)
)
11 changes: 10 additions & 1 deletion data/images/objects/lightmap_light/lightmap_light-large.sprite
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
(supertux-sprite
(action
(name "default")
(images "lightmap_light-large.png")
(surfaces
(surface
(diffuse-texture
(file "lightmap_light-large.png")
)
(circle
(radius 360)
)
)
)
(hitbox 512 512 0 0)
)
)
11 changes: 10 additions & 1 deletion data/images/objects/lightmap_light/lightmap_light-medium.sprite
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
(supertux-sprite
(action
(name "default")
(images "lightmap_light-medium.png")
(surfaces
(surface
(diffuse-texture
(file "lightmap_light-medium.png")
)
(circle
(radius 160)
)
)
)
(hitbox 192 192 0 0)
)
)
11 changes: 10 additions & 1 deletion data/images/objects/lightmap_light/lightmap_light-small.sprite
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
(supertux-sprite
(action
(name "default")
(images "lightmap_light-small.png")
(surfaces
(surface
(diffuse-texture
(file "lightmap_light-small.png")
)
(circle
(radius 50)
)
)
)
(hitbox 64 64 0 0)
)
)
11 changes: 10 additions & 1 deletion data/images/objects/lightmap_light/lightmap_light-tiny.sprite
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
(supertux-sprite
(action
(name "default")
(images "lightmap_light-tiny.png")
(surfaces
(surface
(diffuse-texture
(file "lightmap_light-tiny.png")
)
(circle
(radius 30)
)
)
)
(hitbox 32 32 0 0)
)
)
11 changes: 10 additions & 1 deletion data/images/objects/lightmap_light/lightmap_light.sprite
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
(supertux-sprite
(action
(name "default")
(images "lightmap_light.png")
(surfaces
(surface
(diffuse-texture
(file "lightmap_light.png")
)
(circle
(radius 200)
)
)
)
(hitbox 256 256 0 0)
)
)
22 changes: 20 additions & 2 deletions data/images/objects/torch/flame_light.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,29 @@
(action
(name "default")
(hitbox 357 384 384 384)
(images "flame_light.png")
(surfaces
(surface
(diffuse-texture
(file "flame_light.png")
)
(circle
(radius 220)
)
)
)
)
(action
(name "greyscale")
(hitbox 357 384 384 384)
(images "greyscale/flame_light.png")
(surfaces
(surface
(diffuse-texture
(file "greyscale/flame_light.png")
)
(circle
(radius 220)
)
)
)
)
)
2 changes: 1 addition & 1 deletion src/badguy/badguy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ BadGuy::draw(DrawingContext& context)

if (m_glowing)
{
m_lightsprite->draw(context.light(), m_col.m_bbox.get_middle(), 0);
m_lightsprite->draw(context.light(), m_col.m_bbox.get_middle(), 0, NO_FLIP, ColorSpace::LIGHTSPRITES);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/badguy/bomb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Bomb::draw(DrawingContext& context)
m_exploding_sprite->set_action("exploding");
m_exploding_sprite->set_blend(Blend::ADD);
m_exploding_sprite->draw(context.light(),
get_pos() + Vector(get_bbox().get_width() / 2, get_bbox().get_height() / 2), m_layer, m_flip);
get_pos() + Vector(get_bbox().get_width() / 2, get_bbox().get_height() / 2), m_layer, m_flip, ColorSpace::LIGHTSPRITES);
BadGuy::draw(context);
}

Expand Down
2 changes: 1 addition & 1 deletion src/badguy/dive_mine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ DiveMine::draw(DrawingContext& context)
m_ticking_glow->draw(context.light(),
Vector(m_col.m_bbox.get_left() + m_col.m_bbox.get_width() / 2,
m_col.m_bbox.get_top() - 8.f),
m_layer, m_flip);
m_layer, m_flip, ColorSpace::LIGHTSPRITES);
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/badguy/ghosttree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ GhostTree::draw(DrawingContext& context)
} else {
context.set_alpha(0.5f);
}
glow_sprite->draw(context.light(), get_pos(), m_layer);
glow_sprite->draw(context.light(), get_pos(), m_layer, NO_FLIP, ColorSpace::LIGHTSPRITES);
context.pop_transform();
}

Expand Down
2 changes: 1 addition & 1 deletion src/badguy/goldbomb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ GoldBomb::draw(DrawingContext& context)
{
m_exploding_sprite->set_blend(Blend::ADD);
m_exploding_sprite->draw(context.light(),
get_pos() + Vector(get_bbox().get_width() / 2, get_bbox().get_height() / 2), m_layer, m_flip);
get_pos() + Vector(get_bbox().get_width() / 2, get_bbox().get_height() / 2), m_layer, m_flip, ColorSpace::LIGHTSPRITES);
}
WalkingBadguy::draw(context);
}
Expand Down
2 changes: 1 addition & 1 deletion src/badguy/haywire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Haywire::draw(DrawingContext& context)
{
m_exploding_sprite->set_blend(Blend::ADD);
m_exploding_sprite->draw(context.light(),
get_pos()+Vector(get_bbox().get_width()/2, get_bbox().get_height()/2), m_layer, m_flip);
get_pos()+Vector(get_bbox().get_width()/2, get_bbox().get_height()/2), m_layer, m_flip, ColorSpace::LIGHTSPRITES);
}
WalkingBadguy::draw(context);
}
Expand Down
2 changes: 1 addition & 1 deletion src/badguy/kugelblitz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void
Kugelblitz::draw(DrawingContext& context)
{
m_sprite->draw(context.color(), get_pos(), m_layer);
lightsprite->draw(context.light(), m_col.m_bbox.get_middle(), 0);
lightsprite->draw(context.light(), m_col.m_bbox.get_middle(), 0, NO_FLIP, ColorSpace::LIGHTSPRITES);
}

void
Expand Down
2 changes: 1 addition & 1 deletion src/badguy/treewillowisp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void
TreeWillOWisp::draw(DrawingContext& context)
{
m_sprite->draw(context.color(), get_pos(), m_layer);
m_sprite->draw(context.light(), get_pos(), m_layer);
m_sprite->draw(context.light(), get_pos(), m_layer, NO_FLIP, ColorSpace::LIGHTSPRITES);
}

void
Expand Down
46 changes: 46 additions & 0 deletions src/math/circle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SuperTux
// Copyright (C) 2024 Vankata453
//
// 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 "math/circle.hpp"

#include "math/rectf.hpp"
#include "util/reader_mapping.hpp"

Circle
Circle::from_reader(const ReaderMapping& mapping)
{
Circle circle;

mapping.get("radius", circle.m_radius);

return circle;
}


Circle::Circle(const Vector& center, float radius) :
m_center(center),
m_radius(radius)
{
}

bool
Circle::contains(const Vector& point) const
{
const float distance = powf(point.x - m_center.x, 2) + powf(point.y - m_center.y, 2);
return distance <= powf(m_radius, 2);
}

/* EOF */
45 changes: 45 additions & 0 deletions src/math/circle.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SuperTux
// Copyright (C) 2024 Vankata453
//
// 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/>.

#ifndef HEADER_SUPERTUX_MATH_CIRCLE_HPP
#define HEADER_SUPERTUX_MATH_CIRCLE_HPP

#include "math/vector.hpp"

class ReaderMapping;
class Rectf;

class Circle final
{
public:
static Circle from_reader(const ReaderMapping& mapping);

public:
Circle(const Vector& center = Vector(0.f, 0.f), float radius = 0.f);

bool contains(const Vector& point) const;

const Vector& get_center() const { return m_center; }
void set_center(const Vector& center) { m_center = center; }

private:
Vector m_center;
float m_radius;
};

#endif

/* EOF */
2 changes: 1 addition & 1 deletion src/object/bonus_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ BonusBlock::draw(DrawingContext& context)
{
Vector pos = get_pos() + (m_col.m_bbox.get_size().as_vector() - Vector(static_cast<float>(m_lightsprite->get_width()),
static_cast<float>(m_lightsprite->get_height()))) / 2.0f;
context.light().draw_surface(m_lightsprite, pos, 10);
context.light().draw_surface(m_lightsprite, pos, 10, ColorSpace::LIGHTSPRITES);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/object/bullet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Bullet::draw(DrawingContext& context)
{
sprite->draw(context.color(), get_pos(), LAYER_OBJECTS);
if (type == FIRE_BONUS){
lightsprite->draw(context.light(), m_col.m_bbox.get_middle(), 0);
lightsprite->draw(context.light(), m_col.m_bbox.get_middle(), 0, NO_FLIP, ColorSpace::LIGHTSPRITES);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/object/candle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ Candle::draw(DrawingContext& context)
// draw approx. 1 in 10 frames darker. Makes the candle flicker.
if (graphicsRandom.rand(10) != 0 || !flicker) {
// context.color().draw_surface(candle_light_1, pos, layer);
candle_light_1->draw(context.light(), m_col.m_bbox.get_middle(), m_layer);
candle_light_1->draw(context.light(), m_col.m_bbox.get_middle(), m_layer, NO_FLIP, ColorSpace::LIGHTSPRITES);
} else {
// context.color().draw_surface(candle_light_2, pos, layer);
candle_light_2->draw(context.light(), m_col.m_bbox.get_middle(), m_layer);
candle_light_2->draw(context.light(), m_col.m_bbox.get_middle(), m_layer, NO_FLIP, ColorSpace::LIGHTSPRITES);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/object/explosion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void
Explosion::draw(DrawingContext& context)
{
m_sprite->draw(context.color(), get_pos(), LAYER_OBJECTS+40);
lightsprite->draw(context.light(), m_col.m_bbox.get_middle(), 0);
lightsprite->draw(context.light(), m_col.m_bbox.get_middle(), 0, NO_FLIP, ColorSpace::LIGHTSPRITES);
}

HitResponse
Expand Down
Loading