File indexing completed on 2024-04-28 15:07:59

0001 /* GCompris - penalty.js
0002  *
0003  * SPDX-FileCopyrightText: 2014 Stephane Mankowski <stephane@mankowski.fr>
0004  *
0005  * Authors:
0006  *   Bruno Coudoin <bruno.coudoin@gcompris.net> (GTK+ version)
0007  *   Stephane Mankowski <stephane@mankowski.fr> (Qt Quick port)
0008  *
0009  *   SPDX-License-Identifier: GPL-3.0-or-later
0010  */
0011 .pragma library
0012 .import QtQuick 2.12 as Quick
0013 .import "qrc:/gcompris/src/core/core.js" as Core
0014 
0015 var numberOfLevel = 9
0016 var items
0017 
0018 var url = "qrc:/gcompris/src/activities/penalty/resource/"
0019 
0020 function start(items_) {
0021     items = items_
0022     items.currentLevel = Core.getInitialLevel(numberOfLevel)
0023     initLevel()
0024 }
0025 
0026 function stop() {
0027 }
0028 
0029 function initLevel() {
0030     if(items.currentLevel === 0) items.duration = 1000
0031     else if(items.currentLevel === 1) items.duration = 800
0032     else if(items.currentLevel === 2) items.duration = 700
0033     else if(items.currentLevel === 3) items.duration = 600
0034     else if(items.currentLevel === 4) items.duration = 500
0035     else if(items.currentLevel === 5) items.duration = 400
0036     else if(items.currentLevel === 6) items.duration = 350
0037     else if(items.currentLevel === 7) items.duration = 300
0038     else if(items.currentLevel === 8) items.duration = 250
0039 
0040     resetLevel()
0041 }
0042 
0043 function resetLevel() {
0044     items.ball.state = "INITIAL"
0045     items.saveBallState = "INITIAL"
0046     items.progressRight.ratio = 0
0047     items.progressLeft.ratio = 0
0048     items.progressTop.ratio = 0
0049 }
0050 
0051 function nextLevel() {
0052     items.currentLevel = Core.getNextLevel(items.currentLevel, numberOfLevel);
0053     initLevel();
0054 }
0055 
0056 function previousLevel() {
0057     items.currentLevel = Core.getPreviousLevel(items.currentLevel, numberOfLevel);
0058     initLevel();
0059 }