Skip to content

Instantly share code, notes, and snippets.

@nielsvanvelzen
Created November 29, 2016 12:15
Show Gist options
  • Save nielsvanvelzen/686550be098489b0e4c1b9fa8a566cc8 to your computer and use it in GitHub Desktop.
Save nielsvanvelzen/686550be098489b0e4c1b9fa8a566cc8 to your computer and use it in GitHub Desktop.
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