Skip to content

Commit

Permalink
TEST MODE AND SYSTOOLS
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesisfeline committed Dec 14, 2023
1 parent e541305 commit a06fa73
Show file tree
Hide file tree
Showing 8 changed files with 596 additions and 13 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Build Game
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ main, experimental ]
branches: [main, experimental]
pull_request:
branches: [ main, experimental ]
branches: [main, experimental]

# For release builds
workflow_call:
Expand Down Expand Up @@ -41,10 +41,13 @@ jobs:
sudo apt-get install libvlccore-dev
haxelib setup ~/haxelib
haxelib install hxcpp > /dev/null --quiet
haxelib git systools https://github.com/haya3218/retools
haxelib install format > nul
haxe -cp ./setup -D analyzer-optimize -main Main --interp
- name: Skip SScript setup mode
run: echo 'oy9:showMacroty8:loopCosti25y10:includeAllfg' >> ~/settings.cocoa
- name: Rebuild systools
run: lime rebuild systools linux
- name: Create Version Tag
run: echo "${{github.run_id}}" > VERSION
- name: Compile
Expand All @@ -53,7 +56,7 @@ jobs:
uses: actions/[email protected]
with:
name: linuxBuild
path: 'export/release/linux/bin'
path: "export/release/linux/bin"
buildWindows:
runs-on: windows-latest

Expand All @@ -69,12 +72,15 @@ jobs:
run: |
haxelib setup C:/haxelib
haxelib install hxcpp > /dev/null --quiet
haxelib git systools https://github.com/haya3218/retools
haxelib install format > nul
haxe -cp ./setup -D analyzer-optimize -main Main --interp
shell: cmd
- name: Skip SScript setup mode
run: echo 'oy9:showMacroty8:loopCosti25y10:includeAllfg' >> %USERPROFILE%/settings.cocoa
shell: cmd
- name: Rebuild systools
run: lime rebuild systools windows
- name: Create Version Tag
run: echo "${{github.run_id}}" > VERSION
- name: Compile
Expand All @@ -99,10 +105,13 @@ jobs:
run: |
haxelib setup ~/haxelib
haxelib install hxcpp > /dev/null --quiet
haxelib git systools https://github.com/haya3218/retools
haxelib install format > nul
haxe -cp ./setup -D analyzer-optimize -main Main --interp
- name: Skip SScript setup mode
run: echo 'oy9:showMacroty8:loopCosti25y10:includeAllfg' >> ~/settings.cocoa
- name: Rebuild systools
run: lime rebuild systools mac
- name: Create Version Tag
run: echo "${{github.run_id}}" > VERSION
- name: Compile
Expand Down
21 changes: 15 additions & 6 deletions Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<project>
<!-- _________________________ Application Settings _________________________ -->

<app title="Friday Night Funkin': Vs. Foxa" file="VsFoxa" packageName="com.shadowmario.psychengine" package="com.shadowmario.psychengine" main="Main" version="0.2.8" company="ShadowMario" />
<app title="Friday Night Funkin': Vs. Foxa" packageName="com.shadowmario.psychengine" package="com.shadowmario.psychengine" main="Main" version="0.2.8" company="ShadowMario" />

<app file="VsFoxa" unless="STORY_EDITION" />
<app file="VsFoxaStoryEdition" if="STORY_EDITION" />

<!--<define name="STORY_EDITION" />-->

<!-- NOTE TO SELF: DISABLE THIS IF ISSUES ARE FOUND, theres no issues :) -->
<haxedef name="LINC_LUA_RELATIVE_DYNAMIC_LIB"/> <!-- stable lua -->
Expand Down Expand Up @@ -34,6 +39,10 @@
<!--Desktop-specific-->
<window if="desktop" orientation="landscape" fullscreen="false" resizable="true" vsync="false"/>

<!--macOS-->
<window if="mac" orientation="auto" fullscreen="false" resizable="true" vsync="false"
allow-high-dpi="true" />

<!--Mobile-specific-->
<window if="mobile" orientation="landscape" fullscreen="true" width="0" height="0" resizable="false"/>

Expand Down Expand Up @@ -90,16 +99,15 @@
<!-- Enables a terminal log prompt on debug builds -->
<haxelib name="hxcpp-debug-server" if="debug"/>
<haxedef name="HXC_LIBVLC_LOGGING" if="VIDEOS_ALLOWED debug" />

<haxelib name="systools" />
<ndll name="systools" haxelib="systools" />

<!-- ______________________________ Haxedefines _____________________________ -->

<!--Enable the Flixel core recording system-->
<haxedef name="FLX_RECORD" if="debug"/>

<!-- <haxedef name="FLX_NO_MOUSE" if="mobile" /> -->
<!-- <haxedef name="FLX_NO_KEYBOARD" if="mobile" /> -->
<!-- <haxedef name="FLX_NO_TOUCH" if="desktop" /> -->

<!--Disable the Flixel core focus lost screen-->
<haxedef name="FLX_NO_FOCUS_LOST_SCREEN" />

Expand All @@ -109,7 +117,7 @@
<!--Disable the Flixel core debugger. Automatically gets set whenever you compile in release mode!-->
<haxedef name="FLX_NO_DEBUG" unless="debug" />

<haxedef name="HXCPP_GC_BIG_BLOCKS" if="cpp debug" /> <!-- mmmm memory -->
<haxedef name="HXCPP_GC_BIG_BLOCKS" if="debug" /> <!-- mmmm memory (for debug only) -->

