Skip to content

Commit 5f1dbe2

Browse files
committed
Add visual debugging information
- Restore some deleted css - Restyle a bit - Add Morpheus
1 parent 083cd1d commit 5f1dbe2

File tree

6 files changed

+297
-64
lines changed

6 files changed

+297
-64
lines changed

assets/css/app.scss

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,92 @@
1+
/* This file is for your main application css. */
2+
@import "./phoenix.css";
13
@import "./tile_map.scss";
24
@import "../node_modules/nprogress/nprogress.css";
5+
6+
/* LiveView specific classes for your customizations */
7+
.phx-no-feedback.invalid-feedback,
8+
.phx-no-feedback .invalid-feedback {
9+
display: none;
10+
}
11+
12+
.phx-click-loading {
13+
opacity: 0.5;
14+
transition: opacity 1s ease-out;
15+
}
16+
17+
.phx-disconnected{
18+
cursor: wait;
19+
}
20+
.phx-disconnected *{
21+
pointer-events: none;
22+
}
23+
24+
.phx-modal {
25+
opacity: 1!important;
26+
position: fixed;
27+
z-index: 1;
28+
left: 0;
29+
top: 0;
30+
width: 100%;
31+
height: 100%;
32+
overflow: auto;
33+
background-color: rgb(0,0,0);
34+
background-color: rgba(0,0,0,0.4);
35+
}
36+
37+
.phx-modal-content {
38+
background-color: #fefefe;
39+
margin: 15% auto;
40+
padding: 20px;
41+
border: 1px solid #888;
42+
width: 80%;
43+
}
44+
45+
.phx-modal-close {
46+
color: #aaa;
47+
float: right;
48+
font-size: 28px;
49+
font-weight: bold;
50+
}
51+
52+
.phx-modal-close:hover,
53+
.phx-modal-close:focus {
54+
color: black;
55+
text-decoration: none;
56+
cursor: pointer;
57+
}
58+
59+
60+
/* Alerts and form errors */
61+
.alert {
62+
padding: 15px;
63+
margin-bottom: 20px;
64+
border: 1px solid transparent;
65+
border-radius: 4px;
66+
}
67+
.alert-info {
68+
color: #31708f;
69+
background-color: #d9edf7;
70+
border-color: #bce8f1;
71+
}
72+
.alert-warning {
73+
color: #8a6d3b;
74+
background-color: #fcf8e3;
75+
border-color: #faebcc;
76+
}
77+
.alert-danger {
78+
color: #a94442;
79+
background-color: #f2dede;
80+
border-color: #ebccd1;
81+
}
82+
.alert p {
83+
margin-bottom: 0;
84+
}
85+
.alert:empty {
86+
display: none;
87+
}
88+
.invalid-feedback {
89+
color: #a94442;
90+
display: block;
91+
margin: -1rem 0 2rem;
92+
}

assets/css/tile_map.scss

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1+
body {
2+
font-family: sans-serif;
3+
}
4+
15
* {
26
margin: 0;
37
padding: 0;
48
}
59

10+
h1 {
11+
margin: 1em;
12+
text-align: center;
13+
}
14+
615
div.tilemap-container {
716
display: flex;
8-
9-
& div.tile_map {
10-
}
11-
12-
& div.toolbar {
13-
}
17+
flex-flow: row nowrap;
18+
width: 100%;
1419
}
1520

