Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package s1.demo
- import scala.collection.mutable.Queue
- import scala.math._
- import java.awt.Color._
- import java.awt.BasicStroke
- import scala.util.Random
- import o1._
- import o1.gui._
- case class Pukki(x: Double, y: Double) {
- //Circles do not like being too close to each other.
- // def tooNear(other: Triangle) = math.hypot(this.x - other.x, this.y - other. y) < 5
- }
- object omaLuomus extends Effect(500,500) {
- var last = Pukki(0,250)
- val y1 = (0 until 500).map(_ / 10.0).map(i => sin(i)).toVector
- val x1 = (0 until 500).toVector
- var k = 0
- val random = new Random
- val snowRadius = 5
- private val snowSpeed1 = 5
- private val snowSpeed2 = 10
- private var currentPos = randomLaunchPosition
- def pos = this.currentPos
- private def randomLaunchPosition() = {
- val launchX = snowRadius + 1000 + Random.nextInt(499)
- val launchY = Random.nextInt(400)
- new Pos(launchX, launchY)
- }
- def lumiIsActive = {
- if (pos.x >= -snowRadius) true
- else false
- }
- def lumiApproach() = {
- if (lumiIsActive == true) this.currentPos = this.currentPos.addX(-snowSpeed1)
- else {
- this.currentPos = randomLaunchPosition
- }
- }
- def changeThings() = {
- // Calculate the new coordinates
- val xdiff = x1(k) * 2
- val ydiff = y1(k) * 30
- val x = xdiff
- val y = (250 + ydiff)
- last = new Pukki(x,y)
- k += 1
- if(last.x == 500 || last.y == 500) {
- k = 0
- last = new Pukki(0,250)
- }
- this.lumiApproach
- }
- override def makePic(): Pic = {
- val background = rectangle(this.width, this.height, Black)
- var pic = background
- var paa = (circle(25,White).below(triangle(10,5,Red)))
- pic = paa.against(pic, new Pos(last.x, last.y))
- val lumet1 = Vector(circle(snowRadius, White), circle(snowRadius, White))
- val lumet2 = Vector(circle(snowRadius, Grey), circle(snowRadius, Grey))
- for{lumi <- lumet1
- x <- lumet2 }{
- pic = lumi.against(pic, this.pos)
- pic = x.against(pic,this.pos)
- }
- pic
- }
- override def next = false
- }
Advertisement
Add Comment
Please, Sign In to add comment