Skip to content

Commit

Permalink
[ #75 ] Done and tested, closes #75
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Jan 21, 2018
1 parent a7dd197 commit 337e63a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/org/frice/Game.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ open class Game @JvmOverloads constructor(layerCount: Int = 1) : JFrame(), Frice
iconImage = read(javaClass.getResourceAsStream("/icon.png"))

/// to prevent this engine from the call#cking NPE!!
this.add(panel, BorderLayout.CENTER)
add(panel, BorderLayout.CENTER)
bounds = BIG_SQUARE
onInit()
drawer = JvmDrawer(this).apply(JvmDrawer::init)
drawer = JvmDrawer(this).also(JvmDrawer::init)
isVisible = true
FLog.v("If the window doesn't appear, please call `launch(YourGameClass.class)` instead of the constructor.")
}
Expand All @@ -136,6 +136,9 @@ open class Game @JvmOverloads constructor(layerCount: Int = 1) : JFrame(), Frice
}
}

fun putBottom(component: JComponent) = add(component, BorderLayout.SOUTH)
fun putTop(component: JComponent) = add(component, BorderLayout.NORTH)

override fun measureText(text: FText): FRectangle {
drawer.useFont(text)
val g = drawer.g
Expand Down
2 changes: 1 addition & 1 deletion src/org/frice/obj/FObject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract class FObject(x: Double, y: Double) : PhysicalObject(x, y) {
abstract fun scale(x: Double, y: Double)

@Suppress("FunctionName")
internal fun `{-# runAnims #-}`() = anims.forEach { a -> a.`{-# do #-}`(this) }
internal fun `{-# runAnims #-}`() = anims.forEach { it.`{-# do #-}`(this) }

fun addAnim(anim: FAnim) = anims.add(anim)

Expand Down
8 changes: 7 additions & 1 deletion test/org/frice/Test.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import org.frice.util.shape.*
import org.frice.util.time.FTimer
import java.util.*
import java.util.function.Consumer
import javax.swing.JButton
import javax.swing.JTextField
import kotlin.test.assertEquals

/**
Expand All @@ -42,6 +44,10 @@ class Test : Game() {
override fun onInit() {
super.onInit()
autoGC = true
val textField = JTextField()
putBottom(textField)
val button = JButton("Boy next door")
putTop(button)

addObject(ParticleEffect(ParticleResource(
this, width / 10, height / 10, 0.01), width * 0.1, height * 0.1))
Expand All @@ -52,7 +58,7 @@ class Test : Game() {
width = 100.0,
height = 30.0).apply {
onMouseListener = Consumer {
val obj = ShapeObject(ColorResource.西木野真姬, FOval(40.0, 30.0), 100.0, 100.0).apply {
val obj = ShapeObject(ColorResource.西木野真姬, FOval(50.0, 20.0), 100.0, 100.0).apply {
addAnim(AccelerateMove(-200.0, -200.0))
addAnim(SimpleMove(400, 400))
addAnim(SimpleScale(1.1, 1.1))
Expand Down

0 comments on commit 337e63a

Please sign in to comment.