Skip to content
Binary file added assets/Whale/Cannon(50x30).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/Whale/Cannonball(32x36).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions assets/levels/lev01.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,18 @@
"x":210.0,
"y":548.0
},
{
"height":0,
"id":70,
"name":"cannon",
"point":true,
"rotation":0,
"type":"",
"visible":true,
"width":0,
"x":700.0,
"y":548.0
},
{
"height":0,
"id":68,
Expand Down
31 changes: 29 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ pub enum GameType {

struct Resources {
hit_fxses: EmittersCache,
cannonball_hit_fxses: EmittersCache,
explosion_fxses: EmittersCache,
life_explosion_fxses: EmittersCache,
tiled_map: tiled::Map,
collision_world: CollisionWorld,
whale: Texture2D,
whale_red: Texture2D,
grenades: Texture2D,
cannon: Texture2D,
cannonballs: Texture2D,
curse: Texture2D,
flying_curses: Texture2D,
gun: Texture2D,
Expand All @@ -64,6 +67,10 @@ struct Resources {
pub const HIT_FX: &'static str = r#"{"local_coords":false,"emission_shape":"Point","one_shot":true,"lifetime":0.2,"lifetime_randomness":0,"explosiveness":0.65,"amount":41,"shape":{"Circle":{"subdivisions":10}},"emitting":false,"initial_direction":{"x":0,"y":-1},"initial_direction_spread":6.2831855,"initial_velocity":73.9,"initial_velocity_randomness":0.2,"linear_accel":0,"size":5.6000004,"size_randomness":0.4,"blend_mode":"Alpha","colors_curve":{"start":{"r":0.8200004,"g":1,"b":0.31818175,"a":1},"mid":{"r":0.71000004,"g":0.36210018,"b":0,"a":1},"end":{"r":0.02,"g":0,"b":0.000000007152557,"a":1}},"gravity":{"x":0,"y":0},"post_processing":{}}
"#;

/// Has no size randomness, in order to make it clear to players which the radius is.
pub const CANNONBALL_HIT_FX: &'static str = r#"{"local_coords":false,"emission_shape":"Point","one_shot":true,"lifetime":0.2,"lifetime_randomness":0,"explosiveness":0.65,"amount":41,"shape":{"Circle":{"subdivisions":10}},"emitting":false,"initial_direction":{"x":0,"y":-1},"initial_direction_spread":6.2831855,"initial_velocity":73.9,"initial_velocity_randomness":0.2,"linear_accel":0,"size":64.0,"size_randomness":0.0,"blend_mode":"Alpha","colors_curve":{"start":{"r":0.8200004,"g":1,"b":0.31818175,"a":1},"mid":{"r":0.71000004,"g":0.36210018,"b":0,"a":1},"end":{"r":0.02,"g":0,"b":0.000000007152557,"a":1}},"gravity":{"x":0,"y":0},"post_processing":{}}
"#;

pub const EXPLOSION_FX: &'static str = r#"{"local_coords":false,"emission_shape":{"Sphere":{"radius":0.6}},"one_shot":true,"lifetime":0.35,"lifetime_randomness":0,"explosiveness":0.6,"amount":131,"shape":{"Circle":{"subdivisions":10}},"emitting":false,"initial_direction":{"x":0,"y":-1},"initial_direction_spread":6.2831855,"initial_velocity":316,"initial_velocity_randomness":0.6,"linear_accel":-7.4000025,"size":5.5,"size_randomness":0.3,"size_curve":{"points":[[0.005,1.48],[0.255,1.0799999],[1,0.120000005]],"interpolation":"Linear","resolution":30},"blend_mode":"Additive","colors_curve":{"start":{"r":0.9825908,"g":1,"b":0.13,"a":1},"mid":{"r":0.8,"g":0.19999999,"b":0.2000002,"a":1},"end":{"r":0.101,"g":0.099,"b":0.099,"a":1}},"gravity":{"x":0,"y":-500},"post_processing":{}}
"#;

Expand Down Expand Up @@ -102,6 +109,12 @@ impl Resources {
let sproinger = load_texture("assets/Whale/Sproinger(32x32).png").await?;
sproinger.set_filter(FilterMode::Nearest);

let cannon = load_texture("assets/Whale/Cannon(50x30).png").await?;
cannon.set_filter(FilterMode::Nearest);

let cannonballs = load_texture("assets/Whale/Cannonball(32x36).png").await?;
cannonballs.set_filter(FilterMode::Nearest);

let curse = load_texture("assets/Whale/Curse(32x32).png").await?;
curse.set_filter(FilterMode::Nearest);

Expand Down Expand Up @@ -157,20 +170,25 @@ impl Resources {
);

let hit_fxses = EmittersCache::new(nanoserde::DeJson::deserialize_json(HIT_FX).unwrap());
let cannonball_hit_fxses =
EmittersCache::new(nanoserde::DeJson::deserialize_json(CANNONBALL_HIT_FX).unwrap());
let explosion_fxses =
EmittersCache::new(nanoserde::DeJson::deserialize_json(EXPLOSION_FX).unwrap());
let life_explosion_fxses =
EmittersCache::new(nanoserde::DeJson::deserialize_json(LIFE_EXPLOSION_FX).unwrap());

Ok(Resources {
hit_fxses,
cannonball_hit_fxses,
explosion_fxses,
life_explosion_fxses,
tiled_map,
collision_world,
whale,
whale_red,
grenades,
cannon,
cannonballs,
curse,
flying_curses,
gun,
Expand All @@ -195,8 +213,9 @@ impl Resources {

async fn game(game_type: GameType, map: &str) {
use nodes::{
Bullets, Camera, Crate, Curse, Decoration, FlyingCurses, Fxses, GameState, Grenades,
LevelBackground, Mines, Muscet, Player, ScoreCounter, Shoes, Sproinger, Sword, MachineGun,
Bullets, Camera, Cannon, Cannonballs, Crate, Curse, Decoration, FlyingCurses, Fxses,
GameState, Grenades, LevelBackground, Mines, Muscet, Player, ScoreCounter, Shoes,
Sproinger, Sword, MachineGun,
};

let resources_loading = start_coroutine({
Expand Down Expand Up @@ -323,6 +342,13 @@ async fn game(game_type: GameType, map: &str) {
scene::add_node(grenade);
wat_facing ^= true;
}
if object.name == "cannon" {
let mut cannon =
Cannon::new(wat_facing, vec2(object.world_x - 35., object.world_y - 25.));
cannon.throw(false);
scene::add_node(cannon);
wat_facing ^= true;
}

if object.name == "crate" {
let mut crate_node =
Expand Down Expand Up @@ -353,6 +379,7 @@ async fn game(game_type: GameType, map: &str) {
}

scene::add_node(FlyingCurses::new());
scene::add_node(Cannonballs::new());

scene::add_node(Bullets::new());

Expand Down
16 changes: 10 additions & 6 deletions src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ mod armed_grenade;
mod armed_mine;
mod bullets;
mod camera;
mod cannon;
mod cannonball;
mod crates;
mod curse;
mod decoration;
mod flying_curse;
Expand All @@ -13,16 +16,18 @@ mod mines;
mod muscet;
pub mod player;
mod score_counter;
mod sword;
mod sproinger;
mod crates;
mod shoes;
mod sproinger;
mod sword;
mod machine_gun;

pub use armed_grenade::ArmedGrenade;
pub use armed_mine::ArmedMine;
pub use bullets::Bullets;
pub use camera::Camera;
pub use cannon::Cannon;
pub use cannonball::Cannonballs;
pub use crates::Crate;
pub use curse::Curse;
pub use decoration::Decoration;
pub use flying_curse::FlyingCurses;
Expand All @@ -34,8 +39,7 @@ pub use mines::Mines;
pub use muscet::Muscet;
pub use player::Player;
pub use score_counter::ScoreCounter;
pub use sword::Sword;
pub use sproinger::Sproinger;
pub use crates::Crate;
pub use shoes::Shoes;
pub use sproinger::Sproinger;
pub use sword::Sword;
pub use machine_gun::MachineGun;
Loading