@ -45,17 +45,24 @@ function tutoCreateLayer() {
initEnd ( ) ;
initEnd ( ) ;
}
}
function resetAllTabs ( ) {
function resetAllTabs ( save ) {
switchs = [ ] , lineCount = [ ] , logiques = [ ] , lines = [ ] , endLines = [ ] , end , switchsInfo = [ ] , switchsInfoCopy = [ ] , lineRemove = [ ] ;
if ( ! save ) {
width = window . innerWidth - window . innerWidth / 100 * 10 ;
logiques = [ ] ;
height = window . innerHeight / 1.5 ;
timeEnd = 5 ;
numberPerColonne = [ ] ;
liveColonneNumber = [ ] ;
timeEnd = 5 ;
switchsInfoCopy = [ ] ;
numberOfSwitch = 0 ;
colonneTot = 0 ;
}
numberOfSwitch = 0 ;
switchs = [ ] , lineCount = [ ] , lines = [ ] , endLines = [ ] , end , switchsInfo = [ ] , lineRemove = [ ] ;
colonneTot = 0 ;
width = ( window . innerWidth - window . innerWidth / 100 * 10 ) ;
numberPerColonne = [ ] ;
height = window . innerHeight / 1.5 ;
liveColonneNumber = [ ] ;
layer . destroyChildren ( ) ;
layer . destroyChildren ( ) ;
}
}
@ -180,9 +187,9 @@ function createGameOne(niveau) {
logiqueCount ++ ;
logiqueCount ++ ;
let type = null ;
let type = null ;
let x = 1 ;
let x = 1 ;
if ( isOuAllowed ) x ++ ;
if ( isOuAllowed ) x ++ ;
if ( isEtNonAllowed ) x ++ ;
if ( isEtNonAllowed ) x ++ ;
if ( isOuNonAllowed ) x ++ ;
if ( isOuNonAllowed ) x ++ ;
let numberRandom = getRandomArbitrary ( 0 , x ) ;
let numberRandom = getRandomArbitrary ( 0 , x ) ;
switch ( numberRandom ) {
switch ( numberRandom ) {
case 0 :
case 0 :
@ -220,20 +227,72 @@ function createGameOne(niveau) {
}
}
window . addEventListener ( 'resize' , changeCanvas ) ;
window . addEventListener ( 'resize' , changeStage ) ;
window . addEventListener ( 'resize' , changeStage ) ;
var rtime ;
var timeout = false ;
function changeCanvas ( ) {
rtime = new Date ( ) ;
if ( timeout === false ) {
timeout = true ;
setTimeout ( resizeend , 200 ) ;
}
}
function saveStage ( ) {
resetAllTabs ( true ) ;
stage = new Konva . Stage ( {
container : 'play_container' ,
width : width ,
height : height ,
} ) ;
stage . add ( layer ) ;
logique2 = logiques ;
logiques = [ ] ;
var logiqueCount = 0 ;
for ( let i = 0 ; i < colonneTot ; i ++ ) {
liveColonneNumber [ i ] = [ ] ;
}
for ( let i = 0 ; i < colonneTot ; i ++ ) {
for ( let j = 0 ; j < numberPerColonne [ i ] ; j ++ ) {
insertLogiqueColonne ( "logique" + logiqueCount , logique2 [ logiqueCount ] . type , i ) ;
logiqueCount ++ ;
}
}
logiques . forEach ( function ( element ) {
createLinkAuto ( element . name ) ;
} ) ;
calculNombreSwitch ( ) ;
switchCreator ( numberOfSwitch ) ;
createAllLinkSwitch ( ) ;
initAllSwitch ( ) ;
createEnd ( ) ;
initEnd ( ) ;
checkAllSortieLogique ( ) ;
}
function resizeend ( ) {
if ( new Date ( ) - rtime < 200 ) {
setTimeout ( resizeend , 200 ) ;
} else {
timeout = false ;
saveStage ( ) ;
}
}
function changeStage ( ) {
function changeStage ( ) {
if ( window . innerWidth <= 900 ) {
if ( window . innerWidth <= 900 ) {
console . log ( "mobile" ) ;
if ( ! mobile ) {
if ( ! mobile ) {
console . log ( "mobile" ) ;
stage . rotate ( 90 ) ;
stage . rotate ( 90 ) ;
stage . x ( stage . getX ( ) + stage . height ( ) ) ;
stage . x ( stage . getX ( ) + stage . height ( ) ) ;
mobile = true ;
mobile = true ;
}
}
} else {
} else {
stage . scaleX ( window . innerWidth / windowWidth ) ;
stage . scaleX ( window . innerWidth / windowWidth ) ;
console . log ( document . querySelector ( "#play_container" ) . offsetHeight ) ;
stage . scaleY ( window . innerHeight / windowHeight ) ;
stage . scaleY ( window . innerHeight / windowHeight ) ;
}
}