Skip to content

Commit

Permalink
wip options menu + basic note logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Joalor64GH authored Jul 25, 2024
1 parent f9588e8 commit 585c987
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 10 deletions.
Binary file added assets/images/options/options_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/title/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions source/states/InitialState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package states;
class InitialState extends FlxState {
var intro:FlxSprite;
var logo:FlxSprite;
var bg:FlxSprite;

override function create() {
super.create();
Expand All @@ -20,6 +21,10 @@ class InitialState extends FlxState {
intro.alpha = 0;
add(intro);

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;
Expand All @@ -31,8 +36,10 @@ class InitialState extends FlxState {
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});
Expand Down
13 changes: 4 additions & 9 deletions source/states/MenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class MenuState extends FlxState {

var grid:FlxBackdrop = new FlxBackdrop(FlxGridOverlay.createGrid(80, 80, 160, 160, true, 0x33FFFFFF, 0x0));
grid.velocity.set(40, 40);
grid.alpha = 0;
FlxTween.tween(grid, {alpha: 0.6}, 0.5, {ease: FlxEase.quadOut});
add(grid);

grpSelection = new FlxTypedGroup<FlxSprite>();
Expand Down Expand Up @@ -46,23 +48,16 @@ class MenuState extends FlxState {
case 0:
FlxG.switchState(PlayState.new);
case 1:
trace('options menu unfinished sorry');
FlxG.switchState(OptionState.new);
case 2:
Sys.exit(0);
}
}
}

function changeSelection(change:Int = 0) {
curSelected += change;

curSelected = FlxMath.wrap(curSelected + change, 0, selections - 1);
FlxG.sound.play(Paths.sound('scroll'));

if (curSelected < 0)
curSelected = grpSelection.length - 1;
if (curSelected >= grpSelection.length)
curSelected = 0;

grpSelection.forEach((spr:FlxSprite) -> {
spr.alpha = (spr.ID == curSelected) ? 1 : 0.6;
});
Expand Down
41 changes: 41 additions & 0 deletions source/states/OptionsState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,53 @@ class OptionState extends FlxState {
"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 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)
{
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();

FlxG.camera.follow(camObject, LOCKON, 0.25);
}

override function update(elapsed:Float) {
super.update(elapsed);

if (Input.is("up") || Input.is("down"))
changeItem(Input.is("up") ? -1 : 1);

if (Input.is("exit"))
FlxG.switchState(MenuState.new);
}

function changeItem(number:Int = 0)
{
curSelected = FlxMath.wrap(curSelected + number, 0, options - 1);
camObject.y = usersAssets[curSelected].text.y;
FlxG.sound.play(Paths.sound('scroll'));
}
}
32 changes: 31 additions & 1 deletion source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ package states;
class PlayState extends FlxState {
var noteDirs:Array<String> = ['left', 'down', 'up', 'right'];
var strumline:FlxTypedGroup<Note>;
var notes:FlxTypedGroup<Note>;

var ratings:FlxTypedGroup<Rating>;

var score:Int = 0;
var scoreTxt:FlxText;
var timeBar:Bar;

override function create() {
super.create();
Expand All @@ -16,7 +21,7 @@ class PlayState extends FlxState {
strumline = new FlxTypedGroup<Note>();
add(strumline);

var noteWidth:Float = 200;
var noteWidth:Float = 150;
var totalWidth:Float = noteDirs.length * noteWidth;
var startX:Float = (FlxG.width - totalWidth) / 2;

Expand All @@ -31,5 +36,30 @@ class PlayState extends FlxState {

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");
case "down":
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");
case "right":
if (Input.is("right", PRESSED))
spr.press();
else
spr.animation.play("receptor");
}
})
}
}

0 comments on commit 585c987

Please sign in to comment.