2018-11-20 15:56:28 +01:00
function Automaton ( async , dom , messaging , screen , session , ui ) {
2018-11-18 23:08:36 +01:00
var menus = {
start : {
entries : [
{ label : 'New Game' , action : newGame } ,
{ label : 'Settings' , action : function ( ) { console . log ( "Not implemented yet" ) ; } }
] ,
cancel : intro
} ,
name : {
} ,
skin : {
}
} ;
var game = session . getGame ( ) ;
if ( game != undefined ) {
menus . start . entries . unshift (
{ label : 'Continue' , action : function ( ) { messaging . send ( { tag : 'Resume' , game : game } ) ; } }
) ;
2018-11-17 19:07:58 +01:00
}
2018-11-18 23:08:36 +01:00
return {
run : run
}
//messaging.addEventListener(['Init'], function(game) {
// console.log(game);
//});
function run ( ) {
intro ( ) ;
}
function intro ( ) {
var title = dom . make ( 'p' , { textContent : "P O K E M O N" , class : 'title' } ) ;
var subtitle = dom . make ( 'p' , { textContent : "< press start >" , class : 'subtitle' } ) ;
2018-11-20 15:56:28 +01:00
ui . frame ( 'Intro' ) ;
async . run (
ui . cinematic ( [
{ action : function ( ) { } , delay : 500 } ,
{ action : function ( ) { screen . show ( title ) ; } , delay : 1000 } ,
{ action : function ( ) { screen . show ( subtitle ) ; } , delay : null }
] , {
'B' : intro ,
'Start' : function ( ) { ui . frame ( 'StartMenu' ) ; ui . menu ( menus . start ) ; }
} )
) ;
2018-11-18 23:08:36 +01:00
}
function newGame ( ) {
2018-11-20 15:56:28 +01:00
ui . frame ( 'GameInit' ) ;
2018-11-18 23:08:36 +01:00
async . run (
2018-11-20 15:56:28 +01:00
ui . text ( "Bonjour ! Bienvenue dans le monde merveilleux des pokémons !" ) ,
ui . text ( "Pour certains, les pokemons sont des amis. Pour d'autres, ils sont une ressource. Pour ma part, hé bien l'étude des pokémons est ma passion et mon métier." ) ,
2018-11-18 23:08:36 +01:00
) ;
}
2018-11-17 19:07:58 +01:00
}