mirror of
https://gitlab.com/cc-ru/ocelot/ocelot-desktop.git
synced 2025-12-20 02:59:19 +01:00
Having fun
This commit is contained in:
parent
23bcbd6f19
commit
349f99283e
@ -1 +1 @@
|
|||||||
Subproject commit 795cd61fe8232761712bf58fd515c94e578b35d1
|
Subproject commit 48b35103e17eb1d2eba79a7f9a788d58d7ecf68a
|
||||||
@ -9,7 +9,7 @@ import org.apache.logging.log4j.LogManager
|
|||||||
import org.apache.logging.log4j.scala.Logging
|
import org.apache.logging.log4j.scala.Logging
|
||||||
import org.lwjgl.Version
|
import org.lwjgl.Version
|
||||||
import totoro.ocelot.brain.Ocelot
|
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.event._
|
||||||
import totoro.ocelot.brain.loot.Loot
|
import totoro.ocelot.brain.loot.Loot
|
||||||
import totoro.ocelot.brain.network.Network
|
import totoro.ocelot.brain.network.Network
|
||||||
@ -72,18 +72,19 @@ object OcelotDesktop extends Logging {
|
|||||||
val network = new Network()
|
val network = new Network()
|
||||||
|
|
||||||
val cable = new Cable()
|
val cable = new Cable()
|
||||||
|
|
||||||
network.connect(cable)
|
network.connect(cable)
|
||||||
|
|
||||||
computer = new Case(Tier.Four)
|
computer = new Case(Tier.Six)
|
||||||
|
|
||||||
cable.connect(computer)
|
cable.connect(computer)
|
||||||
|
|
||||||
val cpu = new APU(Tier.Two)
|
computer.add(new CPU(Tier.Three))
|
||||||
computer.add(cpu)
|
computer.add(new GraphicsCard(Tier.Three))
|
||||||
|
computer.add(new InternetCard)
|
||||||
val memory = new Memory(Tier.Six)
|
computer.add(new Memory(Tier.Six))
|
||||||
computer.add(memory)
|
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.AdvLoaderEEPROM.create())
|
||||||
computer.add(Loot.OpenOsFloppy.create())
|
computer.add(Loot.OpenOsFloppy.create())
|
||||||
|
|||||||
@ -18,7 +18,7 @@ object KeyHandler extends Logging {
|
|||||||
def handleKey(window: Long, key: Int, scancode: Int, action: Int, mods: Int): Unit = {
|
def handleKey(window: Long, key: Int, scancode: Int, action: Int, mods: Int): Unit = {
|
||||||
val state = KeyEvent.State(action)
|
val state = KeyEvent.State(action)
|
||||||
val code = KeyMapping.map(key)
|
val code = KeyMapping.map(key)
|
||||||
val char = charMap.getOrElse(code, '\0')
|
val char = charMap.getOrElse(code, KeyMapping.mapChar(key))
|
||||||
|
|
||||||
events += KeyEvent(state, code, char)
|
events += KeyEvent(state, code, char)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 = {
|
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 (sx <- x until x + w) {
|
||||||
for (sy <- y until y + h) {
|
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) {
|
if (nx >= 0 && nx < width && ny >= 0 && ny < height) {
|
||||||
val src = dataClone(sy * width + sx)
|
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.char = src.char
|
||||||
dst.bg = src.bg
|
dst.bg = src.bg
|
||||||
|
|||||||
@ -16,6 +16,7 @@ class FPSCalculator {
|
|||||||
if (currentTime - prevTime > 1000) {
|
if (currentTime - prevTime > 1000) {
|
||||||
val delta = currentTime - prevTime
|
val delta = currentTime - prevTime
|
||||||
prevTime = currentTime
|
prevTime = currentTime
|
||||||
|
numFrames = 0
|
||||||
_fps = numFrames.asInstanceOf[Float] / delta * 1000f
|
_fps = numFrames.asInstanceOf[Float] / delta * 1000f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,13 @@ package ocelot.desktop.util
|
|||||||
import org.lwjgl.glfw.GLFW
|
import org.lwjgl.glfw.GLFW
|
||||||
|
|
||||||
object KeyMapping {
|
object KeyMapping {
|
||||||
|
def mapChar(code: Int): Char = {
|
||||||
|
code match {
|
||||||
|
case GLFW.GLFW_KEY_ENTER => 13
|
||||||
|
case _ => '\0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def map(code: Int): Int = {
|
def map(code: Int): Int = {
|
||||||
code match {
|
code match {
|
||||||
case GLFW.GLFW_KEY_ESCAPE => 1
|
case GLFW.GLFW_KEY_ESCAPE => 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user