# Program

Beatwalls is written in kotlin (opens new window) and maven (opens new window). While it helps if you are familiar with it or any other object oriented language, I don't think its required.

As always, follow the fork -> commit -> pull request workflow

It is highly recommended to use intellij idea (opens new window), the free community edition is perfectly fine.

To open the project use project from version control and enter the git url. After downloading and indexing, intellij will ask if you want to setup the maven project. Just say yes.

The easiest (and most helpful) way is to add new Wallstructures.

# Setup

  1. Open src/main/kotlin/structure/WallStructure.kt. This file holds all Properties and docs for all Wallstructures. Add something like this in your file:
/**
 * Add a description on what your Wallstructure does
 */
class MyStructName:WallStructure(){
    /**
     * An example Property the user can set
     * Supported Properties are `BwInt, BwIntOrNull, BwDouble, BwDoubleOrNull, BwPoint, BwString
     */
    val myProperty by BwInt(20)
    
    /**
     * This controls the amount of walls created
     * override the default Property.
     */
    override val amount by BwInt(16*myProperty)

    /**
     * required Function
     */
    override fun generateWalls() = run()
}

Now under src/main/kotlin/structure/specialStrucures add a file called MyStructName.kt. In this you will create a base function like this:

fun RandomNoise.run(): List<SpookyWall> {
    val l = mutableListOf<SpookyWall>()
    // your code for creating the Wallstructure will goe here
    return l.toList()
}

# Crash course Kotlin

Here is some example code from learnXinY (opens new window) to get you up in running.

    /*
    Declaring values is done using either "var" or "val".
    "val" declarations cannot be reassigned, whereas "vars" can.
    */
    val fooVal = 10 // we cannot later reassign fooVal to something else
    var fooVar = 10
    fooVar = 20 // fooVar can be reassigned

    /*
    We can create a list using the "listOf" function.
    The list will be immutable - elements cannot be added or removed.
    */
    val fooList = listOf("a", "b", "c")
    println(fooList.size) // => 3
    println(fooList.first()) // => a
    println(fooList.last()) // => c
    // Elements of a list can be accessed by their index.
    println(fooList[1]) // => b

    // A mutable list can be created using the "mutableListOf" function.
    val fooMutableList = mutableListOf("a", "b", "c")
    fooMutableList.add("d")
    println(fooMutableList.last()) // => d
    println(fooMutableList.size) // => 4

    // A "for" loop can be used with anything that provides an iterator.
    for (i in 0 until amount) {
        l.add(SpookyWall())
    }
    for (c in "hello") {
        println(c)
    }
    // Example for using math library
    // most of the time, you can search for stuff and bring them up with ctrl space
    val c = abs(-5.0)
    val r = c.pow(2)

# CuboidConstrains

If you use Points, there is a helper class for you.

val cc = CuboidConstrains(p1, p2)
// Example of getting the lowest x. 
// For more information check out the class itself
val x = cc.sx

# Testing it

It would be nice, (but not needed) to see some automated test for your Wallstructure. For an easy way, place your cursor on the run method and click alt enter -> create test. You can then write your code and test it with junit4. Example

@Test
fun myTest(){
    val s = MyWallStructure()
    val actual = s.run
    val expected = listOf(SpookyWall())
    assertEquals(expected,actual)
}

# Need help?

Just hit me up on discord or github. I'm more than willing to help you with anything.