mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
update games
This commit is contained in:
parent
2ef1dd0bf2
commit
3e3039a7f6
|
@ -88,7 +88,8 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
.object
|
||||
.set_y((chicken.position.y >> 8).try_into().unwrap());
|
||||
chicken.object.show();
|
||||
chicken.object.commit();
|
||||
|
||||
object.commit();
|
||||
|
||||
let acceleration = 1 << 4;
|
||||
let gravity = 1 << 4;
|
||||
|
@ -133,8 +134,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
restrict_to_screen(&mut chicken);
|
||||
update_chicken_object(&mut chicken, &object, state, frame_count);
|
||||
|
||||
// Commit the chicken to vram
|
||||
chicken.object.commit();
|
||||
object.commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ extern crate alloc;
|
|||
use agb::display::object::{Graphics, ObjectController, Sprite, TagMap};
|
||||
use alloc::vec::Vec;
|
||||
|
||||
|
||||
const GRAPHICS: &Graphics = agb::include_aseprite!(
|
||||
"../examples/the-purple-night/gfx/objects.aseprite",
|
||||
"../examples/the-purple-night/gfx/boss.aseprite"
|
||||
|
@ -49,7 +48,7 @@ fn all_sprites(gfx: &ObjectController) {
|
|||
for (i, obj) in objs.iter_mut().enumerate() {
|
||||
let this_image = (image + i * SPRITES.len() / objs_len) % SPRITES.len();
|
||||
obj.set_sprite(gfx.sprite(&SPRITES[this_image]));
|
||||
obj.commit();
|
||||
gfx.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,8 +90,8 @@ fn all_tags(gfx: &ObjectController) {
|
|||
image += 1;
|
||||
for (obj, tag) in objs.iter_mut() {
|
||||
obj.set_sprite(gfx.sprite(tag.animation_sprite(image)));
|
||||
obj.commit();
|
||||
}
|
||||
gfx.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,10 +100,6 @@ fn all_tags(gfx: &ObjectController) {
|
|||
fn main(mut gba: agb::Gba) -> ! {
|
||||
let gfx = gba.display.object.get();
|
||||
|
||||
let mut timers = gba.timers.timers();
|
||||
|
||||
let _a = agb::interrupt::profiler(&mut timers.timer0, 5000);
|
||||
|
||||
loop {
|
||||
all_tags(&gfx);
|
||||
all_sprites(&gfx);
|
||||
|
|
|
@ -258,7 +258,6 @@ impl<'a> Entity<'a> {
|
|||
} else {
|
||||
self.sprite.show();
|
||||
}
|
||||
self.sprite.commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,8 +355,7 @@ impl<'a> Player<'a> {
|
|||
wizard.sprite.show();
|
||||
hat.sprite.show();
|
||||
|
||||
wizard.sprite.commit();
|
||||
hat.sprite.commit();
|
||||
hat.sprite.set_z(-1);
|
||||
|
||||
wizard.position = start_position;
|
||||
hat.position = start_position - (0, 10).into();
|
||||
|
@ -498,22 +496,6 @@ impl<'a> Player<'a> {
|
|||
_ => HAT_SPIN_3,
|
||||
};
|
||||
|
||||
match self.facing {
|
||||
agb::input::Tri::Negative => {
|
||||
self.wizard.sprite.set_hflip(true);
|
||||
self.hat
|
||||
.sprite
|
||||
.set_sprite(controller.sprite(hat_base_tile.sprite(5)));
|
||||
}
|
||||
agb::input::Tri::Positive => {
|
||||
self.wizard.sprite.set_hflip(false);
|
||||
self.hat
|
||||
.sprite
|
||||
.set_sprite(controller.sprite(hat_base_tile.sprite(0)));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let hat_resting_position = match self.wizard_frame {
|
||||
1 | 2 => (0, 9).into(),
|
||||
5 => (0, 10).into(),
|
||||
|
@ -571,6 +553,21 @@ impl<'a> Player<'a> {
|
|||
self.hat_slow_counter = 0;
|
||||
self.hat_left_range = false;
|
||||
self.hat.position = self.wizard.position - hat_resting_position;
|
||||
match self.facing {
|
||||
agb::input::Tri::Negative => {
|
||||
self.wizard.sprite.set_hflip(true);
|
||||
self.hat
|
||||
.sprite
|
||||
.set_sprite(controller.sprite(hat_base_tile.sprite(5)));
|
||||
}
|
||||
agb::input::Tri::Positive => {
|
||||
self.wizard.sprite.set_hflip(false);
|
||||
self.hat
|
||||
.sprite
|
||||
.set_sprite(controller.sprite(hat_base_tile.sprite(0)));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
HatState::WizardTowards => {
|
||||
self.hat.sprite.set_sprite(
|
||||
|
@ -907,6 +904,8 @@ fn main(mut agb: agb::Gba) -> ! {
|
|||
mixer.after_vblank();
|
||||
}
|
||||
|
||||
object.commit();
|
||||
|
||||
level.show_backgrounds();
|
||||
|
||||
world_display.hide();
|
||||
|
@ -925,6 +924,7 @@ fn main(mut agb: agb::Gba) -> ! {
|
|||
mixer.frame();
|
||||
vblank.wait_for_vblank();
|
||||
mixer.after_vblank();
|
||||
object.commit();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -938,6 +938,7 @@ fn main(mut agb: agb::Gba) -> ! {
|
|||
mixer.frame();
|
||||
vblank.wait_for_vblank();
|
||||
mixer.after_vblank();
|
||||
object.commit();
|
||||
}
|
||||
|
||||
level.hide_backgrounds();
|
||||
|
|
|
@ -285,7 +285,6 @@ impl<'a> Entity<'a> {
|
|||
self.sprite.show();
|
||||
}
|
||||
}
|
||||
self.sprite.commit();
|
||||
}
|
||||
|
||||
fn commit_with_size(&mut self, offset: Vector2D<Number>, size: Vector2D<i32>) {
|
||||
|
@ -304,7 +303,6 @@ impl<'a> Entity<'a> {
|
|||
self.sprite.show();
|
||||
}
|
||||
}
|
||||
self.sprite.commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -540,7 +538,6 @@ impl<'a> Player<'a> {
|
|||
entity.sprite.set_sprite(s);
|
||||
entity.sprite.show();
|
||||
entity.position = (144, 0).into();
|
||||
entity.sprite.commit();
|
||||
|
||||
Player {
|
||||
entity,
|
||||
|
@ -1405,8 +1402,6 @@ impl<'a> Enemy<'a> {
|
|||
entity.sprite.set_sprite(sprite);
|
||||
entity.sprite.show();
|
||||
|
||||
entity.sprite.commit();
|
||||
|
||||
Self { entity, enemy_data }
|
||||
}
|
||||
|
||||
|
@ -2285,6 +2280,7 @@ fn game_with_level(gba: &mut agb::Gba) {
|
|||
sfx.frame();
|
||||
vblank.wait_for_vblank();
|
||||
sfx.after_vblank();
|
||||
object.commit();
|
||||
match game.advance_frame(&object, &mut vram, &mut sfx) {
|
||||
GameStatus::Continue => {}
|
||||
GameStatus::Lost => {
|
||||
|
|
Loading…
Reference in a new issue