1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-11-15 18:32:48 +00:00

air counter and drowning

This commit is contained in:
Alula 2020-10-30 15:24:12 +01:00
parent 43a756fcc2
commit 28da301e8c
No known key found for this signature in database
GPG key ID: 3E00485503A1D8BA
2 changed files with 61 additions and 25 deletions

View file

@ -45,14 +45,16 @@ pub struct Player {
pub update_target: bool, pub update_target: bool,
pub stars: u8, pub stars: u8,
pub damage: u16, pub damage: u16,
pub air_counter: u16,
pub air: u16,
weapon_offset_y: i8, weapon_offset_y: i8,
index_x: isize, index_x: isize,
index_y: isize, index_y: isize,
splash: bool, splash: bool,
booster_switch: u8, booster_switch: u8,
bubble: u8, bubble: u8,
exp_wait: isize, damage_counter: u16,
exp_count: isize, damage_taken: i16,
anim_num: u16, anim_num: u16,
anim_counter: u16, anim_counter: u16,
anim_rect: Rect<usize>, anim_rect: Rect<usize>,
@ -93,9 +95,11 @@ impl Player {
booster_switch: 0, booster_switch: 0,
stars: 0, stars: 0,
damage: 0, damage: 0,
air_counter: 0,
air: 0,
bubble: 0, bubble: 0,
exp_wait: 0, damage_counter: 0,
exp_count: 0, damage_taken: 0,
anim_num: 0, anim_num: 0,
anim_counter: 0, anim_counter: 0,
anim_rect: constants.my_char.animations_right[0], anim_rect: constants.my_char.animations_right[0],
@ -104,11 +108,37 @@ impl Player {
} }
fn tick_normal(&mut self, state: &mut SharedGameState) -> GameResult { fn tick_normal(&mut self, state: &mut SharedGameState) -> GameResult {
if !state.control_flags.interactions_disabled() && state.control_flags.control_enabled() {
if self.equip.has_air_tank() {
self.air = 1000;
self.air_counter = 0;
} else if self.flags.in_water() {
self.air_counter = 60;
if self.air > 0 {
self.air -= 1;
} else {
self.cond.set_hidden(true);
state.textscript_vm.start_script(41);
state.create_caret(self.x, self.y, CaretType::DrownedQuote, self.direction);
}
} else {
self.air = 1000;
if self.air_counter > 0 {
self.air_counter -= 1;
}
}
}
if self.cond.hidden() { if self.cond.hidden() {
return Ok(()); return Ok(());
} }
let physics = if self.flags.in_water() { state.constants.my_char.water_physics } else { state.constants.my_char.air_physics }; let physics = if self.flags.in_water() {
state.constants.my_char.water_physics
} else {
state.constants.my_char.air_physics
};
self.question = false; self.question = false;
@ -572,29 +602,21 @@ impl GameEntity<()> for Player {
return Ok(()); return Ok(());
} }
if self.exp_wait != 0 { if self.damage_counter != 0 {
self.exp_wait -= 1; self.damage_counter -= 1;
} }
if self.shock_counter != 0 { if self.shock_counter != 0 {
self.shock_counter -= 1; self.shock_counter -= 1;
} else if self.exp_count != 0 { } else if self.damage_taken != 0 {
// SetValueView(&self.x, &self.y, self.exp_count); // todo: damage popup // SetValueView(&self.x, &self.y, self.exp_count); // todo: damage popup
self.exp_count = 0; self.damage_taken = 0;
} }
// todo: add additional control modes like NXEngine has such as noclip? // todo: add additional control modes like NXEngine has such as noclip?
match self.control_mode { match self.control_mode {
ControlMode::Normal => { ControlMode::Normal => self.tick_normal(state)?,
if state.control_flags.interactions_disabled() && state.control_flags.control_enabled() { ControlMode::IronHead => self.tick_ironhead(state)?,
// AirProcess(); // todo
}
self.tick_normal(state)?;
}
ControlMode::IronHead => {
self.tick_ironhead(state)?;
}
} }
self.cond.set_increase_acceleration(false); self.cond.set_increase_acceleration(false);

View file

@ -150,13 +150,24 @@ impl GameScene {
if self.player.max_life != 0 { if self.player.max_life != 0 {
// life box // life box
batch.add_rect(16.0, 40.0, batch.add_rect(16.0, 40.0,
&Rect::<usize>::new_size(0, 40, 64, 8)); &Rect::new_size(0, 40, 64, 8));
// yellow bar // yellow bar
batch.add_rect(40.0, 40.0, batch.add_rect(40.0, 40.0,
&Rect::<usize>::new_size(0, 32, ((self.life_bar as usize * 40) / self.player.max_life as usize), 8)); &Rect::new_size(0, 32, ((self.life_bar as usize * 40) / self.player.max_life as usize), 8));
// life // life
batch.add_rect(40.0, 40.0, batch.add_rect(40.0, 40.0,
&Rect::<usize>::new_size(0, 24, ((self.player.life as usize * 40) / self.player.max_life as usize), 8)); &Rect::new_size(0, 24, ((self.player.life as usize * 40) / self.player.max_life as usize), 8));
}
if self.player.air_counter > 0 {
let rect = if self.player.air % 30 > 10 {
Rect::new_size(112, 72, 32, 8)
} else {
Rect::new_size(112, 80, 32, 8)
};
batch.add_rect((state.canvas_size.0 / 2.0).floor() - 40.0,
(state.canvas_size.1 / 2.0).floor(), &rect);
} }
batch.draw(ctx)?; batch.draw(ctx)?;
@ -192,6 +203,12 @@ impl GameScene {
batch.draw(ctx)?; batch.draw(ctx)?;
if self.player.air_counter > 0 && self.player.air_counter % 6 < 4 {
self.draw_number((state.canvas_size.0 / 2.0).floor() + 8.0,
(state.canvas_size.1 / 2.0).floor(),
(self.player.air / 10) as usize, Alignment::Left, state, ctx)?;
}
if max_ammo != 0 { if max_ammo != 0 {
self.draw_number(weap_x + 64.0, 16.0, ammo as usize, Alignment::Right, state, ctx)?; self.draw_number(weap_x + 64.0, 16.0, ammo as usize, Alignment::Right, state, ctx)?;
self.draw_number(weap_x + 64.0, 24.0, max_ammo as usize, Alignment::Right, state, ctx)?; self.draw_number(weap_x + 64.0, 24.0, max_ammo as usize, Alignment::Right, state, ctx)?;
@ -1104,9 +1121,6 @@ impl Scene for GameScene {
self.player.target_y = self.player.y; self.player.target_y = self.player.y;
self.frame.immediate_update(state, &self.player, &self.stage); self.frame.immediate_update(state, &self.player, &self.stage);
// self.inventory.add_weapon(WeaponType::PolarStar, 0);
// self.inventory.add_xp(120, state);
// self.player.equip.set_booster_2_0(true);
Ok(()) Ok(())
} }