android port
|
|
@ -1,8 +1,10 @@
|
|||
-cp src
|
||||
-lib heaps
|
||||
-lib hlsdl
|
||||
-lib zyheaps
|
||||
-hl marblegame.hl
|
||||
-D windowSize=1280x720
|
||||
-D keep-inline-positions
|
||||
-D android
|
||||
--main Main
|
||||
-debug
|
||||
BIN
data/icon.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
data/icons/icon-128.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
data/icons/icon-144.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
data/icons/icon-180.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
data/icons/icon-192.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
data/icons/icon-256.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
data/icons/icon-32.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
data/icons/icon-48.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
data/icons/icon-512.png
Normal file
|
After Width: | Height: | Size: 224 KiB |
BIN
data/icons/icon-64.png
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
BIN
data/icons/icon-96.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
68
data/manifest.json
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"name": "Marble Blast Gold Haxe Port",
|
||||
"short_name": "Marble Blast Gold",
|
||||
"description": "A reimplementation of Marble Blast Gold in Haxe",
|
||||
"dir": "ltr",
|
||||
"start_url": "/index.html?app=true",
|
||||
"scope": "/",
|
||||
"display": "fullscreen",
|
||||
"orientation": "landscape",
|
||||
"background_color": "black",
|
||||
"theme_color": "black",
|
||||
"categories": [
|
||||
"games"
|
||||
],
|
||||
"lang": "en-US",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/data/icons/icon-512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
},
|
||||
{
|
||||
"src": "/data/icons/icon-256.png",
|
||||
"type": "image/png",
|
||||
"sizes": "256x256"
|
||||
},
|
||||
{
|
||||
"src": "/data/icons/icon-192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "/data/icons/icon-180.png",
|
||||
"type": "image/png",
|
||||
"sizes": "180x180"
|
||||
},
|
||||
{
|
||||
"src": "/data/icons/icon-144.png",
|
||||
"type": "image/png",
|
||||
"sizes": "144x144"
|
||||
},
|
||||
{
|
||||
"src": "/data/icons/icon-128.png",
|
||||
"type": "image/png",
|
||||
"sizes": "128x128"
|
||||
},
|
||||
{
|
||||
"src": "/data/icons/icon-96.png",
|
||||
"type": "image/png",
|
||||
"sizes": "96x96"
|
||||
},
|
||||
{
|
||||
"src": "/data/icons/icon-64.png",
|
||||
"type": "image/png",
|
||||
"sizes": "64x64"
|
||||
},
|
||||
{
|
||||
"src": "/data/icons/icon-48.png",
|
||||
"type": "image/png",
|
||||
"sizes": "48x48"
|
||||
},
|
||||
{
|
||||
"src": "/data/icons/icon-32.png",
|
||||
"type": "image/png",
|
||||
"sizes": "32x32"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -4,6 +4,9 @@
|
|||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Marble Blast Gold Haxe Port</title>
|
||||
<link rel="shortcut icon" href="./data/icon.png" id="favicon">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="manifest" href="/data/manifest.json">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ class DifBuilder {
|
|||
tex = tex.split('/')[1];
|
||||
}
|
||||
|
||||
#if js
|
||||
#if (js || android)
|
||||
path = StringTools.replace(path, "data/", "");
|
||||
#end
|
||||
|
||||
|
|
|
|||
56
src/Main.hx
|
|
@ -1,5 +1,6 @@
|
|||
package;
|
||||
|
||||
import hxd.Key;
|
||||
import src.Util;
|
||||
import src.ResourceLoader;
|
||||
#if js
|
||||
|
|
@ -23,41 +24,76 @@ class Main extends hxd.App {
|
|||
var debugProfiler:h3d.impl.Benchmark;
|
||||
var loaded:Bool = false;
|
||||
|
||||
var keyCounter:Text;
|
||||
|
||||
override function init() {
|
||||
super.init();
|
||||
|
||||
#if hl
|
||||
#if (hl && !android)
|
||||
hl.UI.closeConsole();
|
||||
#end
|
||||
#if js
|
||||
var zoomRatio = Util.isTouchDevice() ? js.Browser.window.screen.height * js.Browser.window.devicePixelRatio / 600 : js.Browser.window.devicePixelRatio; // js.Browser.window.devicePixelRatio;
|
||||
s2d.scaleMode = Zoom(zoomRatio);
|
||||
#end
|
||||
|
||||
#if android
|
||||
Window.getInstance().addEventTarget(ev -> {
|
||||
if (ev.kind == EPush || ev.kind == ERelease || ev.kind == EMove) {
|
||||
@:privateAccess s2d.window.curMouseX = cast ev.relX;
|
||||
@:privateAccess s2d.window.curMouseY = cast ev.relY;
|
||||
ev.propagate = true;
|
||||
}
|
||||
|
||||
if (ev.kind == EPush) {
|
||||
@:privateAccess Key.keyPressed[Key.MOUSE_LEFT] = Key.getFrame();
|
||||
}
|
||||
|
||||
if (ev.kind == ERelease) {
|
||||
@:privateAccess Key.keyPressed[Key.MOUSE_LEFT] = -Key.getFrame();
|
||||
}
|
||||
});
|
||||
#end
|
||||
|
||||
ResourceLoader.init(s2d, () -> {
|
||||
Settings.init();
|
||||
AudioManager.init();
|
||||
AudioManager.playShell();
|
||||
marbleGame = new MarbleGame(s2d, s3d);
|
||||
MarbleGame.canvas.setContent(new MainMenuGui());
|
||||
// world = new MarbleWorld(s3d, s2d, mission);
|
||||
|
||||
// world.init();
|
||||
// world.start();
|
||||
// debugProfiler = new h3d.impl.Benchmark(s2d);
|
||||
// debugProfiler.y = 40;
|
||||
|
||||
// fpsCounter = new Text(DefaultFont.get(), s2d);
|
||||
// fpsCounter.y = 40;
|
||||
// fpsCounter.color = new Vector(1, 1, 1, 1);
|
||||
keyCounter = new Text(DefaultFont.get(), s2d);
|
||||
keyCounter.color = new Vector(1, 1, 1, 1);
|
||||
|
||||
loaded = true;
|
||||
});
|
||||
|
||||
// ResourceLoader.init(s2d, () -> {
|
||||
// Settings.init();
|
||||
// AudioManager.init();
|
||||
// AudioManager.playShell();
|
||||
// marbleGame = new MarbleGame(s2d, s3d);
|
||||
// MarbleGame.canvas.setContent(new MainMenuGui());
|
||||
// // world = new MarbleWorld(s3d, s2d, mission);
|
||||
|
||||
// // world.init();
|
||||
// // world.start();
|
||||
// // debugProfiler = new h3d.impl.Benchmark(s2d);
|
||||
// // debugProfiler.y = 40;
|
||||
|
||||
// // fpsCounter = new Text(DefaultFont.get(), s2d);
|
||||
// // fpsCounter.y = 40;
|
||||
// // fpsCounter.color = new Vector(1, 1, 1, 1);
|
||||
|
||||
// loaded = true;
|
||||
// });
|
||||
}
|
||||
|
||||
override function update(dt:Float) {
|
||||
super.update(dt);
|
||||
if (loaded) {
|
||||
marbleGame.update(dt);
|
||||
keyCounter.text = 'Mouse: ${Window.getInstance().mouseX} ${Window.getInstance().mouseY}';
|
||||
// world.update(dt);
|
||||
// fpsCounter.text = 'FPS: ${this.engine.fps}';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class Mission {
|
|||
var path = StringTools.replace(rawElementPath.substring(rawElementPath.indexOf('data/')), "\"", "");
|
||||
if (StringTools.contains(path, 'interiors_mbg/'))
|
||||
path = StringTools.replace(path, 'interiors_mbg/', 'interiors/');
|
||||
#if js
|
||||
#if (js || android)
|
||||
path = StringTools.replace(path, "data/", "");
|
||||
#end
|
||||
if (ResourceLoader.fileSystem.exists(path))
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ class MissionList {
|
|||
if (_build)
|
||||
return;
|
||||
function parseDifficulty(difficulty:String) {
|
||||
#if hl
|
||||
#if (hl && !android)
|
||||
var difficultyFiles = ResourceLoader.fileSystem.dir("data/missions/" + difficulty);
|
||||
#end
|
||||
#if js
|
||||
#if (js || android)
|
||||
var difficultyFiles = ResourceLoader.fileSystem.dir("missions/" + difficulty);
|
||||
#end
|
||||
var difficultyMissions = [];
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package src;
|
||||
|
||||
#if js
|
||||
#if (js || android)
|
||||
import fs.ManifestLoader;
|
||||
import fs.ManifestBuilder;
|
||||
import fs.ManifestProgress;
|
||||
|
|
@ -18,16 +18,16 @@ import hxd.res.Loader;
|
|||
import src.Resource;
|
||||
|
||||
class ResourceLoader {
|
||||
#if hl
|
||||
#if (hl && !android)
|
||||
public static var fileSystem:FileSystem = new LocalFileSystem(".", null);
|
||||
#end
|
||||
#if js
|
||||
#if (js || android)
|
||||
public static var fileSystem:FileSystem = null;
|
||||
#end
|
||||
#if hl
|
||||
#if (hl && !android)
|
||||
public static var loader = new Loader(fileSystem);
|
||||
#end
|
||||
#if js
|
||||
#if (js || android)
|
||||
public static var loader:Loader = null;
|
||||
#end
|
||||
static var interiorResources:Map<String, Resource<Dif>> = new Map();
|
||||
|
|
@ -39,7 +39,7 @@ class ResourceLoader {
|
|||
// static var threadPool:FixedThreadPool = new FixedThreadPool(4);
|
||||
|
||||
public static function init(scene2d:h2d.Scene, onLoadedFunc:Void->Void) {
|
||||
#if js
|
||||
#if (js || android)
|
||||
var mfileSystem = ManifestBuilder.create("data");
|
||||
var mloader = new ManifestLoader(mfileSystem);
|
||||
|
||||
|
|
@ -50,13 +50,13 @@ class ResourceLoader {
|
|||
}, scene2d);
|
||||
preloader.start();
|
||||
#end
|
||||
#if hl
|
||||
#if (hl && !android)
|
||||
onLoadedFunc();
|
||||
#end
|
||||
}
|
||||
|
||||
public static function loadInterior(path:String) {
|
||||
#if js
|
||||
#if (js || android)
|
||||
path = StringTools.replace(path, "data/", "");
|
||||
#end
|
||||
if (interiorResources.exists(path))
|
||||
|
|
@ -76,7 +76,7 @@ class ResourceLoader {
|
|||
}
|
||||
|
||||
public static function loadDts(path:String) {
|
||||
#if js
|
||||
#if (js || android)
|
||||
path = StringTools.replace(path, "data/", "");
|
||||
#end
|
||||
if (dtsResources.exists(path))
|
||||
|
|
@ -96,7 +96,7 @@ class ResourceLoader {
|
|||
}
|
||||
|
||||
public static function getTexture(path:String) {
|
||||
#if js
|
||||
#if (js || android)
|
||||
path = StringTools.replace(path, "data/", "");
|
||||
#end
|
||||
if (textureCache.exists(path))
|
||||
|
|
@ -118,7 +118,7 @@ class ResourceLoader {
|
|||
}
|
||||
|
||||
public static function getImage(path:String) {
|
||||
#if js
|
||||
#if (js || android)
|
||||
path = StringTools.replace(path, "data/", "");
|
||||
#end
|
||||
if (imageCache.exists(path))
|
||||
|
|
@ -133,7 +133,7 @@ class ResourceLoader {
|
|||
}
|
||||
|
||||
public static function getAudio(path:String) {
|
||||
#if js
|
||||
#if (js || android)
|
||||
path = StringTools.replace(path, "data/", "");
|
||||
#end
|
||||
if (audioCache.exists(path))
|
||||
|
|
@ -160,7 +160,7 @@ class ResourceLoader {
|
|||
}
|
||||
|
||||
public static function getFileEntry(path:String) {
|
||||
#if js
|
||||
#if (js || android)
|
||||
path = StringTools.replace(path, "data/", "");
|
||||
#end
|
||||
var file = loader.load(path);
|
||||
|
|
@ -176,7 +176,7 @@ class ResourceLoader {
|
|||
}
|
||||
|
||||
public static function getFullNamesOf(path:String) {
|
||||
#if js
|
||||
#if (js || android)
|
||||
path = StringTools.replace(path, "data/", "");
|
||||
#end
|
||||
var files = fileSystem.dir(Path.directory(path)); // FileSystem.readDirectory(Path.directory(path));
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ class Settings {
|
|||
outputData.highScores = jobj;
|
||||
#end
|
||||
var json = Json.stringify(outputData);
|
||||
#if hl
|
||||
#if (hl && !android)
|
||||
File.saveContent("settings.json", json);
|
||||
#end
|
||||
#if js
|
||||
|
|
|
|||
|
|
@ -332,13 +332,22 @@ class Util {
|
|||
#if hl
|
||||
switch (Settings.isTouch) {
|
||||
case None:
|
||||
#if android
|
||||
Settings.isTouch = Some(true);
|
||||
return true;
|
||||
#else
|
||||
Settings.isTouch = Some(false);
|
||||
return false;
|
||||
#end
|
||||
case Some(val):
|
||||
return val;
|
||||
}
|
||||
#if android
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#end
|
||||
#end
|
||||
}
|
||||
|
||||
public static function isSafari() {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ import haxe.io.Encoding;
|
|||
import haxe.io.Path;
|
||||
import haxe.io.Bytes;
|
||||
|
||||
#if android
|
||||
// import zygame.utils.hl.AssetsTools;
|
||||
#end
|
||||
@:allow(fs.ManifestFileSystem)
|
||||
class ManifestEntry extends FileEntry {
|
||||
private var fs:ManifestFileSystem;
|
||||
|
|
@ -38,7 +41,7 @@ class ManifestEntry extends FileEntry {
|
|||
|
||||
private var file:String;
|
||||
private var originalFile:String;
|
||||
#if sys
|
||||
#if (sys && !android)
|
||||
private var fio:sys.io.FileInput;
|
||||
#else
|
||||
private var bytes:Bytes;
|
||||
|
|
@ -59,7 +62,7 @@ class ManifestEntry extends FileEntry {
|
|||
}
|
||||
|
||||
override public function getSign():Int {
|
||||
#if sys
|
||||
#if (sys && !android)
|
||||
var old = if (fio == null) -1 else fio.tell();
|
||||
open();
|
||||
var i = fio.readInt32();
|
||||
|
|
@ -74,14 +77,20 @@ class ManifestEntry extends FileEntry {
|
|||
}
|
||||
|
||||
override public function getBytes():Bytes {
|
||||
#if sys
|
||||
#if (sys && !android)
|
||||
return sys.io.File.getBytes(file);
|
||||
#elseif android
|
||||
bytes = sys.io.File.getBytes(file); // AssetsTools.getBytes(file);
|
||||
return bytes;
|
||||
#else
|
||||
return bytes;
|
||||
#end
|
||||
}
|
||||
|
||||
override function readBytes(out:haxe.io.Bytes, outPos:Int, pos:Int, len:Int):Int {
|
||||
if (this.bytes == null) {
|
||||
this.bytes = getBytes();
|
||||
}
|
||||
if (pos + len > bytes.length)
|
||||
len = bytes.length - pos;
|
||||
if (len < 0)
|
||||
|
|
@ -132,7 +141,8 @@ class ManifestEntry extends FileEntry {
|
|||
}
|
||||
#else
|
||||
if (onReady != null)
|
||||
haxe.Timer.delay(onReady, 1);
|
||||
onReady();
|
||||
// haxe.Timer.delay(onReady, 1);
|
||||
#end
|
||||
}
|
||||
|
||||
|
|
@ -198,8 +208,11 @@ class ManifestEntry extends FileEntry {
|
|||
}
|
||||
|
||||
override private function get_size():Int {
|
||||
#if sys
|
||||
#if (sys && !android)
|
||||
return sys.FileSystem.stat(file).size;
|
||||
#elseif android
|
||||
var fb = sys.io.File.getBytes(file); // AssetsTools.getBytes(file);
|
||||
return fb != null ? fb.length : 0;
|
||||
#else
|
||||
return bytes != null ? bytes.length : 0;
|
||||
#end
|
||||
|
|
@ -211,7 +224,7 @@ class ManifestEntry extends FileEntry {
|
|||
c.dispose();
|
||||
contents = null;
|
||||
}
|
||||
#if sys
|
||||
#if (sys && !android)
|
||||
close();
|
||||
#else
|
||||
bytes = null;
|
||||
|
|
|
|||
16
zyheaps.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<project>
|
||||
<meta title="Marble Blast Gold" package="com.marble.blast" version="1.0.0" company="RandomityGuy" />
|
||||
<!-- Main app -->
|
||||
<app main="Main" path="Export" file="MBHaxe"/>
|
||||
<!-- Assets -->
|
||||
<assets path="data" rename="data" />
|
||||
<!-- Haxelib -->
|
||||
<haxelib name="zyheaps" />
|
||||
<haxelib name="heaps" />
|
||||
<!-- Sources -->
|
||||
<source name="src" />
|
||||
<!-- Android Config -->
|
||||
<define name="NDK_DIR" value="E:/Android/ndk/18.1.5063045" />
|
||||
<define name="ANDROID_SDK_DIR" value="E:/Android" />
|
||||
<define name="NDK_VERSION" value="18.1.5063045" />
|
||||
</project>
|
||||