Add intro scene

This commit is contained in:
Alula 2020-10-30 09:49:30 +01:00
parent 118fbeb785
commit 771516f7e4
No known key found for this signature in database
GPG Key ID: 3E00485503A1D8BA
4 changed files with 24 additions and 3 deletions

0
src/npc/santa.rs Normal file
View File

View File

@ -3,7 +3,7 @@ use log::info;
use crate::bullet::BulletManager;
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::frame::Frame;
use crate::ggez::{Context, GameResult, graphics, timer};
@ -15,6 +15,7 @@ use crate::physics::PhysicalEntity;
use crate::player::Player;
use crate::rng::RNG;
use crate::scene::Scene;
use crate::scene::title_scene::TitleScene;
use crate::shared_game_state::SharedGameState;
use crate::stage::{BackgroundType, Stage};
use crate::text_script::{ConfirmSelection, ScriptMode, TextScriptExecutionState, TextScriptVM};
@ -31,6 +32,7 @@ pub struct GameScene {
pub npc_map: NPCMap,
pub bullet_manager: BulletManager,
pub current_teleport_slot: u8,
pub intro_mode: bool,
tex_background_name: String,
tex_tileset_name: String,
life_bar: u16,
@ -79,13 +81,14 @@ impl GameScene {
stage_id: id,
npc_map: NPCMap::new(),
bullet_manager: BulletManager::new(),
current_teleport_slot: 0,
intro_mode: false,
tex_background_name,
tex_tileset_name,
life_bar: 0,
life_bar_counter: 0,
map_name_counter: 0,
stage_select_text_y_pos: 54,
current_teleport_slot: 0,
weapon_x_pos: 16,
})
}
@ -1100,6 +1103,10 @@ impl Scene for GameScene {
fn tick(&mut self, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
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 {
ScriptMode::Map if state.control_flags.tick_world() => self.tick_world(state)?,
ScriptMode::StageSelect => self.tick_stage_select(state)?,

View File

@ -39,7 +39,7 @@ impl Scene for LoadingScene {
let stage_select_script = TextScript::load_from(stage_select_tsc, &state.constants)?;
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;

View File

@ -164,6 +164,20 @@ impl SharedGameState {
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 {
if let Ok(data) = filesystem::open_options(ctx, "/Profile.dat", OpenOptions::new().write(true).create(true)) {
let profile = GameProfile::dump(self, game_scene);