Kojo – Version 150111 Released, Featuring Sprites

A new release of Kojo is out.

Highlights:

  • Support for Sprites within the Staging module – driven by the desire to make Physics animations more fun. Here’s some sample code to get you going:
val a = 20.0
val u = 0.0

val S = Staging
S.clear

axesOn()
gridOn()
zoom(0.75, 500, 300)

val car = S.sprite(0, 25, """C:\Users\lalit\scratch\car.gif""")
val splot = S.path(0, 0)
splot.setPenColor(blue)

val vplot = S.path(0, 0)
vplot.setPenColor(green)

val t0 = S.time
val time = S.text("0", 100, -50)
time.setFontSize(17)
time.setPenColor(blue)

S.animate {
    val t = S.time - t0
    val v = u + a*t
    val s = u*t + 0.5*a*S.sq(t)
    car.setPosition(s, 25)
    splot.lineTo(t*50, s)
    vplot.lineTo(t*50, v)
    time.setContent("Time: %.3f seconds" format(t))
}

The sprite image for the car in the animation is included below. You need to save the image on your computer, and then point to it from within the animation script (above) to get the desired effect.

  • Support for basic mouse and keyboard handling for Staging shapes.

As always, the new version is available on the Kojo Download Page.

Advertisements
This entry was posted in News, Release. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s