From 35938b5257e3dad065396f7d38b32fe83c347df6 Mon Sep 17 00:00:00 2001 From: Joalor64 Date: Thu, 25 Jul 2024 10:09:41 -0400 Subject: [PATCH] formatting --- Project.xml | 2 +- source/backend/Input.hx | 109 ++++++++++--------- source/backend/Localization.hx | 192 ++++++++++++++++----------------- source/game/GameSprite.hx | 8 +- source/game/Note.hx | 32 +++--- source/game/Rating.hx | 31 +++--- source/states/InitialState.hx | 62 +++++------ source/states/MenuState.hx | 88 +++++++-------- source/states/OptionsState.hx | 61 +++++------ source/states/PlayState.hx | 38 +++---- 10 files changed, 297 insertions(+), 326 deletions(-) diff --git a/Project.xml b/Project.xml index 03475db..2ade409 100644 --- a/Project.xml +++ b/Project.xml @@ -3,7 +3,7 @@ - + diff --git a/source/backend/Input.hx b/source/backend/Input.hx index 8a8a0db..057e8a0 100644 --- a/source/backend/Input.hx +++ b/source/backend/Input.hx @@ -3,64 +3,63 @@ package backend; import flixel.input.FlxInput.FlxInputState; class Input { - public static var actionMap:Map = [ - "left" => SaveData.settings.keyboardBinds[0], - "down" => SaveData.settings.keyboardBinds[1], - "up" => SaveData.settings.keyboardBinds[2], - "right" => SaveData.settings.keyboardBinds[3], - "accept" => SaveData.settings.keyboardBinds[4], - "exit" => SaveData.settings.keyboardBinds[5] - ]; + public static var actionMap:Map = [ + "left" => SaveData.settings.keyboardBinds[0], + "down" => SaveData.settings.keyboardBinds[1], + "up" => SaveData.settings.keyboardBinds[2], + "right" => SaveData.settings.keyboardBinds[3], + "accept" => SaveData.settings.keyboardBinds[4], + "exit" => SaveData.settings.keyboardBinds[5] + ]; - public static function is(action:String, ?state:FlxInputState = JUST_PRESSED, ?exact:Bool = false):Bool { - if (!exact) { - if (state == PRESSED && is(action, JUST_PRESSED)) - return true; - if (state == RELEASED && is(action, JUST_RELEASED)) - return true; - } - - return (actionMap.exists(action)) ? FlxG.keys.checkStatus(actionMap.get(action), state) - : FlxG.keys.checkStatus(FlxKey.fromString(action), state); - } + public static function is(action:String, ?state:FlxInputState = JUST_PRESSED, ?exact:Bool = false):Bool { + if (!exact) { + if (state == PRESSED && is(action, JUST_PRESSED)) + return true; + if (state == RELEASED && is(action, JUST_RELEASED)) + return true; + } - public static function get(action:String):FlxInputState { - var gamepad:FlxGamepad = FlxG.gamepads.lastActive; - - if (gamepad != null) { - if (gamepadIs(action, JUST_PRESSED)) - return JUST_PRESSED; - if (gamepadIs(action, PRESSED)) - return PRESSED; - if (gamepadIs(action, JUST_RELEASED)) - return JUST_RELEASED; - } else { - if (is(action, JUST_PRESSED)) - return JUST_PRESSED; - if (is(action, PRESSED)) - return PRESSED; - if (is(action, JUST_RELEASED)) - return JUST_RELEASED; - } - - return RELEASED; - } + return (actionMap.exists(action)) ? FlxG.keys.checkStatus(actionMap.get(action), state) : FlxG.keys.checkStatus(FlxKey.fromString(action), state); + } - public static var controllerMap:Map = [ - "gamepad_left" => SaveData.settings.gamepadBinds[0], - "gamepad_down" => SaveData.settings.gamepadBinds[1], - "gamepad_up" => SaveData.settings.gamepadBinds[2], - "gamepad_right" => SaveData.settings.gamepadBinds[3], - "gamepad_accept" => SaveData.settings.gamepadBinds[4], - "gamepad_exit" => SaveData.settings.gamepadBinds[5] - ]; + public static function get(action:String):FlxInputState { + var gamepad:FlxGamepad = FlxG.gamepads.lastActive; - public static function gamepadIs(key:String, ?state:FlxInputState = JUST_PRESSED):Bool { - var gamepad:FlxGamepad = FlxG.gamepads.lastActive; - if (gamepad != null) - return (controllerMap.exists(key)) ? gamepad.checkStatus(controllerMap.get(key), state) - : gamepad.checkStatus(FlxGamepadInputID.fromString(key), state); + if (gamepad != null) { + if (gamepadIs(action, JUST_PRESSED)) + return JUST_PRESSED; + if (gamepadIs(action, PRESSED)) + return PRESSED; + if (gamepadIs(action, JUST_RELEASED)) + return JUST_RELEASED; + } else { + if (is(action, JUST_PRESSED)) + return JUST_PRESSED; + if (is(action, PRESSED)) + return PRESSED; + if (is(action, JUST_RELEASED)) + return JUST_RELEASED; + } - return false; - } + return RELEASED; + } + + public static var controllerMap:Map = [ + "gamepad_left" => SaveData.settings.gamepadBinds[0], + "gamepad_down" => SaveData.settings.gamepadBinds[1], + "gamepad_up" => SaveData.settings.gamepadBinds[2], + "gamepad_right" => SaveData.settings.gamepadBinds[3], + "gamepad_accept" => SaveData.settings.gamepadBinds[4], + "gamepad_exit" => SaveData.settings.gamepadBinds[5] + ]; + + public static function gamepadIs(key:String, ?state:FlxInputState = JUST_PRESSED):Bool { + var gamepad:FlxGamepad = FlxG.gamepads.lastActive; + if (gamepad != null) + return (controllerMap.exists(key)) ? gamepad.checkStatus(controllerMap.get(key), + state) : gamepad.checkStatus(FlxGamepadInputID.fromString(key), state); + + return false; + } } \ No newline at end of file diff --git a/source/backend/Localization.hx b/source/backend/Localization.hx index 8011583..b93a3c3 100644 --- a/source/backend/Localization.hx +++ b/source/backend/Localization.hx @@ -5,9 +5,9 @@ import openfl.system.Capabilities; #end typedef ApplicationConfig = { - var languages:Array; - @:optional var directory:String; - @:optional var default_language:String; + var languages:Array; + @:optional var directory:String; + @:optional var default_language:String; } /** @@ -15,101 +15,93 @@ typedef ApplicationConfig = { * Please credit me if you use it! * @author Joalor64GH */ - -class Localization -{ - private static final DEFAULT_DIR:String = "languages"; - - private static var data:Map; - private static var currentLanguage:String; - - public static var DEFAULT_LANGUAGE:String = "en"; - public static var directory:String = DEFAULT_DIR; - - public static var systemLanguage(get, never):String; - - public static function get_systemLanguage() - { - #if openfl - return Capabilities.language; - #else - return throw "This Variable is for OpenFl only!"; - #end - } - - public static function init(config:ApplicationConfig) - { - directory = config.directory ?? "languages"; - DEFAULT_LANGUAGE = config.default_language ?? "en"; - - loadLanguages(config.languages); - switchLanguage(DEFAULT_LANGUAGE); - } - - public static function loadLanguages(languages:Array) - { - data = new Map(); - - for (language in languages) { - var languageData:Dynamic = loadLanguageData(language); - data.set(language, languageData); - } - } - - private static function loadLanguageData(language:String):Dynamic - { - var jsonContent:String; - - try { - #if sys - jsonContent = File.getContent(path(language)); - #else - jsonContent = Assets.getText(path(language)); - #end - } catch (e) { - trace('file not found: $e'); - #if sys - jsonContent = File.getContent(path(DEFAULT_LANGUAGE)); - #else - jsonContent = Assets.getText(path(DEFAULT_LANGUAGE)); - #end - } - - return Json.parse(jsonContent); - } - - public static function switchLanguage(newLanguage:String) - { - if (newLanguage == currentLanguage) - return; - - var languageData:Dynamic = loadLanguageData(newLanguage); - - currentLanguage = newLanguage; - data.set(newLanguage, languageData); - trace('Language changed to $currentLanguage'); - } - - public static function get(key:String, ?language:String):String - { - var targetLanguage:String = language ?? currentLanguage; - var languageData = data.get(targetLanguage); - - if (data == null) { - trace("You haven't initialized the class!"); - return null; - } - - if (data.exists(targetLanguage)) - if (Reflect.hasField(languageData, key)) - return Reflect.field(languageData, key); - - return null; - } - - private static function path(language:String) { - var localDir = Path.join([directory, language + ".json"]); - var path:String = Paths.file(localDir); - return path; - } +class Localization { + private static final DEFAULT_DIR:String = "languages"; + + private static var data:Map; + private static var currentLanguage:String; + + public static var DEFAULT_LANGUAGE:String = "en"; + public static var directory:String = DEFAULT_DIR; + + public static var systemLanguage(get, never):String; + + public static function get_systemLanguage() { + #if openfl + return Capabilities.language; + #else + return throw "This Variable is for OpenFl only!"; + #end + } + + public static function init(config:ApplicationConfig) { + directory = config.directory ?? "languages"; + DEFAULT_LANGUAGE = config.default_language ?? "en"; + + loadLanguages(config.languages); + switchLanguage(DEFAULT_LANGUAGE); + } + + public static function loadLanguages(languages:Array) { + data = new Map(); + + for (language in languages) { + var languageData:Dynamic = loadLanguageData(language); + data.set(language, languageData); + } + } + + private static function loadLanguageData(language:String):Dynamic { + var jsonContent:String; + + try { + #if sys + jsonContent = File.getContent(path(language)); + #else + jsonContent = Assets.getText(path(language)); + #end + } catch (e) { + trace('file not found: $e'); + #if sys + jsonContent = File.getContent(path(DEFAULT_LANGUAGE)); + #else + jsonContent = Assets.getText(path(DEFAULT_LANGUAGE)); + #end + } + + return Json.parse(jsonContent); + } + + public static function switchLanguage(newLanguage:String) { + if (newLanguage == currentLanguage) + return; + + var languageData:Dynamic = loadLanguageData(newLanguage); + + currentLanguage = newLanguage; + data.set(newLanguage, languageData); + trace('Language changed to $currentLanguage'); + } + + public static function get(key:String, ?language:String):String { + var targetLanguage:String = language ?? currentLanguage; + var languageData = data.get(targetLanguage); + + if (data == null) { + trace("You haven't initialized the class!"); + return null; + } + + if (data.exists(targetLanguage)) + if (Reflect.hasField(languageData, key)) + return Reflect.field(languageData, key); + + return null; + } + + private static function path(language:String) { + var localDir = Path.join([directory, language + ".json"]); + var path:String = Paths.file(localDir); + return path; + } } \ No newline at end of file diff --git a/source/game/GameSprite.hx b/source/game/GameSprite.hx index 8de3f0d..e54003b 100644 --- a/source/game/GameSprite.hx +++ b/source/game/GameSprite.hx @@ -1,8 +1,8 @@ package game; class GameSprite extends FlxSprite { - public function new(x:Float = 0, y:Float = 0) { - super(x, y); - antialiasing = SaveData.settings.antialiasing; - } + public function new(x:Float = 0, y:Float = 0) { + super(x, y); + antialiasing = SaveData.settings.antialiasing; + } } \ No newline at end of file diff --git a/source/game/Note.hx b/source/game/Note.hx index 8d4672b..996b92f 100644 --- a/source/game/Note.hx +++ b/source/game/Note.hx @@ -1,26 +1,26 @@ package game; class Note extends GameSprite { - public var dir:String = ''; // note direction - public var type:String = ''; // receptor or plain note + public var dir:String = ''; // note direction + public var type:String = ''; // receptor or plain note - public function new(x:Float, y:Float, dir:String, type:String) { - super(x, y); + public function new(x:Float, y:Float, dir:String, type:String) { + super(x, y); - this.dir = dir; - this.type = type; + this.dir = dir; + this.type = type; - loadGraphic(Paths.image('ui/note_$dir'), true, 200, 200); - scale.set(0.6, 0.6); + loadGraphic(Paths.image('ui/note_$dir'), true, 200, 200); + scale.set(0.6, 0.6); - animation.add("note", [0], 1); - animation.add("press", [1], 1); - animation.add("receptor", [2], 1); + animation.add("note", [0], 1); + animation.add("press", [1], 1); + animation.add("receptor", [2], 1); - animation.play((type == 'receptor') ? "receptor" : "note"); - } + animation.play((type == 'receptor') ? "receptor" : "note"); + } - public function press() { - animation.play("press"); - } + public function press() { + animation.play("press"); + } } \ No newline at end of file diff --git a/source/game/Rating.hx b/source/game/Rating.hx index 7288749..ceb4841 100644 --- a/source/game/Rating.hx +++ b/source/game/Rating.hx @@ -1,24 +1,25 @@ package backend; typedef RatingData = { - var name:String; - var score:Int; - var hitWindow:Int; + var name:String; + var score:Int; + var hitWindow:Int; } class Rating extends GameSprite { - public var name:String = ''; - public var score:Int = 350; - public var hitWindow:Null = 0; + public var name:String = ''; + public var score:Int = 350; + public var hitWindow:Null = 0; - public function new(x:Float, y:Float, rating:RatingData) { - super(x, y); + public function new(x:Float, y:Float, rating:RatingData) { + super(x, y); - this.name = rating.name; - this.score = rating.score; - this.hitWindow = rating.hitWindow; - if (hitWindow == null) hitWindow = 0; + this.name = rating.name; + this.score = rating.score; + this.hitWindow = rating.hitWindow; + if (hitWindow == null) + hitWindow = 0; - loadGraphic(Paths.image('ui/$name')); - } -} \ No newline at end of file + loadGraphic(Paths.image('ui/$name')); + } +} diff --git a/source/states/InitialState.hx b/source/states/InitialState.hx index 6f50527..40ca303 100644 --- a/source/states/InitialState.hx +++ b/source/states/InitialState.hx @@ -1,14 +1,14 @@ package states; class InitialState extends FlxState { - var intro:FlxSprite; - var logo:FlxSprite; - var bg:FlxSprite; + var intro:FlxSprite; + var logo:FlxSprite; + var bg:FlxSprite; - override function create() { - super.create(); + override function create() { + super.create(); - SaveData.init(); + SaveData.init(); Localization.init({ languages: ['en', 'es'], directory: "languages", @@ -17,36 +17,36 @@ class InitialState extends FlxState { trace('current platform: ${PlatformUtil.getPlatform()}'); - intro = new FlxSprite().loadGraphic(Paths.image('title/credist')); - intro.alpha = 0; - add(intro); + intro = new FlxSprite().loadGraphic(Paths.image('title/credist')); + intro.alpha = 0; + add(intro); - bg = new FlxSprite().loadGraphic(Paths.image('title/title_bg')); - bg.alpha = 0; - add(bg); + bg = new FlxSprite().loadGraphic(Paths.image('title/title_bg')); + bg.alpha = 0; + add(bg); - logo = new FlxSprite(0, 0).loadGraphic(Paths.image('title/logo')); - logo.scale.set(0.4, 0.4); - logo.alpha = 0; - add(logo); + logo = new FlxSprite(0, 0).loadGraphic(Paths.image('title/logo')); + logo.scale.set(0.4, 0.4); + logo.screenCenter(); + logo.alpha = 0; + add(logo); - FlxTween.tween(intro, {alpha: 1}, 1, {ease: FlxEase.quadOut}); - } + FlxTween.tween(intro, {alpha: 1}, 1, {ease: FlxEase.quadOut}); + } - override function update(elapsed:Float) { + override function update(elapsed:Float) { super.update(elapsed); - // i know this code looks bad, but it works - new FlxTimer().start(3, (tmr:FlxTimer) -> { - FlxTween.tween(intro, {alpha: 0}, 0.5, {ease: FlxEase.quadOut}); - FlxTween.tween(bg, {alpha: 1}, 0.5, {ease: FlxEase.quadOut}); - FlxTween.tween(logo, {alpha: 1}, 0.5, {ease: FlxEase.quadOut}); - new FlxTimer().start(4.5, (tmr:FlxTimer) -> { - FlxTween.tween(logo, {alpha: 0}, 0.5, {ease: FlxEase.quadOut}); - new FlxTimer().start(0.5, (tmr:FlxTimer) -> { - FlxG.switchState(MenuState.new); - }); - }); - }); + new FlxTimer().start(3, (tmr:FlxTimer) -> { + FlxTween.tween(intro, {alpha: 0}, 0.5, {ease: FlxEase.quadOut}); + FlxTween.tween(bg, {alpha: 1}, 0.5, {ease: FlxEase.quadOut}); + FlxTween.tween(logo, {alpha: 1}, 0.5, {ease: FlxEase.quadOut}); + new FlxTimer().start(4.5, (tmr:FlxTimer) -> { + FlxTween.tween(logo, {alpha: 0}, 0.5, {ease: FlxEase.quadOut}); + new FlxTimer().start(0.5, (tmr:FlxTimer) -> { + FlxG.switchState(MenuState.new); + }); + }); + }); } } \ No newline at end of file diff --git a/source/states/MenuState.hx b/source/states/MenuState.hx index ab50c09..e1366f8 100644 --- a/source/states/MenuState.hx +++ b/source/states/MenuState.hx @@ -1,65 +1,65 @@ package states; class MenuState extends FlxState { - var curSelected:Int = 0; - var grpSelection:FlxTypedGroup; - var selections:Array = ['play', 'options', 'exit']; + var curSelected:Int = 0; + var grpSelection:FlxTypedGroup; + var selections:Array = ['play', 'options', 'exit']; - override function create() { - super.create(); + override function create() { + super.create(); - FlxG.mouse.visible = true; + FlxG.mouse.visible = true; - var bg:FlxSprite = new FlxSprite().loadGraphic(Paths.image('title/title_bg')); - add(bg); + var bg:FlxSprite = new FlxSprite().loadGraphic(Paths.image('title/title_bg')); + add(bg); - var grid:FlxBackdrop = new FlxBackdrop(FlxGridOverlay.createGrid(80, 80, 160, 160, true, 0x33FFFFFF, 0x0)); + var grid:FlxBackdrop = new FlxBackdrop(FlxGridOverlay.createGrid(80, 80, 160, 160, true, 0x33FFFFFF, 0x0)); grid.velocity.set(40, 40); - grid.alpha = 0; + grid.alpha = 0; FlxTween.tween(grid, {alpha: 0.6}, 0.5, {ease: FlxEase.quadOut}); add(grid); - grpSelection = new FlxTypedGroup(); - add(grpSelection); + grpSelection = new FlxTypedGroup(); + add(grpSelection); - for (i in 0...selections.length) { - var menuItem:FlxSprite = new FlxSprite(0, i * 160).loadGraphic(Paths.image('title/' + selections[i])); - menuItem.scale.set(0.3, 0.3); - menuItem.screenCenter(X); - menuItem.ID = i; - grpSelection.add(menuItem); - } + for (i in 0...selections.length) { + var menuItem:FlxSprite = new FlxSprite(0, i * 160).loadGraphic(Paths.image('title/' + selections[i])); + menuItem.scale.set(0.3, 0.3); + menuItem.screenCenter(X); + menuItem.ID = i; + grpSelection.add(menuItem); + } - var versii:FlxText = new FlxText(5, FlxG.height - 24, 0, 'v${Lib.application.meta.get('version')}' , 12); - versii.setFormat(Paths.font('vcr.ttf'), 26, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); - add(versii); + var versii:FlxText = new FlxText(5, FlxG.height - 24, 0, 'v${Lib.application.meta.get('version')}', 12); + versii.setFormat(Paths.font('vcr.ttf'), 26, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); + add(versii); - changeSelection(); - } + changeSelection(); + } - override function update(elapsed:Float) { + override function update(elapsed:Float) { super.update(elapsed); - if (Input.is("up") || Input.is("down")) - changeSelection(Input.is("up") ? -1 : 1); + if (Input.is("up") || Input.is("down")) + changeSelection(Input.is("up") ? -1 : 1); - if (Input.is("accept")) { - switch (curSelected) { - case 0: - FlxG.switchState(PlayState.new); - case 1: - FlxG.switchState(OptionState.new); - case 2: - Sys.exit(0); - } - } + if (Input.is("accept")) { + switch (curSelected) { + case 0: + FlxG.switchState(PlayState.new); + case 1: + FlxG.switchState(OptionState.new); + case 2: + Sys.exit(0); + } + } } - function changeSelection(change:Int = 0) { - curSelected = FlxMath.wrap(curSelected + change, 0, selections - 1); - FlxG.sound.play(Paths.sound('scroll')); - grpSelection.forEach((spr:FlxSprite) -> { - spr.alpha = (spr.ID == curSelected) ? 1 : 0.6; - }); - } + function changeSelection(change:Int = 0) { + curSelected = FlxMath.wrap(curSelected + change, 0, selections.length - 1); + FlxG.sound.play(Paths.sound('scroll')); + grpSelection.forEach((spr:FlxSprite) -> { + spr.alpha = (spr.ID == curSelected) ? 1 : 0.6; + }); + } } \ No newline at end of file diff --git a/source/states/OptionsState.hx b/source/states/OptionsState.hx index 4bd3f31..0255df7 100644 --- a/source/states/OptionsState.hx +++ b/source/states/OptionsState.hx @@ -1,61 +1,52 @@ package states; class OptionState extends FlxState { - final options:Array = [ - "FPS Counter", - "Fullscreen", - "Antialiasing", - "Framerate", - "Controls", - "Language" - ]; - - var curSelected:Int = 0; - var camObject:FlxObject; - - var notSelectedAlpha:Float = 0.55; - - override function create() { - super.create(); - - camObject = new FlxObject(80, 0, 0, 0); + final options:Array = ["FPS Counter", "Fullscreen", "Antialiasing", "Framerate", "Controls", "Language"]; + + var curSelected:Int = 0; + var camObject:FlxObject; + + var notSelectedAlpha:Float = 0.55; + + override function create() { + super.create(); + + camObject = new FlxObject(80, 0, 0, 0); camObject.screenCenter(X); - var bg:FlxSprite = new FlxSprite().loadGraphic(Paths.image('options/options_bg')); - add(bg); + var bg:FlxSprite = new FlxSprite().loadGraphic(Paths.image('options/options_bg')); + add(bg); var grid = new FlxBackdrop(FlxGridOverlay.createGrid(80, 80, 160, 160, true, 0x2C00FF95, 0x0)); grid.scrollFactor.set(); grid.velocity.set(25, 25); add(grid); - for (i in 0...options.length) - { + for (i in 0...options.length) { var text = new FlxText(80, 40 + (60 * i), 0, options[i], 20); text.setFormat(Paths.font('vcr.ttf'), 30, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); text.alpha = notSelectedAlpha; add(text); } - changeItem(); + changeItem(); FlxG.camera.follow(camObject, LOCKON, 0.25); - } + } - override function update(elapsed:Float) { - super.update(elapsed); + override function update(elapsed:Float) { + super.update(elapsed); - if (Input.is("up") || Input.is("down")) - changeItem(Input.is("up") ? -1 : 1); + if (Input.is("up") || Input.is("down")) + changeItem(Input.is("up") ? -1 : 1); - if (Input.is("exit")) - FlxG.switchState(MenuState.new); - } + if (Input.is("exit")) + FlxG.switchState(MenuState.new); + } - function changeItem(number:Int = 0) - { - curSelected = FlxMath.wrap(curSelected + number, 0, options - 1); + function changeItem(number:Int = 0) { + curSelected = FlxMath.wrap(curSelected + number, 0, options.length - 1); camObject.y = usersAssets[curSelected].text.y; - FlxG.sound.play(Paths.sound('scroll')); + FlxG.sound.play(Paths.sound('scroll')); } } \ No newline at end of file diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index 8dc7061..30394f3 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -22,44 +22,32 @@ class PlayState extends FlxState { add(strumline); var noteWidth:Float = 150; - var totalWidth:Float = noteDirs.length * noteWidth; - var startX:Float = (FlxG.width - totalWidth) / 2; + var totalWidth:Float = noteDirs.length * noteWidth; + var startX:Float = (FlxG.width - totalWidth) / 2; - for (i in 0...noteDirs.length) { - var note:Note = new Note(startX + i * noteWidth, 50, noteDirs[i], "receptor"); - strumline.add(note); - } + for (i in 0...noteDirs.length) { + var note:Note = new Note(startX + i * noteWidth, 50, noteDirs[i], "receptor"); + strumline.add(note); + } } override function update(elapsed:Float) { super.update(elapsed); - if (Input.is("exit")) - FlxG.switchState(MenuState.new); + if (Input.is("exit")) + FlxG.switchState(MenuState.new); strumline.forEach((spr:Note) -> { switch (spr.dir) { case "left": - if (Input.is("left", PRESSED)) - spr.press(); - else - spr.animation.play("receptor"); + if (Input.is("left", PRESSED)) spr.press(); else spr.animation.play("receptor"); case "down": - if (Input.is("down", PRESSED)) - spr.press(); - else - spr.animation.play("receptor"); + if (Input.is("down", PRESSED)) spr.press(); else spr.animation.play("receptor"); case "up": - if (Input.is("up", PRESSED)) - spr.press(); - else - spr.animation.play("receptor"); + if (Input.is("up", PRESSED)) spr.press(); else spr.animation.play("receptor"); case "right": - if (Input.is("right", PRESSED)) - spr.press(); - else - spr.animation.play("receptor"); + if (Input.is("right", PRESSED)) spr.press(); else spr.animation.play("receptor"); } - }) + }); } } \ No newline at end of file