1621
div.tile_map {
@@ -28,7 +33,8 @@ div.tile_map {
2833
height: 64px;
2934
display: table-cell;
3035

31-
border: 1px solid lightgrey;
36+
outline: 1px solid lightgrey;
37+
outline-offset: -1px;
3238
border-collapse: collapse;
3339

3440
img, div {
@@ -42,11 +48,11 @@ div.tile_map {
4248
color: white;
4349

4450
// FIXME
45-
display: none;
51+
// display: none;
4652
}
4753

4854
&.tile-clear {
49-
background-color: #c2b280;
55+
background-color: white;
5056
cursor: pointer;
5157
}
5258

@@ -55,7 +61,7 @@ div.tile_map {
5561
cursor: not-allowed;
5662
}
5763

58-
div.entity, div.target {
64+
div.entity, div.target, div.open_list {
5965
width: 64px;
6066
height: 64px;
6167
// display: inline-block;
@@ -70,5 +76,61 @@ div.tile_map {
7076

7177
}
7278
}
79+
80+
div.open_list {
81+
background-color: lightblue;
82+
}
83+
84+
div.closed_list {
85+
background-color: orange;
86+
}
87+
88+
div.info-container {
89+
display: flex;
90+
flex-flow: row wrap;
91+
justify-content: space-evenly;
92+
93+
span.span-g {
94+
width: 50%;
95+
text-align: left;
96+
}
97+
98+
span.span-h {
99+
width: 50%;
100+
text-align: right;
101+
}
102+
103+
span.span-f {
104+
font-size: 1.4em;
105+
}
106+
}
107+
}
108+
}
109+
110+
div.toolbar {
111+
flex: auto;
112+
113+
display: flex;
114+
flex-flow: column wrap;
115+
justify-content: space-around;
116+
117+
button {
118+
padding: 1em;
119+
font-size: 1.4em;
120+
cursor: pointer;
121+
}
122+
123+
img.morpheus {
124+
max-width: 300px;
125+
margin: auto;
73126
}
74-
}
127+
}
128+
129+
ul.entities-list {
130+
background-color: black;
131+
color: white;
132+
font-family: monospace;
133+
font-size: 1.4em;
134+
padding: 1em;
135+
list-style-type: none;
136+
}

assets/static/images/morpheus.jpg

59.1 KB
Loading

lib/move_your_cedric/models/player.ex

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,51 @@ defmodule MoveYourCedric.Models.Player do
1919
{:ok, state}
2020
end
2121

22-
def handle_call(:get_status, _from, state) do
23-
{:reply, state.status, state}
22+
def update_path(tiles) do
23+
GenServer.cast(__MODULE__, {:update_path, tiles})
24+
end
25+
26+
def walk_path() do
27+
GenServer.cast(__MODULE__, :walk_path)
28+
end
29+
30+
def get_path() do
31+
GenServer.call(__MODULE__, :get_path)
32+
end
33+
34+
def get_position() do
35+
GenServer.call(__MODULE__, :get_position)
36+
end
37+
38+
def get_status() do
39+
GenServer.call(__MODULE__, :get_status)
40+
end
41+
42+
def get_target() do
43+
GenServer.call(__MODULE__, :get_target)
44+
end
45+
46+
def set_position(position) do
47+
GenServer.cast(__MODULE__, {:set_position, position})
48+
end
49+
50+
def pick_target(position) do
51+
GenServer.cast(__MODULE__, {:pick_target, position})
52+
end
53+
54+
def handle_call(:get_path, _from, state) do
55+
{:reply, state.path, state}
2456
end
2557

2658
def handle_call(:get_position, _from, state) do
2759
{:reply, state.position, state}
2860
end
2961

30-
def handle_call(:get_target, _from, state) do
62+
def handle_call(:get_status, _from, state) do
63+
{:reply, state.status, state}
64+
end
65+
66+
def handle_call(:get_target, _from, state) do
3167
{:reply, state.target, state}
3268
end
3369

@@ -174,11 +210,8 @@ defmodule MoveYourCedric.Models.Player do
174210
def handle_cast(:walk_path, %{path: %{final_path: []}} = state) do
175211
Logger.debug("[PLAYER] Reached destination.")
176212

177-
new_path =
178-
%{state.path | final_path: nil}
179-
180213
state =
181-
%{state | path: new_path,
214+
%{state | path: nil,
182215
position: state.target,
183216
status: :idle,
184217
target: nil}
@@ -200,34 +233,6 @@ defmodule MoveYourCedric.Models.Player do
200233
{:noreply, state}
201234
end
202235

203-
def update_path(tiles) do
204-
GenServer.cast(__MODULE__, {:update_path, tiles})
205-
end
206-
207-
def walk_path() do
208-
GenServer.cast(__MODULE__, :walk_path)
209-
end
210-
211-
def get_status() do
212-
GenServer.call(__MODULE__, :get_status)
213-
end
214-
215-
def get_position() do
216-
GenServer.call(__MODULE__, :get_position)
217-
end
218-
219-
def set_position(position) do
220-
GenServer.cast(__MODULE__, {:set_position, position})
221-
end
222-
223-
def get_target() do
224-
GenServer.call(__MODULE__, :get_target)
225-
end
226-
227-
def pick_target(position) do
228-
GenServer.cast(__MODULE__, {:pick_target, position})
229-
end
230-
231236
defp pick_target([tx, ty] = target, %{position: [tx, ty]} = state) do
232237
%{state | status: :idle, target: target, path: nil}
233238
end

0 commit comments

Comments
 (0)