mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2024-11-10 16:24:40 +00:00
Add intro scene
This commit is contained in:
parent
118fbeb785
commit
771516f7e4
0
src/npc/santa.rs
Normal file
0
src/npc/santa.rs
Normal file
|
@ -3,7 +3,7 @@ use log::info;
|
||||||
|
|
||||||
use crate::bullet::BulletManager;
|
use crate::bullet::BulletManager;
|
||||||
use crate::caret::CaretType;
|
use crate::caret::CaretType;
|
||||||
use crate::common::{Direction, FadeDirection, FadeState, Rect, fix9_scale};
|
use crate::common::{Direction, FadeDirection, FadeState, fix9_scale, Rect};
|
||||||
use crate::entity::GameEntity;
|
use crate::entity::GameEntity;
|
||||||
use crate::frame::Frame;
|
use crate::frame::Frame;
|
||||||
use crate::ggez::{Context, GameResult, graphics, timer};
|
use crate::ggez::{Context, GameResult, graphics, timer};
|
||||||
|
@ -15,6 +15,7 @@ use crate::physics::PhysicalEntity;
|
||||||
use crate::player::Player;
|
use crate::player::Player;
|
||||||
use crate::rng::RNG;
|
use crate::rng::RNG;
|
||||||
use crate::scene::Scene;
|
use crate::scene::Scene;
|
||||||
|
use crate::scene::title_scene::TitleScene;
|
||||||
use crate::shared_game_state::SharedGameState;
|
use crate::shared_game_state::SharedGameState;
|
||||||
use crate::stage::{BackgroundType, Stage};
|
use crate::stage::{BackgroundType, Stage};
|
||||||
use crate::text_script::{ConfirmSelection, ScriptMode, TextScriptExecutionState, TextScriptVM};
|
use crate::text_script::{ConfirmSelection, ScriptMode, TextScriptExecutionState, TextScriptVM};
|
||||||
|
@ -31,6 +32,7 @@ pub struct GameScene {
|
||||||
pub npc_map: NPCMap,
|
pub npc_map: NPCMap,
|
||||||
pub bullet_manager: BulletManager,
|
pub bullet_manager: BulletManager,
|
||||||
pub current_teleport_slot: u8,
|
pub current_teleport_slot: u8,
|
||||||
|
pub intro_mode: bool,
|
||||||
tex_background_name: String,
|
tex_background_name: String,
|
||||||
tex_tileset_name: String,
|
tex_tileset_name: String,
|
||||||
life_bar: u16,
|
life_bar: u16,
|
||||||
|
@ -79,13 +81,14 @@ impl GameScene {
|
||||||
stage_id: id,
|
stage_id: id,
|
||||||
npc_map: NPCMap::new(),
|
npc_map: NPCMap::new(),
|
||||||
bullet_manager: BulletManager::new(),
|
bullet_manager: BulletManager::new(),
|
||||||
|
current_teleport_slot: 0,
|
||||||
|
intro_mode: false,
|
||||||
tex_background_name,
|
tex_background_name,
|
||||||
tex_tileset_name,
|
tex_tileset_name,
|
||||||
life_bar: 0,
|
life_bar: 0,
|
||||||
life_bar_counter: 0,
|
life_bar_counter: 0,
|
||||||
map_name_counter: 0,
|
map_name_counter: 0,
|
||||||
stage_select_text_y_pos: 54,
|
stage_select_text_y_pos: 54,
|
||||||
current_teleport_slot: 0,
|
|
||||||
weapon_x_pos: 16,
|
weapon_x_pos: 16,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1100,6 +1103,10 @@ impl Scene for GameScene {
|
||||||
fn tick(&mut self, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
|
fn tick(&mut self, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
|
||||||
state.update_key_trigger();
|
state.update_key_trigger();
|
||||||
|
|
||||||
|
if self.intro_mode && (state.key_trigger.jump() || self.tick >= 500){
|
||||||
|
state.next_scene = Some(Box::new(TitleScene::new()));
|
||||||
|
}
|
||||||
|
|
||||||
match state.textscript_vm.mode {
|
match state.textscript_vm.mode {
|
||||||
ScriptMode::Map if state.control_flags.tick_world() => self.tick_world(state)?,
|
ScriptMode::Map if state.control_flags.tick_world() => self.tick_world(state)?,
|
||||||
ScriptMode::StageSelect => self.tick_stage_select(state)?,
|
ScriptMode::StageSelect => self.tick_stage_select(state)?,
|
||||||
|
|
|
@ -39,7 +39,7 @@ impl Scene for LoadingScene {
|
||||||
let stage_select_script = TextScript::load_from(stage_select_tsc, &state.constants)?;
|
let stage_select_script = TextScript::load_from(stage_select_tsc, &state.constants)?;
|
||||||
state.textscript_vm.set_stage_select_script(stage_select_script);
|
state.textscript_vm.set_stage_select_script(stage_select_script);
|
||||||
|
|
||||||
state.next_scene = Some(Box::new(TitleScene::new()));
|
state.start_intro(ctx)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.tick += 1;
|
self.tick += 1;
|
||||||
|
|
|
@ -164,6 +164,20 @@ impl SharedGameState {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn start_intro(&mut self, ctx: &mut Context) -> GameResult {
|
||||||
|
let mut next_scene = GameScene::new(self, ctx, 72)?;
|
||||||
|
next_scene.player.cond.set_hidden(true);
|
||||||
|
next_scene.player.x = 3 * 16 * 0x200;
|
||||||
|
next_scene.player.y = 3 * 16 * 0x200;
|
||||||
|
next_scene.intro_mode = true;
|
||||||
|
self.fade_state = FadeState::Hidden;
|
||||||
|
self.textscript_vm.state = TextScriptExecutionState::Running(100, 0);
|
||||||
|
|
||||||
|
self.next_scene = Some(Box::new(next_scene));
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn save_game(&mut self, game_scene: &mut GameScene, ctx: &mut Context) -> GameResult {
|
pub fn save_game(&mut self, game_scene: &mut GameScene, ctx: &mut Context) -> GameResult {
|
||||||
if let Ok(data) = filesystem::open_options(ctx, "/Profile.dat", OpenOptions::new().write(true).create(true)) {
|
if let Ok(data) = filesystem::open_options(ctx, "/Profile.dat", OpenOptions::new().write(true).create(true)) {
|
||||||
let profile = GameProfile::dump(self, game_scene);
|
let profile = GameProfile::dump(self, game_scene);
|
||||||
|
|
Loading…
Reference in a new issue