Skip to content

Commit

Permalink
modificações das classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiagodemas committed Dec 9, 2017
1 parent 3b270a2 commit a095036
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 73 deletions.
Binary file added .cache-main
Binary file not shown.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Jerimum - Scala Game Library

Scala Game Library is a library for developing 2D video games in Scala.
4 changes: 2 additions & 2 deletions src/exemplo/CataEstrela.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import jerimum._
import scala.util.Random

object CataEstrela extends App {

/*
case class Jogador(var x: Double, var y: Double) {
val imagem = Imagem("Nave.png")
var placar = 0
Expand Down Expand Up @@ -130,4 +130,4 @@ object CataEstrela extends App {
def atualize_fim() = {}
jogo.iniciar("Cata Estrelas", 640, 480, atualize, desenhe)
}
*/}
100 changes: 50 additions & 50 deletions src/jerimum/Keyboard.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package jerimum
import java.awt.event.{ KeyEvent, KeyListener }


object Teclado extends KeyListener with TecladoLetras {
protected[this] val teclas = new Array[Boolean](256)
object Keyboard extends KeyListener with LettersKeyboard {
protected[this] val keyboardKey = new Array[Boolean](256)

private[this] def update(e: KeyEvent, valor: Boolean) = {
private[this] def update(e: KeyEvent, value: Boolean) = {
val cod = e.getKeyCode()
if (cod >= 0 && cod < teclas.length)
teclas(cod) = valor
if (cod >= 0 && cod < keyboardKey.length)
keyboardKey(cod) = value
}

override def keyPressed(e: KeyEvent) = this(e) = true
Expand All @@ -19,50 +19,50 @@ object Teclado extends KeyListener with TecladoLetras {
override def keyTyped(e: KeyEvent) = {}
}

trait TecladoLetras {
protected[this] val teclas: Array[Boolean]
trait LettersKeyboard {
protected[this] val keyboardKey: Array[Boolean]
import java.awt.event.KeyEvent._
def TECLA_A: Boolean = teclas(VK_A)
def TECLA_B: Boolean = teclas(VK_B)
def TECLA_C: Boolean = teclas(VK_C)
def TECLA_D: Boolean = teclas(VK_D)
def TECLA_E: Boolean = teclas(VK_E)
def TECLA_F: Boolean = teclas(VK_F)
def TECLA_G: Boolean = teclas(VK_G)
def TECLA_H: Boolean = teclas(VK_H)
def TECLA_I: Boolean = teclas(VK_I)
def TECLA_J: Boolean = teclas(VK_J)
def TECLA_K: Boolean = teclas(VK_K)
def TECLA_L: Boolean = teclas(VK_L)
def TECLA_M: Boolean = teclas(VK_M)
def TECLA_N: Boolean = teclas(VK_N)
def TECLA_O: Boolean = teclas(VK_O)
def TECLA_P: Boolean = teclas(VK_P)
def TECLA_Q: Boolean = teclas(VK_Q)
def TECLA_R: Boolean = teclas(VK_R)
def TECLA_S: Boolean = teclas(VK_S)
def TECLA_T: Boolean = teclas(VK_T)
def TECLA_U: Boolean = teclas(VK_U)
def TECLA_V: Boolean = teclas(VK_V)
def TECLA_W: Boolean = teclas(VK_W)
def TECLA_X: Boolean = teclas(VK_X)
def TECLA_Y: Boolean = teclas(VK_Y)
def TECLA_Z: Boolean = teclas(VK_Z)
def TECLA_0: Boolean = teclas(VK_0)
def TECLA_1: Boolean = teclas(VK_1)
def TECLA_2: Boolean = teclas(VK_2)
def TECLA_3: Boolean = teclas(VK_3)
def TECLA_4: Boolean = teclas(VK_4)
def TECLA_5: Boolean = teclas(VK_5)
def TECLA_6: Boolean = teclas(VK_6)
def TECLA_7: Boolean = teclas(VK_7)
def TECLA_8: Boolean = teclas(VK_8)
def TECLA_9: Boolean = teclas(VK_9)
def TECLA_ESPACO: Boolean = teclas(VK_SPACE)
def TECLA_ESPAÇO: Boolean = TECLA_ESPACO
def TECLA_ENTER: Boolean = teclas(VK_ENTER)
def TECLA_PARA_CIMA: Boolean = teclas(VK_UP)
def TECLA_PARA_BAIXO: Boolean = teclas(VK_DOWN)
def TECLA_PARA_ESQUERDA: Boolean = teclas(VK_LEFT)
def TECLA_PARA_DIREITA: Boolean = teclas(VK_RIGHT)
def KEY_A: Boolean = keyboardKey(VK_A)
def KEY_B: Boolean = keyboardKey(VK_B)
def KEY_C: Boolean = keyboardKey(VK_C)
def KEY_D: Boolean = keyboardKey(VK_D)
def KEY_E: Boolean = keyboardKey(VK_E)
def KEY_F: Boolean = keyboardKey(VK_F)
def KEY_G: Boolean = keyboardKey(VK_G)
def KEY_H: Boolean = keyboardKey(VK_H)
def KEY_I: Boolean = keyboardKey(VK_I)
def KEY_J: Boolean = keyboardKey(VK_J)
def KEY_K: Boolean = keyboardKey(VK_K)
def KEY_L: Boolean = keyboardKey(VK_L)
def KEY_M: Boolean = keyboardKey(VK_M)
def KEY_N: Boolean = keyboardKey(VK_N)
def KEY_O: Boolean = keyboardKey(VK_O)
def KEY_P: Boolean = keyboardKey(VK_P)
def KEY_Q: Boolean = keyboardKey(VK_Q)
def KEY_R: Boolean = keyboardKey(VK_R)
def KEY_S: Boolean = keyboardKey(VK_S)
def KEY_T: Boolean = keyboardKey(VK_T)
def KEY_U: Boolean = keyboardKey(VK_U)
def KEY_V: Boolean = keyboardKey(VK_V)
def KEY_W: Boolean = keyboardKey(VK_W)
def KEY_X: Boolean = keyboardKey(VK_X)
def KEY_Y: Boolean = keyboardKey(VK_Y)
def KEY_Z: Boolean = keyboardKey(VK_Z)
def KEY_0: Boolean = keyboardKey(VK_0)
def KEY_1: Boolean = keyboardKey(VK_1)
def KEY_2: Boolean = keyboardKey(VK_2)
def KEY_3: Boolean = keyboardKey(VK_3)
def KEY_4: Boolean = keyboardKey(VK_4)
def KEY_5: Boolean = keyboardKey(VK_5)
def KEY_6: Boolean = keyboardKey(VK_6)
def KEY_7: Boolean = keyboardKey(VK_7)
def KEY_8: Boolean = keyboardKey(VK_8)
def KEY_9: Boolean = keyboardKey(VK_9)
def SPACE_BUTTON: Boolean = keyboardKey(VK_SPACE)
def SPACE: Boolean = SPACE_BUTTON
def ENTER: Boolean = keyboardKey(VK_ENTER)
def UP: Boolean = keyboardKey(VK_UP)
def DOWN: Boolean = keyboardKey(VK_DOWN)
def LEFT: Boolean = keyboardKey(VK_LEFT)
def RIGHT: Boolean = keyboardKey(VK_RIGHT)
}
20 changes: 10 additions & 10 deletions src/jerimum/Mouse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import java.awt.event.{ MouseEvent, MouseListener, MouseMotionListener }


object Mouse extends MouseListener with MouseMotionListener {
private[this] val botoes = new Array[Boolean](4)
private[this] val buttons = new Array[Boolean](4)
private[this] var _x, _y: Int = 0
def BOTAO_ESQUERDO: Boolean = botoes(1)
def BOTAO_DIREITO: Boolean = botoes(3)

private[this] def update(e: MouseEvent, valor: Boolean) = {
val botao = e.getButton()
if (botao == MouseEvent.BUTTON1)
botoes(1) = valor
if (botao == MouseEvent.BUTTON3)
botoes(3) = valor
def LEFT_BUTTON: Boolean = buttons(1)
def RIGHT_BUTTON: Boolean = buttons(3)

private[this] def update(e: MouseEvent, value: Boolean) = {
val button = e.getButton()
if (button == MouseEvent.BUTTON1)
buttons(1) = value
if (button == MouseEvent.BUTTON3)
buttons(3) = value
}

override def mousePressed(e: MouseEvent) = this(e) = true
Expand Down
6 changes: 3 additions & 3 deletions src/jerimum/Screen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import java.awt.{ Canvas, Dimension }

import javax.swing.JFrame

class Tela(var titulo: String, var largura: Int, var altura: Int) {
private[this] val dim = new Dimension(largura, altura)
class Tela(var title: String, var width: Int, var height: Int) {
private[this] val dim = new Dimension(width, height)
val canvas = new Canvas() {
setPreferredSize(dim)
setMaximumSize(dim)
setMinimumSize(dim)
setFocusable(false)
}
val frame = new JFrame(titulo) {
val frame = new JFrame(title) {
setIconImage(Imagem("potigol.png").buffer)
setSize(dim)
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
Expand Down
16 changes: 8 additions & 8 deletions src/jerimum/Sound.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ package jerimum



case class Som(var arquivo: String) {
case class Sound(var file: String) {
def toque: Unit = ()
}

case class Musica(var arquivo: String) {
def toque(loop: Boolean = false): Unit = {
// Musica._musica = this
case class Music(var file: String) {
def touch(loop: Boolean = false): Unit = {
// Music._music = this
}
def tocando: Boolean = false
def pare: Unit = ()
def pause: Unit = ()
def pausado: Boolean = false
}

object Musica {
private var _musica: Option[Musica] = None
def musica_atual: Option[Musica] = _musica
def música_atual = musica_atual
object Music {
private var _music: Option[Music] = None
def current_music: Option[Music] = _music
def current_Music = current_music
}

0 comments on commit a095036

Please sign in to comment.