Skip to content

Commit 457cafe

Browse files
committed
Change win image to scale instead of fade
1 parent 1b8c22a commit 457cafe

4 files changed

Lines changed: 21 additions & 32 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.2.2
2+
3+
- Change puzzle image on win screen to scale instead of fade in
4+
15
# 0.2.1
26

37
- Add 8 12x12

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "nonogram_advance"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
publish = false
55
authors = ["Emma Britton <emmabritton@pm.me>"]
66
readme = "README.md"

assets/22x12.nonos

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ _##___#__#__#__#___##_
77
####_______________###
88
####_______________###
99
#####____________#####
10-
#####____________#####
11-
######__________######
10+
#####_____##_____#####
11+
######____##____######
1212
#######________#######
1313

1414
____##_____###________

src/scenes/scene_game_win.rs

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
use crate::puzzle_size::PuzzleSize;
22
use crate::sfx::stop_bgm;
3-
use crate::{bg_gfx, sprites, Scene, SceneAction, SceneMusic, SFX_CONGRATS};
4-
use agb::display::object::{AffineMatrixObject, AffineMode, GraphicsMode, Object, ObjectAffine, Sprite};
3+
use crate::{SFX_CONGRATS, Scene, SceneAction, SceneMusic, bg_gfx, sprites};
4+
use agb::display::object::{AffineMatrixObject, AffineMode, Object, ObjectAffine, Sprite};
55
use agb::display::tiled::RegularBackgroundSize::Background32x32;
66
use agb::display::tiled::{RegularBackground, TileFormat, VRAM_MANAGER};
77
use agb::display::{AffineMatrix, GraphicsFrame, Priority};
8-
use agb::fixnum::{num, vec2, Num, Vector2D};
8+
use agb::fixnum::{Num, Vector2D, num, vec2};
99
use agb::input::{Button, ButtonController};
1010
use agb::sound::mixer::{ChannelId, Mixer, SoundChannel};
1111
use alloc::boxed::Box;
1212
use core::ops::Sub;
1313

1414
const DURATION: i32 = 50;
15-
const IMG_DURATION: f32 = 80.0;
1615

1716
// C o n g r a t u l a t i o n s !
1817
const LETTER_SPACING: [i32; 16] = [14, 12, 12, 14, 10, 14, 10, 14, 7, 12, 10, 8, 12, 14, 12, 0];
@@ -23,7 +22,7 @@ pub struct GameWinScene {
2322
puzzle_size: PuzzleSize,
2423
music_enabled: bool,
2524
puzzle_sprite: &'static Sprite,
26-
scale: Num<i32, 4>
25+
scale: Num<i32, 16>,
2726
}
2827

2928
impl GameWinScene {
@@ -39,7 +38,7 @@ impl GameWinScene {
3938
puzzle_size,
4039
music_enabled,
4140
puzzle_sprite: puzzle_size.images().sprite(game_idx),
42-
scale: num!(0.5)
41+
scale: num!(2.0),
4342
})
4443
}
4544
}
@@ -58,7 +57,7 @@ impl Scene for GameWinScene {
5857
}
5958

6059
fn update(&mut self, buttons: &ButtonController, mixer: &mut Mixer) -> Option<SceneAction> {
61-
self.scale = self.scale.sub(num!(0.01)).max(num!(0.5));
60+
self.scale = self.scale.sub(num!(0.005)).max(num!(0.5));
6261
if self.music_enabled && self.anim_timer == 4 {
6362
let mut music = SoundChannel::new_high_priority(SFX_CONGRATS);
6463
music.stereo();
@@ -75,48 +74,34 @@ impl Scene for GameWinScene {
7574
fn show(&mut self, graphics: &mut GraphicsFrame) {
7675
let obj = ObjectAffine::new(
7776
self.puzzle_sprite,
78-
AffineMatrixObject::new(AffineMatrix::from_scale(Vector2D::new(self.scale, self.scale))),
77+
AffineMatrixObject::new(AffineMatrix::from_scale(Vector2D::new(
78+
self.scale, self.scale,
79+
))),
7980
AffineMode::AffineDouble,
8081
);
8182

82-
draw_bg_and_image(
83-
&mut self.anim_timer,
84-
self.puzzle_size,
85-
obj,
86-
&self.background,
87-
graphics,
88-
);
83+
self.anim_timer += 1;
84+
85+
draw_bg_and_image(self.puzzle_size, obj, &self.background, graphics);
8986

9087
draw_congrats(self.anim_timer, graphics);
9188
}
9289
}
9390

9491
fn draw_bg_and_image(
95-
anim_timer: &mut u16,
9692
puzzle_size: PuzzleSize,
9793
mut puzzle_sprite: ObjectAffine,
9894
background: &RegularBackground,
9995
graphics: &mut GraphicsFrame,
10096
) {
101-
let id = background.show(graphics);
102-
*anim_timer += 1;
103-
104-
let perc = ((*anim_timer as f32) / IMG_DURATION).min(1.0);
97+
background.show(graphics);
10598

10699
let (x, y) = match puzzle_size {
107100
PuzzleSize::_12x12 | PuzzleSize::_10x10 | PuzzleSize::_6x6 | PuzzleSize::_8x8 => (104, 36),
108101
PuzzleSize::_20x10 | PuzzleSize::_22x12 => (88, 32),
109102
};
110103

111-
puzzle_sprite
112-
.set_pos(vec2(x, y))
113-
.set_graphics_mode(GraphicsMode::AlphaBlending)
114-
.show(graphics);
115-
116-
graphics
117-
.blend()
118-
.object_transparency(Num::from_f32(perc), Num::from_f32(1.0 - perc))
119-
.enable_background(id);
104+
puzzle_sprite.set_pos(vec2(x, y)).show(graphics);
120105
}
121106

122107
fn draw_congrats(anim_timer: u16, graphics: &mut GraphicsFrame) {

0 commit comments

Comments
 (0)