Skip to content

Commit

Permalink
detect dev mode vs packaged app
Browse files Browse the repository at this point in the history
  • Loading branch information
pandoragabor committed May 8, 2017
1 parent f0fd8de commit 5f299fd
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 207 deletions.
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
<img src="https://raw.githubusercontent.com/uzudil/arkona/master/screenshots/screen1.png" width="320">
<img src="https://raw.githubusercontent.com/uzudil/arkona/master/screenshots/screen2.png" width="320">
<img src="https://raw.githubusercontent.com/uzudil/arkona/master/screenshots/screen3.png" width="320">
Arkona II is the open-world, desktop app version of <a href="https://github.com/uzudil/arkona">Arkona</a>.

Thanks to the https://github.com/lean/phaser-es6-webpack project!
# Releases

<i>distros to be posted soon</i>

# Developer

### To run the dev version:
- <a href="http://blog.npmjs.org/post/85484771375/how-to-install-npm">install npm</a>
- git clone https://github.com/uzudil/arkona2.git
- cd arkona2
- npm install
- npm run dev

### To make a release:
- you might have to install additional software to be able to build for platforms other than what you're using. See https://github.com/electron-userland/electron-builder/wiki/Multi-Platform-Build
- npm run dist
- releases are created in the ./dist/ folder

# Artist
- characters/some models: https://www.blender.org/
- everything else: https://inkscape.org/en/

### Tech links:
- http://phaser.io/
- https://github.com/lean/phaser-es6-webpack
- https://electron.atom.io
- https://github.com/electron-userland/electron-builder

