Skip to content

Commit

Permalink
drawing spacecraft
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiagodemas committed Dec 22, 2017
1 parent c785b45 commit ebc4c0f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Binary file modified .cache-main
Binary file not shown.
23 changes: 14 additions & 9 deletions src/exemplo/CatchTheStars.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import scala.util.Random
import java.awt.Color
import java.util.Random;
import scala.util.Random;
import com.sun.org.apache.bcel.internal.generic.Select
import com.sun.org.apache.bcel.internal.generic.Select
import sun.applet.resources.MsgAppletViewer_pt_BR


object CatchTheStars extends App {
Expand Down Expand Up @@ -37,8 +38,8 @@ object CatchTheStars extends App {
y = y + vel_y
x = (game.width + x) % game.width
y = (game.height + y) % game.height
vel_x = vel_x * 0.95
vel_y = vel_y * 0.95
vel_x = vel_x * 0.65
vel_y = vel_y * 0.65
}

def catch_the_stars(stars: List[Star]) = {
Expand Down Expand Up @@ -85,7 +86,8 @@ object CatchTheStars extends App {

def draw() = {
background.draw(0, 0, 0)
println("Desenhando")
spacecraft.draw()

state match {
case "START" => update_start
case "PLAYING" => update_playing
Expand All @@ -96,17 +98,19 @@ object CatchTheStars extends App {
// State start
def update_start() = {
if (Keyboard.KEY_I) state = "PLAYING"

}

def draw_start() = {

val msg = "PRESS [I] TO GET STARTED"
font.draw_centered(msg, game.width / 2, game.height / 2, 3, ColorF.YELLOW)
}

// State Player
def update_playing() = {
val r = scala.util.Random
// eventos

if (Keyboard.RIGHT) spacecraft.rotate_right
if (Keyboard.LEFT) spacecraft.rotate_left
if (Keyboard.UP) spacecraft.accelerate
Expand All @@ -124,9 +128,10 @@ object CatchTheStars extends App {
}

def draw_player() = {
spacecraft.draw
spacecraft.draw()

for (star <- stars) {
star.draw
star.draw()

}
font.draw(s"Placar: ${spacecraft.score}", 10, 20, 3, ColorF.YELLOW)
Expand All @@ -141,7 +146,7 @@ object CatchTheStars extends App {

def update_end() = {}

game.start("Catch the Stars", 640, 480, update, draw)

game.start("Catch the Stars", 640, 480, update(), draw())

}
2 changes: 1 addition & 1 deletion src/jerimum/Game.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object Game extends Runnable {
stop()
}

def start(title: String = "Potigol com Jerimum", width: Int = 640,
def start(title: String = "Potigol with Jerimum", width: Int = 640,
height: Int = 480, update: => Unit = {},
draw: => Unit = {}, fps: Int = 60) = synchronized {
this.title = title
Expand Down

0 comments on commit ebc4c0f

Please sign in to comment.