Skip to content

Commit

Permalink
feat: Cannon re-implement (#965)
Browse files Browse the repository at this point in the history
This PR closes #576.

I started this as draft because I think the team feedback is important
before I head to writing the cannon itself.

There are many `.yaml` fields that are used only when holding the
kickbomb, and I wonder if I should delete these from the cannonball (as
it will only work at the lit state) or just leave it there because the
game would just crash if the cannonball is used as non-lit.

I also used `.clone()` while dealing with `SVec<>` and animations in
`kick_bomb.rs` because I think it was the only option, but using
`.clone()` is quite inefficient so I wonder if there's another way of
doing that.
  • Loading branch information
DRuppFv authored May 2, 2024
1 parent cb8db89 commit fe29788
Show file tree
Hide file tree
Showing 22 changed files with 505 additions and 43 deletions.
4 changes: 4 additions & 0 deletions assets/elements/item/cannon/cannon.atlas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image: ./cannon.png
tile_size: [60, 42]
rows: 1
columns: 4
3 changes: 2 additions & 1 deletion assets/elements/item/cannon/cannon.element.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
name: Canon
name: Cannon
category: Weapons
data: cannon.yaml
Binary file added assets/elements/item/cannon/cannon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions assets/elements/item/cannon/cannon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
atlas: ./cannon.atlas.yaml
animation_fps: 12

max_ammo: 4
cooldown: 600ms
bullet_spawn_offset: [22, 2]

shoot_fps: 10
shoot_frames: 5
shoot_lifetime: 0.5
shoot_sound_volume: 0.1
shoot_sound: ./shoot/shoot.ogg
empty_shoot_sound_volume: 0.1
empty_shoot_sound: ./shoot/gun_empty.ogg
shoot_atlas: ./shoot/cannon_shoot.atlas.yaml

bomb_meta: ../cannonball/kick_bomb.yaml

bounciness: 0.3
can_rotate: true
fin_anim: grab_2
body_size: [32, 18]
angular_velocity: 0.1
throw_velocity: 360
grab_offset: [12, 0]
kickback: 0
Binary file added assets/elements/item/cannon/shoot/cannon_fire.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/elements/item/cannon/shoot/cannon_shoot.atlas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image: ./cannon_fire.png
tile_size: [30, 48]
rows: 1
columns: 5
Binary file added assets/elements/item/cannon/shoot/gun_empty.ogg
Binary file not shown.
Binary file added assets/elements/item/cannon/shoot/shoot.ogg
Binary file not shown.
4 changes: 4 additions & 0 deletions assets/elements/item/cannonball/cannonball.atlas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image: ./cannonball.png
tile_size: [17, 17]
rows: 1
columns: 1
3 changes: 3 additions & 0 deletions assets/elements/item/cannonball/cannonball.element.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: Cannonball
category: Weapons
data: kick_bomb.yaml
Binary file added assets/elements/item/cannonball/cannonball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/elements/item/cannonball/explosion.atlas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image: ./explosion.png
tile_size: [144, 112]
rows: 1
columns: 11
Binary file added assets/elements/item/cannonball/explosion.ogg
Binary file not shown.
Binary file added assets/elements/item/cannonball/explosion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/elements/item/cannonball/fuse.ogg
Binary file not shown.
31 changes: 31 additions & 0 deletions assets/elements/item/cannonball/kick_bomb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
fuse_time: 2s
kick_velocity: [0.0, 0.0]
kickable: false
throw_velocity: 800
damage_region_size: [70, 70]
damage_region_lifetime: 0.5

atlas: ./cannonball.atlas.yaml

explosion_atlas: ./explosion.atlas.yaml
explosion_lifetime: 1.0
explosion_frames: 12
explosion_fps: 8
explosion_sound: ./explosion.ogg
explosion_volume: 0.1
explode_on_contact: true

lit_frames_start: 0
lit_frames_end: 1
lit_fps: 1.0

fuse_sound: ./fuse.ogg
fuse_sound_volume: 0.1

body_diameter: 16
grab_offset: [0, -2]
fin_anim: grab_2
can_rotate: true
bounciness: 0.5
angular_velocity: 0.2
arm_delay: 500ms
6 changes: 6 additions & 0 deletions assets/elements/item/kick_bomb/kick_bomb.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fuse_time: 4s
kick_velocity: [600.0, 120.0]
kickable: true
throw_velocity: 600
damage_region_size: [60, 60]
damage_region_lifetime: 0.6
Expand All @@ -12,6 +13,11 @@ explosion_frames: 12
explosion_fps: 8
explosion_sound: ./explosion.ogg
explosion_volume: 0.1
explode_on_contact: false

lit_frames_start: 3
lit_frames_end: 5
lit_fps: 8.0

fuse_sound_volume: 0.1
fuse_sound: ./fuse.ogg
Expand Down
2 changes: 2 additions & 0 deletions assets/game.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ core:
- /elements/environment/slippery/slippery.element.yaml
- /elements/environment/slippery_seaweed/slippery_seaweed.element.yaml
- /elements/item/crate/crate.element.yaml
- /elements/item/cannon/cannon.element.yaml
- /elements/item/cannonball/cannonball.element.yaml
- /elements/item/grenade/grenade.element.yaml
- /elements/item/jellyfish/jellyfish.element.yaml
- /elements/item/kick_bomb/kick_bomb.element.yaml
Expand Down
2 changes: 1 addition & 1 deletion assets/map/levels/level_10.map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ layers:
- pos:
- 800.0
- 406.5
element: /elements/item/musket/musket.element.yaml
element: /elements/item/cannon/cannon.element.yaml
- pos:
- 64.0
- 406.5
Expand Down
2 changes: 2 additions & 0 deletions src/core/elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::sync::Mutex;
use crate::{impl_system_param, prelude::*};

pub mod buss;
pub mod cannon;
pub mod crab;
pub mod crate_item;
pub mod decoration;
Expand Down Expand Up @@ -311,6 +312,7 @@ macro_rules! install_plugins {
install_plugins!(
crab,
crate_item,
cannon,
decoration,
fish_school,
grenade,
Expand Down
Loading

0 comments on commit fe29788

Please sign in to comment.