(c) 2017 uzudil
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"name": "arkona2",
"version": "1.0.0",
"version": "0.1.0",
"description": "retro isometric rpg",
"author": "Gabor Torok <[email protected]>",
"repository": "https://github.com/uzudil/arkona2",
"main": "start.js",
"scripts": {
"dev": "webpack",
"deploy": "webpack --config webpack.production.config.js",
"test": "standard",
"pack": "build -mwl --dir",
"dist": "build -mwl"
Expand Down
3 changes: 2 additions & 1 deletion src/config/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export const START_X = 347
export const START_Y = 1176
export const PLAYER_CREATURE_NAME = "man"
export const GODMODE = false
export const DEBUG_MODE = true
let args = window.require("electron").remote.process.argv
export const DEBUG_MODE = args && args.length > 0 && args[0].indexOf("node_modules") >= 0

export const NO_BLEND = 0
export const BLENDS = 1
Expand Down
256 changes: 129 additions & 127 deletions src/states/Splash.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,135 +8,137 @@ import Transition from "../ui/Transition"
import Arkona from "./Arkona"
import ConvoEditor from "../editor/ConvoEditor"

const MENU_OPTIONS = Config.DEBUG_MODE ? ["New Game", "Load Game", "Options", "Game Editor", "Convo Editor", "Mapper"] : ["New Game", "Load Game", "Options"]

export default class extends Phaser.State {
init() {
}

preload() {
this.loaderBg = this.add.sprite(this.game.world.centerX, this.game.world.centerY, "loaderBg")
this.loaderBar = this.add.sprite(this.game.world.centerX, this.game.world.centerY, "loaderBar")
centerGameObjects([this.loaderBg, this.loaderBar])

this.load.setPreloadSprite(this.loaderBar)
//
// load your assets
//
this.atlas()
this.atlas(2)
this.atlas(3)
this.atlas(4)
this.atlas(5)

this.load.image("logo", "./assets/images/logo.png")
this.load.image("back", "./assets/images/back.png")
this.load.image("device", "./assets/images/device.png")

for(let k in Creatures.CREATURES) {
let c = Creatures.CREATURES[k]
this.game.load.spritesheet(k, c.src + "?cb=" + Date.now(), ...c.dim)
}
for(let k in Vehicles.VEHICLES) {
let c = Vehicles.VEHICLES[k]
this.game.load.spritesheet(k, c.src + "?cb=" + Date.now(), ...c.dim)
}
}

atlas(n) {
if(n == null) {
this.load.atlas("sprites", "assets/images/arkona.png?cb=" + Date.now(), null, Config.toJson(), Phaser.Loader.TEXTURE_ATLAS_JSON_HASH);
} else {
this.load.atlas("sprites" + n, "assets/images/arkona" + n + ".png?cb=" + Date.now(), null, Config.toJson(n), Phaser.Loader.TEXTURE_ATLAS_JSON_HASH);
}
}

create() {
$("#close-options").click(()=>{
$(".dialog").hide()
window.location.reload()
});
$("#use-webgl").click(()=>{
let o = loadSettings()
o["use_webgl"] = $("#use-webgl").is(":checked")
saveSettings(o)
});

this.loaderBg.kill()
this.loaderBar.kill()
this.game.stage.backgroundColor = "#000000";


this.back = this.add.image(512, 400, "back")
this.back.anchor.setTo(0.5, 0.5)

this.logo = this.add.image(750, 100, "logo")
this.logo.anchor.setTo(0.5, 0)

var style = {font: "bold 20px " + Config.FONT_FAMILY, fill: "#888"};
this.menu = []
let y = 230
for(let s of ["Game Editor", "New Game", "Load Game", "Options", "Convo Editor", "Mapper"]) {
let m = this.game.add.text(750, y, s, style)
m.anchor.setTo(0.5, 0.5)
this.menu.push(m)
y += 35
}
style = {font: "bold 11px " + Config.FONT_FAMILY, fill: "#555"};
this.copyright = this.game.add.text(this.game.world.centerX, 720, "MMXVII \u00A9 Gabor Torok", style);
this.copyright.anchor.setTo(0.5, 0.5)

this.menuIndex = 0
this.updateMenu()

this.cursors = this.game.input.keyboard.createCursorKeys()
this.space = this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR)

this.transition = new Transition()
}

updateMenu() {
var style = {font: "bold 20px " + Config.FONT_FAMILY, fill: "#888"};
var activeStyle = {font: "bold 22px " + Config.FONT_FAMILY, fill: "#6ac"};
for(let i = 0; i < this.menu.length; i++) {
this.menu[i].setStyle(i == this.menuIndex ? activeStyle : style)
}
}

update() {
let oldMenu = this.menuIndex
if (this.cursors.up.justDown) {
this.menuIndex--
} else if (this.cursors.down.justDown) {
this.menuIndex++
}
if (this.menuIndex >= this.menu.length) this.menuIndex = 0
else if (this.menuIndex < 0) this.menuIndex = this.menu.length - 1
if (oldMenu != this.menuIndex) this.updateMenu()

if(this.space.justDown) {
if(this.menuIndex == 0) {
$("#right-menu").show()
this.state.start("Editor")
} else if(this.menuIndex == 1) {
// new game
if(!Arkona.doesSaveGameExist() || confirm("Delete saved game?")) {
this.transition.fadeIn(() => {
this.state.start("Intro")
})
}
} else if(this.menuIndex == 2) {
// load game
this.transition.fadeIn(() => {
this.state.start("Arkona", true, false, { loadGame: true })
})
} else if(this.menuIndex == 3) {
let o = loadSettings()
$("#use-webgl").attr("checked", o["use_webgl"])
$("#options").show();
init() {
}

preload() {
this.loaderBg = this.add.sprite(this.game.world.centerX, this.game.world.centerY, "loaderBg")
this.loaderBar = this.add.sprite(this.game.world.centerX, this.game.world.centerY, "loaderBar")
centerGameObjects([this.loaderBg, this.loaderBar])

this.load.setPreloadSprite(this.loaderBar)
//
// load your assets
//
this.atlas()
this.atlas(2)
this.atlas(3)
this.atlas(4)
this.atlas(5)

this.load.image("logo", "./assets/images/logo.png")
this.load.image("back", "./assets/images/back.png")
this.load.image("device", "./assets/images/device.png")

for(let k in Creatures.CREATURES) {
let c = Creatures.CREATURES[k]
this.game.load.spritesheet(k, c.src + "?cb=" + Date.now(), ...c.dim)
}
for(let k in Vehicles.VEHICLES) {
let c = Vehicles.VEHICLES[k]
this.game.load.spritesheet(k, c.src + "?cb=" + Date.now(), ...c.dim)
}
}

atlas(n) {
if(n == null) {
this.load.atlas("sprites", "assets/images/arkona.png?cb=" + Date.now(), null, Config.toJson(), Phaser.Loader.TEXTURE_ATLAS_JSON_HASH);
} else {
this.load.atlas("sprites" + n, "assets/images/arkona" + n + ".png?cb=" + Date.now(), null, Config.toJson(n), Phaser.Loader.TEXTURE_ATLAS_JSON_HASH);
}
}

create() {
$("#close-options").click(()=>{
$(".dialog").hide()
window.location.reload()
});
$("#use-webgl").click(()=>{
let o = loadSettings()
o["use_webgl"] = $("#use-webgl").is(":checked")
saveSettings(o)
});

this.loaderBg.kill()
this.loaderBar.kill()
this.game.stage.backgroundColor = "#000000";


this.back = this.add.image(512, 400, "back")
this.back.anchor.setTo(0.5, 0.5)

this.logo = this.add.image(750, 100, "logo")
this.logo.anchor.setTo(0.5, 0)

var style = {font: "bold 20px " + Config.FONT_FAMILY, fill: "#888"};
this.menu = []
let y = 230
for(let s of MENU_OPTIONS) {
let m = this.game.add.text(750, y, s, style)
m.anchor.setTo(0.5, 0.5)
this.menu.push(m)
y += 35
}
style = {font: "bold 11px " + Config.FONT_FAMILY, fill: "#555"};
this.copyright = this.game.add.text(this.game.world.centerX, 720, "MMXVII \u00A9 Gabor Torok", style);
this.copyright.anchor.setTo(0.5, 0.5)

this.menuIndex = 0
this.updateMenu()

this.cursors = this.game.input.keyboard.createCursorKeys()
this.space = this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR)

this.transition = new Transition()
}

updateMenu() {
var style = {font: "bold 20px " + Config.FONT_FAMILY, fill: "#888"};
var activeStyle = {font: "bold 22px " + Config.FONT_FAMILY, fill: "#6ac"};
for(let i = 0; i < this.menu.length; i++) {
this.menu[i].setStyle(i == this.menuIndex ? activeStyle : style)
}
}

update() {
let oldMenu = this.menuIndex
if (this.cursors.up.justDown) {
this.menuIndex--
} else if (this.cursors.down.justDown) {
this.menuIndex++
}
if (this.menuIndex >= this.menu.length) this.menuIndex = 0
else if (this.menuIndex < 0) this.menuIndex = this.menu.length - 1
if (oldMenu != this.menuIndex) this.updateMenu()

if(this.space.justDown) {
if(this.menuIndex == 0) {
// new game
if(!Arkona.doesSaveGameExist() || confirm("Delete saved game?")) {
this.transition.fadeIn(() => {
this.state.start("Intro")
})
}
} else if(this.menuIndex == 1) {
// load game
this.transition.fadeIn(() => {
this.state.start("Arkona", true, false, { loadGame: true })
})
} else if(this.menuIndex == 2) {
let o = loadSettings()
$("#use-webgl").attr("checked", o["use_webgl"])
$("#options").show();
} else if(this.menuIndex == 3) {
$("#right-menu").show()
this.state.start("Editor")
} else if(this.menuIndex == 4) {
new ConvoEditor();
new ConvoEditor();
} else if(this.menuIndex == 5) {
this.state.start("Mapper")
}
}
}
}
}
}
}
73 changes: 0 additions & 73 deletions webpack.production.config.js

This file was deleted.

0 comments on commit 5f299fd

Please sign in to comment.