Skip to content

Commit

Permalink
Inky Isolation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dsrw committed Nov 26, 2023
1 parent af9f01a commit 2c6fd64
Show file tree
Hide file tree
Showing 14 changed files with 124 additions and 53 deletions.
8 changes: 7 additions & 1 deletion src/controllers/script_controllers/host_bridge.nim
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,12 @@ proc tool(self: Unit): int =
proc `tool=`(self: Unit, value: int) =
state.tool = Tools(value)

proc open_sign(self: Unit): Sign =
state.open_sign

proc `open_sign=`(self: Unit, value: Sign) =
state.open_sign = value

# Sign bindings

proc new_markdown_sign(self: Worker,
Expand Down Expand Up @@ -524,4 +530,4 @@ proc bridge_to_vm*(worker: Worker) =

result.bridged_from_vm "players",
playing, `playing=`, god, `god=`, flying, `flying=`, tool, `tool=`,
coding, `coding=`, running, `running=`
coding, `coding=`, running, `running=`, open_sign, `open_sign=`
43 changes: 22 additions & 21 deletions src/game.nim
Original file line number Diff line number Diff line change
Expand Up @@ -360,28 +360,29 @@ Trying to connect to {state.config.connect_address}.
state.set_flag MouseCaptured, MouseCaptured notin state.local_flags
self.get_tree().set_input_as_handled()

if event.is_action_pressed("toggle_code_mode"):
if state.tool != CodeMode:
self.last_tool = state.tool
if state.tool != Disabled:
if event.is_action_pressed("toggle_code_mode"):
if state.tool != CodeMode:
self.last_tool = state.tool
state.tool = CodeMode
else:
state.tool = self.last_tool
elif event.is_action_pressed("mode_1"):
state.tool = CodeMode
else:
state.tool = self.last_tool
elif event.is_action_pressed("mode_1"):
state.tool = CodeMode
elif event.is_action_pressed("mode_2"):
state.tool = BlueBlock
elif event.is_action_pressed("mode_3"):
state.tool = RedBlock
elif event.is_action_pressed("mode_4"):
state.tool = GreenBlock
elif event.is_action_pressed("mode_5"):
state.tool = BlackBlock
elif event.is_action_pressed("mode_6"):
state.tool = WhiteBlock
elif event.is_action_pressed("mode_7"):
state.tool = BrownBlock
elif event.is_action_pressed("mode_8"):
state.tool = PlaceBot
elif event.is_action_pressed("mode_2"):
state.tool = BlueBlock
elif event.is_action_pressed("mode_3"):
state.tool = RedBlock
elif event.is_action_pressed("mode_4"):
state.tool = GreenBlock
elif event.is_action_pressed("mode_5"):
state.tool = BlackBlock
elif event.is_action_pressed("mode_6"):
state.tool = WhiteBlock
elif event.is_action_pressed("mode_7"):
state.tool = BrownBlock
elif event.is_action_pressed("mode_8"):
state.tool = PlaceBot

method on_meta_clicked(url: string) =
if url.starts_with("nim://"):
Expand Down
7 changes: 6 additions & 1 deletion src/models/builds.nim
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ proc remove(self: Build) =

proc fire(self: Build) =
let global_point = self.target_point.global_from(self)
if state.tool notin {CodeMode, PlaceBot}:
if state.tool notin {Disabled, CodeMode, PlaceBot}:
state.skip_block_paint = true
draw_normal = self.target_normal
let point = (self.target_point + (self.target_normal * 0.5)).floor
Expand Down Expand Up @@ -446,6 +446,11 @@ method main_thread_joined*(self: Build) =
if PrimaryDown.removed or SecondaryDown.removed:
state.draw_unit_id = ""
last_point = vec3()
if Playing.added:
self.local_flags -= Highlight
elif Playing.removed:
if Hover in self.local_flags:
self.local_flags += Highlight

method on_collision*(self: Build, partner: Model, normal: Vector3) =
self.collisions.add (partner.id, normal)
Expand Down
3 changes: 1 addition & 2 deletions src/nodes/player_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,7 @@ gdobj PlayerNode of KinematicBody:
if event.is_action_pressed("fire"):
if EditorVisible in state.local_flags:
self.skip_release = true
if Playing notin state.local_flags:
state.push_flag PrimaryDown
state.push_flag PrimaryDown
elif event.is_action_released("fire"):
self.skip_release = false
state.pop_flag PrimaryDown
Expand Down
2 changes: 1 addition & 1 deletion src/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type

Tools* = enum
CodeMode, BlueBlock, RedBlock, GreenBlock, BlackBlock, WhiteBlock,
BrownBlock, PlaceBot
BrownBlock, PlaceBot, Disabled

TaskStates* = enum
Running, Done, NextTask
Expand Down
5 changes: 4 additions & 1 deletion src/ui/toolbar.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ gdobj Toolbar of HBoxContainer:
state.local_flags.changes:
if Playing.added:
self.visible = false
state.tool = Disabled
if Playing.removed:
self.visible = true
state.tool = BlueBlock

self.zid = state.tool_value.changes:
if added:
let b = self.get_child(int(change.item)) as Button
b.set_pressed true
if ?b:
b.set_pressed true

method process*(delta: float) =
if self.preview_result.is_some:
Expand Down
3 changes: 3 additions & 0 deletions vmlib/enu/players.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ bridged_to_host:

proc coding*(self: PlayerType): Unit = discard
proc `coding=`*(self: PlayerType, value: Unit) = discard

proc open_sign*(self: PlayerType): Sign = discard
proc `open_sign=`*(self: PlayerType, value: Sign) = discard
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0]
],
"origin": [10.0, 0.0, -15.0]
"origin": [10.0, 3.0, -15.0]
},
"start_color": "black",
"edits": {
Expand Down
2 changes: 1 addition & 1 deletion vmlib/worlds/tutorial/tutorial-1/level.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"enu_version": "v0.1.99-190-gd71a4a25",
"enu_version": "v0.1.99-200-gaf9f01a9",
"format_version": "v0.9.2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ If you're not new, here are some other things to do:
a simple game made with Enu. You can see how it was built in
[this video](https://youtu.be/9e9sLsmsu_o).
- [Load CodeBots](<nim://load_level("codebots-1", "codebots")>). `CodeBots` is
an in-progress coding game that
[FrogTower](https://www.youtube.com/@frogtower) is working on.
- [Load default world](<nim://load_level("default-1", "default")>).
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"id": "build_uu8u87ua76wp0",
"start_transform": {
"basis": [
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0]
],
"origin": [-22.0, 0.0, 98.0]
},
"start_color": "black",
"edits": {

}
}
2 changes: 1 addition & 1 deletion vmlib/worlds/tutorial/tutorial-2/level.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"enu_version": "v0.1.99-168-g6dbf6334",
"enu_version": "v0.1.99-200-gaf9f01a9",
"format_version": "v0.9.2"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
turn left
level_menu(me, show_restart = false)
79 changes: 60 additions & 19 deletions vmlib/worlds/tutorial/tutorial-2/scripts/build_zdvcvo11pyd20.nim
Original file line number Diff line number Diff line change
@@ -1,26 +1,67 @@
let copy = """
proc restart* =
player.flying = false
sleep()
player.open_sign = nil
player.position = start_spot
player.rotation = 180

proc stop_playing* =
player.playing = false
player.running = false

# Inky: Isolation
proc level_menu*(me: Build, show_restart = true) =
let blurb = "`Inky: Isolation` is a simple survivial game created in Enu. You can see how it was made in the video [Inky: Isolation. A 90 minute game built with Enu and Nim](https://youtu.be/9e9sLsmsu_o)"

let copy = \"""
`Inky: Isolation` is a simple survivial game created in Enu. You can see how it was made in the video [Inky: Isolation. A 90 minute game built with Enu and Nim](https://youtu.be/9e9sLsmsu_o)
# Inky: Isolation
Click to [RESTART](nim://restart())
{blurb}
"""
right 3
- CLICK TO OPEN MENU
var sign1 = say(copy, more = copy, width = 4, height = 2, size = 200)
up 1
left 3
turn 180
down 1
"""

me.right 3

var sign2 = say(copy, more = copy, width = 4, height = 2, size = 200)
left 3
let sign1 = me.say(copy, width = 4, height = 2, size = 200)
me.up 1
me.left 3
me.turn 180
me.down 1

let sign2 = me.say(copy, width = 4, height = 2, size = 200)
me.left 3

forever:
let return_action = if show_restart:
"- [RETURN TO START](<nim://restart()>)"
else:
""

let toolbar_action = if player.playing:
"- [SHOW TOOLBAR AND STOP PLAYING](<nim://player.playing = false;player.running = false;player.open_sign = nil>)"
else:
""

let more = \"""
# Menu
{blurb}
{toolbar_action}
{return_action}
- [LOAD TUTORIAL](<nim://load_level("tutorial-1", "tutorial")>)
- [CLEAR CHANGES AND RESET LEVEL](<nim://reset_level()>)
"""
sign1.more = more
sign2.more = more
sleep 1

level_menu(me)

proc restart =
sign1.open = false
sign2.open = false
player.position = start_spot
player.rotation = 180
player.playing = true

0 comments on commit 2c6fd64

Please sign in to comment.