Platformer with Level Editor
import Felgo 3.0
import QtQuick 2.0
import "scenes"
import "common"
GameWindow {
id: gameWindow
activeScene: menuScene
screenWidth: 960
screenHeight: 640
property alias levelEditor: levelEditor
property alias itemEditor: gameScene.itemEditor
onActiveSceneChanged: {
audioManager.handleMusic()
}
LevelEditor {
id: levelEditor
Component.onCompleted: levelEditor.loadAllLevelsFromStorageLocation(authorGeneratedLevelsLocation)
toRemoveEntityTypes: [ "ground", "platform", "spikes", "opponent", "coin", "mushroom", "star", "finish" ]
toStoreEntityTypes: [ "ground", "platform", "spikes", "opponent", "coin", "mushroom", "star", "finish" ]
gameNetworkItem: gameNetwork
applicationJSONLevelsDirectory: "levels/"
onLevelPublished: {
gameScene.editorOverlay.saveLevel()
var leaderboard = levelId
if(leaderboard) {
gameNetwork.reportScore(100000, leaderboard, null, "lowest_is_best")
}
gameWindow.state = "level"
}
}
AudioManager {
id: audioManager
}
EntityManager {
id: entityManager
entityContainer: gameScene.container
poolingEnabled: true
}
FelgoGameNetwork {
id: gameNetwork
gameId: 220
secret: "platformerEditorDevPasswordForVPlayGameNetwork"
gameNetworkView: myGameNetworkView
}
FontLoader {
id: marioFont
source: "../assets/fonts/SuperMario256.ttf"
}
MenuScene {
id: menuScene
onLevelScenePressed: {
gameWindow.state = "level"
}
}
LevelScene {
id: levelScene
GameNetworkView {
id: myGameNetworkView
z: 1000
anchors.fill: parent.gameWindowAnchorItem
visible: false
onShowCalled: {
myGameNetworkView.visible = true
}
onBackClicked: {
myGameNetworkView.visible = false
}
}
onNewLevelPressed: {
var creationProperties = {
levelMetaData: {
levelName: "newLevel"
}
}
levelEditor.createNewLevel(creationProperties)
gameWindow.state = "game"
gameScene.state = "edit"
gameScene.initLevel()
}
onPlayLevelPressed: {
levelEditor.loadSingleLevel(levelData)
gameWindow.state = "game"
gameScene.state = "play"
gameScene.initLevel()
}
onEditLevelPressed: {
levelEditor.loadSingleLevel(levelData)
gameWindow.state = "game"
gameScene.state = "edit"
gameScene.initLevel()
}
onRemoveLevelPressed: {
levelEditor.loadSingleLevel(levelData)
levelEditor.removeCurrentLevel()
}
onBackPressed: {
gameWindow.state = "menu"
}
}
GameScene {
id: gameScene
onBackPressed: {
gameScene.resetLevel()
gameWindow.state = "level"
}
}
state: "menu"
states: [
State {
name: "menu"
PropertyChanges {target: menuScene; opacity: 1}
PropertyChanges {target: gameWindow; activeScene: menuScene}
},
State {
name: "level"
PropertyChanges {target: levelScene; opacity: 1}
PropertyChanges {target: gameWindow; activeScene: levelScene}
},
State {
name: "game"
PropertyChanges {target: gameScene; opacity: 1}
PropertyChanges {target: gameWindow; activeScene: gameScene}
}