Commit 5f075603 authored by Rahix's avatar Rahix 🦀
Browse files

bottle-drop: Use a sprite for rendering

Drop the home-cooked temporary debug rendering system for bottle drop
points and instead use a sprite for this.
parent d93a8b0b
use crate::colliders;
use crate::components;
use crate::sprites;
use crate::svg_loader;
use rand::seq::SliceRandom;
......@@ -17,6 +18,7 @@ pub fn create_drop_points(world: &mut legion::World, level: &svg_loader::SvgLeve
components::Matebottledrop,
components::Position::new(droppoint.x, droppoint.y),
colliders::Collider::new_sensor_circle(50.0),
components::Sprite::new(sprites::Sprite::BottleDropPointFull),
));
}
}
......@@ -4,12 +4,16 @@ use crate::svg_loader;
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Sprite {
Player,
BottleDropPointFull,
BottleDropPointEmpty,
}
impl Sprite {
pub fn filename(&self) -> &'static str {
match *self {
Sprite::Player => "player.svg",
Sprite::BottleDropPointFull => "droppoint-full.svg",
Sprite::BottleDropPointEmpty => "droppoint-empty.svg",
}
}
......@@ -27,7 +31,11 @@ impl Sprite {
}
pub async fn load_and_register_all(renderer: &mut resources::Rendering) {
for sprite in &[Sprite::Player] {
for sprite in &[
Sprite::Player,
Sprite::BottleDropPointFull,
Sprite::BottleDropPointEmpty,
] {
sprite.load_and_register(renderer).await;
}
}
......
......@@ -65,7 +65,6 @@ impl InGameState {
.add_thread_local(systems::draw_level_layer_system(background))
.add_thread_local(systems::draw_sprites_system())
.add_thread_local(systems::draw_level_layer_system(foreground))
.add_thread_local(systems::draw_tmp_matebottledrop_system())
.add_thread_local(systems::draw_tmp_stationary_obstacles_system())
// .add_thread_local(systems::draw_debug_colliders_system())
;
......
......@@ -4,7 +4,6 @@ mod level;
mod moving;
mod player;
mod sprite;
mod tmp_matebottledrop;
mod tmp_stationary_obstacles;
pub use camera::camera_system;
......@@ -13,5 +12,4 @@ pub use level::draw_level_layer_system;
pub use moving::{move_camera_to_player_system, move_movable_system};
pub use player::{sanity_goes_up_and_down_system, update_sanity_bar_system};
pub use sprite::draw_sprites_system;
pub use tmp_matebottledrop::draw_tmp_matebottledrop_system;
pub use tmp_stationary_obstacles::draw_tmp_stationary_obstacles_system;
use crate::colors;
use crate::components;
use crate::resources;
#[legion::system(for_each)]
pub fn draw_tmp_matebottledrop(
_player: &components::Matebottledrop,
pos: &components::Position,
#[resource] rendering: &mut resources::Rendering,
) {
rendering.begin_path();
rendering.set_fill_style(&colors::PRIMARY3_SHADE4);
rendering.arc(
pos.0.x as f64,
pos.0.y as f64,
50.0,
0.0,
std::f64::consts::TAU,
);
rendering.fill();
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="100"
height="100"
viewBox="0 0 100 100"
version="1.1"
id="svg8"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
sodipodi:docname="droppoint-empty.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="7.9195959"
inkscape:cx="56.580318"
inkscape:cy="48.350229"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="true"
units="px"
inkscape:window-width="2560"
inkscape:window-height="1381"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid833"
spacingx="5"
spacingy="5" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:#05b9ec;fill-opacity:0.567125;stroke:#05b9ec;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 5,60 5,35 h 80 l 5,-35 z"
id="path837"
sodipodi:nodetypes="ccccc" />
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="100"
height="100"
viewBox="0 0 100 100"
version="1.1"
id="svg8"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
sodipodi:docname="droppoint-full.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="7.9195959"
inkscape:cx="56.580318"
inkscape:cy="48.350229"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="true"
units="px"
inkscape:window-width="2560"
inkscape:window-height="1381"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid833"
spacingx="5"
spacingy="5" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:#67029f;stroke:#b239ff;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 17.564745,63.618788 31.71766,68.588193 40,45 l -3.061171,-6.374107 3.312937,-9.435278 -4.71764,-1.656466 -3.312935,9.435276 -6.374108,3.061171 z"
id="path847" />
<path
style="fill:#440069;stroke:#b239ff;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 65.300491,62.012624 80,65 l 4.978959,-24.499183 -3.904045,-5.895628 1.991585,-9.799675 -4.899838,-0.995789 -1.991583,9.799672 -5.89563,3.904045 z"
id="path849" />
<path
style="fill:#41008b;stroke:#6800e7;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 71.276857,57.202736 80,45 59.662105,30.461429 l -6.975292,1.159864 -8.13516,-5.815429 -2.907712,4.067581 8.135158,5.815427 1.159864,6.975295 z"
id="path851" />
<path
style="fill:#41008b;stroke:#6800e7;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 61.047367,63.427098 70.223254,75.293146 90,60 l 0.89672,-7.013978 7.910699,-6.117259 -3.05863,-3.955349 -7.910698,6.117258 -7.013979,-0.89672 z"
id="path843" />
<path
style="fill:#67029f;stroke:#b239ff;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 60.782065,76.089672 73.905108,68.824292 61.796141,46.952554 55,45 l -4.843587,-8.748695 -4.374348,2.421794 4.843587,8.748695 -1.952554,6.796141 z"
id="path841" />
<path
style="fill:#440069;stroke:#b239ff;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 20,75 33.123043,67.73462 21.014076,45.862882 14.217935,43.910328 9.374348,35.161633 5,37.583427 9.843587,46.332122 7.891033,53.128263 Z"
id="path839" />
<path
style="fill:#2a005e;stroke:#6800e7;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 23.209276,64.396426 9.175887,11.866048 19.776746,-15.293146 0.89672,-7.013978 7.910699,-6.117259 -3.05863,-3.955349 L 50,50 42.986021,49.10328 Z"
id="path845" />
<path
style="fill:#05b9ec;fill-opacity:0.567125;stroke:#05b9ec;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 5,60 5,35 h 80 l 5,-35 z"
id="path837"
sodipodi:nodetypes="ccccc" />
</g>
</svg>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment