1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-22 21:26:49 +00:00

INIT COMMIT

This commit is contained in:
Cameron Taylor 2020-10-02 23:50:15 -07:00
commit 38802b333c
9 changed files with 331 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
export/
.vscode/

82
Project.xml Normal file
View file

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<!-- _________________________ Application Settings _________________________ -->
<app title="ld47" file="ld47" 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="true" />
<!--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>

15
hxformat.json Normal file
View file

@ -0,0 +1,15 @@
{
"lineEnds": {
"leftCurly": "both",
"rightCurly": "both",
"objectLiteralCurly": {
"leftCurly": "after"
}
},
"sameLine": {
"ifElse": "next",
"doWhile": "next",
"tryBody": "next",
"tryCatch": "next"
}
}

4
source/AssetPaths.hx Normal file
View file

@ -0,0 +1,4 @@
package;
@:build(flixel.system.FlxAssets.buildFileReferences("assets", true))
class AssetPaths {}

0
source/BeatBattle.hx Normal file
View file

16
source/Conductor.hx Normal file
View file

@ -0,0 +1,16 @@
package;
/**
* ...
* @author
*/
class Conductor
{
public static var bpm:Int = 100;
public static var crochet:Float = ((60 / bpm) * 1000); // beats in milliseconds
public static var stepCrochet:Float = crochet / 4; // steps in milliseconds
public static var songPosition:Float;
public static var offset:Float = 0;
public function new() {}
}

13
source/Main.hx Normal file
View 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, PlayState));
}
}

37
source/Note.hx Normal file
View file

@ -0,0 +1,37 @@
package;
import flixel.FlxSprite;
import flixel.util.FlxColor;
class Note extends FlxSprite
{
public var strumTime:Float = 0;
public var mustPress:Bool = false;
public var noteData:Int = 0;
public function new(strumTime:Float, noteData:Int)
{
super();
this.strumTime = strumTime;
this.noteData = noteData;
makeGraphic(50, 50);
switch (Math.abs(noteData))
{
case 1:
color = FlxColor.GREEN;
case 2:
color = FlxColor.RED;
case 3:
color = FlxColor.BLUE;
case 4:
color = FlxColor.PURPLE;
}
if (noteData < 0)
alpha = 0.6;
}
}

162
source/PlayState.hx Normal file
View file

@ -0,0 +1,162 @@
package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.system.FlxSound;
import flixel.text.FlxText;
import haxe.Json;
import lime.utils.Assets;
class PlayState extends FlxState
{
private var lastBeat:Float = 0;
private var lastStep:Float = 0;
private var safeFrames:Int = 5;
private var safeZoneOffset:Float = 0; // is calculated in create(), is safeFrames in milliseconds
private var canHit:Bool = false;
private var canHitText:FlxText;
private var dad:FlxSprite;
private var boyfriend:FlxSprite;
private var notes:FlxTypedGroup<Note>;
private var strumLine:FlxSprite;
override public function create()
{
dad = new FlxSprite(100, 100).loadGraphic(AssetPaths.DADDY_DEAREST__png);
add(dad);
boyfriend = new FlxSprite(470, 100).loadGraphic(AssetPaths.BOYFRIEND__png);
add(boyfriend);
generateSong('assets/data/bopeebo.json');
safeZoneOffset = (safeFrames / 60) * 1000;
canHitText = new FlxText(10, 10, 0, "weed");
strumLine = new FlxSprite(0, 50).makeGraphic(FlxG.width, 10);
add(strumLine);
super.create();
}
var debugNum:Int = 0;
private function generateSong(dataPath:String):Void
{
var songData = Json.parse(Assets.getText(dataPath));
FlxG.sound.playMusic("assets/music/" + songData.song + ".mp3");
notes = new FlxTypedGroup<Note>();
add(notes);
var noteData:Array<Dynamic> = songData.data;
var playerCounter:Int = 0;
while (playerCounter < 2)
{
var daBeats:Int = 0; // Not exactly representative of 'daBeats' lol, just how much it has looped
for (section in noteData)
{
var dumbassSection:Array<Dynamic> = section;
var daStep:Int = 0;
for (songNotes in dumbassSection)
{
if (songNotes != 0)
{
var daStrumTime:Float = (daStep * Conductor.stepCrochet) + ((Conductor.crochet * 4) * playerCounter);
var swagNote:Note = new Note(daStrumTime, songNotes);
var swagWidth:Float = 40;
swagNote.x += (swagWidth * (Math.abs(songNotes))) + ((FlxG.width / 2) * playerCounter);
if (playerCounter == 2) // is the player
{
swagNote.mustPress = true;
}
notes.add(swagNote);
}
daStep += 1;
}
daBeats += 1;
}
playerCounter += 1;
}
}
override public function update(elapsed:Float)
{
super.update(elapsed);
Conductor.songPosition = FlxG.sound.music.time;
if (dad.scale.x > 1)
{
dad.setGraphicSize(Std.int(dad.width - (FlxG.elapsed * 2)));
}
canHitText.visible = canHit;
canHitText.text = 'WWEED' + debugNum;
if (canHit)
{
debugNum += 1;
}
else
debugNum = 0;
everyBeat();
everyStep();
notes.forEach(function(daNote:Note)
{
daNote.y = (strumLine.y + 5 - (daNote.height / 2)) - ((Conductor.songPosition - daNote.strumTime) * 0.4);
});
}
function everyBeat():Void
{
if (Conductor.songPosition > lastBeat + Conductor.crochet - safeZoneOffset || Conductor.songPosition < lastBeat + safeZoneOffset)
{
if (Conductor.songPosition > lastBeat + Conductor.crochet)
{
lastBeat += Conductor.crochet;
canHitText.text += "\nWEED\nWEED";
dad.setGraphicSize(Std.int(dad.width * 1.1));
}
}
}
function everyStep()
{
if (Conductor.songPosition > lastStep + Conductor.stepCrochet - safeZoneOffset
|| Conductor.songPosition < lastStep + safeZoneOffset)
{
canHit = true;
if (Conductor.songPosition > lastStep + Conductor.stepCrochet)
{
lastStep += Conductor.stepCrochet;
canHitText.text += "\nWEED\nWEED";
}
}
else
canHit = false;
}
}