mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
fix games
This commit is contained in:
parent
c03c1664cb
commit
660adbe961
|
@ -7,7 +7,7 @@ use agb_fixnum::Vector2D;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use slotmap::{new_key_type, SlotMap};
|
use slotmap::{new_key_type, SlotMap};
|
||||||
|
|
||||||
use crate::{display::Priority, sync::Static};
|
use crate::display::Priority;
|
||||||
|
|
||||||
use super::{AffineMode, Sprite, SpriteVram, StaticSpriteLoader, UnmanagedOAM, UnmanagedObject};
|
use super::{AffineMode, Sprite, SpriteVram, StaticSpriteLoader, UnmanagedOAM, UnmanagedObject};
|
||||||
|
|
||||||
|
|
|
@ -102,13 +102,22 @@ pub struct UnmanagedObject {
|
||||||
impl UnmanagedObject {
|
impl UnmanagedObject {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(sprite: SpriteVram) -> Self {
|
pub fn new(sprite: SpriteVram) -> Self {
|
||||||
Self {
|
let sprite_location = sprite.location();
|
||||||
|
let palette_location = sprite.palette_location();
|
||||||
|
let (shape, size) = sprite.size().shape_size();
|
||||||
|
|
||||||
|
let mut sprite = Self {
|
||||||
attributes: Attributes::default(),
|
attributes: Attributes::default(),
|
||||||
sprites: UnsafeCell::new(VramSprites {
|
sprites: UnsafeCell::new(VramSprites {
|
||||||
sprite,
|
sprite,
|
||||||
previous_sprite: None,
|
previous_sprite: None,
|
||||||
}),
|
}),
|
||||||
}
|
};
|
||||||
|
|
||||||
|
sprite.attributes.set_sprite(sprite_location, shape, size);
|
||||||
|
sprite.attributes.set_palette(palette_location);
|
||||||
|
|
||||||
|
sprite
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_visible(&self) -> bool {
|
pub fn is_visible(&self) -> bool {
|
||||||
|
@ -170,16 +179,21 @@ impl UnmanagedObject {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_sprite(&mut self, sprite: SpriteVram) -> &mut Self {
|
fn set_sprite_attributes(&mut self, sprite: &SpriteVram) -> &mut Self {
|
||||||
// SAFETY: This is called here and in OAMSlot set, neither of which call the other.
|
|
||||||
let sprites = unsafe { &mut *self.sprites.get() };
|
|
||||||
|
|
||||||
let size = sprite.size();
|
let size = sprite.size();
|
||||||
let (shape, size) = size.shape_size();
|
let (shape, size) = size.shape_size();
|
||||||
|
|
||||||
self.attributes.set_sprite(sprite.location(), shape, size);
|
self.attributes.set_sprite(sprite.location(), shape, size);
|
||||||
self.attributes.set_palette(sprite.palette_location());
|
self.attributes.set_palette(sprite.palette_location());
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_sprite(&mut self, sprite: SpriteVram) -> &mut Self {
|
||||||
|
self.set_sprite_attributes(&sprite);
|
||||||
|
|
||||||
|
// SAFETY: This is called here and in OAMSlot set, neither of which call the other.
|
||||||
|
let sprites = unsafe { &mut *self.sprites.get() };
|
||||||
sprites.sprite = sprite;
|
sprites.sprite = sprite;
|
||||||
|
|
||||||
self
|
self
|
||||||
|
|
82
examples/combo/Cargo.lock
generated
82
examples/combo/Cargo.lock
generated
|
@ -26,6 +26,7 @@ dependencies = [
|
||||||
"bitflags 2.0.2",
|
"bitflags 2.0.2",
|
||||||
"modular-bitfield",
|
"modular-bitfield",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
|
"slotmap",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -201,7 +202,7 @@ version = "0.7.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6a62391ecb864cf12ed06b2af4eda2e609b97657950d6a8f06841b17726ab253"
|
checksum = "6a62391ecb864cf12ed06b2af4eda2e609b97657950d6a8f06841b17726ab253"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashbrown",
|
"hashbrown 0.11.2",
|
||||||
"ttf-parser",
|
"ttf-parser",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -234,6 +235,12 @@ dependencies = [
|
||||||
"ahash",
|
"ahash",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.12.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hound"
|
name = "hound"
|
||||||
version = "3.5.0"
|
version = "3.5.0"
|
||||||
|
@ -245,7 +252,6 @@ name = "hyperspace-roll"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"agb",
|
"agb",
|
||||||
"bare-metal",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -263,6 +269,16 @@ dependencies = [
|
||||||
"png",
|
"png",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "indexmap"
|
||||||
|
version = "1.9.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"hashbrown 0.12.3",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.6"
|
version = "1.0.6"
|
||||||
|
@ -296,6 +312,12 @@ dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.3.7"
|
version = "0.3.7"
|
||||||
|
@ -467,6 +489,24 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_spanned"
|
||||||
|
version = "0.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "slotmap"
|
||||||
|
version = "1.0.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342"
|
||||||
|
dependencies = [
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "static_assertions"
|
name = "static_assertions"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -533,11 +573,36 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.5.11"
|
version = "0.7.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
|
checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_spanned",
|
||||||
|
"toml_datetime",
|
||||||
|
"toml_edit",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml_datetime"
|
||||||
|
version = "0.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml_edit"
|
||||||
|
version = "0.19.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13"
|
||||||
|
dependencies = [
|
||||||
|
"indexmap",
|
||||||
|
"serde",
|
||||||
|
"serde_spanned",
|
||||||
|
"toml_datetime",
|
||||||
|
"winnow",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -564,6 +629,15 @@ version = "0.11.0+wasi-snapshot-preview1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winnow"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xml-rs"
|
name = "xml-rs"
|
||||||
version = "0.8.4"
|
version = "0.8.4"
|
||||||
|
|
13
examples/hyperspace-roll/Cargo.lock
generated
13
examples/hyperspace-roll/Cargo.lock
generated
|
@ -26,6 +26,7 @@ dependencies = [
|
||||||
"bitflags 2.0.2",
|
"bitflags 2.0.2",
|
||||||
"modular-bitfield",
|
"modular-bitfield",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
|
"slotmap",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -423,6 +424,18 @@ dependencies = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
name = "slotmap"
|
||||||
|
version = "1.0.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342"
|
||||||
|
dependencies = [
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
>>>>>>> ff9ab890 (fix games)
|
||||||
name = "static_assertions"
|
name = "static_assertions"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
|
@ -494,7 +494,7 @@ pub(crate) fn battle_screen(
|
||||||
|
|
||||||
let obj = &agb.obj;
|
let obj = &agb.obj;
|
||||||
|
|
||||||
let mut select_box_obj = agb.obj.object(agb.obj.sprite(SELECT_BOX.sprite(0)));
|
let mut select_box_obj = agb.obj.add_object_static_sprite(SELECT_BOX.sprite(0));
|
||||||
select_box_obj.show();
|
select_box_obj.show();
|
||||||
|
|
||||||
let num_dice = player_dice.dice.len();
|
let num_dice = player_dice.dice.len();
|
||||||
|
@ -585,7 +585,10 @@ pub(crate) fn battle_screen(
|
||||||
select_box_obj
|
select_box_obj
|
||||||
.set_y(120 - 4)
|
.set_y(120 - 4)
|
||||||
.set_x(selected_die as u16 * 40 + 28 - 4)
|
.set_x(selected_die as u16 * 40 + 28 - 4)
|
||||||
.set_sprite(agb.obj.sprite(SELECT_BOX.animation_sprite(counter / 10)));
|
.set_sprite(
|
||||||
|
agb.obj
|
||||||
|
.get_vram_sprite(SELECT_BOX.animation_sprite(counter / 10)),
|
||||||
|
);
|
||||||
|
|
||||||
agb.star_background.update();
|
agb.star_background.update();
|
||||||
agb.sfx.frame();
|
agb.sfx.frame();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use agb::display::object::{Object, ObjectController};
|
use agb::display::object::{OAMManager, Object};
|
||||||
use agb::rng;
|
use agb::rng;
|
||||||
use alloc::vec;
|
use alloc::vec;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
@ -39,7 +39,7 @@ pub struct BattleScreenDisplay<'a> {
|
||||||
const HEALTH_BAR_WIDTH: usize = 48;
|
const HEALTH_BAR_WIDTH: usize = 48;
|
||||||
|
|
||||||
impl<'a> BattleScreenDisplay<'a> {
|
impl<'a> BattleScreenDisplay<'a> {
|
||||||
pub fn new(obj: &'a ObjectController, current_battle_state: &CurrentBattleState) -> Self {
|
pub fn new(obj: &'a OAMManager, current_battle_state: &CurrentBattleState) -> Self {
|
||||||
let mut misc_sprites = vec![];
|
let mut misc_sprites = vec![];
|
||||||
let player_x = 12;
|
let player_x = 12;
|
||||||
let player_y = 8;
|
let player_y = 8;
|
||||||
|
@ -52,8 +52,8 @@ impl<'a> BattleScreenDisplay<'a> {
|
||||||
Ship::PilotedShip
|
Ship::PilotedShip
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut player_obj = obj.object(obj.sprite(player_sprite));
|
let mut player_obj = obj.add_object_static_sprite(player_sprite);
|
||||||
let mut enemy_obj = obj.object(obj.sprite(enemy_sprite));
|
let mut enemy_obj = obj.add_object_static_sprite(enemy_sprite);
|
||||||
|
|
||||||
player_obj.set_x(player_x).set_y(player_y).set_z(1).show();
|
player_obj.set_x(player_x).set_y(player_y).set_z(1).show();
|
||||||
enemy_obj.set_x(enemy_x).set_y(player_y).set_z(1).show();
|
enemy_obj.set_x(enemy_x).set_y(player_y).set_z(1).show();
|
||||||
|
@ -66,7 +66,7 @@ impl<'a> BattleScreenDisplay<'a> {
|
||||||
.faces_to_render()
|
.faces_to_render()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, (face, _))| {
|
.map(|(i, (face, _))| {
|
||||||
let mut die_obj = obj.object(obj.sprite(FACE_SPRITES.sprite_for_face(face)));
|
let mut die_obj = obj.add_object_static_sprite(FACE_SPRITES.sprite_for_face(face));
|
||||||
|
|
||||||
die_obj.set_y(120).set_x(i as u16 * 40 + 28).show();
|
die_obj.set_y(120).set_x(i as u16 * 40 + 28).show();
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ impl<'a> BattleScreenDisplay<'a> {
|
||||||
|
|
||||||
let player_shield: Vec<_> = (0..5)
|
let player_shield: Vec<_> = (0..5)
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
let mut shield_obj = obj.object(obj.sprite(shield_sprite));
|
let mut shield_obj = obj.add_object_static_sprite(shield_sprite);
|
||||||
shield_obj
|
shield_obj
|
||||||
.set_x(player_x + 18 + 11 * i)
|
.set_x(player_x + 18 + 11 * i)
|
||||||
.set_y(player_y)
|
.set_y(player_y)
|
||||||
|
@ -101,7 +101,7 @@ impl<'a> BattleScreenDisplay<'a> {
|
||||||
|
|
||||||
let enemy_shield: Vec<_> = (0..5)
|
let enemy_shield: Vec<_> = (0..5)
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
let mut shield_obj = obj.object(obj.sprite(shield_sprite));
|
let mut shield_obj = obj.add_object_static_sprite(shield_sprite);
|
||||||
shield_obj
|
shield_obj
|
||||||
.set_x(enemy_x - 16 - 11 * i)
|
.set_x(enemy_x - 16 - 11 * i)
|
||||||
.set_y(player_y)
|
.set_y(player_y)
|
||||||
|
@ -146,8 +146,8 @@ impl<'a> BattleScreenDisplay<'a> {
|
||||||
|
|
||||||
let enemy_attack_display = (0..2)
|
let enemy_attack_display = (0..2)
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
let mut attack_obj = obj.object(
|
let mut attack_obj = obj.add_object_static_sprite(
|
||||||
obj.sprite(ENEMY_ATTACK_SPRITES.sprite_for_attack(EnemyAttackType::Attack)),
|
ENEMY_ATTACK_SPRITES.sprite_for_attack(EnemyAttackType::Attack),
|
||||||
);
|
);
|
||||||
|
|
||||||
let attack_obj_position = (120, 56 + 32 * i).into();
|
let attack_obj_position = (120, 56 + 32 * i).into();
|
||||||
|
@ -189,14 +189,14 @@ impl<'a> BattleScreenDisplay<'a> {
|
||||||
|
|
||||||
pub fn update(
|
pub fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
obj: &'a ObjectController,
|
obj: &'a OAMManager,
|
||||||
current_battle_state: &CurrentBattleState,
|
current_battle_state: &CurrentBattleState,
|
||||||
) -> Vec<Action> {
|
) -> Vec<Action> {
|
||||||
for (i, player_shield) in self.objs.player_shield.iter_mut().enumerate() {
|
for (i, player_shield) in self.objs.player_shield.iter_mut().enumerate() {
|
||||||
if i < current_battle_state.player.shield_count as usize {
|
if i < current_battle_state.player.shield_count as usize {
|
||||||
player_shield
|
player_shield
|
||||||
.show()
|
.show()
|
||||||
.set_sprite(obj.sprite(SHIELD.sprite(0)));
|
.set_sprite(obj.get_vram_sprite(SHIELD.sprite(0)));
|
||||||
} else {
|
} else {
|
||||||
player_shield.hide();
|
player_shield.hide();
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ impl<'a> BattleScreenDisplay<'a> {
|
||||||
if i < current_battle_state.enemy.shield_count as usize {
|
if i < current_battle_state.enemy.shield_count as usize {
|
||||||
player_shield
|
player_shield
|
||||||
.show()
|
.show()
|
||||||
.set_sprite(obj.sprite(SHIELD.sprite(0)));
|
.set_sprite(obj.get_vram_sprite(SHIELD.sprite(0)));
|
||||||
} else {
|
} else {
|
||||||
player_shield.hide();
|
player_shield.hide();
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ impl<'a> BattleScreenDisplay<'a> {
|
||||||
.zip(current_battle_state.rolled_dice.faces_to_render())
|
.zip(current_battle_state.rolled_dice.faces_to_render())
|
||||||
.zip(self.objs.dice_cooldowns.iter_mut())
|
.zip(self.objs.dice_cooldowns.iter_mut())
|
||||||
{
|
{
|
||||||
die_obj.set_sprite(obj.sprite(FACE_SPRITES.sprite_for_face(current_face)));
|
die_obj.set_sprite(obj.get_vram_sprite(FACE_SPRITES.sprite_for_face(current_face)));
|
||||||
|
|
||||||
if let Some(cooldown) = cooldown {
|
if let Some(cooldown) = cooldown {
|
||||||
cooldown_healthbar
|
cooldown_healthbar
|
||||||
|
@ -279,7 +279,7 @@ impl<'a> BattleScreenDisplay<'a> {
|
||||||
actions_to_apply
|
actions_to_apply
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_action(&mut self, action: Action, obj: &'a ObjectController, sfx: &mut Sfx) {
|
pub fn add_action(&mut self, action: Action, obj: &'a OAMManager, sfx: &mut Sfx) {
|
||||||
play_sound_for_action_start(&action, sfx);
|
play_sound_for_action_start(&action, sfx);
|
||||||
|
|
||||||
self.animations
|
self.animations
|
||||||
|
@ -309,10 +309,10 @@ impl<'a> EnemyAttackDisplay<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, attack: &Option<EnemyAttackState>, obj: &'a ObjectController) {
|
pub fn update(&mut self, attack: &Option<EnemyAttackState>, obj: &'a OAMManager) {
|
||||||
if let Some(attack) = attack {
|
if let Some(attack) = attack {
|
||||||
self.face.show().set_sprite(
|
self.face.show().set_sprite(
|
||||||
obj.sprite(ENEMY_ATTACK_SPRITES.sprite_for_attack(attack.attack_type())),
|
obj.get_vram_sprite(ENEMY_ATTACK_SPRITES.sprite_for_attack(attack.attack_type())),
|
||||||
);
|
);
|
||||||
self.cooldown
|
self.cooldown
|
||||||
.set_value((attack.cooldown * 48 / attack.max_cooldown) as usize, obj);
|
.set_value((attack.cooldown * 48 / attack.max_cooldown) as usize, obj);
|
||||||
|
@ -350,27 +350,27 @@ enum AnimationUpdateState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AnimationStateHolder<'a> {
|
impl<'a> AnimationStateHolder<'a> {
|
||||||
fn for_action(a: Action, obj: &'a ObjectController) -> Self {
|
fn for_action(a: Action, obj: &'a OAMManager) -> Self {
|
||||||
let state = match a {
|
let state = match a {
|
||||||
Action::PlayerActivateShield { amount, .. } => {
|
Action::PlayerActivateShield { amount, .. } => {
|
||||||
AnimationState::PlayerActivateShield { amount, frame: 0 }
|
AnimationState::PlayerActivateShield { amount, frame: 0 }
|
||||||
}
|
}
|
||||||
Action::PlayerShoot { .. } => AnimationState::PlayerShoot {
|
Action::PlayerShoot { .. } => AnimationState::PlayerShoot {
|
||||||
bullet: obj.object(obj.sprite(BULLET_SPRITE)),
|
bullet: obj.add_object_static_sprite(BULLET_SPRITE),
|
||||||
x: 64,
|
x: 64,
|
||||||
},
|
},
|
||||||
Action::PlayerDisrupt { .. } => AnimationState::PlayerDisrupt {
|
Action::PlayerDisrupt { .. } => AnimationState::PlayerDisrupt {
|
||||||
bullet: obj.object(obj.sprite(DISRUPT_BULLET)),
|
bullet: obj.add_object_static_sprite(DISRUPT_BULLET),
|
||||||
x: 64,
|
x: 64,
|
||||||
},
|
},
|
||||||
Action::PlayerHeal { .. } => AnimationState::PlayerHeal {},
|
Action::PlayerHeal { .. } => AnimationState::PlayerHeal {},
|
||||||
Action::PlayerBurstShield { .. } => AnimationState::PlayerBurstShield { frame: 0 },
|
Action::PlayerBurstShield { .. } => AnimationState::PlayerBurstShield { frame: 0 },
|
||||||
Action::PlayerSendBurstShield { .. } => AnimationState::PlayerSendBurstShield {
|
Action::PlayerSendBurstShield { .. } => AnimationState::PlayerSendBurstShield {
|
||||||
bullet: obj.object(obj.sprite(BURST_BULLET)),
|
bullet: obj.add_object_static_sprite(BURST_BULLET),
|
||||||
x: 64,
|
x: 64,
|
||||||
},
|
},
|
||||||
Action::EnemyShoot { .. } => AnimationState::EnemyShoot {
|
Action::EnemyShoot { .. } => AnimationState::EnemyShoot {
|
||||||
bullet: obj.object(obj.sprite(BULLET_SPRITE)),
|
bullet: obj.add_object_static_sprite(BULLET_SPRITE),
|
||||||
x: 175,
|
x: 175,
|
||||||
},
|
},
|
||||||
Action::EnemyShield { amount, .. } => AnimationState::EnemyShield { amount, frame: 0 },
|
Action::EnemyShield { amount, .. } => AnimationState::EnemyShield { amount, frame: 0 },
|
||||||
|
@ -383,7 +383,7 @@ impl<'a> AnimationStateHolder<'a> {
|
||||||
fn update(
|
fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
objs: &mut BattleScreenDisplayObjects<'a>,
|
objs: &mut BattleScreenDisplayObjects<'a>,
|
||||||
obj: &'a ObjectController,
|
obj: &'a OAMManager,
|
||||||
current_battle_state: &CurrentBattleState,
|
current_battle_state: &CurrentBattleState,
|
||||||
) -> AnimationUpdateState {
|
) -> AnimationUpdateState {
|
||||||
match &mut self.state {
|
match &mut self.state {
|
||||||
|
@ -414,7 +414,7 @@ impl<'a> AnimationStateHolder<'a> {
|
||||||
for i in current_player_shields..*amount {
|
for i in current_player_shields..*amount {
|
||||||
objs.player_shield[i as usize]
|
objs.player_shield[i as usize]
|
||||||
.show()
|
.show()
|
||||||
.set_sprite(obj.sprite(SHIELD.sprite(3 - *frame / 2)));
|
.set_sprite(obj.get_vram_sprite(SHIELD.sprite(3 - *frame / 2)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return AnimationUpdateState::RemoveWithAction(self.action.clone());
|
return AnimationUpdateState::RemoveWithAction(self.action.clone());
|
||||||
|
@ -445,7 +445,7 @@ impl<'a> AnimationStateHolder<'a> {
|
||||||
for i in current_enemy_shields..*amount {
|
for i in current_enemy_shields..*amount {
|
||||||
objs.enemy_shield[i as usize]
|
objs.enemy_shield[i as usize]
|
||||||
.show()
|
.show()
|
||||||
.set_sprite(obj.sprite(SHIELD.sprite(3 - *frame / 2)));
|
.set_sprite(obj.get_vram_sprite(SHIELD.sprite(3 - *frame / 2)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return AnimationUpdateState::RemoveWithAction(self.action.clone());
|
return AnimationUpdateState::RemoveWithAction(self.action.clone());
|
||||||
|
@ -468,7 +468,7 @@ impl<'a> AnimationStateHolder<'a> {
|
||||||
AnimationState::PlayerBurstShield { frame } => {
|
AnimationState::PlayerBurstShield { frame } => {
|
||||||
if *frame < 10 {
|
if *frame < 10 {
|
||||||
for shield in objs.player_shield.iter_mut() {
|
for shield in objs.player_shield.iter_mut() {
|
||||||
shield.set_sprite(obj.sprite(SHIELD.sprite(*frame / 2)));
|
shield.set_sprite(obj.get_vram_sprite(SHIELD.sprite(*frame / 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
*frame += 1;
|
*frame += 1;
|
||||||
|
@ -476,7 +476,7 @@ impl<'a> AnimationStateHolder<'a> {
|
||||||
AnimationUpdateState::Continue
|
AnimationUpdateState::Continue
|
||||||
} else {
|
} else {
|
||||||
for shield in objs.player_shield.iter_mut() {
|
for shield in objs.player_shield.iter_mut() {
|
||||||
shield.set_sprite(obj.sprite(SHIELD.sprite(0)));
|
shield.set_sprite(obj.get_vram_sprite(SHIELD.sprite(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationUpdateState::RemoveWithAction(self.action.clone())
|
AnimationUpdateState::RemoveWithAction(self.action.clone())
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use agb::{
|
use agb::{
|
||||||
display::{
|
display::{
|
||||||
object::{Object, ObjectController},
|
object::{OAMManager, Object},
|
||||||
tiled::{RegularMap, TiledMap},
|
tiled::{RegularMap, TiledMap},
|
||||||
HEIGHT, WIDTH,
|
HEIGHT, WIDTH,
|
||||||
},
|
},
|
||||||
|
@ -91,10 +91,10 @@ fn move_net_position_ud(idx: usize, direction: Tri) -> usize {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_dice_display<'a>(gfx: &'a ObjectController, dice: &'_ PlayerDice) -> Vec<Object<'a>> {
|
fn create_dice_display<'a>(gfx: &'a OAMManager, dice: &'_ PlayerDice) -> Vec<Object<'a>> {
|
||||||
let mut objects = Vec::new();
|
let mut objects = Vec::new();
|
||||||
for (idx, dice) in dice.dice.iter().enumerate() {
|
for (idx, dice) in dice.dice.iter().enumerate() {
|
||||||
let mut obj = gfx.object(gfx.sprite(FACE_SPRITES.sprite_for_face(dice.faces[1])));
|
let mut obj = gfx.add_object_static_sprite(FACE_SPRITES.sprite_for_face(dice.faces[1]));
|
||||||
obj.set_x((idx as i32 * 32 - 24 / 2 + 20) as u16);
|
obj.set_x((idx as i32 * 32 - 24 / 2 + 20) as u16);
|
||||||
obj.set_y(16 - 24 / 2);
|
obj.set_y(16 - 24 / 2);
|
||||||
|
|
||||||
|
@ -105,10 +105,10 @@ fn create_dice_display<'a>(gfx: &'a ObjectController, dice: &'_ PlayerDice) -> V
|
||||||
objects
|
objects
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_net<'a>(gfx: &'a ObjectController, die: &'_ Die, modified: &[usize]) -> Vec<Object<'a>> {
|
fn create_net<'a>(gfx: &'a OAMManager, die: &'_ Die, modified: &[usize]) -> Vec<Object<'a>> {
|
||||||
let mut objects = Vec::new();
|
let mut objects = Vec::new();
|
||||||
for (idx, &face) in die.faces.iter().enumerate() {
|
for (idx, &face) in die.faces.iter().enumerate() {
|
||||||
let mut obj = gfx.object(gfx.sprite(FACE_SPRITES.sprite_for_face(face)));
|
let mut obj = gfx.add_object_static_sprite(FACE_SPRITES.sprite_for_face(face));
|
||||||
let (x, y) = screen_position_for_index(idx);
|
let (x, y) = screen_position_for_index(idx);
|
||||||
obj.set_x((x - 24 / 2) as u16);
|
obj.set_x((x - 24 / 2) as u16);
|
||||||
obj.set_y((y - 24 / 2) as u16);
|
obj.set_y((y - 24 / 2) as u16);
|
||||||
|
@ -119,7 +119,7 @@ fn create_net<'a>(gfx: &'a ObjectController, die: &'_ Die, modified: &[usize]) -
|
||||||
}
|
}
|
||||||
|
|
||||||
for &m in modified.iter().chain(core::iter::once(&3)) {
|
for &m in modified.iter().chain(core::iter::once(&3)) {
|
||||||
let mut obj = gfx.object(gfx.sprite(MODIFIED_BOX));
|
let mut obj = gfx.add_object_static_sprite(MODIFIED_BOX);
|
||||||
let (x, y) = screen_position_for_index(m);
|
let (x, y) = screen_position_for_index(m);
|
||||||
obj.set_x((x - 32 / 2) as u16);
|
obj.set_x((x - 32 / 2) as u16);
|
||||||
obj.set_y((y - 32 / 2) as u16);
|
obj.set_y((y - 32 / 2) as u16);
|
||||||
|
@ -139,10 +139,10 @@ fn upgrade_position(idx: usize) -> (u32, u32) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_upgrade_objects<'a>(gfx: &'a ObjectController, upgrades: &[Face]) -> Vec<Object<'a>> {
|
fn create_upgrade_objects<'a>(gfx: &'a OAMManager, upgrades: &[Face]) -> Vec<Object<'a>> {
|
||||||
let mut objects = Vec::new();
|
let mut objects = Vec::new();
|
||||||
for (idx, &upgrade) in upgrades.iter().enumerate() {
|
for (idx, &upgrade) in upgrades.iter().enumerate() {
|
||||||
let mut obj = gfx.object(gfx.sprite(FACE_SPRITES.sprite_for_face(upgrade)));
|
let mut obj = gfx.add_object_static_sprite(FACE_SPRITES.sprite_for_face(upgrade));
|
||||||
let (x, y) = upgrade_position(idx);
|
let (x, y) = upgrade_position(idx);
|
||||||
obj.set_x((x - 24 / 2) as u16);
|
obj.set_x((x - 24 / 2) as u16);
|
||||||
obj.set_y((y - 24 / 2) as u16);
|
obj.set_y((y - 24 / 2) as u16);
|
||||||
|
@ -180,13 +180,13 @@ pub(crate) fn customise_screen(
|
||||||
|
|
||||||
let mut input = agb::input::ButtonController::new();
|
let mut input = agb::input::ButtonController::new();
|
||||||
|
|
||||||
let mut select_box = agb.obj.object(agb.obj.sprite(SELECT_BOX.sprite(0)));
|
let mut select_box = agb.obj.add_object_static_sprite(SELECT_BOX.sprite(0));
|
||||||
|
|
||||||
select_box.show();
|
select_box.show();
|
||||||
|
|
||||||
let mut selected_dice = agb.obj.object(agb.obj.sprite(SELECTED_BOX));
|
let mut selected_dice = agb.obj.add_object_static_sprite(SELECTED_BOX);
|
||||||
selected_dice.hide();
|
selected_dice.hide();
|
||||||
let mut selected_face = agb.obj.object(agb.obj.sprite(SELECTED_BOX));
|
let mut selected_face = agb.obj.add_object_static_sprite(SELECTED_BOX);
|
||||||
selected_face.hide();
|
selected_face.hide();
|
||||||
agb.sfx.frame();
|
agb.sfx.frame();
|
||||||
|
|
||||||
|
@ -338,7 +338,10 @@ pub(crate) fn customise_screen(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
select_box.set_sprite(agb.obj.sprite(SELECT_BOX.animation_sprite(counter / 10)));
|
select_box.set_sprite(
|
||||||
|
agb.obj
|
||||||
|
.get_vram_sprite(SELECT_BOX.animation_sprite(counter / 10)),
|
||||||
|
);
|
||||||
|
|
||||||
agb.star_background.update();
|
agb.star_background.update();
|
||||||
let _ = agb::rng::gen();
|
let _ = agb::rng::gen();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use agb::{
|
use agb::{
|
||||||
display::object::{Object, ObjectController, Sprite, Tag},
|
display::object::{OAMManager, Object, Sprite, Tag},
|
||||||
fixnum::Vector2D,
|
fixnum::Vector2D,
|
||||||
};
|
};
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
@ -141,14 +141,12 @@ pub struct HealthBar<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HealthBar<'a> {
|
impl<'a> HealthBar<'a> {
|
||||||
pub fn new(pos: Vector2D<i32>, max: usize, obj: &'a ObjectController) -> Self {
|
pub fn new(pos: Vector2D<i32>, max: usize, obj: &'a OAMManager) -> Self {
|
||||||
assert_eq!(max % 8, 0);
|
assert_eq!(max % 8, 0);
|
||||||
|
|
||||||
let sprites = (0..(max / 8))
|
let sprites = (0..(max / 8))
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
let health_sprite = obj.sprite(SMALL_SPRITES.red_bar(0));
|
let mut health_object = obj.add_object_static_sprite(SMALL_SPRITES.red_bar(0));
|
||||||
|
|
||||||
let mut health_object = obj.object(health_sprite);
|
|
||||||
health_object
|
health_object
|
||||||
.set_position(pos + (i as i32 * 8, 0).into())
|
.set_position(pos + (i as i32 * 8, 0).into())
|
||||||
.show();
|
.show();
|
||||||
|
@ -159,16 +157,18 @@ impl<'a> HealthBar<'a> {
|
||||||
Self { max, sprites }
|
Self { max, sprites }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_value(&mut self, new_value: usize, obj: &'a ObjectController) {
|
pub fn set_value(&mut self, new_value: usize, obj: &'a OAMManager) {
|
||||||
assert!(new_value <= self.max);
|
assert!(new_value <= self.max);
|
||||||
|
|
||||||
for (i, sprite) in self.sprites.iter_mut().enumerate() {
|
for (i, sprite) in self.sprites.iter_mut().enumerate() {
|
||||||
if (i + 1) * 8 < new_value {
|
if (i + 1) * 8 < new_value {
|
||||||
sprite.set_sprite(obj.sprite(SMALL_SPRITES.red_bar(0)));
|
sprite.set_sprite(obj.get_vram_sprite(SMALL_SPRITES.red_bar(0)));
|
||||||
} else if i * 8 < new_value {
|
} else if i * 8 < new_value {
|
||||||
sprite.set_sprite(obj.sprite(SMALL_SPRITES.red_bar(8 - (new_value - i * 8))));
|
sprite.set_sprite(
|
||||||
|
obj.get_vram_sprite(SMALL_SPRITES.red_bar(8 - (new_value - i * 8))),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
sprite.set_sprite(obj.sprite(SMALL_SPRITES.red_bar(8)));
|
sprite.set_sprite(obj.get_vram_sprite(SMALL_SPRITES.red_bar(8)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,22 +195,22 @@ pub struct FractionDisplay<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FractionDisplay<'a> {
|
impl<'a> FractionDisplay<'a> {
|
||||||
pub fn new(pos: Vector2D<i32>, digits: usize, obj: &'a ObjectController) -> Self {
|
pub fn new(pos: Vector2D<i32>, digits: usize, obj: &'a OAMManager) -> Self {
|
||||||
let mut sprites = Vec::with_capacity(digits * 2 + 1);
|
let mut sprites = Vec::with_capacity(digits * 2 + 1);
|
||||||
|
|
||||||
for i in 0..digits {
|
for i in 0..digits {
|
||||||
let mut left_digit = obj.object(obj.sprite(SMALL_SPRITES.number(0)));
|
let mut left_digit = obj.add_object_static_sprite(SMALL_SPRITES.number(0));
|
||||||
left_digit.set_position(pos + (i as i32 * 4, 0).into());
|
left_digit.set_position(pos + (i as i32 * 4, 0).into());
|
||||||
|
|
||||||
sprites.push(left_digit);
|
sprites.push(left_digit);
|
||||||
|
|
||||||
let mut right_digit = obj.object(obj.sprite(SMALL_SPRITES.number(0)));
|
let mut right_digit = obj.add_object_static_sprite(SMALL_SPRITES.number(0));
|
||||||
right_digit.set_position(pos + (i as i32 * 4 + digits as i32 * 4 + 7, 0).into());
|
right_digit.set_position(pos + (i as i32 * 4 + digits as i32 * 4 + 7, 0).into());
|
||||||
|
|
||||||
sprites.push(right_digit);
|
sprites.push(right_digit);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut slash = obj.object(obj.sprite(SMALL_SPRITES.slash()));
|
let mut slash = obj.add_object_static_sprite(SMALL_SPRITES.slash());
|
||||||
slash.set_position(pos + (digits as i32 * 4 + 1, 0).into());
|
slash.set_position(pos + (digits as i32 * 4 + 1, 0).into());
|
||||||
sprites.push(slash);
|
sprites.push(slash);
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ impl<'a> FractionDisplay<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_value(&mut self, current: usize, max: usize, obj: &'a ObjectController) {
|
pub fn set_value(&mut self, current: usize, max: usize, obj: &'a OAMManager) {
|
||||||
if self.current_current == current && self.current_max == max {
|
if self.current_current == current && self.current_max == max {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -235,12 +235,13 @@ impl<'a> FractionDisplay<'a> {
|
||||||
current /= 10;
|
current /= 10;
|
||||||
let current_value_sprite = &mut self.sprites[(self.digits - i) * 2 - 2];
|
let current_value_sprite = &mut self.sprites[(self.digits - i) * 2 - 2];
|
||||||
current_value_sprite
|
current_value_sprite
|
||||||
.set_sprite(obj.sprite(SMALL_SPRITES.number(current_value_digit as u32)));
|
.set_sprite(obj.get_vram_sprite(SMALL_SPRITES.number(current_value_digit as u32)));
|
||||||
|
|
||||||
let max_value_digit = max % 10;
|
let max_value_digit = max % 10;
|
||||||
max /= 10;
|
max /= 10;
|
||||||
let max_value_sprite = &mut self.sprites[(self.digits - i) * 2 - 1];
|
let max_value_sprite = &mut self.sprites[(self.digits - i) * 2 - 1];
|
||||||
max_value_sprite.set_sprite(obj.sprite(SMALL_SPRITES.number(max_value_digit as u32)));
|
max_value_sprite
|
||||||
|
.set_sprite(obj.get_vram_sprite(SMALL_SPRITES.number(max_value_digit as u32)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,7 +261,7 @@ impl<'a> NumberDisplay<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_value(&mut self, new_value: Option<u32>, obj: &'a ObjectController) {
|
pub fn set_value(&mut self, new_value: Option<u32>, obj: &'a OAMManager) {
|
||||||
if self.value == new_value {
|
if self.value == new_value {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -271,7 +272,7 @@ impl<'a> NumberDisplay<'a> {
|
||||||
|
|
||||||
if let Some(mut new_value) = new_value {
|
if let Some(mut new_value) = new_value {
|
||||||
if new_value == 0 {
|
if new_value == 0 {
|
||||||
let mut zero_object = obj.object(obj.sprite(SMALL_SPRITES.number(0)));
|
let mut zero_object = obj.add_object_static_sprite(SMALL_SPRITES.number(0));
|
||||||
zero_object.show().set_position(self.position);
|
zero_object.show().set_position(self.position);
|
||||||
|
|
||||||
self.objects.push(zero_object);
|
self.objects.push(zero_object);
|
||||||
|
@ -284,7 +285,7 @@ impl<'a> NumberDisplay<'a> {
|
||||||
new_value /= 10;
|
new_value /= 10;
|
||||||
|
|
||||||
let mut current_value_obj =
|
let mut current_value_obj =
|
||||||
obj.object(obj.sprite(SMALL_SPRITES.number(current_value_digit)));
|
obj.add_object_static_sprite(SMALL_SPRITES.number(current_value_digit));
|
||||||
|
|
||||||
current_value_obj
|
current_value_obj
|
||||||
.show()
|
.show()
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#![cfg_attr(test, reexport_test_harness_main = "test_main")]
|
#![cfg_attr(test, reexport_test_harness_main = "test_main")]
|
||||||
#![cfg_attr(test, test_runner(agb::test_runner::test_runner))]
|
#![cfg_attr(test, test_runner(agb::test_runner::test_runner))]
|
||||||
|
|
||||||
use agb::display::object::ObjectController;
|
use agb::display::object::OAMManager;
|
||||||
use agb::display::tiled::{TileFormat, TiledMap, VRamManager};
|
use agb::display::tiled::{TileFormat, TiledMap, VRamManager};
|
||||||
use agb::display::Priority;
|
use agb::display::Priority;
|
||||||
use agb::interrupt::VBlank;
|
use agb::interrupt::VBlank;
|
||||||
|
@ -90,7 +90,7 @@ pub struct PlayerDice {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Agb<'a> {
|
struct Agb<'a> {
|
||||||
obj: ObjectController<'a>,
|
obj: OAMManager<'a>,
|
||||||
vblank: VBlank,
|
vblank: VBlank,
|
||||||
star_background: StarBackground<'a>,
|
star_background: StarBackground<'a>,
|
||||||
vram: VRamManager,
|
vram: VRamManager,
|
||||||
|
@ -104,7 +104,7 @@ pub fn main(mut gba: agb::Gba) -> ! {
|
||||||
save::save_high_score(&mut gba.save, 0).expect("Could not reset high score");
|
save::save_high_score(&mut gba.save, 0).expect("Could not reset high score");
|
||||||
}
|
}
|
||||||
|
|
||||||
let gfx = gba.display.object.get();
|
let gfx = gba.display.object.get_managed();
|
||||||
let vblank = agb::interrupt::VBlank::get();
|
let vblank = agb::interrupt::VBlank::get();
|
||||||
|
|
||||||
let (tiled, mut vram) = gba.display.video.tiled0();
|
let (tiled, mut vram) = gba.display.video.tiled0();
|
||||||
|
|
10
examples/the-hat-chooses-the-wizard/Cargo.lock
generated
10
examples/the-hat-chooses-the-wizard/Cargo.lock
generated
|
@ -26,6 +26,7 @@ dependencies = [
|
||||||
"bitflags 2.0.2",
|
"bitflags 2.0.2",
|
||||||
"modular-bitfield",
|
"modular-bitfield",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
|
"slotmap",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -438,6 +439,15 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "slotmap"
|
||||||
|
version = "1.0.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342"
|
||||||
|
dependencies = [
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "static_assertions"
|
name = "static_assertions"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::TAG_MAP;
|
||||||
|
|
||||||
use super::{sfx::SfxPlayer, Entity, FixedNumberType, HatState, Level};
|
use super::{sfx::SfxPlayer, Entity, FixedNumberType, HatState, Level};
|
||||||
use agb::{
|
use agb::{
|
||||||
display::object::{ObjectController, Tag},
|
display::object::{OAMManager, Tag},
|
||||||
fixnum::Vector2D,
|
fixnum::Vector2D,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,11 +35,11 @@ pub enum EnemyUpdateState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Enemy<'a> {
|
impl<'a> Enemy<'a> {
|
||||||
pub fn new_slime(object: &'a ObjectController, start_pos: Vector2D<FixedNumberType>) -> Self {
|
pub fn new_slime(object: &'a OAMManager, start_pos: Vector2D<FixedNumberType>) -> Self {
|
||||||
Enemy::Slime(Slime::new(object, start_pos + (0, 1).into()))
|
Enemy::Slime(Slime::new(object, start_pos + (0, 1).into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_snail(object: &'a ObjectController, start_pos: Vector2D<FixedNumberType>) -> Self {
|
pub fn new_snail(object: &'a OAMManager, start_pos: Vector2D<FixedNumberType>) -> Self {
|
||||||
Enemy::Snail(Snail::new(object, start_pos))
|
Enemy::Snail(Snail::new(object, start_pos))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ impl<'a> Enemy<'a> {
|
||||||
|
|
||||||
pub fn update(
|
pub fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
controller: &'a ObjectController,
|
controller: &'a OAMManager,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
player_pos: Vector2D<FixedNumberType>,
|
player_pos: Vector2D<FixedNumberType>,
|
||||||
hat_state: HatState,
|
hat_state: HatState,
|
||||||
|
@ -94,7 +94,7 @@ struct EnemyInfo<'a> {
|
||||||
|
|
||||||
impl<'a> EnemyInfo<'a> {
|
impl<'a> EnemyInfo<'a> {
|
||||||
fn new(
|
fn new(
|
||||||
object: &'a ObjectController,
|
object: &'a OAMManager,
|
||||||
start_pos: Vector2D<FixedNumberType>,
|
start_pos: Vector2D<FixedNumberType>,
|
||||||
collision: Vector2D<u16>,
|
collision: Vector2D<u16>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -135,7 +135,7 @@ pub struct Slime<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Slime<'a> {
|
impl<'a> Slime<'a> {
|
||||||
fn new(object: &'a ObjectController, start_pos: Vector2D<FixedNumberType>) -> Self {
|
fn new(object: &'a OAMManager, start_pos: Vector2D<FixedNumberType>) -> Self {
|
||||||
let slime = Slime {
|
let slime = Slime {
|
||||||
enemy_info: EnemyInfo::new(object, start_pos, (14u16, 14u16).into()),
|
enemy_info: EnemyInfo::new(object, start_pos, (14u16, 14u16).into()),
|
||||||
state: SlimeState::Idle,
|
state: SlimeState::Idle,
|
||||||
|
@ -146,7 +146,7 @@ impl<'a> Slime<'a> {
|
||||||
|
|
||||||
fn update(
|
fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
controller: &'a ObjectController,
|
controller: &'a OAMManager,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
player_pos: Vector2D<FixedNumberType>,
|
player_pos: Vector2D<FixedNumberType>,
|
||||||
hat_state: HatState,
|
hat_state: HatState,
|
||||||
|
@ -161,7 +161,7 @@ impl<'a> Slime<'a> {
|
||||||
let offset = (timer / 16) as usize;
|
let offset = (timer / 16) as usize;
|
||||||
|
|
||||||
let frame = SLIME_IDLE.animation_sprite(offset);
|
let frame = SLIME_IDLE.animation_sprite(offset);
|
||||||
let sprite = controller.sprite(frame);
|
let sprite = controller.get_vram_sprite(frame);
|
||||||
|
|
||||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ impl<'a> Slime<'a> {
|
||||||
self.state = SlimeState::Idle;
|
self.state = SlimeState::Idle;
|
||||||
} else {
|
} else {
|
||||||
let frame = SLIME_JUMP.animation_sprite(offset);
|
let frame = SLIME_JUMP.animation_sprite(offset);
|
||||||
let sprite = controller.sprite(frame);
|
let sprite = controller.get_vram_sprite(frame);
|
||||||
|
|
||||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ impl<'a> Slime<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let frame = SLIME_SPLAT.animation_sprite(offset);
|
let frame = SLIME_SPLAT.animation_sprite(offset);
|
||||||
let sprite = controller.sprite(frame);
|
let sprite = controller.get_vram_sprite(frame);
|
||||||
|
|
||||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ pub struct Snail<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Snail<'a> {
|
impl<'a> Snail<'a> {
|
||||||
fn new(object: &'a ObjectController, start_pos: Vector2D<FixedNumberType>) -> Self {
|
fn new(object: &'a OAMManager, start_pos: Vector2D<FixedNumberType>) -> Self {
|
||||||
let snail = Snail {
|
let snail = Snail {
|
||||||
enemy_info: EnemyInfo::new(object, start_pos, (16u16, 16u16).into()),
|
enemy_info: EnemyInfo::new(object, start_pos, (16u16, 16u16).into()),
|
||||||
state: SnailState::Idle(0),
|
state: SnailState::Idle(0),
|
||||||
|
@ -272,7 +272,7 @@ impl<'a> Snail<'a> {
|
||||||
|
|
||||||
fn update(
|
fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
controller: &'a ObjectController,
|
controller: &'a OAMManager,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
player_pos: Vector2D<FixedNumberType>,
|
player_pos: Vector2D<FixedNumberType>,
|
||||||
hat_state: HatState,
|
hat_state: HatState,
|
||||||
|
@ -298,7 +298,7 @@ impl<'a> Snail<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let frame = SNAIL_IDLE.animation_sprite(0);
|
let frame = SNAIL_IDLE.animation_sprite(0);
|
||||||
let sprite = controller.sprite(frame);
|
let sprite = controller.get_vram_sprite(frame);
|
||||||
|
|
||||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||||
if player_has_collided {
|
if player_has_collided {
|
||||||
|
@ -318,7 +318,7 @@ impl<'a> Snail<'a> {
|
||||||
self.enemy_info.entity.velocity = (0, 0).into();
|
self.enemy_info.entity.velocity = (0, 0).into();
|
||||||
|
|
||||||
let frame = SNAIL_EMERGE.animation_sprite(offset);
|
let frame = SNAIL_EMERGE.animation_sprite(offset);
|
||||||
let sprite = controller.sprite(frame);
|
let sprite = controller.get_vram_sprite(frame);
|
||||||
|
|
||||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ impl<'a> Snail<'a> {
|
||||||
let offset = (timer - time) as usize / 8;
|
let offset = (timer - time) as usize / 8;
|
||||||
|
|
||||||
let frame = SNAIL_MOVE.animation_sprite(offset);
|
let frame = SNAIL_MOVE.animation_sprite(offset);
|
||||||
let sprite = controller.sprite(frame);
|
let sprite = controller.get_vram_sprite(frame);
|
||||||
|
|
||||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ impl<'a> Snail<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let frame = SNAIL_EMERGE.animation_sprite(offset);
|
let frame = SNAIL_EMERGE.animation_sprite(offset);
|
||||||
let sprite = controller.sprite(frame);
|
let sprite = controller.get_vram_sprite(frame);
|
||||||
|
|
||||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||||
self.enemy_info.entity.velocity = (0, 0).into();
|
self.enemy_info.entity.velocity = (0, 0).into();
|
||||||
|
@ -403,7 +403,7 @@ impl<'a> Snail<'a> {
|
||||||
return UpdateState::Remove;
|
return UpdateState::Remove;
|
||||||
};
|
};
|
||||||
|
|
||||||
let sprite = controller.sprite(frame);
|
let sprite = controller.get_vram_sprite(frame);
|
||||||
|
|
||||||
self.enemy_info.entity.sprite.set_sprite(sprite);
|
self.enemy_info.entity.sprite.set_sprite(sprite);
|
||||||
self.enemy_info.entity.velocity = (0, 0).into();
|
self.enemy_info.entity.velocity = (0, 0).into();
|
||||||
|
|
|
@ -8,7 +8,7 @@ extern crate alloc;
|
||||||
|
|
||||||
use agb::{
|
use agb::{
|
||||||
display::{
|
display::{
|
||||||
object::{Graphics, Object, ObjectController, Tag, TagMap},
|
object::{Graphics, OAMManager, Object, Tag, TagMap},
|
||||||
tiled::{
|
tiled::{
|
||||||
InfiniteScrolledMap, PartialUpdateStatus, RegularBackgroundSize, TileFormat, TileSet,
|
InfiniteScrolledMap, PartialUpdateStatus, RegularBackgroundSize, TileFormat, TileSet,
|
||||||
TileSetting, TiledMap, VRamManager,
|
TileSetting, TiledMap, VRamManager,
|
||||||
|
@ -124,12 +124,11 @@ pub struct Entity<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Entity<'a> {
|
impl<'a> Entity<'a> {
|
||||||
pub fn new(object: &'a ObjectController, collision_mask: Vector2D<u16>) -> Self {
|
pub fn new(object: &'a OAMManager, collision_mask: Vector2D<u16>) -> Self {
|
||||||
let dummy_sprite = object.sprite(WALKING.sprite(0));
|
let mut dummy_object = object.add_object_static_sprite(WALKING.sprite(0));
|
||||||
let mut sprite = object.object(dummy_sprite);
|
dummy_object.set_priority(Priority::P1);
|
||||||
sprite.set_priority(Priority::P1);
|
|
||||||
Entity {
|
Entity {
|
||||||
sprite,
|
sprite: dummy_object,
|
||||||
collision_mask,
|
collision_mask,
|
||||||
position: (0, 0).into(),
|
position: (0, 0).into(),
|
||||||
velocity: (0, 0).into(),
|
velocity: (0, 0).into(),
|
||||||
|
@ -348,15 +347,15 @@ fn ping_pong(i: i32, n: i32) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Player<'a> {
|
impl<'a> Player<'a> {
|
||||||
fn new(controller: &'a ObjectController, start_position: Vector2D<FixedNumberType>) -> Self {
|
fn new(controller: &'a OAMManager, start_position: Vector2D<FixedNumberType>) -> Self {
|
||||||
let mut wizard = Entity::new(controller, (6_u16, 14_u16).into());
|
let mut wizard = Entity::new(controller, (6_u16, 14_u16).into());
|
||||||
let mut hat = Entity::new(controller, (6_u16, 6_u16).into());
|
let mut hat = Entity::new(controller, (6_u16, 6_u16).into());
|
||||||
|
|
||||||
wizard
|
wizard
|
||||||
.sprite
|
.sprite
|
||||||
.set_sprite(controller.sprite(HAT_SPIN_1.sprite(0)));
|
.set_sprite(controller.get_vram_sprite(HAT_SPIN_1.sprite(0)));
|
||||||
hat.sprite
|
hat.sprite
|
||||||
.set_sprite(controller.sprite(HAT_SPIN_1.sprite(0)));
|
.set_sprite(controller.get_vram_sprite(HAT_SPIN_1.sprite(0)));
|
||||||
|
|
||||||
wizard.sprite.show();
|
wizard.sprite.show();
|
||||||
hat.sprite.show();
|
hat.sprite.show();
|
||||||
|
@ -382,7 +381,7 @@ impl<'a> Player<'a> {
|
||||||
fn update_frame(
|
fn update_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
input: &ButtonController,
|
input: &ButtonController,
|
||||||
controller: &'a ObjectController,
|
controller: &'a OAMManager,
|
||||||
timer: i32,
|
timer: i32,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
enemies: &[enemies::Enemy],
|
enemies: &[enemies::Enemy],
|
||||||
|
@ -461,7 +460,7 @@ impl<'a> Player<'a> {
|
||||||
self.wizard_frame = offset as u8;
|
self.wizard_frame = offset as u8;
|
||||||
|
|
||||||
let frame = WALKING.animation_sprite(offset);
|
let frame = WALKING.animation_sprite(offset);
|
||||||
let sprite = controller.sprite(frame);
|
let sprite = controller.get_vram_sprite(frame);
|
||||||
|
|
||||||
self.wizard.sprite.set_sprite(sprite);
|
self.wizard.sprite.set_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
@ -471,7 +470,7 @@ impl<'a> Player<'a> {
|
||||||
self.wizard_frame = 5;
|
self.wizard_frame = 5;
|
||||||
|
|
||||||
let frame = JUMPING.animation_sprite(0);
|
let frame = JUMPING.animation_sprite(0);
|
||||||
let sprite = controller.sprite(frame);
|
let sprite = controller.get_vram_sprite(frame);
|
||||||
|
|
||||||
self.wizard.sprite.set_sprite(sprite);
|
self.wizard.sprite.set_sprite(sprite);
|
||||||
} else if self.wizard.velocity.y > FixedNumberType::new(1) / 16 {
|
} else if self.wizard.velocity.y > FixedNumberType::new(1) / 16 {
|
||||||
|
@ -486,7 +485,7 @@ impl<'a> Player<'a> {
|
||||||
self.wizard_frame = 0;
|
self.wizard_frame = 0;
|
||||||
|
|
||||||
let frame = FALLING.animation_sprite(offset);
|
let frame = FALLING.animation_sprite(offset);
|
||||||
let sprite = controller.sprite(frame);
|
let sprite = controller.get_vram_sprite(frame);
|
||||||
|
|
||||||
self.wizard.sprite.set_sprite(sprite);
|
self.wizard.sprite.set_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
@ -513,13 +512,13 @@ impl<'a> Player<'a> {
|
||||||
self.wizard.sprite.set_hflip(true);
|
self.wizard.sprite.set_hflip(true);
|
||||||
self.hat
|
self.hat
|
||||||
.sprite
|
.sprite
|
||||||
.set_sprite(controller.sprite(hat_base_tile.sprite(5)));
|
.set_sprite(controller.get_vram_sprite(hat_base_tile.sprite(5)));
|
||||||
}
|
}
|
||||||
agb::input::Tri::Positive => {
|
agb::input::Tri::Positive => {
|
||||||
self.wizard.sprite.set_hflip(false);
|
self.wizard.sprite.set_hflip(false);
|
||||||
self.hat
|
self.hat
|
||||||
.sprite
|
.sprite
|
||||||
.set_sprite(controller.sprite(hat_base_tile.sprite(0)));
|
.set_sprite(controller.get_vram_sprite(hat_base_tile.sprite(0)));
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
@ -545,7 +544,7 @@ impl<'a> Player<'a> {
|
||||||
let hat_sprite_offset = (timer / hat_sprite_divider) as usize;
|
let hat_sprite_offset = (timer / hat_sprite_divider) as usize;
|
||||||
|
|
||||||
self.hat.sprite.set_sprite(
|
self.hat.sprite.set_sprite(
|
||||||
controller.sprite(hat_base_tile.animation_sprite(hat_sprite_offset)),
|
controller.get_vram_sprite(hat_base_tile.animation_sprite(hat_sprite_offset)),
|
||||||
);
|
);
|
||||||
|
|
||||||
if self.hat_slow_counter < 30 && self.hat.velocity.magnitude() < 2.into() {
|
if self.hat_slow_counter < 30 && self.hat.velocity.magnitude() < 2.into() {
|
||||||
|
@ -578,7 +577,7 @@ impl<'a> Player<'a> {
|
||||||
}
|
}
|
||||||
HatState::WizardTowards => {
|
HatState::WizardTowards => {
|
||||||
self.hat.sprite.set_sprite(
|
self.hat.sprite.set_sprite(
|
||||||
controller.sprite(hat_base_tile.animation_sprite(timer as usize / 2)),
|
controller.get_vram_sprite(hat_base_tile.animation_sprite(timer as usize / 2)),
|
||||||
);
|
);
|
||||||
let distance_vector =
|
let distance_vector =
|
||||||
self.hat.position - self.wizard.position + hat_resting_position;
|
self.hat.position - self.wizard.position + hat_resting_position;
|
||||||
|
@ -616,7 +615,7 @@ enum UpdateState {
|
||||||
impl<'a, 'b> PlayingLevel<'a, 'b> {
|
impl<'a, 'b> PlayingLevel<'a, 'b> {
|
||||||
fn open_level(
|
fn open_level(
|
||||||
level: &'a Level,
|
level: &'a Level,
|
||||||
object_control: &'a ObjectController,
|
object_control: &'a OAMManager,
|
||||||
background: &'a mut InfiniteScrolledMap<'b>,
|
background: &'a mut InfiniteScrolledMap<'b>,
|
||||||
foreground: &'a mut InfiniteScrolledMap<'b>,
|
foreground: &'a mut InfiniteScrolledMap<'b>,
|
||||||
input: ButtonController,
|
input: ButtonController,
|
||||||
|
@ -677,11 +676,11 @@ impl<'a, 'b> PlayingLevel<'a, 'b> {
|
||||||
self.player.wizard.sprite.set_priority(Priority::P0);
|
self.player.wizard.sprite.set_priority(Priority::P0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dead_update(&mut self, controller: &'a ObjectController) -> bool {
|
fn dead_update(&mut self, controller: &'a OAMManager) -> bool {
|
||||||
self.timer += 1;
|
self.timer += 1;
|
||||||
|
|
||||||
let frame = PLAYER_DEATH.animation_sprite(self.timer as usize / 8);
|
let frame = PLAYER_DEATH.animation_sprite(self.timer as usize / 8);
|
||||||
let sprite = controller.sprite(frame);
|
let sprite = controller.get_vram_sprite(frame);
|
||||||
|
|
||||||
self.player.wizard.velocity += (0.into(), FixedNumberType::new(1) / 32).into();
|
self.player.wizard.velocity += (0.into(), FixedNumberType::new(1) / 32).into();
|
||||||
self.player.wizard.position += self.player.wizard.velocity;
|
self.player.wizard.position += self.player.wizard.velocity;
|
||||||
|
@ -696,7 +695,7 @@ impl<'a, 'b> PlayingLevel<'a, 'b> {
|
||||||
&mut self,
|
&mut self,
|
||||||
sfx_player: &mut SfxPlayer,
|
sfx_player: &mut SfxPlayer,
|
||||||
vram: &mut VRamManager,
|
vram: &mut VRamManager,
|
||||||
controller: &'a ObjectController,
|
controller: &'a OAMManager,
|
||||||
) -> UpdateState {
|
) -> UpdateState {
|
||||||
self.timer += 1;
|
self.timer += 1;
|
||||||
self.input.update();
|
self.input.update();
|
||||||
|
@ -828,7 +827,7 @@ pub fn main(mut agb: agb::Gba) -> ! {
|
||||||
|
|
||||||
vram.set_background_palettes(tile_sheet::PALETTES);
|
vram.set_background_palettes(tile_sheet::PALETTES);
|
||||||
|
|
||||||
let object = agb.display.object.get();
|
let object = agb.display.object.get_managed();
|
||||||
|
|
||||||
let vblank = agb::interrupt::VBlank::get();
|
let vblank = agb::interrupt::VBlank::get();
|
||||||
let mut current_level = 0;
|
let mut current_level = 0;
|
||||||
|
|
10
examples/the-purple-night/Cargo.lock
generated
10
examples/the-purple-night/Cargo.lock
generated
|
@ -26,6 +26,7 @@ dependencies = [
|
||||||
"bitflags 2.0.2",
|
"bitflags 2.0.2",
|
||||||
"modular-bitfield",
|
"modular-bitfield",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
|
"slotmap",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -457,6 +458,15 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "slotmap"
|
||||||
|
version = "1.0.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342"
|
||||||
|
dependencies = [
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "static_assertions"
|
name = "static_assertions"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
|
|
@ -14,7 +14,7 @@ use alloc::{boxed::Box, vec::Vec};
|
||||||
|
|
||||||
use agb::{
|
use agb::{
|
||||||
display::{
|
display::{
|
||||||
object::{Graphics, Object, ObjectController, Sprite, Tag, TagMap},
|
object::{Graphics, OAMManager, Object, Sprite, Tag, TagMap},
|
||||||
tiled::{
|
tiled::{
|
||||||
InfiniteScrolledMap, RegularBackgroundSize, TileFormat, TileSet, TileSetting,
|
InfiniteScrolledMap, RegularBackgroundSize, TileFormat, TileSet, TileSetting,
|
||||||
VRamManager,
|
VRamManager,
|
||||||
|
@ -164,9 +164,8 @@ struct Entity<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Entity<'a> {
|
impl<'a> Entity<'a> {
|
||||||
fn new(object_controller: &'a ObjectController, collision_mask: Rect<u16>) -> Self {
|
fn new(object_controller: &'a OAMManager, collision_mask: Rect<u16>) -> Self {
|
||||||
let s = object_controller.sprite(LONG_SWORD_IDLE.sprite(0));
|
let mut sprite = object_controller.add_object_static_sprite(LONG_SWORD_IDLE.sprite(0));
|
||||||
let mut sprite = object_controller.object(s);
|
|
||||||
sprite.set_priority(Priority::P1);
|
sprite.set_priority(Priority::P1);
|
||||||
Entity {
|
Entity {
|
||||||
sprite,
|
sprite,
|
||||||
|
@ -533,12 +532,12 @@ struct Player<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Player<'a> {
|
impl<'a> Player<'a> {
|
||||||
fn new(object_controller: &'a ObjectController<'a>) -> Player {
|
fn new(object_controller: &'a OAMManager<'a>) -> Player {
|
||||||
let mut entity = Entity::new(
|
let mut entity = Entity::new(
|
||||||
object_controller,
|
object_controller,
|
||||||
Rect::new((0_u16, 0_u16).into(), (4_u16, 12_u16).into()),
|
Rect::new((0_u16, 0_u16).into(), (4_u16, 12_u16).into()),
|
||||||
);
|
);
|
||||||
let s = object_controller.sprite(LONG_SWORD_IDLE.sprite(0));
|
let s = object_controller.get_vram_sprite(LONG_SWORD_IDLE.sprite(0));
|
||||||
entity.sprite.set_sprite(s);
|
entity.sprite.set_sprite(s);
|
||||||
entity.sprite.show();
|
entity.sprite.show();
|
||||||
entity.position = (144, 0).into();
|
entity.position = (144, 0).into();
|
||||||
|
@ -559,7 +558,7 @@ impl<'a> Player<'a> {
|
||||||
|
|
||||||
fn update(
|
fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
controller: &'a ObjectController,
|
controller: &'a OAMManager,
|
||||||
buttons: &ButtonController,
|
buttons: &ButtonController,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
sfx: &mut sfx::Sfx,
|
sfx: &mut sfx::Sfx,
|
||||||
|
@ -590,12 +589,12 @@ impl<'a> Player<'a> {
|
||||||
self.entity.sprite.set_hflip(self.facing == Tri::Negative);
|
self.entity.sprite.set_hflip(self.facing == Tri::Negative);
|
||||||
self.entity.velocity.x += self.sword.ground_walk_force() * x as i32;
|
self.entity.velocity.x += self.sword.ground_walk_force() * x as i32;
|
||||||
if self.entity.velocity.x.abs() > Number::new(1) / 10 {
|
if self.entity.velocity.x.abs() > Number::new(1) / 10 {
|
||||||
let sprite =
|
let sprite = controller
|
||||||
controller.sprite(self.sword.walk_animation(self.sprite_offset));
|
.get_vram_sprite(self.sword.walk_animation(self.sprite_offset));
|
||||||
self.entity.sprite.set_sprite(sprite);
|
self.entity.sprite.set_sprite(sprite);
|
||||||
} else {
|
} else {
|
||||||
let sprite =
|
let sprite = controller
|
||||||
controller.sprite(self.sword.idle_animation(self.sprite_offset));
|
.get_vram_sprite(self.sword.idle_animation(self.sprite_offset));
|
||||||
self.entity.sprite.set_sprite(sprite);
|
self.entity.sprite.set_sprite(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,7 +614,8 @@ impl<'a> Player<'a> {
|
||||||
let frame = self.sword.attack_frame(*a);
|
let frame = self.sword.attack_frame(*a);
|
||||||
self.fudge_factor.x = self.sword.fudge(frame) * self.facing as i32;
|
self.fudge_factor.x = self.sword.fudge(frame) * self.facing as i32;
|
||||||
let tag = self.sword.attack_tag();
|
let tag = self.sword.attack_tag();
|
||||||
let sprite = controller.sprite(tag.animation_sprite(frame as usize));
|
let sprite =
|
||||||
|
controller.get_vram_sprite(tag.animation_sprite(frame as usize));
|
||||||
self.entity.sprite.set_sprite(sprite);
|
self.entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
hurtbox = self.sword.ground_attack_hurtbox(frame);
|
hurtbox = self.sword.ground_attack_hurtbox(frame);
|
||||||
|
@ -629,7 +629,8 @@ impl<'a> Player<'a> {
|
||||||
let frame = self.sword.hold_frame();
|
let frame = self.sword.hold_frame();
|
||||||
self.fudge_factor.x = self.sword.fudge(frame) * self.facing as i32;
|
self.fudge_factor.x = self.sword.fudge(frame) * self.facing as i32;
|
||||||
let tag = self.sword.attack_tag();
|
let tag = self.sword.attack_tag();
|
||||||
let sprite = controller.sprite(tag.animation_sprite(frame as usize));
|
let sprite =
|
||||||
|
controller.get_vram_sprite(tag.animation_sprite(frame as usize));
|
||||||
self.entity.sprite.set_sprite(sprite);
|
self.entity.sprite.set_sprite(sprite);
|
||||||
if *a == 0 {
|
if *a == 0 {
|
||||||
self.attack_timer = AttackTimer::Idle;
|
self.attack_timer = AttackTimer::Idle;
|
||||||
|
@ -654,7 +655,8 @@ impl<'a> Player<'a> {
|
||||||
2
|
2
|
||||||
};
|
};
|
||||||
let tag = self.sword.jump_tag();
|
let tag = self.sword.jump_tag();
|
||||||
let sprite = controller.sprite(tag.animation_sprite(frame as usize));
|
let sprite =
|
||||||
|
controller.get_vram_sprite(tag.animation_sprite(frame as usize));
|
||||||
self.entity.sprite.set_sprite(sprite);
|
self.entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
if x != Tri::Zero {
|
if x != Tri::Zero {
|
||||||
|
@ -676,7 +678,8 @@ impl<'a> Player<'a> {
|
||||||
*a -= 1;
|
*a -= 1;
|
||||||
let frame = self.sword.jump_attack_frame(*a);
|
let frame = self.sword.jump_attack_frame(*a);
|
||||||
let tag = self.sword.jump_attack_tag();
|
let tag = self.sword.jump_attack_tag();
|
||||||
let sprite = controller.sprite(tag.animation_sprite(frame as usize));
|
let sprite =
|
||||||
|
controller.get_vram_sprite(tag.animation_sprite(frame as usize));
|
||||||
self.entity.sprite.set_sprite(sprite);
|
self.entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
hurtbox = self.sword.air_attack_hurtbox(frame);
|
hurtbox = self.sword.air_attack_hurtbox(frame);
|
||||||
|
@ -811,7 +814,7 @@ impl BatData {
|
||||||
|
|
||||||
fn update<'a>(
|
fn update<'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
controller: &'a ObjectController,
|
controller: &'a OAMManager,
|
||||||
entity: &mut Entity<'a>,
|
entity: &mut Entity<'a>,
|
||||||
player: &Player,
|
player: &Player,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
|
@ -839,7 +842,7 @@ impl BatData {
|
||||||
}
|
}
|
||||||
|
|
||||||
let sprite = BAT_IDLE.sprite(self.sprite_offset as usize / 8);
|
let sprite = BAT_IDLE.sprite(self.sprite_offset as usize / 8);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
|
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
|
@ -874,7 +877,7 @@ impl BatData {
|
||||||
}
|
}
|
||||||
|
|
||||||
let sprite = BAT_IDLE.sprite(self.sprite_offset as usize / 2);
|
let sprite = BAT_IDLE.sprite(self.sprite_offset as usize / 2);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
|
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
|
@ -901,7 +904,7 @@ impl BatData {
|
||||||
BatState::Dead => {
|
BatState::Dead => {
|
||||||
const BAT_DEAD: &Tag = TAG_MAP.get("bat dead");
|
const BAT_DEAD: &Tag = TAG_MAP.get("bat dead");
|
||||||
let sprite = BAT_DEAD.sprite(0);
|
let sprite = BAT_DEAD.sprite(0);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
|
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
|
@ -944,7 +947,7 @@ impl SlimeData {
|
||||||
|
|
||||||
fn update<'a>(
|
fn update<'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
controller: &'a ObjectController,
|
controller: &'a OAMManager,
|
||||||
entity: &mut Entity<'a>,
|
entity: &mut Entity<'a>,
|
||||||
player: &Player,
|
player: &Player,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
|
@ -969,7 +972,7 @@ impl SlimeData {
|
||||||
const IDLE: &Tag = TAG_MAP.get("slime idle");
|
const IDLE: &Tag = TAG_MAP.get("slime idle");
|
||||||
|
|
||||||
let sprite = IDLE.sprite(self.sprite_offset as usize / 16);
|
let sprite = IDLE.sprite(self.sprite_offset as usize / 16);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
|
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
|
@ -1009,7 +1012,7 @@ impl SlimeData {
|
||||||
const CHASE: &Tag = TAG_MAP.get("Slime jump");
|
const CHASE: &Tag = TAG_MAP.get("Slime jump");
|
||||||
|
|
||||||
let sprite = CHASE.sprite(frame as usize);
|
let sprite = CHASE.sprite(frame as usize);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
|
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
|
@ -1039,7 +1042,7 @@ impl SlimeData {
|
||||||
if *count < 5 * 4 {
|
if *count < 5 * 4 {
|
||||||
const DEATH: &Tag = TAG_MAP.get("Slime death");
|
const DEATH: &Tag = TAG_MAP.get("Slime death");
|
||||||
let sprite = DEATH.sprite(*count as usize / 4);
|
let sprite = DEATH.sprite(*count as usize / 4);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
|
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
*count += 1;
|
*count += 1;
|
||||||
|
@ -1073,7 +1076,7 @@ impl MiniFlameData {
|
||||||
|
|
||||||
fn update<'a>(
|
fn update<'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
controller: &'a ObjectController,
|
controller: &'a OAMManager,
|
||||||
entity: &mut Entity<'a>,
|
entity: &mut Entity<'a>,
|
||||||
player: &Player,
|
player: &Player,
|
||||||
_level: &Level,
|
_level: &Level,
|
||||||
|
@ -1107,7 +1110,7 @@ impl MiniFlameData {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let sprite = ANGRY.animation_sprite(self.sprite_offset as usize / 8);
|
let sprite = ANGRY.animation_sprite(self.sprite_offset as usize / 8);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
entity.velocity = (0.into(), Number::new(-1) / Number::new(4)).into();
|
entity.velocity = (0.into(), Number::new(-1) / Number::new(4)).into();
|
||||||
|
@ -1155,7 +1158,7 @@ impl MiniFlameData {
|
||||||
}
|
}
|
||||||
|
|
||||||
let sprite = ANGRY.animation_sprite(self.sprite_offset as usize / 2);
|
let sprite = ANGRY.animation_sprite(self.sprite_offset as usize / 2);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
}
|
}
|
||||||
MiniFlameState::Dead => {
|
MiniFlameState::Dead => {
|
||||||
|
@ -1167,7 +1170,7 @@ impl MiniFlameData {
|
||||||
const DEATH: &Tag = TAG_MAP.get("angry boss dead");
|
const DEATH: &Tag = TAG_MAP.get("angry boss dead");
|
||||||
|
|
||||||
let sprite = DEATH.animation_sprite(self.sprite_offset as usize / 12);
|
let sprite = DEATH.animation_sprite(self.sprite_offset as usize / 12);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
self.sprite_offset += 1;
|
self.sprite_offset += 1;
|
||||||
|
@ -1202,7 +1205,7 @@ impl EmuData {
|
||||||
|
|
||||||
fn update<'a>(
|
fn update<'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
controller: &'a ObjectController,
|
controller: &'a OAMManager,
|
||||||
entity: &mut Entity<'a>,
|
entity: &mut Entity<'a>,
|
||||||
player: &Player,
|
player: &Player,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
|
@ -1228,7 +1231,7 @@ impl EmuData {
|
||||||
const IDLE: &Tag = TAG_MAP.get("emu - idle");
|
const IDLE: &Tag = TAG_MAP.get("emu - idle");
|
||||||
|
|
||||||
let sprite = IDLE.sprite(self.sprite_offset as usize / 16);
|
let sprite = IDLE.sprite(self.sprite_offset as usize / 16);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
if (entity.position.y - player.entity.position.y).abs() < 10.into() {
|
if (entity.position.y - player.entity.position.y).abs() < 10.into() {
|
||||||
|
@ -1275,7 +1278,7 @@ impl EmuData {
|
||||||
const WALK: &Tag = TAG_MAP.get("emu-walk");
|
const WALK: &Tag = TAG_MAP.get("emu-walk");
|
||||||
|
|
||||||
let sprite = WALK.sprite(self.sprite_offset as usize / 2);
|
let sprite = WALK.sprite(self.sprite_offset as usize / 2);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
let gravity: Number = 1.into();
|
let gravity: Number = 1.into();
|
||||||
|
@ -1330,7 +1333,7 @@ impl EmuData {
|
||||||
const DEATH: &Tag = TAG_MAP.get("emu - die");
|
const DEATH: &Tag = TAG_MAP.get("emu - die");
|
||||||
|
|
||||||
let sprite = DEATH.animation_sprite(self.sprite_offset as usize / 4);
|
let sprite = DEATH.animation_sprite(self.sprite_offset as usize / 4);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
self.sprite_offset += 1;
|
self.sprite_offset += 1;
|
||||||
|
@ -1375,7 +1378,7 @@ impl EnemyData {
|
||||||
|
|
||||||
fn update<'a>(
|
fn update<'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
controller: &'a ObjectController,
|
controller: &'a OAMManager,
|
||||||
entity: &mut Entity<'a>,
|
entity: &mut Entity<'a>,
|
||||||
player: &Player,
|
player: &Player,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
|
@ -1396,11 +1399,11 @@ struct Enemy<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Enemy<'a> {
|
impl<'a> Enemy<'a> {
|
||||||
fn new(object_controller: &'a ObjectController, enemy_data: EnemyData) -> Self {
|
fn new(object_controller: &'a OAMManager, enemy_data: EnemyData) -> Self {
|
||||||
let mut entity = Entity::new(object_controller, enemy_data.collision_mask());
|
let mut entity = Entity::new(object_controller, enemy_data.collision_mask());
|
||||||
|
|
||||||
let sprite = enemy_data.sprite();
|
let sprite = enemy_data.sprite();
|
||||||
let sprite = object_controller.sprite(sprite);
|
let sprite = object_controller.get_vram_sprite(sprite);
|
||||||
|
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
entity.sprite.show();
|
entity.sprite.show();
|
||||||
|
@ -1410,7 +1413,7 @@ impl<'a> Enemy<'a> {
|
||||||
|
|
||||||
fn update(
|
fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
controller: &'a ObjectController,
|
controller: &'a OAMManager,
|
||||||
player: &Player,
|
player: &Player,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
sfx: &mut sfx::Sfx,
|
sfx: &mut sfx::Sfx,
|
||||||
|
@ -1441,7 +1444,7 @@ impl ParticleData {
|
||||||
|
|
||||||
fn update<'a>(
|
fn update<'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
controller: &'a ObjectController,
|
controller: &'a OAMManager,
|
||||||
entity: &mut Entity<'a>,
|
entity: &mut Entity<'a>,
|
||||||
player: &Player,
|
player: &Player,
|
||||||
_level: &Level,
|
_level: &Level,
|
||||||
|
@ -1454,7 +1457,7 @@ impl ParticleData {
|
||||||
|
|
||||||
const DUST: &Tag = TAG_MAP.get("dust");
|
const DUST: &Tag = TAG_MAP.get("dust");
|
||||||
let sprite = DUST.sprite(*frame as usize / 3);
|
let sprite = DUST.sprite(*frame as usize / 3);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
|
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
|
@ -1468,7 +1471,7 @@ impl ParticleData {
|
||||||
|
|
||||||
const HEALTH: &Tag = TAG_MAP.get("Heath");
|
const HEALTH: &Tag = TAG_MAP.get("Heath");
|
||||||
let sprite = HEALTH.animation_sprite(*frame as usize / 3);
|
let sprite = HEALTH.animation_sprite(*frame as usize / 3);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
|
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
|
@ -1494,7 +1497,7 @@ impl ParticleData {
|
||||||
ParticleData::BossHealer(frame, target) => {
|
ParticleData::BossHealer(frame, target) => {
|
||||||
const HEALTH: &Tag = TAG_MAP.get("Heath");
|
const HEALTH: &Tag = TAG_MAP.get("Heath");
|
||||||
let sprite = HEALTH.animation_sprite(*frame as usize / 3);
|
let sprite = HEALTH.animation_sprite(*frame as usize / 3);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
|
|
||||||
entity.sprite.set_sprite(sprite);
|
entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
|
@ -1529,7 +1532,7 @@ struct Particle<'a> {
|
||||||
|
|
||||||
impl<'a> Particle<'a> {
|
impl<'a> Particle<'a> {
|
||||||
fn new(
|
fn new(
|
||||||
object_controller: &'a ObjectController,
|
object_controller: &'a OAMManager,
|
||||||
particle_data: ParticleData,
|
particle_data: ParticleData,
|
||||||
position: Vector2D<Number>,
|
position: Vector2D<Number>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -1548,7 +1551,7 @@ impl<'a> Particle<'a> {
|
||||||
|
|
||||||
fn update(
|
fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
controller: &'a ObjectController,
|
controller: &'a OAMManager,
|
||||||
player: &Player,
|
player: &Player,
|
||||||
level: &Level,
|
level: &Level,
|
||||||
) -> UpdateInstruction {
|
) -> UpdateInstruction {
|
||||||
|
@ -1575,7 +1578,7 @@ impl<'a> BossState<'a> {
|
||||||
fn update(
|
fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
enemies: &mut Arena<Enemy<'a>>,
|
enemies: &mut Arena<Enemy<'a>>,
|
||||||
object_controller: &'a ObjectController,
|
object_controller: &'a OAMManager,
|
||||||
player: &Player,
|
player: &Player,
|
||||||
sfx: &mut sfx::Sfx,
|
sfx: &mut sfx::Sfx,
|
||||||
) -> BossInstruction {
|
) -> BossInstruction {
|
||||||
|
@ -1610,7 +1613,7 @@ struct FollowingBoss<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FollowingBoss<'a> {
|
impl<'a> FollowingBoss<'a> {
|
||||||
fn new(object_controller: &'a ObjectController, position: Vector2D<Number>) -> Self {
|
fn new(object_controller: &'a OAMManager, position: Vector2D<Number>) -> Self {
|
||||||
let mut entity = Entity::new(
|
let mut entity = Entity::new(
|
||||||
object_controller,
|
object_controller,
|
||||||
Rect::new((0_u16, 0_u16).into(), (0_u16, 0_u16).into()),
|
Rect::new((0_u16, 0_u16).into(), (0_u16, 0_u16).into()),
|
||||||
|
@ -1625,7 +1628,7 @@ impl<'a> FollowingBoss<'a> {
|
||||||
gone: false,
|
gone: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn update(&mut self, controller: &'a ObjectController, player: &Player) {
|
fn update(&mut self, controller: &'a OAMManager, player: &Player) {
|
||||||
let difference = player.entity.position - self.entity.position;
|
let difference = player.entity.position - self.entity.position;
|
||||||
self.timer += 1;
|
self.timer += 1;
|
||||||
|
|
||||||
|
@ -1658,7 +1661,7 @@ impl<'a> FollowingBoss<'a> {
|
||||||
const BOSS: &Tag = TAG_MAP.get("happy boss");
|
const BOSS: &Tag = TAG_MAP.get("happy boss");
|
||||||
|
|
||||||
let sprite = BOSS.animation_sprite(frame as usize);
|
let sprite = BOSS.animation_sprite(frame as usize);
|
||||||
let sprite = controller.sprite(sprite);
|
let sprite = controller.get_vram_sprite(sprite);
|
||||||
|
|
||||||
self.entity.sprite.set_sprite(sprite);
|
self.entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
|
@ -1694,7 +1697,7 @@ enum BossInstruction {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Boss<'a> {
|
impl<'a> Boss<'a> {
|
||||||
fn new(object_controller: &'a ObjectController, screen_coords: Vector2D<Number>) -> Self {
|
fn new(object_controller: &'a OAMManager, screen_coords: Vector2D<Number>) -> Self {
|
||||||
let mut entity = Entity::new(
|
let mut entity = Entity::new(
|
||||||
object_controller,
|
object_controller,
|
||||||
Rect::new((0_u16, 0_u16).into(), (28_u16, 28_u16).into()),
|
Rect::new((0_u16, 0_u16).into(), (28_u16, 28_u16).into()),
|
||||||
|
@ -1713,7 +1716,7 @@ impl<'a> Boss<'a> {
|
||||||
fn update(
|
fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
enemies: &mut Arena<Enemy<'a>>,
|
enemies: &mut Arena<Enemy<'a>>,
|
||||||
object_controller: &'a ObjectController,
|
object_controller: &'a OAMManager,
|
||||||
player: &Player,
|
player: &Player,
|
||||||
sfx: &mut sfx::Sfx,
|
sfx: &mut sfx::Sfx,
|
||||||
) -> BossInstruction {
|
) -> BossInstruction {
|
||||||
|
@ -1794,7 +1797,7 @@ impl<'a> Boss<'a> {
|
||||||
const BOSS: &Tag = TAG_MAP.get("Boss");
|
const BOSS: &Tag = TAG_MAP.get("Boss");
|
||||||
|
|
||||||
let sprite = BOSS.animation_sprite(frame as usize);
|
let sprite = BOSS.animation_sprite(frame as usize);
|
||||||
let sprite = object_controller.sprite(sprite);
|
let sprite = object_controller.get_vram_sprite(sprite);
|
||||||
|
|
||||||
self.entity.sprite.set_sprite(sprite);
|
self.entity.sprite.set_sprite(sprite);
|
||||||
|
|
||||||
|
@ -1817,7 +1820,7 @@ impl<'a> Boss<'a> {
|
||||||
self.entity
|
self.entity
|
||||||
.commit_with_size(offset + shake, (32, 32).into());
|
.commit_with_size(offset + shake, (32, 32).into());
|
||||||
}
|
}
|
||||||
fn explode(&self, enemies: &mut Arena<Enemy<'a>>, object_controller: &'a ObjectController) {
|
fn explode(&self, enemies: &mut Arena<Enemy<'a>>, object_controller: &'a OAMManager) {
|
||||||
for _ in 0..(6 - self.health) {
|
for _ in 0..(6 - self.health) {
|
||||||
let x_offset: Number = Number::from_raw(rng::gen()).rem_euclid(2.into()) - 1;
|
let x_offset: Number = Number::from_raw(rng::gen()).rem_euclid(2.into()) - 1;
|
||||||
let y_offset: Number = Number::from_raw(rng::gen()).rem_euclid(2.into()) - 1;
|
let y_offset: Number = Number::from_raw(rng::gen()).rem_euclid(2.into()) - 1;
|
||||||
|
@ -1891,7 +1894,7 @@ impl<'a> Game<'a> {
|
||||||
|
|
||||||
fn advance_frame(
|
fn advance_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
object_controller: &'a ObjectController,
|
object_controller: &'a OAMManager,
|
||||||
vram: &mut VRamManager,
|
vram: &mut VRamManager,
|
||||||
sfx: &mut sfx::Sfx,
|
sfx: &mut sfx::Sfx,
|
||||||
) -> GameStatus {
|
) -> GameStatus {
|
||||||
|
@ -2105,7 +2108,7 @@ impl<'a> Game<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_enemies(&mut self, object_controller: &'a ObjectController) {
|
fn load_enemies(&mut self, object_controller: &'a OAMManager) {
|
||||||
if self.slime_load < self.level.slime_spawns.len() {
|
if self.slime_load < self.level.slime_spawns.len() {
|
||||||
for (idx, slime_spawn) in self
|
for (idx, slime_spawn) in self
|
||||||
.level
|
.level
|
||||||
|
@ -2175,7 +2178,7 @@ impl<'a> Game<'a> {
|
||||||
vram.set_background_palettes(&modified_palettes);
|
vram.set_background_palettes(&modified_palettes);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(object: &'a ObjectController, level: Level<'a>, start_at_boss: bool) -> Self {
|
fn new(object: &'a OAMManager, level: Level<'a>, start_at_boss: bool) -> Self {
|
||||||
let mut player = Player::new(object);
|
let mut player = Player::new(object);
|
||||||
let mut offset = (8, 8).into();
|
let mut offset = (8, 8).into();
|
||||||
if start_at_boss {
|
if start_at_boss {
|
||||||
|
@ -2222,7 +2225,7 @@ fn game_with_level(gba: &mut agb::Gba) {
|
||||||
|
|
||||||
let tileset = TileSet::new(background::background.tiles, TileFormat::FourBpp);
|
let tileset = TileSet::new(background::background.tiles, TileFormat::FourBpp);
|
||||||
|
|
||||||
let object = gba.display.object.get();
|
let object = gba.display.object.get_managed();
|
||||||
|
|
||||||
let backdrop = InfiniteScrolledMap::new(
|
let backdrop = InfiniteScrolledMap::new(
|
||||||
background.background(
|
background.background(
|
||||||
|
|
Loading…
Reference in a new issue