Add an opening scene
This commit is contained in:
		
							
								
								
									
										14
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/main.ts
									
									
									
									
									
								
							| @@ -2,17 +2,5 @@ import { hostGame } from "./engine/internal/host.ts"; | ||||
| import { game } from "./game.ts"; | ||||
| import { getStateManager } from "./statemanager.ts"; | ||||
|  | ||||
| getStateManager().startGame( | ||||
|   { | ||||
|     name: "Pyrex", | ||||
|     title: "", | ||||
|     note: null, | ||||
|     stats: { AGI: 10, INT: 10, CHA: 10, PSI: 10 }, | ||||
|     talents: { AGI: 0, INT: 0, CHA: 0, PSI: 0 }, | ||||
|     skills: [], | ||||
|     isCompulsory: false, | ||||
|     inPenance: false, | ||||
|   }, | ||||
|   null, | ||||
| ); | ||||
| getStateManager().startFirstGame(); | ||||
| hostGame(game); | ||||
|   | ||||
							
								
								
									
										21
									
								
								src/openingscene.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								src/openingscene.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| import { compile, VNScene } from "./vnscene.ts"; | ||||
|  | ||||
| export let openingScene: VNScene = compile([ | ||||
|   `Mortal! | ||||
|  | ||||
| ... I can't call you that anymore, can I? | ||||
|  | ||||
| Listen up:  | ||||
|  | ||||
| You've been given a gift! Your life is now over. There's no going back... In nine days you will be one of us. | ||||
|  | ||||
| You probably think this is like a final, but it's more like an entrance exam! | ||||
|  | ||||
| Soon I will forget about you, | ||||
|  | ||||
| Your Progenitor | ||||
|  | ||||
|  | ||||
|  | ||||
| PS: Left mouse + WASD. Like Quake!`, | ||||
| ]); | ||||
| @@ -6,6 +6,7 @@ import { getEndgameModal } from "./endgamemodal.ts"; | ||||
| import { SuccessorOption, Wish } from "./datatypes.ts"; | ||||
| import { generateManor } from "./manormap.ts"; | ||||
| import { sndSleep } from "./sounds.ts"; | ||||
| import { openingScene } from "./openingscene.ts"; | ||||
|  | ||||
| const N_TURNS: number = 9; | ||||
|  | ||||
| @@ -20,6 +21,30 @@ export class StateManager { | ||||
|     return this.#turn; | ||||
|   } | ||||
|  | ||||
|   startFirstGame() { | ||||
|     getVNModal().play([ | ||||
|       ...openingScene, | ||||
|       { | ||||
|         type: "callback", | ||||
|         callback: () => { | ||||
|           this.startGame( | ||||
|             { | ||||
|               name: "Pyrex", | ||||
|               title: "", | ||||
|               note: null, | ||||
|               stats: { AGI: 10, INT: 10, CHA: 10, PSI: 10 }, | ||||
|               talents: { AGI: 0, INT: 0, CHA: 0, PSI: 0 }, | ||||
|               skills: [], | ||||
|               isCompulsory: false, | ||||
|               inPenance: false, | ||||
|             }, | ||||
|             null, | ||||
|           ); | ||||
|         }, | ||||
|       }, | ||||
|     ]); | ||||
|   } | ||||
|  | ||||
|   startGame(asSuccessor: SuccessorOption, withWish: Wish | null) { | ||||
|     this.#turn = 1; | ||||
|     initPlayerProgress(asSuccessor, withWish); | ||||
|   | ||||
| @@ -86,6 +86,9 @@ function createCathexis(part: VNScenePart): SceneCathexis { | ||||
|   switch (part.type) { | ||||
|     case "message": | ||||
|       return new SceneMessageCathexis(part); | ||||
|     case "callback": | ||||
|       part?.callback(); | ||||
|       return new SkipCathexis(); | ||||
|   } | ||||
| } | ||||
|  | ||||
| @@ -109,7 +112,7 @@ class SceneMessageCathexis { | ||||
|     this.#gotOneFrame = true; | ||||
|  | ||||
|     // TODO: SFX | ||||
|     if (!firstFrame && I.isAnythingPressed()) { | ||||
|     if (!firstFrame && I.isMouseClicked("leftMouse")) { | ||||
|       this.#done = true; | ||||
|     } | ||||
|   } | ||||
| @@ -127,3 +130,19 @@ let active: VNModal = new VNModal(); | ||||
| export function getVNModal() { | ||||
|   return active; | ||||
| } | ||||
|  | ||||
| class SkipCathexis { | ||||
|   constructor() {} | ||||
|  | ||||
|   isDone() { | ||||
|     return true; | ||||
|   } | ||||
|  | ||||
|   update() { | ||||
|     throw new Error("shouldn't be updated"); | ||||
|   } | ||||
|  | ||||
|   draw() { | ||||
|     throw new Error("shouldn't ever be drawn"); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -4,9 +4,14 @@ export type VNSceneMessage = { | ||||
|   sfx?: string; | ||||
| }; | ||||
|  | ||||
| export type VNSceneBasisPart = string | VNSceneMessage; | ||||
| export type VNSceneCallback = { | ||||
|   type: "callback"; | ||||
|   callback: () => void; | ||||
| }; | ||||
|  | ||||
| export type VNSceneBasisPart = string | VNSceneMessage | VNSceneCallback; | ||||
| export type VNSceneBasis = VNSceneBasisPart[]; | ||||
| export type VNScenePart = VNSceneMessage; | ||||
| export type VNScenePart = VNSceneMessage | VNSceneCallback; | ||||
| export type VNScene = VNScenePart[]; | ||||
|  | ||||
| export function compile(basis: VNSceneBasis): VNScene { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user