Adding Modcharts - kadedevteam/Kade-Engine-Offical GitHub Wiki

Adding Modcharts

To add custom modcharts you will need to have the ability to compile the game from the source code! Info for compiling the game can be found here!

Actors!

setActor

  • Arguments: setActorX(x:Int,id:String)
  • Description: Set the specified actor's x position.
  • Arguments: setActorY(y:Int,id:String)
  • Description: Set the specified actor's y position.
  • Arguments: setActorX(x:Int,id:String)
  • Description: Set the specified actor's x position.

setActorAccelerationX

  • Arguments: setActorAccelerationX(x:Int,id:String)
  • Description: Set the specified actor's x acceleration.
  • Arguments: setActorAccelerationY(y:Int,id:String)
  • Description: Set the specified actor's y acceleration.

setActorDrag

  • Arguments: setActorDragX(x:Int,id:String)
  • Description: Set the specified actor's drag x.
  • Arguments: setActorDragY(x:Int,id:String)
  • Description: Set the specified actor's drag y.
  • Arguments: setActorVelocityX(x:Int,id:String)
  • Description: Set the specified actor's drag y.

playActorAnimation

  • Arguments: playActorAnimation(id:String,anim:String,force:Bool,reverse:Bool)
  • Description: Play an actor's animation

IDs

SpriteID

  • 0-7 = Represents Receptor 0-7
  • boyfriend = Represents the Boyfriend Actor (player1)
  • dad = Represents the Dad Actor (player2)
  • girlfriend = Represents the Girlfriend Actor

Function Hooks

  • start = Song Name = Gets called when the song starts
  • update = Elapsed frames = Gets called every frame (after the song starts)
  • stepHit = Current Step = Gets called when ever a step hits (steps are in between beats, aka 4 steps are in a beat)
  • beatHit = Current Beat = Gets called when ever a beat hits
  • keyPressed = Key Pressed = Gets called when a key just got pressed (up, down, left, right, accept)

Getting Started

To get started navigate to a chart's .json file. (ex: assets/data/songName/)

Now after that create a file called modchart.lua and then copy and paste this template in.

-- this gets called starts when the level loads.
function start(song) -- arguments, the song name

end

-- this gets called every frame
function update(elapsed) -- arguments, how long it took to complete a frame

end

-- this gets called every beat
function beatHit(beat) -- arguments, the current beat of the song

end

-- this gets called every step
function stepHit(step) -- arguments, the current step of the song (4 steps are in a beat)

end

Now that we've gotten done with our template file, we can start talking about how our modcharts work.

Our modcharts work based on lua which is what you're going to be programming in, and an editor we recommend is Visual Studio Code

You should also look at our actor id system

Full Examples Here are some examples that you can base your code on.

function start (song)
	print("Song: " .. song .. " @ " .. bpm .. " downscroll: " .. downscroll)
end


function update (elapsed) -- example https://twitter.com/KadeDeveloper/status/1382178179184422918
	local currentBeat = (songPos / 1000)*(bpm/60)
	for i=0,7 do
		setActorX(_G['defaultStrum'..i..'X'] + 32 * math.sin((currentBeat + i*0.25) * math.pi), i)
		setActorY(_G['defaultStrum'..i..'Y'] + 32 * math.cos((currentBeat + i*0.25) * math.pi), i)
	end
end

function beatHit (beat)
   -- do nothing
end

function stepHit (step)
   -- do nothing
end

function keyPressed (key)
   -- do nothing
end

print("Mod Chart script loaded :)")

Spinning Receptor Example

function update (elapsed)
	for i=0,7 do
		setActorAngle(getActorAngle(i) + 15, i)
	end
end
Spinning Hud Example

function update (elapsed)
	camHudAngle = camHudAngle + 0.005
end
Spin at a specific part of the song

function update (elapsed)
	if curStep >= 352 and curStep < 400 then
		local currentBeat = (songPos / 1000)*(bpm/60)
		for i=0,7 do
			setActorX(_G['defaultStrum'..i..'X'] + 32 * math.sin((currentBeat + i*0.25) * math.pi), i)
			setActorY(_G['defaultStrum'..i..'Y'] + 32 * math.cos((currentBeat + i*0.25) * math.pi), i)
		end
	else
        	for i=0,7 do
			setActorX(_G['defaultStrum'..i..'X'],i)
			setActorY(_G['defaultStrum'..i..'Y'],i)
        	end
    	end
end

Showing/Hiding receptors/the hud

function start (song)
    showOnlyStrums = true -- remove all hud elements besides notes and strums
    for i=0,3 do -- fade out the first 4 receptors (the ai receptors)
		tweenFadeIn(i,0,0.6)
    end
end
Looping through all of the rendered notes

for i = 0, getRenderedNotes() do -- sets all of the rendered notes to 0 0 on the x and y axsis
	setRenderedNotePos(0,0,i)
end
Centering BF's Side

function setDefault(id)
	_G['defaultStrum'..id..'X'] = getActorX(id)
end

-- put this somewhere in a function

for i = 4, 7 do -- go to the center
	tweenPosXAngle(i, _G['defaultStrum'..i..'X'] - 275,getActorAngle(i) + 360, 0.6, 'setDefault')
end

Jumping Arrows Example

function stepHit (step)
    if step == 1 then
        setActorAccelerationY(100, 4)
    end
    if step == 3 then
        setActorAccelerationY(100, 5)
    end
    if step == 5 then
        setActorAccelerationY(100, 6)
    end
    if step == 7 then
        setActorAccelerationY(100, 7)
    end
    for i=4,7 do
        if getActorY(i) >= 100 then
        setActorY(100, i)
        setActorVelocityY(-100, i)
        end
    end
end

Globaled Variables

  • bpm Float The current BPM of the song
  • fpsCap Int The current FPS Cap (set by the player)
  • downscroll Bool Whether the player is in downscroll or not
  • cameraAngle Float The angle that the Main Camera should be rotated
  • camHudAngle Float The angle that the Hud should be rotated
  • followXOffset Float The x offset to be added when the camera moves between a character
  • followYOffset Float The y offset to be added when the camera moves between a character
  • showOnlyStrums Bool Whether to show the Hud and Strums or only the Strums
  • strumLine1Visible Bool Whether to show the first strum line or not
  • strumLine2Visible Bool Whether to show the secondstrum line or not
  • defaultStrum0-7X Float (0-7 is strum0,strum1,strum2,etc) get the default X coordinate for the strum
  • defaultStrum0-7Y Float (0-7 is strum0,strum1,strum2,etc) get the default Y coordinate for the strum
  • defaultStrum0-7Angle Float (0-7 is strum0,strum1,strum2,etc) get the default Angle for the strum
  • screenWidth Int The width of the current gamespace
  • screenHeight Int The height of the current gamespace
  • hudWidth Int The width of the hud
  • hudHeight Int The height of the hud
  • scrollSpeed Float The current scrollspeed
  • mustHit Bool If the current section is a must hit section
  • strumLineY Float The current Strum Line Y Position

Index Variables

  • Find a Page…
  • Home
  • Actor
  • Actor ID System
  • Function Hooks
  • Getting Started
  • Global Variables
  • Hud & Camera
  • Misc
  • Sprites
  • Window

Compile your game to see changes!

Hope this guide helps!

IF I MISSED ANYTHING PLEASE FIX IT IN A PULL REQUEST