/** * Dragon's Lair was an arcade game released in 1983. * It was the first arcade game to feature a laserdisc video player inside the machine. * The player pressed the right direction or pressed an all-purpose attack button to avoid danger. * If the player failed to press the right command, or otherwise failed, the video would skip to * another part of the disc where the hero would die in an appropriate fashion. * The average lifetime of a Dragon's Lair cabinet was very low because of its mechanical components * and so today many people have never played the game. As a side effect, the entire "interactive video" * genre of games fell in to obscurity. * * This package attempts to recreate a standard Laserdisc game engine. * You are invited to make your own "video"game by splicing some video together linearly * and marking the scenes' expected player actions, and loop/redirect points in XML. * Cuepoints can be defined in an XML file with a start time (beg), end time (end), * the place in the video where a user wins something (win) and a place where the user dies (fail) * you can also use the (seekpoint) xml tag to force things like looping, * a return from a "win" tangent, or, most commonly like in Dragon's Lair, * move the player from a death to completely new room - its signature form of consequence. * * Special attention has been taken to make sure this is Playstation 3 Web Browser compatible. * Use X as the attack (mouse click), and the D-Pad as your direction buttons. * * I hereby release the rights to this code for all to use, share, and collaborate on in happiness * Any new versions will be posted somewhere on my website RGBk.org * * Yours truely, * Wray Bowling */ package{ //xml related import flash.net.URLLoader; import flash.net.URLRequest; import XML; //event related import flash.events.*; //video related import flash.display.Sprite; import fl.video.FLVPlayback; import fl.video.MetadataEvent; public class Laserdisc extends Sprite{ private var xml:XML; //the player has lives and and a score var player_lives:int = 3; //decreased by one every time the user fails var player_score:int = 0; //increased based on difficulty of what's expected //The "Quick Time Event" (as it is called in Shenmue) requires quick action from the player var QTE_expected:String = "OK"; //the user action expected, can be Up, Down, Left, Right, Attack, or None var QTE_fail:Number = 0.0; //the movie position for the user failing var QTE_win:Number = 0.0; //the movie position for the user fulfilling the expected action var QTE_gameover:Number = 0.0; var QTE_win_enabled = false; var QTE_kill_enabled = false; function Laserdisc():void{ //vcr is a FLVPlayback component, e.g. a movie player, that is on the stage vcr.source = "laserdisc.f4v"; vcr.pause(); vcr.playWhenEnoughDownloaded(); //Once the XML file is loaded completely, an event will move on to parsing it var XML_LOADER:URLLoader = new URLLoader(); XML_LOADER.addEventListener(Event.COMPLETE, loadXML); XML_LOADER.load(new URLRequest("cuepoints.xml")); //these events will read in user inputs stage.addEventListener(MouseEvent.CLICK, mouseAction); stage.addEventListener(KeyboardEvent.KEY_DOWN, keyAction); //this little beauty sends an event every time a cue point is reached within the video vcr.addEventListener(MetadataEvent.CUE_POINT, cueRead); } //function that loads all of the cue points from the XML private function loadXML(e:Event):void { var xml = new XML(e.target.data); //adds cue point events for "failpoints" which can only kill the player at failure for(var i:int = 0; i< xml.failpoint.length(); i++){ var cue:Object = new Object(); var parameters:Object = new Object(); cue.name = "failpoint"; cue.time = Number(xml.failpoint[i].start); cue.type = "actionscript"; parameters.key = xml.failpoint[i].key; parameters.fail = Number(xml.failpoint[i].fail); cue.parameters = parameters; vcr.addASCuePoint(cue); trace("cue v"); //ending cuepoint var endCue:Object = new Object(); endCue.name = "close"; endCue.time = xml.failpoint[i].close; vcr.addASCuePoint(endCue); trace("cue ^"); } //adds cue point events for "winpoints" which can only reward the player. good for menus for(var i:int = 0; i< xml.winpoint.length(); i++){ var cue:Object = new Object(); var parameters:Object = new Object(); cue.name = "winpoint"; cue.time = Number(xml.winpoint[i].start); cue.type = "actionscript"; parameters.key = xml.winpoint[i].key; parameters.win = Number(xml.winpoint[i].win); cue.parameters = parameters; vcr.addASCuePoint(cue); trace("cue v"); //ending cuepoint var endCue:Object = new Object(); endCue.name = "close"; endCue.time = xml.winpoint[i].close; vcr.addASCuePoint(endCue); trace("cue ^"); } //adds cue point events for "settings" that resets lives for(var i:int = 0; i"); } //adds cue point events for "scorepoints" that add to the player's score. for(var i:int = 0; i