From b1a1b2e1057415a6a0c77ceb117239e1451b3710 Mon Sep 17 00:00:00 2001 From: rsninja722 Date: Sun, 25 Apr 2021 13:15:06 -0400 Subject: [PATCH] fish? --- assets/img/map/fish.aseprite | Bin 0 -> 1556 bytes assets/img/map/fish.json | 26 +++++++ assets/img/map/fish.png | Bin 0 -> 2022 bytes assets/img/map/fishIdle.aseprite | Bin 0 -> 2625 bytes assets/img/map/fishIdle.json | 130 +++++++++++++++++++++++++++++++ assets/img/map/fishIdle.png | Bin 0 -> 2039 bytes src/entities/fish.rs | 82 +++++++++---------- src/logic/ingame/mod.rs | 2 +- src/resources.rs | 22 ++++++ 9 files changed, 215 insertions(+), 47 deletions(-) create mode 100644 assets/img/map/fish.aseprite create mode 100644 assets/img/map/fish.json create mode 100644 assets/img/map/fish.png create mode 100644 assets/img/map/fishIdle.aseprite create mode 100644 assets/img/map/fishIdle.json create mode 100644 assets/img/map/fishIdle.png diff --git a/assets/img/map/fish.aseprite b/assets/img/map/fish.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..18832477ccd50ad3a650b490becfd37b68ca224a GIT binary patch literal 1556 zcmcJOdq`7J9LLYR?anYaNmI+$wMkfn=}1jWW>!lwqZBNOab42Lv6h9}W1!YbD|!=T zSt&&?%Fsj$11YDt$PlrX(?Waus3@thWxIXv6dU_v6x6w#59gk9x!>>i{Lb;A3F*5u znRt@PgdqY#hz$LA3nK!4l6c|yA5H8=i1oA3t}29pFS>}aOFGC6V?3P+8=sLntk{Pf zAv2lz;Ii;VpgJxJJesi(?A& zQ5-0j=Yf$~d%*R&7hrZd2eOY|gAaQ~K@N?O@~Ye5-ojEaN238VGt$6dS^@Ajqi7N3w?*u*0x>=X$j8T-gnE}B5&@Z+(w!_NfmaKKevt* zR8J_oxu{@EuG!>1ce~MCFW%1?M#i=8drW#!{rq z$X1DqEJH=ytPw*pR8wOaxfl1I^Si%(|9n2rc|Xtlbw1B|&gVSIw$>KHP$?(?0K(Yw z=Jo&p*4d2(`1y8Ez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zj6;TwIT0(pmr!?Ll$|4(4tD04g^~~uP^ihdJ`M+Vr`oBSIFZ8MdE7FGpDeTZy@_F! zQ$uyn1FogvwEI4-Eh?j_ij;uB%CY}~yxxc4Xr>AT0MA|N`$O$07+^LgBPZN$vv=yr zA*jIDik_29+CVE~T_4mkzMf>45OW&2A5CSS^v_gBJ8Fl*&nNXVo-h8*Sy>F5|4iKN zYOFDfjuhdoPvfm`aP&EO_fpN5LD_2Dj^qlwp&OGl0J?5 z1FO`-87SLsR{QXY+li>m$(-U4hgWl6j$eYf^0!VP5WPhmXi0*VCV5stNcp<2bdMY> zQwOlzL`(VlIq2-}i3fkGnI=zNg?8MY1$4 zVe4vaZeaNi^YsDNvqkO_qJ(43I+#UTNmozh{CgENp})sQyAox~cNGd@{T9xT>7_~< z8XVR%J*SK?06{O9-XxpF|3{m+P9Ia3JkcTNy|G=MB!MU;r!S2kO^7NB?E7vg$;u(w zrPZ2u8A}(k*!$RV61c_?dP0?!Vo`mK#Yb5cnM`u*^Mdkk3ly|EmWh zjPaSJ$L*@D6G*6ARm1bw*bg-%(Wy0B@;r{)hzOm0e`2T-xUxo1#gQ1=qG33Y=msuR zltlkpqgBjvh@*!#B!fmqrNq_IhVBwFOiT^vb%sz;<7l=m2+Ea`lj#Ng{8I%E7u7x7 zOUSkP8fZ>XcOcp^Sb=RW7Ph8kg9^^S#Ez}W{69faB6HO~g+RgX P;s&s1t<7uC;A8&+)!WBu literal 0 HcmV?d00001 diff --git a/assets/img/map/fishIdle.aseprite b/assets/img/map/fishIdle.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..6514d45e2ada2137ca1d5330adea7fa84491c26e GIT binary patch literal 2625 zcmcJQeM}Q~7{`BDp^8A+ObXZuhoW0F=!vWZYYP>r&A_=qf+^^vzz|tek?=C0!l1Op z7gls`l;OMRC>A!}l{f|zM;AedGNB4V6ehyJA%cjdx2LUc3p0`avAf(S*SjXq_xs#8 z&%?Gx=-zodWQ!Ie3|SzAqTu@HSb;1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Q6RTt9#oJab(2evTZgy0=IcvrX>YYZjsONpJFm#3q^&;(QV|*vIOD9wMMV}L2tV|%(PaC?h32aF-xx8H2vc=1-xM8BP_0CPz zmuIN`EA44gb}ZYI>mEqSkt+R@9O?@B>9CHJel-qZQw@J?o^+`B(*p6{FQ_xSQ4Xe+ zM{kCex4Pxk%FC&J?aI>@8&{qtZ0;+s&Pm~9ZlG=)db#pk4J*(4)ym^s`R~f3nO5GF NYBN^e$2aqIe*s%@r5OMK literal 0 HcmV?d00001 diff --git a/assets/img/map/fishIdle.json b/assets/img/map/fishIdle.json new file mode 100644 index 0000000..f8f5e3b --- /dev/null +++ b/assets/img/map/fishIdle.json @@ -0,0 +1,130 @@ +{ "frames": { + "fishIdle 0.aseprite": { + "frame": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "sourceSize": { "w": 13, "h": 9 }, + "duration": 100 + }, + "fishIdle 1.aseprite": { + "frame": { "x": 13, "y": 0, "w": 13, "h": 9 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "sourceSize": { "w": 13, "h": 9 }, + "duration": 100 + }, + "fishIdle 2.aseprite": { + "frame": { "x": 26, "y": 0, "w": 13, "h": 9 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "sourceSize": { "w": 13, "h": 9 }, + "duration": 100 + }, + "fishIdle 3.aseprite": { + "frame": { "x": 39, "y": 0, "w": 13, "h": 9 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "sourceSize": { "w": 13, "h": 9 }, + "duration": 100 + }, + "fishIdle 4.aseprite": { + "frame": { "x": 52, "y": 0, "w": 13, "h": 9 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "sourceSize": { "w": 13, "h": 9 }, + "duration": 100 + }, + "fishIdle 5.aseprite": { + "frame": { "x": 65, "y": 0, "w": 13, "h": 9 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "sourceSize": { "w": 13, "h": 9 }, + "duration": 100 + }, + "fishIdle 6.aseprite": { + "frame": { "x": 78, "y": 0, "w": 13, "h": 9 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "sourceSize": { "w": 13, "h": 9 }, + "duration": 100 + }, + "fishIdle 7.aseprite": { + "frame": { "x": 91, "y": 0, "w": 13, "h": 9 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "sourceSize": { "w": 13, "h": 9 }, + "duration": 100 + }, + "fishIdle 8.aseprite": { + "frame": { "x": 104, "y": 0, "w": 13, "h": 9 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "sourceSize": { "w": 13, "h": 9 }, + "duration": 100 + }, + "fishIdle 9.aseprite": { + "frame": { "x": 117, "y": 0, "w": 13, "h": 9 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "sourceSize": { "w": 13, "h": 9 }, + "duration": 100 + }, + "fishIdle 10.aseprite": { + "frame": { "x": 130, "y": 0, "w": 13, "h": 9 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "sourceSize": { "w": 13, "h": 9 }, + "duration": 100 + }, + "fishIdle 11.aseprite": { + "frame": { "x": 143, "y": 0, "w": 13, "h": 9 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "sourceSize": { "w": 13, "h": 9 }, + "duration": 100 + }, + "fishIdle 12.aseprite": { + "frame": { "x": 156, "y": 0, "w": 13, "h": 9 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "sourceSize": { "w": 13, "h": 9 }, + "duration": 100 + }, + "fishIdle 13.aseprite": { + "frame": { "x": 169, "y": 0, "w": 13, "h": 9 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 13, "h": 9 }, + "sourceSize": { "w": 13, "h": 9 }, + "duration": 100 + } + }, + "meta": { + "app": "http://www.aseprite.org/", + "version": "1.2.27-x64", + "image": "fishIdle.png", + "format": "RGBA8888", + "size": { "w": 182, "h": 9 }, + "scale": "1", + "frameTags": [ + ], + "layers": [ + { "name": "Layer 1", "opacity": 255, "blendMode": "normal" } + ], + "slices": [ + ] + } +} diff --git a/assets/img/map/fishIdle.png b/assets/img/map/fishIdle.png new file mode 100644 index 0000000000000000000000000000000000000000..44c696708e3a68577080128a8cbb4723f94d4562 GIT binary patch literal 2039 zcmVPx+u}MThR9J<*m|tjH=NX58M{(05f0iwGuIx$OGS{7)**M!QXtxrDrcPL4m2HwN zyJ<+uU{|>r3xh)T=b}&ugYKdiBR6j8T^dFcGg#={!JIUt5J5cbs$Lb%)RL`ZxjNG4 zFFHAv&e_E|?`Qq9YH!Bp=6o;b)p-nlelITv*ydU}ecImc*k&Yynq*}ia2 z-&@%i&Wp=u_Jy@kH+M)7v?8y61q~@ z+_l`T`v39A@5^Tk?;f>D=%Og^TJBc;_s>-Mb}?p?(EPEvYq?wXdl+LNxx>@bNj4N zx2DT_=|5>)9=~h9b?(!K-%`&`!@wAma!r^^}=&ghu`*^Y8x74%KFqC_@ z=))I8h%SXI}Jmi(~@!zUAV0j^6Rqx_fj77S4ZrHcaJvw zmU?y?2F93_JN(YHQpjnt&Mc*nI3KkaFE;Vb?b&GF;m+U1mExrTak{Tv| z5JvbN*SGVoZ`b1roqc^F@Kx70pI`O@fQP5k@c8`z0BwC;zT6iIp(_wTu)iMwFdhiN z(sk5NZ<3lZ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6;H(t@YU}$N6beK4b3LdOHc`rKG=zcnWWZS~082_d ze|5wj{^f)1|36+8$1golC=Abj>uD548QC0f2m|fOfU{NrsHqRX*TOfiipcf2LSg9Z zA8@ApYPx9{{-=w+iX@^@n*u@g|NZhB&Xmi!W>X-j-b)UB6}dcq*QP*Fy_X#NDiXbw zuqhB!?45wi5{Fsy^?) { @@ -163,40 +156,37 @@ impl FishEntity { } } - pub fn render(&self, context_2d: &mut RaylibMode2D) { + pub fn render(&mut self, context_2d: &mut RaylibMode2D, resources: &mut GlobalResources) { // Direction let direction = Vector2::zero().angle_to(self.direction.normalized()) + (90.0 as f32).to_radians(); - // Get the corners of the fish - let fish_front = rotate_vector( - Vector2 { - x: 0.0, - y: (self.size.y / 2.0) * -1.0, - }, - direction, - ); - let fish_bl = rotate_vector( - Vector2 { - x: (self.size.x / 2.0) * -1.0, - y: (self.size.y / 2.0), - }, - direction, - ); - let fish_br = rotate_vector( - Vector2 { - x: (self.size.x / 2.0), - y: (self.size.y / 2.0), - }, - direction, - ); + self.animation_counter += 1; - // Draw the fish as a triangle with rotation - context_2d.draw_triangle( - self.position + fish_front, - self.position + fish_bl, - self.position + fish_br, - self.color, - ); + // swimming + if self.following_player { + if self.animation_counter % 3 == 0 { + if self.current_frame == 8 { + self.current_frame = 0; + } + } + resources.fish_animation_swim.draw_frame(context_2d, + self.position, + direction, + (self.current_frame + self.color * 9) as u32); + // idle + } else { + if self.animation_counter % 10 == 0 { + if self.current_frame == 0 { + self.current_frame = 1; + } else { + self.current_frame = 0; + } + } + resources.fish_animation_idle.draw_frame(context_2d, + self.position, + direction, + (self.current_frame + self.color * 2) as u32); + } } } diff --git a/src/logic/ingame/mod.rs b/src/logic/ingame/mod.rs index 3f2bce6..ea95cf2 100644 --- a/src/logic/ingame/mod.rs +++ b/src/logic/ingame/mod.rs @@ -62,7 +62,7 @@ impl InGameScreen { let fish_clone = game_core.world.fish.clone(); for fish in game_core.world.fish.iter_mut() { fish.update_position(&mut game_core.player, dt, &fish_clone); - fish.render(context_2d); + fish.render(context_2d, &mut game_core.resources); } // Render the world texture diff --git a/src/resources.rs b/src/resources.rs index 03cd78c..3e7b27a 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -17,6 +17,10 @@ pub struct GlobalResources { pub player_animation_boost_charge: FrameAnimationWrapper, pub player_animation_boost: FrameAnimationWrapper, pub player_animation_stunned: FrameAnimationWrapper, + + // Fish + pub fish_animation_idle: FrameAnimationWrapper, + pub fish_animation_swim: FrameAnimationWrapper, // Cave pub cave_mid_layer: Texture2D, @@ -76,6 +80,24 @@ impl GlobalResources { 4, 100 / 8, ), + fish_animation_idle: FrameAnimationWrapper::new( + raylib.load_texture_from_image( + &thread, + &Image::load_image("./assets/img/map/fishIdle.png")?, + )?, + Vector2 { x: 13.0, y: 9.0 }, + 14, + 4, + ), + fish_animation_swim: FrameAnimationWrapper::new( + raylib.load_texture_from_image( + &thread, + &Image::load_image("./assets/img/map/fish.png")?, + )?, + Vector2 { x: 13.0, y: 9.0 }, + 63, + 30, + ), cave_mid_layer: raylib.load_texture_from_image( &thread, &Image::load_image("./assets/img/map/cave.png")?,