Having fun

This commit is contained in:
LeshaInc 2019-01-09 19:42:17 +02:00
parent 23bcbd6f19
commit 349f99283e
No known key found for this signature in database
GPG Key ID: B4855290FC36DE72
6 changed files with 23 additions and 14 deletions

@ -1 +1 @@
Subproject commit 795cd61fe8232761712bf58fd515c94e578b35d1
Subproject commit 48b35103e17eb1d2eba79a7f9a788d58d7ecf68a

View File

@ -9,7 +9,7 @@ import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.scala.Logging
import org.lwjgl.Version
import totoro.ocelot.brain.Ocelot
import totoro.ocelot.brain.entity.{APU, Cable, Case, Keyboard, Memory, Screen}
import totoro.ocelot.brain.entity.{APU, CPU, Cable, Case, GraphicsCard, HardDiskDrive, InternetCard, Keyboard, Memory, Screen}
import totoro.ocelot.brain.event._
import totoro.ocelot.brain.loot.Loot
import totoro.ocelot.brain.network.Network
@ -72,18 +72,19 @@ object OcelotDesktop extends Logging {
val network = new Network()
val cable = new Cable()
network.connect(cable)
computer = new Case(Tier.Four)
computer = new Case(Tier.Six)
cable.connect(computer)
val cpu = new APU(Tier.Two)
computer.add(cpu)
val memory = new Memory(Tier.Six)
computer.add(memory)
computer.add(new CPU(Tier.Three))
computer.add(new GraphicsCard(Tier.Three))
computer.add(new InternetCard)
computer.add(new Memory(Tier.Six))
computer.add(new Memory(Tier.Six))
computer.add(new Memory(Tier.Six))
computer.add(new Memory(Tier.Six))
computer.add(new HardDiskDrive(Tier.Three, "hello"))
computer.add(Loot.AdvLoaderEEPROM.create())
computer.add(Loot.OpenOsFloppy.create())
@ -132,4 +133,4 @@ object OcelotDesktop extends Logging {
screenWidget.setResolution(event.width, event.height)
})
}
}
}

View File

@ -18,7 +18,7 @@ object KeyHandler extends Logging {
def handleKey(window: Long, key: Int, scancode: Int, action: Int, mods: Int): Unit = {
val state = KeyEvent.State(action)
val code = KeyMapping.map(key)
val char = charMap.getOrElse(code, '\0')
val char = charMap.getOrElse(code, KeyMapping.mapChar(key))
events += KeyEvent(state, code, char)
}

View File

@ -118,7 +118,7 @@ class ScreenWidget(screen: Screen) extends RootWidget with Logging {
}
def copy(x: Int, y: Int, w: Int, h: Int, tx: Int, ty: Int): Unit = {
val dataClone = data.clone
val dataClone = data.map(_.copy())
for (sx <- x until x + w) {
for (sy <- y until y + h) {
@ -127,7 +127,7 @@ class ScreenWidget(screen: Screen) extends RootWidget with Logging {
if (nx >= 0 && nx < width && ny >= 0 && ny < height) {
val src = dataClone(sy * width + sx)
val dst = data((sy + ty) * width + sx + tx)
val dst = data(ny * width + nx)
dst.char = src.char
dst.bg = src.bg

View File

@ -16,6 +16,7 @@ class FPSCalculator {
if (currentTime - prevTime > 1000) {
val delta = currentTime - prevTime
prevTime = currentTime
numFrames = 0
_fps = numFrames.asInstanceOf[Float] / delta * 1000f
}
}

View File

@ -3,6 +3,13 @@ package ocelot.desktop.util
import org.lwjgl.glfw.GLFW
object KeyMapping {
def mapChar(code: Int): Char = {
code match {
case GLFW.GLFW_KEY_ENTER => 13
case _ => '\0'
}
}
def map(code: Int): Int = {
code match {
case GLFW.GLFW_KEY_ESCAPE => 1