Skip to content

Commit

Permalink
augh
Browse files Browse the repository at this point in the history
  • Loading branch information
Joalor64GH authored Jun 30, 2024
1 parent d9d0efe commit 517eef4
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 4 deletions.
Binary file added assets/images/icons/mgicons/card.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 added assets/images/minigames/cards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions source/meta/state/MinigamesState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class MinigamesState extends MusicBeatState
var controlStrings:Array<Minigame> = [
new Minigame('GET OUT OF MY HEAD', 'the pain never stops\n(Amogus)', 'mgicons/sus'),
new Minigame('.jpegs are funny', "they are and you can't tell me otherwise\n(Compression)", 'mgicons/pico'),
new Minigame('Kill BF', 'lmao\n(Point & Click)', 'mgicons/killBf')
new Minigame('Kill BF', 'lmao\n(Point & Click)', 'mgicons/killBf'),
new Minigame('Funky Memory', 'Do you remember?\n(Point & Click)', 'mgicons/card')
// soon...
// new Minigame('Funky Memory', 'Do you remember?\n(Point & Click)', 'mgicons/card')
// new Minigame("Joalor64's Special", 'It\'s me!\n(Melodic Circuit)', 'mgicons/me')
];

Expand Down Expand Up @@ -88,8 +88,8 @@ class MinigamesState extends MusicBeatState
LoadingState.loadAndSwitchState(new PlayState());
case 2:
MusicBeatState.switchState(new minigames.KillBF());
/* case 3:
MusicBeatState.switchState(new minigames.CardGame()); */
case 3:
MusicBeatState.switchState(new minigames.FunkyMemory());
}
}
}
Expand Down
134 changes: 134 additions & 0 deletions source/minigames/FunkyMemory.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
package minigames;

import minigames.Card;
import minigames.C;

#if (flixel >= "5.0.0")
import flixel.input.mouse.FlxMouseEvent;
#end

class FunkyMemory extends MusicBeatState
{
static inline final READY = "Ready to play";

private var NUMBER_OF_CARDS:Int = 24;
private var CARDS_PER_ROW:Int = 8;
private var cards:Array<Int> = new Array();
private var card:Card;
private var pickedCards:Array<Card> = new Array();
private var canPick:Bool = true;
private var matchesFound = 0;
private var canResetGame = false;
private var statusText:FlxText;

override public function create()
{
super.create();

FlxG.sound.playMusic(Paths.music('breakfast'));

for (i in 0...NUMBER_OF_CARDS)
{
cards.push(Math.floor(i / 2) + 1);
}
trace("My cards: " + cards);

var i:Int = NUMBER_OF_CARDS;
var swap:Int, tmp:Int;
while (i-- > 0)
{
swap = Math.floor(Math.random() * i);
tmp = cards[i];
cards[i] = cards[swap];
cards[swap] = tmp;
}
trace("My shuffled cards: " + cards);

for (i in 0...NUMBER_OF_CARDS)
{
card = new Card(cards[i]);
add(card);
var hm:Float = (FlxG.width - card.width * CARDS_PER_ROW - 10 * (CARDS_PER_ROW - 1)) / 2;
var vm:Float = (FlxG.height - card.height * (NUMBER_OF_CARDS / CARDS_PER_ROW) - 10 * (NUMBER_OF_CARDS / CARDS_PER_ROW)) / 2;
card.x = hm + (card.width + 10) * (i % CARDS_PER_ROW);
card.y = vm + (card.height + 10) * (Math.floor(i / CARDS_PER_ROW));

// update your fucking flixel
#if (flixel >= "5.0.0")
FlxMouseEvent.add(card, onMouseDown);
#end
}

statusText = new FlxText(0, FlxG.height - 50, FlxG.height, READY, 20);
statusText.setFormat(Paths.font('vcr.ttf'), 30, FlxColor.WHITE, FlxTextAlign.CENTER, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
statusText.screenCenter(X);
add(statusText);
}

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

if (((FlxG.mouse.justPressed) && (canResetGame)) || (controls.RESET))
{
MusicBeatState.resetState();
}

if (controls.BACK)
{
MusicBeatState.switchState(new MinigamesState());
FlxG.sound.playMusic(Paths.music('freakyMenu'));
}
}

private function onMouseDown(picked:Card)
{
statusText.text = "You picked a " + C.color[picked.index] + " card";

if (canPick)
{
if (pickedCards.indexOf(picked) == -1)
{
pickedCards.push(picked);
picked.flip();
}

if (pickedCards.length == 2)
{
canPick = false;
if (pickedCards[0].index == pickedCards[1].index)
{
statusText.text = "Cards match!!!!";
FlxMouseEvent.remove(pickedCards[0]);
FlxMouseEvent.remove(pickedCards[1]);
canPick = true;
matchesFound++;
pickedCards = new Array();
if (matchesFound == NUMBER_OF_CARDS / 2)
{
FlxG.sound.play(Paths.sound('confirmMenu'));
statusText.text = "You won! Click anywhere to play again!";
Timer.delay(function()
{
canResetGame = true;
}, 1000);
}
}
else
{
FlxG.sound.play(Paths.sound('cancelMenu'));
statusText.text = "Cards do not match";

Timer.delay(function()
{
pickedCards[0].flipBack();
pickedCards[1].flipBack();
pickedCards = new Array();
canPick = true;
statusText.text = READY;
}, 1000);
}
}
}
}
}

0 comments on commit 517eef4

Please sign in to comment.