Skip to content

Commit

Permalink
correções dos erros
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiagodemas committed Dec 21, 2017
1 parent e7cf39d commit c785b45
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 16 deletions.
Binary file modified .cache-main
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
13 changes: 7 additions & 6 deletions src/exemplo/CatchTheStars.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import com.sun.org.apache.bcel.internal.generic.Select
object CatchTheStars extends App {

case class Player(var x: Double, var y: Double) {
val img = Image("Spacecraft.png")
val image = Image("Spacecraft.png")
var score = 0
var vel_x, vel_y = 0.0
var angle = 0.0

def draw() = {
img.centralized_draw(x, y, 3, angle)
image.centralized_draw(x, y, 3, angle)
}

def rotate_right() = {
Expand Down Expand Up @@ -63,15 +63,15 @@ object CatchTheStars extends App {

def draw() = {
val image = images((Clock.milisegundos / 100 + i) % images.size)
image.centralized_draw(x, y, 1) //PROBLEMA N IDENTIFICADO
image.centralized_draw(x, y, 1)

}
}

val background = Image("Space.png")
val spacecraft = Player(game.width / 2, game.height / 2)
var time = 0.0
var stars = List(0, Star())
var stars = List[Star]()
var state = "START"
val font = Fonts(16)

Expand All @@ -85,6 +85,7 @@ object CatchTheStars extends App {

def draw() = {
background.draw(0, 0, 0)
println("Desenhando")
state match {
case "START" => update_start
case "PLAYING" => update_playing
Expand Down Expand Up @@ -114,7 +115,7 @@ object CatchTheStars extends App {
stars = Star() :: stars
}

stars = spacecraft.catch_the_stars(stars) // Catch the stars //PROBLEMA N IDENTIFICADO
stars = spacecraft.catch_the_stars(stars) // Catch the stars
spacecraft.move // update player position
time = time + 1.0 / 60.0 // increase time
if (time.intValue() >= 30) {
Expand All @@ -125,7 +126,7 @@ object CatchTheStars extends App {
def draw_player() = {
spacecraft.draw
for (star <- stars) {
star.draw //PROBLEMA N IDENTIFICADO
star.draw

}
font.draw(s"Placar: ${spacecraft.score}", 10, 20, 3, ColorF.YELLOW)
Expand Down
2 changes: 1 addition & 1 deletion src/jerimum/Drawing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.awt.{ Graphics2D, RenderingHints }
import scala.collection.SortedMap


object Draw {
object Drawing {
private[this] val empty = SortedMap[Int, List[Graphics2D => Unit]]()
private[this] var layers = empty
private[this] def all = layers.values.flatten
Expand Down
4 changes: 2 additions & 2 deletions src/jerimum/Fonts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ case class Fonts(size: Int) {
private[this] val font = new Font("Dialog", Font.BOLD, size);

def draw_centered(msg: String, x: Double, y: Double, z: Int, c: ColorF) = {
Draw.include(z, g => {
Drawing.include(z, g => {
g.setColor(c.color)
g.setFont(font)
val width = g.getFontMetrics.stringWidth(msg)
Expand All @@ -22,7 +22,7 @@ case class Fonts(size: Int) {
}

def draw(msg: String, x: Double, y: Double, z: Int, c: ColorF) = {
Draw.include(z, g => {
Drawing.include(z, g => {
g.setColor(c.color)
g.setFont(font)
g.drawString(msg, x.toInt, y.toInt)
Expand Down
8 changes: 4 additions & 4 deletions src/jerimum/Game.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object Game extends Runnable {
private[this] var running = false
private[this] var thread: Thread = _

private[this] var draw, update = () => {}
private[this] var dwg, update = () => {}

private[this] def init() = {
display = new Screen(title, width, height) {
Expand All @@ -33,7 +33,7 @@ object Game extends Runnable {
case Some(strategy) => strategy.getDrawGraphics match {
case g: Graphics2D =>
g.clearRect(0, 0, width, height)
Draw.draw(g)
Drawing.draw(g)
strategy.show
g.dispose()
}
Expand All @@ -54,7 +54,7 @@ object Game extends Runnable {
last = now
if (delta >= 1) {
update()
drawing()
dwg()
drawing()
cycles += 1
delta -= 1
Expand All @@ -75,7 +75,7 @@ object Game extends Runnable {
this.height = height
this.fps = fps
this.update = update _
this.draw = draw _
this.dwg = draw _
if (!running) {
running = true
thread = new Thread(this) {
Expand Down
6 changes: 3 additions & 3 deletions src/jerimum/Image.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object Image {
lists(id) = list.toList
lists(id)
})
List(l)
l
}
}

Expand All @@ -62,7 +62,7 @@ class Image(val buffer: BufferedImage, val road: String = "") {
Image.lists(id) = list.toList
Image.lists(id)
})
List(l)
l
}

private[this] def spin(g: Graphics2D, angle: Double, x: Double, y: Double, scalaX: Double, scalaY: Double)(draw: => Unit): Unit = {
Expand All @@ -73,7 +73,7 @@ class Image(val buffer: BufferedImage, val road: String = "") {
}

def draw(x: Double, y: Double, z: Int, angle: Double = 0.0, scalaX: Double = 1.0, scalaY: Double = 1.0): Unit = {
Draw.include(z, g => {
Drawing.include(z, g => {
spin(g, angle, x, y, scalaX, scalaY) {
val width = (buffer.getWidth * scalaX).toInt
val height = (buffer.getHeight * scalaY).toInt
Expand Down

0 comments on commit c785b45

Please sign in to comment.