Skip to content

Instantly share code, notes, and snippets.

@MondayHopscotch
MondayHopscotch / ScrollingTextTestState.hx
Created March 6, 2025 21:01
TextScrollPlayground.hx
package states;
import flixel.FlxBasic;
import flixel.FlxG;
import flixel.graphics.frames.FlxBitmapFont;
import flixel.graphics.frames.FlxFrame;
import flixel.math.FlxMatrix;
import flixel.math.FlxPoint;
import flixel.math.FlxRect;
import flixel.text.FlxBitmapText;
import flixel.FlxG;
class PixelateShader extends flixel.system.FlxAssets.FlxShader
{
var debug = false;
var enabled = true;
@:glFragmentSource('
#pragma header
@MondayHopscotch
MondayHopscotch / gist:23e75a9bf91273ac9e61fe3a27a2bba5
Created February 8, 2023 21:19
HaxeFlixel HTML5 mobile haptics
var button = new FlxButton(X, Y);
#if js // access to JS packages
if (FlxG.onMobile) { // on mobile device
button.onDown.callback = () -> {
js.Browser.navigator.vibrate(5); // vibrate breifly to indicate button was pressed
};
}
#end
package states;
import flixel.util.FlxSpriteUtil;
import shaders.Outline;
import openfl.geom.Matrix;
import openfl.geom.Point;
import flixel.FlxCamera;
import flixel.util.FlxColor;
import flixel.FlxSprite;
import flixel.FlxG;
package cameras;
import flixel.FlxG;
import flixel.math.FlxPoint;
import flixel.FlxCamera;
class CameraUtils {
// getCenterPoint returns the world coordinate that the center of the given camera is located at
public static function getCenterPoint(cam:FlxCamera, ?p:FlxPoint):FlxPoint {
allCollisionAxes.sort((axis1, axis2) -> Float.compare(Math.abs(axis1.translationVector), Math.abs(axis2.translationVector)));
Vector relativeMovement = body1.speed.minus(body2.speed);
float dotProd;
for (Axis axis : allCollisionAxes) {
dotProd = relativeMovement.dot(axis);
if (dotProd != 0 && !sameSign(dotProd, axisOver.translationVector)) {
resolutionAxis = axis;
resolutionDistance = axis.translationVector;
return;
}
axes.sort((o1, o2) -> Float.compare(Math.abs(o1.overlap), Math.abs(o2.overlap)));
BitPoint relativeMovement = body.lastAttempt.minus(otherBody.lastAttempt);
float dotProd;
for (AxisOverlap axisOver : axes) {
dotProd = relativeMovement.dot(axisOver.axis);
if (dotProd != 0 && !sameSign(dotProd, axisOver.overlap)) {
axis = axisOver.axis;
distance = axisOver.overlap;
return;
}
Rectangle intersection = intersection(body1.rectangle, body2.rectangle);if (intersection != null) {
resolve();
}