Added NPCs that the hero can collide with and started planning on how to make them scriptable
This commit is contained in:
parent
1b6a4fac03
commit
94f12b5676
@ -14,9 +14,9 @@ object CharSet {
|
||||
val palette = new Palette(new FileInputStream(file), na, nd)
|
||||
val x = index % NumAcross
|
||||
val y = index / NumAcross
|
||||
val xx = x * NumAcross
|
||||
val xx = x * FramesPerPose + 1
|
||||
def pose(i: Int): AnimatedImage = {
|
||||
val yy = y * NumDown + i
|
||||
val yy = y * Poses.size + i
|
||||
val images = IndexedSeq(palette(xx, yy), palette(xx - 1, yy), palette(xx, yy), palette(xx + 1, yy))
|
||||
new AnimatedImage(images)
|
||||
}
|
||||
|
5
FakeMon/src/fmon/script/Action.scala
Normal file
5
FakeMon/src/fmon/script/Action.scala
Normal file
@ -0,0 +1,5 @@
|
||||
package fmon.script
|
||||
|
||||
trait Action[A] {
|
||||
def apply(env: A): Unit
|
||||
}
|
5
FakeMon/src/fmon/script/Condition.scala
Normal file
5
FakeMon/src/fmon/script/Condition.scala
Normal file
@ -0,0 +1,5 @@
|
||||
package fmon.script
|
||||
|
||||
trait Condition[A] {
|
||||
def apply(t: A): Boolean
|
||||
}
|
7
FakeMon/src/fmon/script/condition/AndCondition.scala
Normal file
7
FakeMon/src/fmon/script/condition/AndCondition.scala
Normal file
@ -0,0 +1,7 @@
|
||||
package fmon.script.condition
|
||||
|
||||
import fmon.script.Condition
|
||||
|
||||
class AndCondition[A](seq: Seq[Condition[A]]) extends Condition[A] {
|
||||
def apply(env: A): Boolean = seq.forall(_(env))
|
||||
}
|
7
FakeMon/src/fmon/script/condition/OrCondition.scala
Normal file
7
FakeMon/src/fmon/script/condition/OrCondition.scala
Normal file
@ -0,0 +1,7 @@
|
||||
package fmon.script.condition
|
||||
|
||||
import fmon.script.Condition
|
||||
|
||||
class OrCondition[A](seq: Seq[Condition[A]]) extends Condition[A] {
|
||||
def apply(env: A): Boolean = seq.exists(_(env))
|
||||
}
|
23
FakeMon/src/fmon/world/EventPage.scala
Normal file
23
FakeMon/src/fmon/world/EventPage.scala
Normal file
@ -0,0 +1,23 @@
|
||||
package fmon.world
|
||||
|
||||
class EventPage {
|
||||
// Conditions
|
||||
// Switch
|
||||
// Variable
|
||||
// Self-Switch
|
||||
// Item
|
||||
// Actor
|
||||
// Graphic
|
||||
// Priority - Above or below
|
||||
// Trigger - Action button / On contact
|
||||
// Movement
|
||||
// Type
|
||||
// Speed
|
||||
// Frequency
|
||||
// Options
|
||||
// Walking Animation
|
||||
// Stepping Animation
|
||||
// Direction Fix
|
||||
// Pass through (no-collide)
|
||||
// Contents (event effects)
|
||||
}
|
6
FakeMon/src/fmon/world/GameEvent.scala
Normal file
6
FakeMon/src/fmon/world/GameEvent.scala
Normal file
@ -0,0 +1,6 @@
|
||||
package fmon.world
|
||||
|
||||
class GameEvent(val name: String, val pages: IndexedSeq[EventPage]) {
|
||||
// Event Name
|
||||
// Event Pages
|
||||
}
|
@ -39,6 +39,9 @@ class GameView {
|
||||
@FXML var characterPane: jfxsl.AnchorPane = _
|
||||
|
||||
var hero: Actor = _
|
||||
var npcs = Seq[Actor]()
|
||||
def actors = hero +: npcs
|
||||
|
||||
var heroImg: AnimatedImageView = _
|
||||
var currDir: Option[Direction] = None
|
||||
|
||||
@ -74,7 +77,18 @@ class GameView {
|
||||
x = hero.x * Config.tileSize
|
||||
y = hero.y * Config.tileSize + Config.yOffset
|
||||
}
|
||||
|
||||
npcs = (0 until 8).map(i =>
|
||||
new Actor(CharSet(new File(heroFile), i), Position(7 + i, 4), new Movement(Direction.Stationary, 0.0))
|
||||
)
|
||||
|
||||
characterPane.children += heroImg
|
||||
val npcImgs = npcs.map(npc => new AnimatedImageView(npc.sprite, new Duration(600)) {
|
||||
x = npc.x * Config.tileSize
|
||||
y = npc.y * Config.tileSize + Config.yOffset
|
||||
})
|
||||
npcImgs.foreach(characterPane.children += _)
|
||||
|
||||
timer.start()
|
||||
}
|
||||
|
||||
@ -124,10 +138,13 @@ class GameView {
|
||||
if (hero.pose != dir.toString()) {
|
||||
hero.pose = dir.toString()
|
||||
} else {
|
||||
val dest = hero.pos + dir
|
||||
val info = level.compositeInfo(hero.pos + dir)
|
||||
val canPass = (dir.x < 0 && info.doesPassEast) || (dir.x > 0 && info.doesPassWest) ||
|
||||
(dir.y < 0 && info.doesPassSouth) || (dir.y > 0 && info.doesPassNorth)
|
||||
if (canPass) {
|
||||
val unoccupied = !actors.exists(a => a.pos == dest && a != hero)
|
||||
|
||||
if (canPass && unoccupied) {
|
||||
hero.pos += dir
|
||||
hero.move = new Movement(dir, 1.0)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user