add handloose
This commit is contained in:
1
projects/handloose/.gitignore
vendored
Normal file
1
projects/handloose/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export
|
5
projects/handloose/.vscode/extensions.json
vendored
Normal file
5
projects/handloose/.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"openfl.lime-vscode-extension"
|
||||
]
|
||||
}
|
21
projects/handloose/.vscode/launch.json
vendored
Normal file
21
projects/handloose/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Build + Debug",
|
||||
"type": "lime",
|
||||
"request": "launch"
|
||||
},
|
||||
{
|
||||
"name": "Debug",
|
||||
"type": "lime",
|
||||
"request": "launch",
|
||||
"preLaunchTask": null
|
||||
},
|
||||
{
|
||||
"name": "Macro",
|
||||
"type": "haxe-eval",
|
||||
"request": "launch"
|
||||
}
|
||||
]
|
||||
}
|
13
projects/handloose/.vscode/settings.json
vendored
Normal file
13
projects/handloose/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"search.exclude": {
|
||||
"export/**/*.hx": true
|
||||
},
|
||||
"[haxe]": {
|
||||
"editor.formatOnSave": true,
|
||||
"editor.formatOnPaste": true,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.sortImports": true
|
||||
}
|
||||
},
|
||||
"haxe.enableExtendedIndentation": true
|
||||
}
|
13
projects/handloose/.vscode/tasks.json
vendored
Normal file
13
projects/handloose/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "lime",
|
||||
"command": "test",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
82
projects/handloose/Project.xml
Normal file
82
projects/handloose/Project.xml
Normal file
@@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<!-- _________________________ Application Settings _________________________ -->
|
||||
|
||||
<app title="FlxProject" file="FlxProject" main="Main" version="0.0.1" company="HaxeFlixel" />
|
||||
|
||||
<!--The flixel preloader is not accurate in Chrome. You can use it regularly if you embed the swf into a html file
|
||||
or you can set the actual size of your file manually at "FlxPreloaderBase-onUpdate-bytesTotal"-->
|
||||
<app preloader="flixel.system.FlxPreloader" />
|
||||
|
||||
<!--Minimum without FLX_NO_GAMEPAD: 11.8, without FLX_NO_NATIVE_CURSOR: 11.2-->
|
||||
<set name="SWF_VERSION" value="11.8" />
|
||||
|
||||
<!-- ____________________________ Window Settings ___________________________ -->
|
||||
|
||||
<!--These window settings apply to all targets-->
|
||||
<window width="1280" height="720" fps="60" background="#000000" hardware="true" vsync="false" />
|
||||
|
||||
<!--HTML5-specific-->
|
||||
<window if="html5" resizable="false" />
|
||||
|
||||
<!--Desktop-specific-->
|
||||
<window if="desktop" orientation="landscape" fullscreen="false" resizable="true" />
|
||||
|
||||
<!--Mobile-specific-->
|
||||
<window if="mobile" orientation="landscape" fullscreen="true" width="0" height="0" />
|
||||
|
||||
<!-- _____________________________ Path Settings ____________________________ -->
|
||||
|
||||
<set name="BUILD_DIR" value="export" />
|
||||
<classpath name="source" />
|
||||
<assets path="assets" />
|
||||
|
||||
<!-- _______________________________ Libraries ______________________________ -->
|
||||
|
||||
<haxelib name="flixel" />
|
||||
|
||||
<!--In case you want to use the addons package-->
|
||||
<!--<haxelib name="flixel-addons" />-->
|
||||
|
||||
<!--In case you want to use the ui package-->
|
||||
<!--<haxelib name="flixel-ui" />-->
|
||||
|
||||
<!--In case you want to use nape with flixel-->
|
||||
<!--<haxelib name="nape-haxe4" />-->
|
||||
|
||||
<!-- ______________________________ Haxedefines _____________________________ -->
|
||||
|
||||
<!--Enable the Flixel core recording system-->
|
||||
<!--<haxedef name="FLX_RECORD" />-->
|
||||
|
||||
<!--Disable the right and middle mouse buttons-->
|
||||
<!--<haxedef name="FLX_NO_MOUSE_ADVANCED" />-->
|
||||
|
||||
<!--Disable the native cursor API on Flash-->
|
||||
<!--<haxedef name="FLX_NO_NATIVE_CURSOR" />-->
|
||||
|
||||
<!--Optimise inputs, be careful you will get null errors if you don't use conditionals in your game-->
|
||||
<haxedef name="FLX_NO_MOUSE" if="mobile" />
|
||||
<haxedef name="FLX_NO_KEYBOARD" if="mobile" />
|
||||
<haxedef name="FLX_NO_TOUCH" if="desktop" />
|
||||
<!--<haxedef name="FLX_NO_GAMEPAD" />-->
|
||||
|
||||
<!--Disable the Flixel core sound tray-->
|
||||
<!--<haxedef name="FLX_NO_SOUND_TRAY" />-->
|
||||
|
||||
<!--Disable the Flixel sound management code-->
|
||||
<!--<haxedef name="FLX_NO_SOUND_SYSTEM" />-->
|
||||
|
||||
<!--Disable the Flixel core focus lost screen-->
|
||||
<!--<haxedef name="FLX_NO_FOCUS_LOST_SCREEN" />-->
|
||||
|
||||
<!--Disable the Flixel core debugger. Automatically gets set whenever you compile in release mode!-->
|
||||
<haxedef name="FLX_NO_DEBUG" unless="debug" />
|
||||
|
||||
<!--Enable this for Nape release builds for a serious peformance improvement-->
|
||||
<haxedef name="NAPE_RELEASE_BUILD" unless="debug" />
|
||||
|
||||
<!-- _________________________________ Custom _______________________________ -->
|
||||
|
||||
<!--Place custom nodes like icons here (higher priority to override the HaxeFlixel icon)-->
|
||||
</project>
|
0
projects/handloose/assets/data/data-goes-here.txt
Normal file
0
projects/handloose/assets/data/data-goes-here.txt
Normal file
0
projects/handloose/assets/images/images-go-here.txt
Normal file
0
projects/handloose/assets/images/images-go-here.txt
Normal file
0
projects/handloose/assets/music/music-goes-here.txt
Normal file
0
projects/handloose/assets/music/music-goes-here.txt
Normal file
0
projects/handloose/assets/sounds/sounds-go-here.txt
Normal file
0
projects/handloose/assets/sounds/sounds-go-here.txt
Normal file
15
projects/handloose/hxformat.json
Normal file
15
projects/handloose/hxformat.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"lineEnds": {
|
||||
"leftCurly": "both",
|
||||
"rightCurly": "both",
|
||||
"objectLiteralCurly": {
|
||||
"leftCurly": "after"
|
||||
}
|
||||
},
|
||||
"sameLine": {
|
||||
"ifElse": "next",
|
||||
"doWhile": "next",
|
||||
"tryBody": "next",
|
||||
"tryCatch": "next"
|
||||
}
|
||||
}
|
4
projects/handloose/source/AssetPaths.hx
Normal file
4
projects/handloose/source/AssetPaths.hx
Normal file
@@ -0,0 +1,4 @@
|
||||
package;
|
||||
|
||||
@:build(flixel.system.FlxAssets.buildFileReferences("assets", true))
|
||||
class AssetPaths {}
|
13
projects/handloose/source/Main.hx
Normal file
13
projects/handloose/source/Main.hx
Normal file
@@ -0,0 +1,13 @@
|
||||
package;
|
||||
|
||||
import flixel.FlxGame;
|
||||
import openfl.display.Sprite;
|
||||
|
||||
class Main extends Sprite
|
||||
{
|
||||
public function new()
|
||||
{
|
||||
super();
|
||||
addChild(new FlxGame(0, 0, TypingState, 1, 60, 60, true));
|
||||
}
|
||||
}
|
172
projects/handloose/source/TypingState.hx
Normal file
172
projects/handloose/source/TypingState.hx
Normal file
@@ -0,0 +1,172 @@
|
||||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxState;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.input.gamepad.FlxGamepad;
|
||||
import flixel.text.FlxText;
|
||||
|
||||
using flixel.util.FlxSpriteUtil;
|
||||
|
||||
enum ButtonBehavior
|
||||
{
|
||||
Cycle(behaviors:Array<ButtonBehavior>);
|
||||
Tab;
|
||||
Control;
|
||||
Backspace;
|
||||
Shift;
|
||||
Space;
|
||||
Letter(char:String);
|
||||
}
|
||||
|
||||
// In DDR order:
|
||||
enum ArrowDir
|
||||
{
|
||||
Left;
|
||||
Down;
|
||||
Up;
|
||||
Right;
|
||||
}
|
||||
|
||||
class TypingState extends FlxState
|
||||
{
|
||||
var buttonIDs:Map<Int, String>;
|
||||
var buttonBehaviors:Map<String, ButtonBehavior>;
|
||||
|
||||
override public function create()
|
||||
{
|
||||
super.create();
|
||||
|
||||
// for now, hard-coded for the wii pad only
|
||||
buttonIDs = [
|
||||
16 => "-", 12 => "+", 7 => "B", 17 => "Up", 6 => "A", 19 => "Left", 20 => "Right", 9 => "Y", 18 => "Down", 8 => "X"
|
||||
];
|
||||
|
||||
buttonBehaviors = [
|
||||
"-" => Tab,
|
||||
"+" => Control,
|
||||
"B" => Cycle([
|
||||
Letter("m"), Letter("f"), Letter("w"), Letter("y"), Letter("p"), Letter("v"), Letter("b"), Letter("g"), Letter("k"), Letter("j"), Letter("q"),
|
||||
Letter("x"), Letter("z")]),
|
||||
"A" => Cycle([
|
||||
Letter("g"), Letter("k"), Letter("j"), Letter("q"), Letter("x"), Letter("z"), Letter("m"), Letter("f"), Letter("w"), Letter("y"), Letter("p"),
|
||||
Letter("v"), Letter("b")]),
|
||||
"Left" => Cycle([
|
||||
Letter("s"),
|
||||
Letter("h"),
|
||||
Letter("r"),
|
||||
Letter("d"),
|
||||
Letter("l"),
|
||||
Letter("u"),
|
||||
Letter("c"),
|
||||
]),
|
||||
"Up" => Cycle([Letter("e"), Letter("t"), Letter("a"), Letter("o"), Letter("i"), Letter("n")]),
|
||||
"Down" => Cycle([Letter("o"), Letter("i"), Letter("n"), Letter("e"), Letter("t"), Letter("a")]),
|
||||
"Y" => Backspace,
|
||||
"Right" => Shift,
|
||||
"X" => Space
|
||||
];
|
||||
|
||||
var background = new FlxSprite();
|
||||
background.makeGraphic(1280, 720, FlxColor.BLACK);
|
||||
// background.x = 0;
|
||||
// background.y = 0;
|
||||
|
||||
FlxSpriteUtil.beginDraw(FlxColor.WHITE);
|
||||
|
||||
var spacing = 20;
|
||||
var shapeSize = 100;
|
||||
var x = spacing;
|
||||
var y = 720 - shapeSize - spacing;
|
||||
|
||||
// Split the screen into text area and dance area:
|
||||
var splitX = 1280 / 2 + shapeSize;
|
||||
background.drawLine(splitX, 0, splitX, 720);
|
||||
// Split the left side into upper/lower:
|
||||
background.drawLine(0, 720 - shapeSize - spacing * 2, splitX, 720 - shapeSize - spacing * 2);
|
||||
|
||||
var bSprite = makeCircleSprite("B", x, y);
|
||||
x += shapeSize + spacing;
|
||||
var leftSprite = makeTriangleSprite(Left, "", x, y);
|
||||
x += shapeSize + spacing;
|
||||
var downSprite = makeTriangleSprite(Down, "", x, y);
|
||||
x += shapeSize + spacing;
|
||||
var upSprite = makeTriangleSprite(Up, "", x, y);
|
||||
x += shapeSize + spacing;
|
||||
var rightSprite = makeTriangleSprite(Right, "", x, y);
|
||||
x += shapeSize + spacing;
|
||||
var aSprite = makeCircleSprite("A", x, y);
|
||||
|
||||
add(background);
|
||||
add(bSprite);
|
||||
add(leftSprite);
|
||||
add(downSprite);
|
||||
add(upSprite);
|
||||
add(rightSprite);
|
||||
add(aSprite);
|
||||
}
|
||||
|
||||
function makeTriangleSprite(dir:ArrowDir, text:String, x:Int, y:Int):FlxSprite
|
||||
{
|
||||
var spr = new FlxSprite();
|
||||
spr.makeGraphic(100, 100, FlxColor.TRANSPARENT, true);
|
||||
FlxSpriteUtil.beginDraw(FlxColor.WHITE);
|
||||
spr.drawTriangle(0, 0, 100);
|
||||
|
||||
spr.angle = switch (dir)
|
||||
{
|
||||
case Left:
|
||||
-90;
|
||||
case Down:
|
||||
180;
|
||||
case Up:
|
||||
0;
|
||||
case Right:
|
||||
90;
|
||||
};
|
||||
var text = new FlxText(text, 24);
|
||||
text.angle = -spr.angle;
|
||||
text.color = FlxColor.BLACK;
|
||||
spr.stamp(text, 50 - Math.floor(text.width / 2), 50 - Math.floor(text.height / 2));
|
||||
|
||||
spr.x = x;
|
||||
spr.y = y;
|
||||
return spr;
|
||||
}
|
||||
|
||||
function makeCircleSprite(text:String, x:Int, y:Int):FlxSprite
|
||||
{
|
||||
var spr = new FlxSprite();
|
||||
spr.makeGraphic(100, 100, FlxColor.TRANSPARENT, true);
|
||||
FlxSpriteUtil.beginDraw(FlxColor.WHITE);
|
||||
spr.drawCircle();
|
||||
var text = new FlxText(text, 24);
|
||||
text.color = FlxColor.BLACK;
|
||||
spr.stamp(text, 50 - Math.floor(text.width / 2), 50 - Math.floor(text.height / 2));
|
||||
spr.x = x;
|
||||
spr.y = y;
|
||||
return spr;
|
||||
}
|
||||
|
||||
override public function update(elapsed:Float)
|
||||
{
|
||||
super.update(elapsed);
|
||||
|
||||
// Important: can be null if there's no active gamepad yet!
|
||||
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
|
||||
if (gamepad != null)
|
||||
{
|
||||
updateGamepadInput(gamepad);
|
||||
}
|
||||
}
|
||||
|
||||
function updateGamepadInput(gamepad:FlxGamepad):Void
|
||||
{
|
||||
var id = gamepad.firstJustPressedRawID();
|
||||
if (id != -1)
|
||||
{
|
||||
var whichButton = buttonIDs[id];
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user