generated from Joalor64GH/HaxeFlixel-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
549ac03
commit 19c53c5
Showing
9 changed files
with
172 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"test": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,32 @@ | ||
{ | ||
"greeting": "Hello, world!" | ||
"memTxt": "Memory: ", | ||
"pressEnter": "Press ENTER to Start!", | ||
|
||
"opFPS": "FPS Counter", | ||
"opFlScrn": "Fullscreen", | ||
"opAnti": "Antialiasing", | ||
"opFrm": "Framerate", | ||
"opLang": "Language", | ||
"opCtrls": "Controls", | ||
|
||
"descFPS": "Toggles the FPS Display. Set to: ", | ||
"descFlScrn": "Toggles fullscreen. Set to: ", | ||
"descAnti": "Toggles global antialiasing. Set to: ", | ||
"descFrm": "Use LEFT/RIGHT to change the framerate (Max 240). Set to: ", | ||
"descLang": "Changes the language. Set to: ", | ||
"descCtrls": "Edit your controls.", | ||
|
||
"scoreTxt": "Score: ", | ||
"missTxt": "Misses: ", | ||
"pauseTxt": "PAUSED?", | ||
"pauseCtrls": "ENTER - Resume / R - Restart / ESCAPE - Menu", | ||
|
||
"timeTxt": "Time: ", | ||
"secTxt": "Section: ", | ||
"bpmTxt": "BPM: ", | ||
"curSTxt": "CurStep: ", | ||
"curBTxt": "CurBeat: ", | ||
"snapTxt": "Note Snap: ", | ||
"disTxt": "DISABLED", | ||
"ctrlArrTxt": "CONTROL + ARROWS" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,32 @@ | ||
{ | ||
"greeting": "Hola mundo!" | ||
"memTxt": "Memory: ", | ||
"pressEnter": "Press ENTER to Start!", | ||
|
||
"opFPS": "FPS Counter", | ||
"opFlScrn": "Fullscreen", | ||
"opAnti": "Antialiasing", | ||
"opFrm": "Framerate", | ||
"opLang": "Language", | ||
"opCtrls": "Controls", | ||
|
||
"descFPS": "Toggles the FPS Display. Set to: ", | ||
"descFlScrn": "Toggles fullscreen. Set to: ", | ||
"descAnti": "Toggles global antialiasing. Set to: ", | ||
"descFrm": "Use LEFT/RIGHT to change the framerate (Max 240). Set to: ", | ||
"descLang": "Changes the language. Set to: ", | ||
"descCtrls": "Edit your controls.", | ||
|
||
"scoreTxt": "Score: ", | ||
"missTxt": "Misses: ", | ||
"pauseTxt": "PAUSED?", | ||
"pauseCtrls": "ENTER - Resume / R - Restart / ESCAPE - Menu", | ||
|
||
"timeTxt": "Time: ", | ||
"secTxt": "Section: ", | ||
"bpmTxt": "BPM: ", | ||
"curSTxt": "CurStep: ", | ||
"curBTxt": "CurBeat: ", | ||
"snapTxt": "Note Snap: ", | ||
"disTxt": "DISABLED", | ||
"ctrlArrTxt": "CONTROL + ARROWS" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,43 @@ | ||
package game; | ||
|
||
typedef HighScoreData = { | ||
var songName:String; | ||
var score:Int; | ||
}; | ||
|
||
class HighScore { | ||
public static var highScores:Array<HighScoreData> = []; | ||
public static var songScores:Map<String, Int> = new Map(); | ||
|
||
public static function loadHighScores():Void { | ||
var fileName:String = Paths.json("highScores"); | ||
if (FileSystem.exists(fileName)) { | ||
var fileContent:String = File.getContent(fileName); | ||
highScores = Json.parse(fileContent); | ||
} | ||
public static function saveScore(song:String, score:Int = 0):Void { | ||
var formattedSong:String = formatSong(song); | ||
if (songScores.exists(formattedSong)) { | ||
if (songScores.get(formattedSong) < score) { | ||
setScore(formattedSong, score); | ||
} | ||
} else | ||
setScore(formattedSong, score); | ||
} | ||
|
||
static function setScore(song:String, score:Int):Void { | ||
songScores.set(song, score); | ||
saveScoresToFile(); | ||
} | ||
|
||
public static function saveHighScores():Void { | ||
var fileName:String = Paths.json("highScores"); | ||
var serializedData:String = Json.stringify(highScores); | ||
File.saveContent(fileName, serializedData); | ||
public static function formatSong(song:String):String { | ||
return song.toLowerCase().replace(" ", "_"); | ||
} | ||
|
||
public static function addHighScore(songName:String, score:Int):Void { | ||
highScores.push({songName: songName, score: score}); | ||
saveHighScores(); | ||
public static function getScore(song:String):Int { | ||
var formattedSong:String = formatSong(song); | ||
if (!songScores.exists(formattedSong)) | ||
setScore(formattedSong, 0); | ||
return songScores.get(formattedSong); | ||
} | ||
|
||
public static function load():Void { | ||
if (FileSystem.exists(Paths.json("highScores"))) { | ||
var loadedScores:Map<String, Int> = Json.parse(File.getContent(Paths.json("highScores"))); | ||
songScores = loadedScores; | ||
} | ||
} | ||
|
||
public static function getHighScores():Array<HighScore> { | ||
return highScores; | ||
public static function saveScoresToFile():Void { | ||
var serializedData:String = Json.stringify(songScores); | ||
File.saveContent(Paths.json("highScores"), serializedData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,65 @@ | ||
package substates; | ||
|
||
class LanguageSubState extends ExtendableSubState { | ||
var languages:Array<String> = ["English (US)", "Español (España)"]; | ||
var group:FlxTypedGroup<FlxText>; | ||
var curSelected:Int = 0; | ||
|
||
public function new() { | ||
super(); | ||
|
||
var bg:FlxSprite = new FlxSprite().makeGraphic(1280, 720, FlxColor.BLACK); | ||
bg.alpha = 0.6; | ||
add(bg); | ||
|
||
var title:FlxText = new FlxText(0, 0, 0, 'SELECT A LANGUAGE', 12); | ||
title.setFormat(Paths.font('vcr.ttf'), 70, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); | ||
title.screenCenter(X); | ||
add(title); | ||
|
||
group = new FlxTypedGroup<FlxText>(); | ||
add(group); | ||
|
||
for (i in 0...languages.length) { | ||
var text:FlxText = new FlxText(0, 20 + (i * 70), 0, languages[i], 32); | ||
text.setFormat(Paths.font('vcr.ttf'), 80, FlxColor.WHITE, FlxTextAlign.CENTER, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); | ||
text.screenCenter(X); | ||
text.ID = i; | ||
grpOptions.add(text); | ||
} | ||
|
||
changeSelection(); | ||
} | ||
|
||
override function update(elapsed:Float) { | ||
super.update(elapsed); | ||
|
||
if (Input.is('up') || Input.is('down')) | ||
changeSelection(Input.is('up') ? -1 : 1); | ||
|
||
if (Input.is('exit')) { | ||
FlxG.sound.play(Paths.sound("cancel")); | ||
close(); | ||
} | ||
|
||
if (Input.is('accept')) { | ||
switch (curSelected) { | ||
case 0: | ||
SaveData.settings.lang = 'en'; | ||
case 1: | ||
SaveData.settings.lang = 'es'; | ||
} | ||
Localization.switchLanguage(SaveData.settings.lang); | ||
SaveData.saveSettings(); | ||
ExtendableState.resetState(); | ||
} | ||
} | ||
|
||
private function changeSelection(change:Int = 0) { | ||
FlxG.sound.play(Paths.sound('scroll')); | ||
curSelected = FlxMath.wrap(curSelected + change, 0, languages.length - 1); | ||
grpOptions.forEach(function(txt:FlxText) { | ||
txt.color = (txt.ID == curSelected) ? FlxColor.LIME : FlxColor.WHITE; | ||
}); | ||
} | ||
} |