quadrant

quadrant

Not enough ratings
Creating your own level
By undef
In this short guide you will learn how making levels in quadrant works.
   
Award
Favorite
Favorited
Unfavorite
Introduction
You think it would be nice to make a level yourself?
You're in luck! It's actually not that hard!
In this short guide I'll show you how to do it.

You will need to program in the Lua programming language[www.lua.org] to make your level.
Lua is a simple, yet very powerful programming language used in lots of games[en.wikipedia.org].
quadrant is made with the LÖVE framework[love2d.org], so the things you learn when making a quadrant level can also be used to make your own game in this framework if you like!

Maybe you never programmed before and think that it's too difficult. That's what I thought for a very long time - it's not.
The Getting Started section on the LÖVE wiki [love2d.org]might be a good place to start!

So first of all we'll have a look at how a level is structured:

Levels are folders that are always in other folders telling the game what levelpack the levels are in.
For example, the original game levels are in the levelpack "base", which is basically a folder called "base", containing three folders - one for each level.
(You can access the quadrant source code if you open the quadrant.exe with a zip program like 7zip. On Mac or Linux you'll have to unzip the quadrant.love in the game files.)

So the base levelpack contains the following folders:
  • 01Bitbasic
  • 02l0qI
  • 03AdhesiveWombat

The names of the folders are not important, but the levels are being displayed alphabetically, so if you renamed "01Bitbasic" to "99" the first level would now be the third level.

Make sure there is no "." in a folder name when renaming (e.g. 00Dr.Dre should rather be 00DrDre), otherwise the level won't load.

So If you get the example stage here[mega.co.nz] and copy it to the location in the readme, you can launch quadrant and select the level in the stage menu when pressing arrow key up, or up on your gamepad.

If you copy and paste the folder 00example inside the workshopExample levelpack folder, you will have multiple levels selectable.

So let's have a look what's inside a level folder:

  • a folder called song, including two audio files
  • a Lua script called challenges.lua
  • an image file called cover.jpg (cover.png also works)
  • a Lua script called stage.lua


song

the song folder contains to audio files:
  • click.ogg
  • click_FILTERED.ogg

click (or whatever you want to call your sound file) is the song that is being played when you play the level.
The FILTERED sound file is the one that the game cross fades to when you make a mistake.
What I usually do is open the sound file in Audacity[audacityteam.org] and apply the filter Bass&Treble twice, with maximum aplification of treble and with bass tuned to the minumum.
Then I export the filtered sound file as an .ogg with the lowest possible quality (you don't need good quality for that effect, and it drastically reduces the size of the file).

Notice that mp3 files also work with quadrant, however not all operating systems may support mp3 because of certain patents. I recommend using ogg - it's not patented and is also a superior audio codec.



challenges.lua

This script file takes care of the challenges/achievements (the ones that are shown on the back of your cover in the stage menu).



cover

The cover file (cover.png / cover.jpg / cover.jpeg) is the cover of your level, I usually take the album cover of the song.
Make sure to take a cover file with high resolution, the game will adapt it to the screen resolution and low resolution cover files may look blotchy.


stage.lua

This is the essence of your level. This is where you put your level code and information.
reference
Global Variables

beat - number

represents how many beats have passed since the level started. At the start of the level beat is 0.

t - number
represents the time (in seconds) that has passed since the level started

transitionProgress - number [0,1]
represents the progress between beats

delayedTransitionProgress - number [0,1]
represents the progress between the middle point of a beat end it's ending - is 0 before the first half of the beat has passed

positionUpdated - bool
is only true for the frame when the position got updated

scored - bool
is true when the player has already scored during the current beat

w - number
the width of the virtual screen in pixels

h - number
the height of the virtual screen in pixels

pi - number
math.pi

Functions

lerp( initialValue, finalValue, progress )
linear interpolation

bulkLerp( initialArray, finalArray, progress )
returns an array that contains the linear interpolation between the first #initialArray indexes of the two arrays.

bulkSet( index, value, tables... )
sets table[index] = value for every table in the vararg list

tsize( table )
gets the size of a table (array and hash part)

tcopy( table )
returns a shallow copy of the table

tdcopy( table )
returns a deep copy of the table

tprint( table )
prints all the indexes and contents of a table recursively

clamp( value, min, max )
clamps a number (value) to the range of two other numbers (min, max) and returns it

makeClamper( min, max ) --> function( x )
returns a function that takes a value and clamps it to the range of min and max and returns it

makeArc( x, y, radius, angle1, angle2, segments )
returns a mesh that you can draw using love.graphics.draw that is a filled arc (and is way more efficient than love.graphics.polygon if you use many segments)

newImage( pathOrData, referenceHeight )
returns an image that you can draw using love.graphics.draw that will be scaled according to the referenceHeight (so it looks roughly the same on all resolutions)

sin( x )
math.sin

cos( x )
math.cos

rand( [x [, y]] )
math.random
writing a stage.lua
Sorry, I haven't written a detailed guide on how to do that yet, but the stage lua in the example stage is well commented and should help you understand how everything works.
You can get it here![mega.co.nz]
uploading a level to the workshop
To upload a level to the workshop you will have to create a small uploading script called workshopItem.lua that looks like this:

return { thumbnailImagePath = "C:\\path\\to\\thumbnail.jpg", folder = "C:\\path\\to\\folder\\containing\\levelpack", visibility = "public", tags = "your,tags,seperated,by,commas", changeNote = "your changenote here", name = "the name", description = "be creative", }

Note that the thumbnail image must be smaller than 1MB, so you probably won't use the same cover image as for the level.

visibility can be "public", "friends" or "private".

Limit the name length to 128 ASCII characters
Limit the description length to 8000 ASCII characters



If you run quadrant from Steam and choose "upload workshop item" as a launch option you will get an error, but the folder where you will have to put the workshopItem.lua opens.
Put the file in the folder and try again.

If this is the first time you're uploading the levelpackage, Steam will assign it an ID, so your workshopItem.lua will be edited automatically to contain the so called "publishedFileId".
I recommend you keep the workshopItem.lua for future updates, so you can just drag and drop it back into the folder in case you make (or add levels to) several levelpackages.

And that's it!
I'm looking foward to try out your stuff :)
10 Comments
Tetaes 21 Jul, 2016 @ 4:17pm 
@undef Oh, thanks! I got it working now.
undef  [author] 21 Jul, 2016 @ 4:22am 
Hey Tetaes!

The Lua function that imports Lua scripts interprets "." as "/" (subdirectory), so your path gets wrong, and the file is not found.

So remove the "." from the 00mr.jack folder (e.g. 00mrJack) and it should be fine.
Thanks for reporting this, I will update the guide accordingly!
Tetaes 20 Jul, 2016 @ 9:11am 
@undef Howdy! I'm having problems with setting up the level, I'm pretty confused why the game keeps displaying this error.
http://i.imgur.com/f7yBDGZ.jpg

also if you want more information, here's my stage.lua and challenges.lua screenshots
http://i.imgur.com/r56G1zR.jpg
http://i.imgur.com/gsoXPEY.jpg

Thanks in advance.
undef  [author] 9 Jul, 2016 @ 3:25pm 
@Krazyjack26
If you subscribe to a workshop item the level should be in the game already, you will have to use arrow key up/down to switch between the original levels and the ones you added.
robin 8 Jul, 2016 @ 11:50am 
@undef
How do i add a workshop level to the game? i found a neat one but can't figure out where to put it.
-KJ
undef  [author] 6 Apr, 2016 @ 2:41am 
Hey Thresio, I still have some unreleased work for quadrant that I'm intending to finish, including a new level.
I'm not ready to announce the song yet though :)

Unfortunately I've been really busy with a paid project the last few months, and it won't be done before June.
After finishing that project I should have enough time to finish the next update and release it.

I will probably also make and release a video tutorial on making quadrant levels then.

You're not the first to suggest a level creator.
I'm tempted to make one, but it will never be able to make levels as versatile as hand-coded ones.

If you're trying to make a level and get stuck at some point, I'm always happy to answer questions - and it'll also help me in improving the guide.
Thresio 4 Apr, 2016 @ 5:27pm 
I have a few questions for you. First off, are you still working on this game? If so, can we get a hint as to what this "something more difficult" song is? How about this tutorial? When do you plan on updating it? And lastly, have you thought about adding a form of level creator to make things simpler for users to create their own level?

All in all, I love this game and I would love to make levels for it. The one thing that stops me from doing that though is the know how you need to have for it. If there was an easier way to create levels, I'm sure there would be way more than the two that are in the workshop.
undef  [author] 29 Aug, 2015 @ 4:05pm 
Hey,
can't wait to see what you come up with!
We definitely need more levels, that's for sure.
The third level gets pretty hard in the end, but I'm already working on something more difficult, don't know when it will be done yet though...
Pistaschios 28 Aug, 2015 @ 4:04pm 
very interesting, i'll probably try to make a lvl when i can...
your game is realy good, but only 3 songs is a little poor :/
and in the third song there is a moment where the pulse disapear and it's the same moment where animation become realy hard (zoom and twist) so i'ts impossible for me to reach the "S" or "A" rank on it without pulse :/
undef  [author] 8 Jul, 2015 @ 3:34pm 
If you find any mistakes, or have any questions, please let me know!