Skip to content

A DSL system for FriceEngine. It's written in Kotlin, powerful and productive!

License

Notifications You must be signed in to change notification settings

icela/FriceEngine-DSL

Repository files navigation

Frice DSL

CI Status
Travis CI Build Status
AppVeyor Build status
CircleCI CircleCI
CodeShip Codeship Status for icela/FriceEngine-DSL


Download

This is a DSL system for FriceEngine.
And it's written in Kotlin.

Overview

If U wonder more about syntax or miscellaneous stuffs, please view Help doc.
It has commented every lines of code with its meaning.

fun main(args: Array<String>) {
  game {
    bounds(500, 500, 800, 750)
    showFPS = false

    whenExit {
      closeWindow()
    }

    whenUpdate {
      if (800.elapsed()) {
        rectangle {
          x = elapsed / 10.0
          y = elapsed / 10.0
          color = PINK
        }
      }
    }

    every(1000) {
      oval {
        x = elapsed / 10.0
        y = elapsed / 10.0
        color = ORANGE
      }
      log("1 second has past.")
    }

    rectangle {
      name("rectangle")
      x = 100.0
      y = 100.0
      width = 100.0
    }
    oval {
      x = 0.0
      y = 85.0
      accelerate {
        x = 10.0
      }
      whenColliding("rectangle") {
        stop()
        x -= 5
        accelerate {
          x = -2.0
          y = 10.0
        }
      }
    }
    image {
      file("C:/frice.png")
      x = 200.0
      y = 300.0
      velocity {
        x = -5.5
      }
    }
  }
}

See? The syntax looks like Gradle, but this one is more powerful, clear and easy.

And they are all VALID Kotlin codes. U can even compile them directly with kotlinc the Kotlin compiler!

How to use

You can use Gradle.

repositories { jcenter() }

dependencies { compile 'org.frice:dsl:1.2.1' }

Or maven.

<dependency>
  <groupId>org.frice</groupId>
  <artifactId>dsl</artifactId>
  <version>1.2.1</version>
  <type>pom</type>
</dependency>

Or Ivy.

<dependency org='org.frice' name='dsl' rev='1.2.1'>
  <artifact name='dsl' ext='pom'/>
</dependency>

The Chinese version

我还做了一个魔改版本,暂时称之为易语言,充满了粗鄙之语。省略import和main:

创建一个游戏窗口 {
  一定要把尺寸设置成这样才好看(300, 300)
  你特么给我把标题栏文字改成("我简直不知道中文编程有什么好玩的")
  你特么倒是给我添加一个椭圆啊 {
    name("老司机")
    x = 60.0
    y = 40.0
    前进前进不择手段地前进 {
      x = 10.0
      y = 20.0
    }
  }
  你特么倒是给我添加一个按钮啊 {
    x = 20.0
    y = 10.0
  }
  你特么倒是给我添加一个长方形啊 {
    name("真·老司机")
  }
  当我被鼠标点击时千万不要忘记 {
    告诉这个傻逼("老司机") {
      在这停顿
    }
  }
  每隔这么多秒一定要好好执行这个代码块喔(2000) {
    弹出一个傻逼一样的提示窗口然后再傻逼地显示("我简直日了狗了")
  }
  当我退出历史的舞台时一定要记得 {
    鎏金哇卡雅酷烈("真·老司机")
    把它给我带来一顿痛日("老司机")
    狗日的把这个傻逼的窗口给关了
  }
}