Jonathan
(after two lessons)
import com.anysolo.toyGraphics.* fun main() { val wnd = Window(640, 360) val turtle = Turtle(wnd) var turn = 1 repeat(100000) { turtle.forward(turn) turtle.turnRight(241.0) turn++ sleep(2) } }
Billy101
(after two months)
package myapp import com.anysolo.toyGraphics.* import kotlin.random.Random /* * Author: bily 2019 * Left key to go left * right key to go right * space to shoot * Have fun */ fun main () { val wnd = Window(1000, 700, buffered = true, background = Pal16.blue) val keyboard = Keyboard(wnd) var enemyBlockX = Random.nextInt(30, 500) var enemyBlockY = 40 var tankX = 365 val tankY = 665 var bulletX = tankX var bulletY = tankY var bulletSpeed = 0 var stop = false var blockSpeed = 0 var score = 0 while (true) { val gc = Graphics(wnd) gc.clear() gc.color = Pal16.black if (score in 5..10) { blockSpeed = 12 gc.color = Pal16.brightYellow gc.drawRect(wnd.height, wnd.width, wnd.height, wnd.width, fill = true) } if (score >= 10) { blockSpeed = 15 gc.color = Pal16.darkGray gc.drawRect(wnd.height, wnd.width, wnd.height, wnd.width) } // Key codes while (true) { val key = keyboard.getPressedKey() ?: break when (key.code) { KeyCodes.LEFT -> { tankX -= 10 if(!stop) bulletX -= 10 } KeyCodes.RIGHT -> { tankX+=10 if(!stop) bulletX += 10 } KeyCodes.SPACE -> { bulletSpeed = 15 stop = true } 'R'.toInt() -> { bulletX = tankX bulletY = tankY bulletSpeed = 0 stop = false } } } if (tankX >= wnd.width-1) tankX = 2 if (bulletX >= wnd.width-1) bulletX = 2 if (tankX <= 0) tankX = wnd.width-1 if (bulletX <= 1) bulletX = wnd.width-1 bulletY -= bulletSpeed gc.drawRect(enemyBlockX, enemyBlockY,40,20, fill = true) enemyBlockY += blockSpeed + 10 if(enemyBlockY <= 5) { enemyBlockY = 20 enemyBlockX = Random.nextInt(8, 500) blockSpeed += 1 } //Tank 1 if (enemyBlockY >= wnd.height) break //TANK gc.color = Pal16.brightRed gc.drawRect(tankX,tankY,34,34,fill = true) //bullet gc.color = Pal16.green gc.drawRect(bulletX,bulletY,14,24,fill = true) //bullet stop when reaches the top if (bulletY<=20) { bulletY= tankY stop = false bulletX = tankX bulletSpeed = 0 } // Score board gc.color = Pal16.white gc.drawText(20,300,"Score: $score") if ( enemyBlockX - 40 <= bulletX && enemyBlockY + 40 >= bulletX && enemyBlockY - 20 <= bulletY && enemyBlockY + 20 >= bulletY ) { score += 1 enemyBlockY = -10 } if (score>=5 && enemyBlockY<=5) enemyBlockX = Random.nextInt(8, 500) // End of the frame gc.close() sleep (ms = 80) } }
Hot potato
(after one month)
package students import com.anysolo.toyGraphics.* import kotlin.math.roundToInt fun main() { val wnd = Window(800, 600, buffered = true) var kop=0 var y = 0 var x = 0.0 var yy = 0 var xx = 0.0 var yyy = 0 var xxx = 0.0 var fastY = 0 var fastX = 0 var y1 = 0 var x1 = 0.0 var y2 = 0 var x2 = 0.0 var fast1 = 0 while (true) { val gc = Graphics(wnd) gc.color = Pal16.brown gc.clear() kop += 1 gc.drawRect(x.roundToInt(), y, 50, 50, fill=true) gc.drawRect(xx.roundToInt(), yy, 50, 50, fill=true) gc.drawRect(xxx.roundToInt(), yyy, 50, 50, fill=true) gc.drawRect(x1.roundToInt(), y1, 50, 50, fill=true) gc.drawRect(x2.roundToInt(), y2, 50, 50, fill=true) y += 1 x += 8.0/6 yy += 2 xx += 4.0/6 yyy += 3 xxx += 6.0/6 y1 += fastY x1 += fastX/6 fastY += 1 fastX += 2 y2 += 3 x2 += fast1/6 fast1 += 1 if(y < 0) y += wnd.height else if (y >= wnd.height) y -= wnd.height if(x < 0) x += wnd.width else if (x >= wnd.width) x -= wnd.width if(yy < 0) yy += wnd.height else if (yy >= wnd.height) yy-= wnd.height if(xx < 0) xx += wnd.width else if (xx >= wnd.width) xx -= wnd.width if(yyy < 0) yyy += wnd.height else if (yyy >= wnd.height) yyy -= wnd.height if(xxx < 0) xxx += wnd.width else if (xxx >= wnd.width) xxx -= wnd.width if(y < 0) y += wnd.height else if (y1 >= wnd.height) y1 -= wnd.height if(x1 < 0) x1 += wnd.width else if (x1 >= wnd.width) x1 -= wnd.width if(y2 < 0) y2 += wnd.height else if (y >= wnd.height) y2 -= wnd.height if(x < 0) x2 += wnd.width else if (x >= wnd.width) x2 -= wnd.width gc.close() sleep(20) } }
Hot potato
(after one lesson)
import com.anysolo.toyGraphics.* fun main() { println("remote") var taco = 15.0 val wnd = Window(800, 1000) val turtle = Turtle(wnd) var shell = 15.0 val tacostand = Turtle(wnd) var pizza = 15.0 val potato = Turtle(wnd) val dirty = Turtle(wnd) var earth = 15.0 val robot = Turtle(wnd) var remote = 15.0 val chinken = Turtle(wnd) var buckit = 15.0 repeat(400) { turtle.forward(shell.toInt()) turtle.turnRight(89.0) shell = shell + 7.5 tacostand.backward(taco.toInt()) tacostand.turnRight(89.0) taco = taco + 7.5 potato.turnLeft(89.0) potato.forward(pizza.toInt()) pizza = pizza + 7.5 dirty.turnLeft(89.0) dirty.backward(earth.toInt()) earth = earth + 7.5 robot.turnRight(79.0) robot.forward(remote.toInt()) remote = remote + 7.5 chinken.turnLeft(79.0) chinken.forward(buckit.toInt()) } }
Timoha
(after one lesson)
import com.anysolo.toyGraphics.* fun main() { val wnd = Window(800, 800) val turtle = Turtle(wnd) repeat(11){ // Draw the first vertical line and return to the starting position turtle.forward(100) turtle.penUp() // pen is up. We are just moving the turtle without drawing anything turtle.backward(100) // Skip 30 to the right and turn up turtle.turnRight(0.0) turtle.forward(30) turtle.turnLeft(30.0) // Draw the second vertical line turtle.penDown() turtle.forward(100) turtle.penUp() turtle.backward(100) // Skip 30 to the right and turn up turtle.turnRight(30.0) turtle.forward(30) turtle.turnLeft(30.0) // Draw the third vertical line turtle.penDown() turtle.forward(100) turtle.penUp() turtle.backward(100) } }

Sanjar
import com.anysolo.toyGraphics.* fun main() { val wnd = Window(800, 800) val turtle = Turtle(wnd) turtle.backward(75) repeat(5) { turtle.forward(150) turtle.turnRight(144.0) } }

Kirill
import com.anysolo.toyGraphics.* fun main() { val wnd = Window(800, 800) val turtle = Turtle(wnd) turtle.turnRight(90.0) repeat(4000){ turtle.forward(122) turtle.turnRight(111.0) } }

King
(7 year old)
import com.anysolo.toyGraphics.* fun main() { val wnd = Window(800, 800) val turtle = Turtle(wnd) turtle.turnLeft(90.0) turtle.forward(300) turtle.turnRight(90.0) turtle.forward(300) turtle.turnRight(90.0) turtle.forward(200) turtle.turnRight(90.0) turtle.forward(200) turtle.turnRight(90.0) turtle.forward(100) turtle.turnRight(90.0) turtle.forward(50) turtle.turnRight(90.0) turtle.forward(40) turtle.turnRight(90.0) turtle.forward(30) turtle.turnRight(90.0) turtle.forward(20) turtle.turnRight(90.0) turtle.forward(10) }

Kisn
import com.anysolo.toyGraphics.* import kotlin.math.roundToInt fun main() { val wnd = Window(800, 600, background = Pal16.black) val g = Graphics(wnd) var lineCount = 0 var colorId = 1 var x = 0.0 while (x < wnd.width) { val y = x * 0.8 x += 2.0 lineCount++ if(lineCount % 20 == 0) { colorId++ if (colorId == 16) break } g.color = Pal16[colorId] g.drawLine(0, y.roundToInt(), x.roundToInt(), wnd.height - y.roundToInt()) } }
