Skip to content
Merged
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
73 changes: 65 additions & 8 deletions assets/maps/test_level.json
Original file line number Diff line number Diff line change
Expand Up @@ -784,14 +784,71 @@
"id": "decorations",
"kind": "object_layer",
"has_collision": false,
"objects": [],
"objects": [
{
"id": "anemones",
"kind": "decoration",
"position": {
"x": 313.01,
"y": 269.10092
}
},
{
"id": "seaweed",
"kind": "decoration",
"position": {
"x": 637.80585,
"y": 269.37476
}
}
],
"is_visible": true
},
{
"id": "items",
"kind": "object_layer",
"has_collision": false,
"objects": [
{
"id": "crab",
"kind": "environment",
"position": {
"x": 486.8546,
"y": 178.04547
}
},
{
"id": "crab",
"kind": "environment",
"position": {
"x": 640.52356,
"y": 432.3415
}
},
{
"id": "crab",
"kind": "environment",
"position": {
"x": 414.69,
"y": 305.67166
}
},
{
"id": "crab",
"kind": "environment",
"position": {
"x": 610.0421,
"y": 302.41638
}
},
{
"id": "crab",
"kind": "environment",
"position": {
"x": 530.3602,
"y": 677.60126
}
},
{
"id": "trident",
"kind": "item",
Expand All @@ -804,8 +861,8 @@
"id": "crown_hat",
"kind": "item",
"position": {
"x": 524.5,
"y": 408.0
"x": 519.0186,
"y": 405.68817
}
},
{
Expand Down Expand Up @@ -892,8 +949,8 @@
"id": "jellyfish",
"kind": "item",
"position": {
"x": 700.0,
"y": 650.0
"x": 696.2978,
"y": 647.9329
}
},
{
Expand Down Expand Up @@ -1742,13 +1799,13 @@
false
],
"tile_attributes": {
"56": [
"58": [
"jumpthrough"
],
"60": [
"56": [
"jumpthrough"
],
"58": [
"60": [
"jumpthrough"
]
}
Expand Down
9 changes: 9 additions & 0 deletions assets/textures.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,15 @@
"y": 20
}
},
{
"id": "crab",
"path": "textures/items/Crab(15x8).png",
"type": "spritesheet",
"sprite_size": {
"x": 15,
"y": 8
}
},
{
"id": "sword",
"path": "textures/items/Sword(65x93).png",
Expand Down
Binary file added assets/textures/items/Crab(15x8).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/editor/gui/windows/create_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl Window for CreateObjectWindow {
.keys()
.map(|k| k.as_str())
.collect::<Vec<&str>>(),
MapObjectKind::Environment => vec!["sproinger"],
MapObjectKind::Environment => vec!["sproinger", "crab"],
MapObjectKind::Decoration => resources
.decoration
.keys()
Expand Down
35 changes: 25 additions & 10 deletions src/editor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::any::TypeId;
use std::path::Path;

use crate::{exit_to_main_menu, quit_to_desktop, Resources};
use crate::{exit_to_main_menu, map::CRAB_TEXTURE_ID, quit_to_desktop, Resources};

mod camera;

Expand Down Expand Up @@ -1449,8 +1449,8 @@ impl Node for Editor {
label = Some("INVALID OBJECT ID".to_string());
}
}
MapObjectKind::Environment => {
if &object.id == "sproinger" {
MapObjectKind::Environment => match object.id.as_str() {
"sproinger" => {
let texture_res =
resources.textures.get("sproinger").unwrap();

Expand All @@ -1476,10 +1476,22 @@ impl Node for Editor {
..Default::default()
},
);
} else {
}
"crab" => {
let texture_res =
resources.textures.get(CRAB_TEXTURE_ID).unwrap();

draw_texture(
texture_res.texture,
object_position.x,
object_position.y,
color::WHITE,
);
}
_ => {
label = Some("INVALID OBJECT ID".to_string());
}
}
},
}

let size = get_object_size(object);
Expand Down Expand Up @@ -1603,14 +1615,17 @@ fn get_object_size(object: &MapObject) -> Vec2 {
label = Some("INVALID OBJECT ID".to_string())
}
}
MapObjectKind::Environment => {
if &object.id == "sproinger" {
MapObjectKind::Environment => match object.id.as_str() {
"sproinger" => {
let texture_res = resources.textures.get("sproinger").unwrap();
res = texture_res.meta.frame_size;
} else {
label = Some("INVALID OBJECT ID".to_string())
}
}
"crab" => {
let texture_res = resources.textures.get(CRAB_TEXTURE_ID).unwrap();
res = texture_res.meta.frame_size;
}
_ => label = Some("INVALID OBJECT ID".to_string()),
},
}

if let Some(label) = &label {
Expand Down
6 changes: 5 additions & 1 deletion src/editor/tools/placement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ impl EditorTool for TilePlacementTool {
for x in 0..3 {
if let Some(layer) = &ctx.selected_layer {
let is_some = map
.get_tile(layer, coords.x + x - 1, coords.y + y - 1)
.get_tile(
layer,
(coords.x + x).saturating_sub(1),
(coords.y + y).saturating_sub(1),
)
.is_some();
surrounding_tiles.push(is_some);
}
Expand Down
20 changes: 14 additions & 6 deletions src/game/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ use crate::effects::active::debug_draw_active_effects;
use crate::effects::active::projectiles::fixed_update_projectiles;
use crate::effects::active::triggered::fixed_update_triggered_effects;
use crate::items::spawn_item;
use crate::map::{fixed_update_sproingers, spawn_decoration, spawn_sproinger};
use crate::map::{
fixed_update_sproingers, spawn_crab, spawn_decoration, spawn_sproinger, update_crabs,
};
use crate::network::{
fixed_update_network_client, fixed_update_network_host, update_network_client,
update_network_host,
Expand Down Expand Up @@ -118,7 +120,8 @@ impl Game {
.add_system(update_player_states)
.add_system(update_player_inventory)
.add_system(update_player_passive_effects)
.add_system(update_player_events);
.add_system(update_player_events)
.add_system(update_crabs);

fixed_updates_builder
.add_system(fixed_update_physics_bodies)
Expand Down Expand Up @@ -258,15 +261,20 @@ pub fn spawn_map_objects(world: &mut World, map: &Map) -> Result<Vec<Entity>> {
println!("WARNING: Invalid item id '{}'", &map_object.id)
}
}
MapObjectKind::Environment => {
if map_object.id == "sproinger" {
MapObjectKind::Environment => match map_object.id.as_str() {
"sproinger" => {
let sproinger = spawn_sproinger(world, map_object.position)?;
objects.push(sproinger);
} else {
}
"crab" => {
let crab = spawn_crab(world, map_object.position)?;
objects.push(crab);
}
_ => {
#[cfg(debug_assertions)]
println!("WARNING: Invalid environment item id '{}'", &map_object.id)
}
}
},
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub mod particles;
pub mod physics;
pub mod player;
pub mod resources;
pub mod utils;

pub mod drawables;

Expand Down
Loading