11use crate :: puzzle_size:: PuzzleSize ;
22use crate :: sfx:: stop_bgm;
3- use crate :: { SFX_CONGRATS , Scene , SceneAction , SceneMusic , bg_gfx , sprites } ;
4- use agb:: display:: object:: { AffineMatrixObject , AffineMode , GraphicsMode , Object , ObjectAffine } ;
3+ use crate :: { bg_gfx , sprites , Scene , SceneAction , SceneMusic , SFX_CONGRATS } ;
4+ use agb:: display:: object:: { AffineMatrixObject , AffineMode , GraphicsMode , Object , ObjectAffine , Sprite } ;
55use agb:: display:: tiled:: RegularBackgroundSize :: Background32x32 ;
66use agb:: display:: tiled:: { RegularBackground , TileFormat , VRAM_MANAGER } ;
77use agb:: display:: { AffineMatrix , GraphicsFrame , Priority } ;
8- use agb:: fixnum:: { Num , Vector2D , num , vec2 } ;
8+ use agb:: fixnum:: { num , vec2 , Num , Vector2D } ;
99use agb:: input:: { Button , ButtonController } ;
1010use agb:: sound:: mixer:: { ChannelId , Mixer , SoundChannel } ;
1111use alloc:: boxed:: Box ;
12+ use core:: ops:: Sub ;
1213
1314const DURATION : i32 = 50 ;
1415const IMG_DURATION : f32 = 80.0 ;
@@ -21,7 +22,8 @@ pub struct GameWinScene {
2122 background : RegularBackground ,
2223 puzzle_size : PuzzleSize ,
2324 music_enabled : bool ,
24- puzzle_sprite : ObjectAffine ,
25+ puzzle_sprite : & ' static Sprite ,
26+ scale : Num < i32 , 4 >
2527}
2628
2729impl GameWinScene {
@@ -31,20 +33,13 @@ impl GameWinScene {
3133 RegularBackground :: new ( Priority :: P3 , Background32x32 , TileFormat :: FourBpp ) ;
3234 background. fill_with ( & bg_gfx:: win) ;
3335
34- let num: Num < i32 , 8 > = num ! ( 0.5 ) ;
35-
36- let puzzle_sprite = ObjectAffine :: new (
37- puzzle_size. images ( ) . sprite ( game_idx) ,
38- AffineMatrixObject :: new ( AffineMatrix :: from_scale ( Vector2D :: new ( num, num) ) ) ,
39- AffineMode :: AffineDouble ,
40- ) ;
41-
4236 Box :: new ( Self {
4337 anim_timer : 0 ,
4438 background,
4539 puzzle_size,
4640 music_enabled,
47- puzzle_sprite,
41+ puzzle_sprite : puzzle_size. images ( ) . sprite ( game_idx) ,
42+ scale : num ! ( 0.5 )
4843 } )
4944 }
5045}
@@ -63,6 +58,7 @@ impl Scene for GameWinScene {
6358 }
6459
6560 fn update ( & mut self , buttons : & ButtonController , mixer : & mut Mixer ) -> Option < SceneAction > {
61+ self . scale = self . scale . sub ( num ! ( 0.01 ) ) . max ( num ! ( 0.5 ) ) ;
6662 if self . music_enabled && self . anim_timer == 4 {
6763 let mut music = SoundChannel :: new_high_priority ( SFX_CONGRATS ) ;
6864 music. stereo ( ) ;
@@ -77,10 +73,16 @@ impl Scene for GameWinScene {
7773 }
7874
7975 fn show ( & mut self , graphics : & mut GraphicsFrame ) {
76+ let obj = ObjectAffine :: new (
77+ self . puzzle_sprite ,
78+ AffineMatrixObject :: new ( AffineMatrix :: from_scale ( Vector2D :: new ( self . scale , self . scale ) ) ) ,
79+ AffineMode :: AffineDouble ,
80+ ) ;
81+
8082 draw_bg_and_image (
8183 & mut self . anim_timer ,
8284 self . puzzle_size ,
83- & mut self . puzzle_sprite ,
85+ obj ,
8486 & self . background ,
8587 graphics,
8688 ) ;
@@ -92,7 +94,7 @@ impl Scene for GameWinScene {
9294fn draw_bg_and_image (
9395 anim_timer : & mut u16 ,
9496 puzzle_size : PuzzleSize ,
95- puzzle_sprite : & mut ObjectAffine ,
97+ mut puzzle_sprite : ObjectAffine ,
9698 background : & RegularBackground ,
9799 graphics : & mut GraphicsFrame ,
98100) {
0 commit comments