Skip to content

Commit

Permalink
you can actually move assets to the export folder now yay
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Jan 7, 2025
1 parent ae1ccf7 commit 07d88b7
Show file tree
Hide file tree
Showing 27 changed files with 71 additions and 31 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ jobs:
with:
haxe-version: 4.3.6

- name: Compiling Ndlls
run: |
haxelib git flixel-raylib https://github.com/Vortex2Oblivion/flixel-raylib
haxelib install lime
haxelib run lime rebuild ndlls/memory windows
- name: Compile Test Project
run: |
haxelib git flixel-raylib https://github.com/Vortex2Oblivion/flixel-raylib
cd test
haxe build.hxml
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ test/bin/*
.vscode/
.zed/

ndlls/*/bin
ndlls/*/obj

!test/bin/images/
!test/bin/sound/
ndlls/*/bin/*/*.hash
ndlls/*/obj
Binary file added assets/fonts/nokiafc22.ttf
Binary file not shown.
File renamed without changes
Binary file added assets/images/logo16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion extraParams.hxml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
--macro raylib.macros.GlobalMetadata.run()
--define no_console
--macro flixel.system.macros.FlxAssetsMacro.run()
--define no_console
--define message.reporting=pretty
Binary file added ndlls/memory/bin/Windows/memory.ndll
Binary file not shown.
Binary file added ndlls/memory/bin/Windows64/memory.ndll
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@
</section>


<copyFile name="memory.ndll" from="${haxelib:flixel-raylib}/ndlls/memory/bin/Windows64" toolId="exe" />
<copyFile name="memory.ndll" from="${haxelib:flixel-raylib}/ndlls/memory/bin/Windows64" overwrite="true" />
</xml>
1 change: 0 additions & 1 deletion src/flixel/FlxG.hx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class FlxG {
cameras.reset();
sound.destroy(true);
state?.destroy();
state = null;
state = nextState;
nextState.create();
}
Expand Down
10 changes: 6 additions & 4 deletions src/flixel/FlxSprite.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package flixel;

import sys.FileSystem;
import raylib.TextureFilter;
import raylib.Color;
import raylib.Colors;
Expand All @@ -21,16 +22,17 @@ class FlxSprite extends FlxObject {

public var antialiasingLevel(default, set):TextureFilter = TEXTURE_FILTER_BILINEAR;

public static var defaultGraphic:String = "assets/images/logo16.png";

public function new(x:Float = 0, y:Float = 0, ?graphic:String) {
super(x, y);
if (graphic != null) {
loadGraphic(graphic);
}
loadGraphic(defaultGraphic);
}


public inline overload extern function loadGraphic(graphic:String):FlxSprite {
unloadTexture(texture);
texture = loadTexture(graphic);
texture = loadTexture(FileSystem.exists(graphic) ? graphic : defaultGraphic);
return this;
}

Expand Down
45 changes: 45 additions & 0 deletions src/flixel/system/macros/FlxAssetsMacro.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package flixel.system.macros;

import haxe.macro.Expr;
import sys.io.File;
import sys.io.Process;
import sys.FileSystem;
import haxe.macro.Compiler;
import haxe.macro.Context;

class FlxAssetsMacro {
public static macro function run():Expr {
var process:Process = new Process('haxelib libpath flixel-raylib');
var libPath:String = process.stdout.readLine();
var assetsPath:String = Context.definedValue('assetsPath');
var outputFolder:String = '${Compiler.getOutput()}/$assetsPath/';
process.close();

moveFiles('$libPath/assets', outputFolder);
moveFiles(assetsPath, outputFolder);

return macro a;
}

public static function moveFiles(start:String, destination:String) {
if (!FileSystem.exists(start)) {
trace('Source directory does not exist');
return;
}

if (!FileSystem.exists(destination)) {
FileSystem.createDirectory(destination);
}

for (file in FileSystem.readDirectory(start)) {
var filePath:String = '$start/$file';
var destPath:String = '$destination/$file';

if (FileSystem.isDirectory(filePath)) {
moveFiles(filePath, destPath);
} else {
File.copy(filePath, destPath);
}
}
}
}
3 changes: 2 additions & 1 deletion src/flixel/text/FlxText.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package flixel.text;

import sys.FileSystem;
import raylib.TextureFilter;
import flixel.FlxSprite;
import raylib.Font;
Expand All @@ -21,7 +22,7 @@ class FlxText extends FlxSprite {
this.text = text;
this.size = size;
this.letterSpacing = 1;
this._font = getFontDefault();
this._font = FileSystem.exists("assets/fonts/nokiafc22.ttf") ? loadFont("assets/fonts/nokiafc22.ttf") : getFontDefault();
}

override public function destroy() {
Expand Down
Binary file added test/assets/images/maurice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/assets/images/scythe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/assets/images/skateboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed test/bin/images/maurice.png
Binary file not shown.
Binary file removed test/bin/images/scythe.png
Binary file not shown.
Binary file removed test/bin/images/skateboard.png
Binary file not shown.
9 changes: 6 additions & 3 deletions test/build.hxml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
-cp src
-D analyzer-optimize
-main Main
--class-path src
--main Main

--define assetsPath=assets

--cpp bin

--library flixel-raylib
--cmd cd bin
--cmd main.exe
2 changes: 1 addition & 1 deletion test/src/OtherState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class OtherState extends FlxState {
override public function create() {
super.create();
maurice = new FlxSprite();
maurice.loadGraphic("images/maurice.png");
maurice.loadGraphic("assets/images/maurice.png");
maurice.screenCenter();
maurice.antialiasing = true;
add(maurice);
Expand Down
5 changes: 2 additions & 3 deletions test/src/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import flixel.math.FlxMath;
import flixel.FlxG;
import flixel.FlxState;
import flixel.FlxSprite;
import raylib.RayMath;
import raylib.Raylib;

class PlayState extends FlxState {
Expand All @@ -16,13 +15,13 @@ class PlayState extends FlxState {
super.create();

skateboard = new FlxSprite();
skateboard.loadGraphic("images/skateboard.png");
skateboard.loadGraphic("assets/images/skateboard.png");
skateboard.velocity.x = 15;
skateboard.antialiasing = true;
add(skateboard);

scythe = new FlxSprite();
scythe.loadGraphic("images/scythe.png");
scythe.loadGraphic("assets/images/scythe.png");
scythe.width *= 0.25;
scythe.height *= 0.25;
scythe.antialiasing = true;
Expand Down
2 changes: 1 addition & 1 deletion test/src/SoundState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SoundState extends FlxState {
override public function create() {
super.create();
sound = FlxG.sound.list.add(new FlxSound());
sound.loadEmbedded("sound/BICYCLE KICK - CYBERVORTEX PHIGHTING OST - aidn.wav");
sound.loadEmbedded("assets/sounds/BICYCLE KICK - CYBERVORTEX PHIGHTING OST - aidn.wav");
sound.play();
}

Expand Down
6 changes: 1 addition & 5 deletions test/src/TextState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ class TextState extends FlxState {

text = new FlxText(0, 0, "This is FlxText!", 32);
text.screenCenter();
text.antialiasing = true;
add(text);
}

override public function update(elapsed:Float) {
super.update(elapsed);
text.size = Math.sin(Raylib.getTime()) * 10 + 32;

if(Raylib.isKeyPressed(KEY_SPACE)) {
text.antialiasingLevel = TEXTURE_FILTER_ANISOTROPIC_16X;
}
text.screenCenter();
}
}

0 comments on commit 07d88b7

Please sign in to comment.