<!--Enable this for Nape release builds for a serious peformance improvement-->
<haxedef name="NAPE_RELEASE_BUILD" unless="debug" />
Expand All @@ -118,6 +126,7 @@
<haxedef name="HXCPP_CHECK_POINTER" if="CRASH_HANDLER" />
<haxedef name="HXCPP_STACK_LINE" if="CRASH_HANDLER" />
<haxedef name="HXCPP_STACK_TRACE" if="CRASH_HANDLER" />
<haxedef name="HXCPP_DEBUG_LINK" if="CRASH_HANDLER" />
<haxedef name='no-deprecation-warnings' unless="debug" />

<!--Macro fixes-->
Expand Down
156 changes: 156 additions & 0 deletions source/extraflixel/FlxSprite3D.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
package extraflixel;

import flixel.math.FlxPoint;
import flixel.math.FlxAngle;
import math.VectorHelpers;
import math.Vector3;
import flixel.graphics.frames.FlxFrame.FlxFrameType;
import openfl.Vector;
import openfl.geom.ColorTransform;
import openfl.display.Shader;
import flixel.system.FlxAssets.FlxShader;

class FlxSprite3D extends FlxSprite {
public var z:Float = 0;

public var yaw:Float = 0;
public var pitch:Float = 0;
@:isVar
public var roll(get, set):Float = 0;

function get_roll() return angle;

function set_roll(val:Float) return angle = val;

override public function draw():Void
{
checkEmptyFrame();

if(alpha == 0 || _frame.type == FlxFrameType.EMPTY) return;

if(dirty) // rarely
calcFrame(useFramePixels);

// TODO: take origin into consideration properly
var wid = frameWidth;
var hei = frameHeight;

var halfW = wid * 0.5;
var halfH = hei * 0.5;

var camPos = new Vector3(0, 0, 1280);
var camOrigin = new Vector3(FlxG.width / 2, FlxG.height / 2); // vertex origin

// TODO: take origin into account properly without this bandaid fix vv

var bandaidOrigin = FlxPoint.weak();
bandaidOrigin.set(origin.x - halfW, origin.y - halfH);
for (camera in cameras)
{
if(!camera.visible || !camera.exists || camera.canvas == null || camera.canvas.graphics == null)
continue;

var quad = [
new Vector3(-halfW, -halfH, 0),
new Vector3(halfW, -halfH, 0),
new Vector3(-halfW, halfH, 0),
new Vector3(halfW, halfH, 0)
];

getScreenPosition(_point, camera).subtractPoint(offset);
//_point.add(bandaidOrigin.x, bandaidOrigin.y);
var pos = new Vector3(_point.x, _point.y, z);

for (idx => vert in quad)
{
if(flipX) vert.x *= -1;
if(flipY) vert.y *= -1;
vert.x -= bandaidOrigin.x;
vert.y -= bandaidOrigin.y;
vert.x *= scale.x;
vert.y *= scale.y;

var vert = VectorHelpers.rotateV3(vert, FlxAngle.TO_RAD * pitch, FlxAngle.TO_RAD * yaw, FlxAngle.TO_RAD * roll);
var originMod = vert.add(pos).subtract(camOrigin);
var projected = VectorHelpers.project(originMod.subtract(camPos));
vert = projected.subtract(pos).add(camOrigin); // puts the vertex back to default pos

vert.x += bandaidOrigin.x;
vert.y += bandaidOrigin.y;

quad[idx] = vert;

}
var frameRect = frame.frame;
var sourceBitmap = graphic.bitmap;

var leftUV = frameRect.left / sourceBitmap.width;
var rightUV = frameRect.right / sourceBitmap.width;
var topUV = frameRect.top / sourceBitmap.height;
var bottomUV = frameRect.bottom / sourceBitmap.height;

// order should be LT, RT, RB, LT, LB, RB
// R is right L is left T is top B is bottom
// order matters! so LT is left, top because they're represented as x, y
var vertices = new Vector<Float>(12, false, [
quad[0].x, quad[0].y,
quad[1].x, quad[1].y,
quad[3].x, quad[3].y,

quad[0].x, quad[0].y,
quad[2].x, quad[2].y,
quad[3].x, quad[3].y
]);

var uvData = new Vector<Float>(12, false, [
leftUV, topUV,
rightUV, topUV,
rightUV, bottomUV,

leftUV, topUV,
leftUV, bottomUV,
rightUV, bottomUV,
]);

var shader = this.shader != null ? this.shader : new FlxShader();
if (this.shader != shader)
this.shader = shader;

shader.bitmap.input = graphic.bitmap;
shader.bitmap.filter = antialiasing ? LINEAR : NEAREST;


var transforms:Array<ColorTransform> = [];
var transfarm:ColorTransform = new ColorTransform();
transfarm.redMultiplier = colorTransform.redMultiplier;
transfarm.greenMultiplier = colorTransform.greenMultiplier;
transfarm.blueMultiplier = colorTransform.blueMultiplier;
transfarm.redOffset = colorTransform.redOffset;
transfarm.greenOffset = colorTransform.greenOffset;
transfarm.blueOffset = colorTransform.blueOffset;
transfarm.alphaOffset = colorTransform.alphaOffset;
transfarm.alphaMultiplier = colorTransform.alphaMultiplier * camera.alpha;

for (n in 0...Std.int(vertices.length / 3)) transforms.push(transfarm);


var indices = new Vector<Int>(vertices.length, false, cast [for (i in 0...vertices.length) i]);
var drawItem = camera.startTrianglesBatch(graphic, antialiasing, true, null, true, shader);

@:privateAccess
{
drawItem.addTrianglesColorArray(vertices, indices, uvData, null, _point, camera._bounds, transforms);
}

#if FLX_DEBUG
FlxBasic.visibleCount++;
#end
}
bandaidOrigin.putWeak();


#if FLX_DEBUG
if(FlxG.debugger.drawDebug) drawDebug();
#end
}
}
Loading

0 comments on commit a06fa73

Please sign in to comment.