Merge pull request #36 from Ewpratten/octopus_asset

Octopus asset
This commit is contained in:
Evan Pratten 2021-04-25 15:45:02 -04:00 committed by GitHub
commit 9bd4cb4122
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 220 additions and 5 deletions

Binary file not shown.

View File

@ -0,0 +1,66 @@
{ "frames": {
"octopus 0.aseprite": {
"frame": { "x": 0, "y": 0, "w": 20, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 20, "h": 20 },
"sourceSize": { "w": 20, "h": 20 },
"duration": 100
},
"octopus 1.aseprite": {
"frame": { "x": 20, "y": 0, "w": 20, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 20, "h": 20 },
"sourceSize": { "w": 20, "h": 20 },
"duration": 100
},
"octopus 2.aseprite": {
"frame": { "x": 40, "y": 0, "w": 20, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 20, "h": 20 },
"sourceSize": { "w": 20, "h": 20 },
"duration": 100
},
"octopus 3.aseprite": {
"frame": { "x": 60, "y": 0, "w": 20, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 20, "h": 20 },
"sourceSize": { "w": 20, "h": 20 },
"duration": 100
},
"octopus 4.aseprite": {
"frame": { "x": 80, "y": 0, "w": 20, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 20, "h": 20 },
"sourceSize": { "w": 20, "h": 20 },
"duration": 100
},
"octopus 5.aseprite": {
"frame": { "x": 100, "y": 0, "w": 20, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 20, "h": 20 },
"sourceSize": { "w": 20, "h": 20 },
"duration": 100
}
},
"meta": {
"app": "http://www.aseprite.org/",
"version": "1.2.27-x64",
"image": "octopus.png",
"format": "RGBA8888",
"size": { "w": 120, "h": 20 },
"scale": "1",
"frameTags": [
],
"layers": [
{ "name": "Layer 1", "opacity": 255, "blendMode": "normal" }
],
"slices": [
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 B

Binary file not shown.

View File

@ -0,0 +1,50 @@
{ "frames": {
"octopusSuck 0.aseprite": {
"frame": { "x": 0, "y": 0, "w": 30, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 30, "h": 20 },
"sourceSize": { "w": 30, "h": 20 },
"duration": 100
},
"octopusSuck 1.aseprite": {
"frame": { "x": 30, "y": 0, "w": 30, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 30, "h": 20 },
"sourceSize": { "w": 30, "h": 20 },
"duration": 100
},
"octopusSuck 2.aseprite": {
"frame": { "x": 60, "y": 0, "w": 30, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 30, "h": 20 },
"sourceSize": { "w": 30, "h": 20 },
"duration": 100
},
"octopusSuck 3.aseprite": {
"frame": { "x": 90, "y": 0, "w": 30, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 30, "h": 20 },
"sourceSize": { "w": 30, "h": 20 },
"duration": 100
}
},
"meta": {
"app": "http://www.aseprite.org/",
"version": "1.2.27-x64",
"image": "octopusSuck.png",
"format": "RGBA8888",
"size": { "w": 120, "h": 20 },
"scale": "1",
"frameTags": [
],
"layers": [
{ "name": "Layer 1", "opacity": 255, "blendMode": "normal" }
],
"slices": [
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/img/items/air1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

BIN
assets/img/items/air2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

BIN
assets/img/items/air3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

BIN
assets/img/items/stun1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

BIN
assets/img/items/stun2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

BIN
assets/img/items/stun3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

View File

@ -0,0 +1,67 @@
{ "frames": {
"Sprite-0002 0.": {
"frame": { "x": 0, "y": 0, "w": 10, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 10, "h": 20 },
"sourceSize": { "w": 10, "h": 20 },
"duration": 100
},
"Sprite-0002 1.": {
"frame": { "x": 10, "y": 0, "w": 10, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 10, "h": 20 },
"sourceSize": { "w": 10, "h": 20 },
"duration": 100
},
"Sprite-0002 2.": {
"frame": { "x": 20, "y": 0, "w": 10, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 10, "h": 20 },
"sourceSize": { "w": 10, "h": 20 },
"duration": 100
},
"Sprite-0002 3.": {
"frame": { "x": 30, "y": 0, "w": 10, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 10, "h": 20 },
"sourceSize": { "w": 10, "h": 20 },
"duration": 100
},
"Sprite-0002 4.": {
"frame": { "x": 40, "y": 0, "w": 10, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 10, "h": 20 },
"sourceSize": { "w": 10, "h": 20 },
"duration": 100
},
"Sprite-0002 5.": {
"frame": { "x": 50, "y": 0, "w": 10, "h": 20 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 10, "h": 20 },
"sourceSize": { "w": 10, "h": 20 },
"duration": 100
}
},
"meta": {
"app": "http://www.aseprite.org/",
"version": "1.2.27-x64",
"image": "transponder.png",
"format": "RGBA8888",
"size": { "w": 60, "h": 20 },
"scale": "1",
"frameTags": [
],
"layers": [
{ "name": "Layer 1", "opacity": 255, "blendMode": "normal" },
{ "name": "Layer 2", "opacity": 255, "blendMode": "normal" }
],
"slices": [
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

View File

@ -1,4 +1,8 @@
use crate::{lib::utils::calculate_linear_slide, pallette::{TRANSLUCENT_RED_64, TRANSLUCENT_WHITE_128, TRANSLUCENT_WHITE_64}, player::Player};
use crate::{
lib::utils::calculate_linear_slide,
pallette::{TRANSLUCENT_RED_64, TRANSLUCENT_WHITE_128, TRANSLUCENT_WHITE_64},
player::Player,
};
use super::base::EnemyBase;
use rand::{prelude::ThreadRng, Rng};
@ -71,7 +75,8 @@ impl EnemyBase for Octopus {
// Every once in a while, start sucking air
if (context_2d.get_time() % OCTOPUS_SUCK_AIR_DELAY) < 0.1
&& self.suck_air_time_remaining == 0.0 && !is_octopus_stunned
&& self.suck_air_time_remaining == 0.0
&& !is_octopus_stunned
{
self.suck_air_time_remaining = OCTOPUS_SUCK_AIR_DURATION;
self.has_taken_air_from_player = false;
@ -107,15 +112,22 @@ impl EnemyBase for Octopus {
self.suck_air_bubbles.clear();
}
// TODO: TMP
context_2d.draw_circle_v(self.current_position, 10.0, Color::RED);
// Render animation
if self.suck_air_time_remaining > 0.0 {
resources
.octopus_animation_attack
.draw(context_2d, self.current_position, 0.0);
} else {
resources
.octopus_animation_regular
.draw(context_2d, self.current_position, 0.0);
}
}
fn handle_logic(&mut self, player: &mut crate::player::Player, dt: f64) {
if self.suck_air_time_remaining > 0.0 && !self.has_taken_air_from_player {
if player.position.distance_to(self.current_position).abs() <= OCTOPUS_SUCK_AIR_RANGE {
// Take air from the player
println!("Stealing");
player.breath_percent -= OCTOPUS_SUCK_AIR_AMOUNT;
// Set the flag

View File

@ -26,6 +26,8 @@ pub struct GlobalResources {
// Enemies
pub jellyfish_animation_regular: FrameAnimationWrapper,
pub jellyfish_animation_attack: FrameAnimationWrapper,
pub octopus_animation_regular: FrameAnimationWrapper,
pub octopus_animation_attack: FrameAnimationWrapper,
// Darkness layer
pub darkness_overlay: Texture2D,
@ -124,6 +126,24 @@ impl GlobalResources {
15,
4,
),
octopus_animation_regular: FrameAnimationWrapper::new(
raylib.load_texture_from_image(
&thread,
&Image::load_image("./assets/img/enemies/octopus.png")?,
)?,
Vector2 { x: 20.0, y: 20.0 },
6,
4,
),
octopus_animation_attack: FrameAnimationWrapper::new(
raylib.load_texture_from_image(
&thread,
&Image::load_image("./assets/img/enemies/octopusSuck.png")?,
)?,
Vector2 { x: 30.0, y: 20.0 },
4,
4,
),
darkness_overlay: raylib.load_texture_from_image(
&thread,
&Image::load_image("./assets/img/map/darkness.png")?,