Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package nl.ndat.yui.scene
import java.io.File
import javax.imageio.ImageIO
class SampleScene : Scene() {
val logo = ImageIO.read(File("logo.png"))!!
var x = 0
var y = 0
var xR = false
var yR = false
var speed = 2
override fun drawFrame(frame: Int): Boolean {
if (frame > 60 * 60)
return false
if (xR)
x -= speed
else
x += speed
if (yR)
y -= speed
else
y += speed
if (x >= width - logo.width)
xR = true
if (y >= height - logo.height)
yR = true
if (x <= 0)
xR = false
if (y <= 0)
yR = false
g.clearRect(0, 0, width, height)
g.drawImage(logo, x, y, null)
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.