Commit c2b7b449 authored by neosam's avatar neosam
Browse files

Merge branch 'rahix/wip' into 'master'

Random fixes and improvements

Closes #27

See merge request !34
parents 0001f127 c94d3c88
use crate::utils;
pub struct Clock {
perf: web_sys::Performance,
start: f64,
last_tick: f64,
frame_delta: f32,
pub max_delta: f32,
......@@ -10,16 +6,9 @@ pub struct Clock {
impl Clock {
pub fn new() -> Clock {
let perf = utils::window()
.performance()
.expect("cannot access `window.performance`");
let start = perf.now();
Clock {
perf,
start,
frame_delta: 0.03,
last_tick: start,
last_tick: 0.0,
max_delta: 0.1,
}
}
......@@ -35,6 +24,6 @@ impl Clock {
}
pub fn wall_time(&self) -> f64 {
(self.perf.now() - self.start) / 1000.0
self.last_tick
}
}
......@@ -30,9 +30,15 @@ impl HeavenState {
utils::get_element_by_id::<web_sys::Element>("heaven-collected-hours")
.unwrap()
.set_inner_html(&format!("{}", player.collected_hours));
if player.collected_hours < 30 {
utils::get_element_by_id::<web_sys::Element>("heaven-needed-hours")
.unwrap()
.set_inner_html(&format!("{}", 30 - player.collected_hours));
} else {
utils::get_element_by_id::<web_sys::Element>("heaven-needed-hours")
.unwrap()
.set_inner_html("None!");
}
// Assign a random shift
let assigned_shift = angel_shifts::generate_random_shift(&mut rand::thread_rng());
......@@ -77,7 +83,12 @@ impl gamestate::State for HeavenState {
.unwrap();
}
fn update(&mut self, _timestamp: f64) -> gamestate::Transition {
fn update(&mut self, timestamp: f64) -> gamestate::Transition {
self.resources
.get_mut::<resources::Clock>()
.unwrap()
.update(timestamp);
{
let rendering = self.resources.get_mut::<resources::Rendering>().unwrap();
rendering.set_fill_style(&colors::BACKGROUND);
......
......@@ -72,7 +72,12 @@ impl gamestate::State for LevelLoadingState {
gamestate::Transition::Loop
}
fn update(&mut self, _timestamp: f64) -> gamestate::Transition {
fn update(&mut self, timestamp: f64) -> gamestate::Transition {
self.resources
.get_mut::<resources::Clock>()
.unwrap()
.update(timestamp);
{
let rendering = self.resources.get_mut::<resources::Rendering>().unwrap();
rendering.set_fill_style(&colors::BACKGROUND);
......
......@@ -732,12 +732,12 @@
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:1.25;font-family:monospace;-inkscape-font-specification:monospace;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none"
x="480.39224"
x="500.39224"
y="2399.9924"
id="text1132"><tspan
sodipodi:role="line"
id="tspan1130"
x="480.39224"
x="500.39224"
y="2399.9924">bottledrop</tspan></text>
<text
xml:space="preserve"
......@@ -803,12 +803,12 @@
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:1.25;font-family:monospace;-inkscape-font-specification:monospace;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none"
x="648.68817"
y="3274.4141"
y="3270.4141"
id="text1160"><tspan
sodipodi:role="line"
id="tspan1158"
x="648.68817"
y="3274.4141">bottledrop</tspan></text>
y="3270.4141">bottledrop</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:1.25;font-family:monospace;-inkscape-font-specification:monospace;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none"
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
......@@ -14,7 +12,7 @@
viewBox="0 0 100 100"
version="1.1"
id="svg8"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"
sodipodi:docname="player.svg">
<defs
id="defs2" />
......@@ -25,19 +23,26 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1"
inkscape:cx="64.175702"
inkscape:cy="91.428571"
inkscape:document-units="px"
inkscape:zoom="7.9195959"
inkscape:cx="32.745272"
inkscape:cy="35.747444"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1702"
inkscape:window-height="1199"
inkscape:window-x="72"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:document-rotation="0"
showgrid="true"
units="px"
viewbox-width="100" />
inkscape:window-width="2560"
inkscape:window-height="1381"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid833"
spacingx="2.5"
spacingy="2.5"
empspacing="10" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
......@@ -53,33 +58,27 @@
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-270.54167)">
<ellipse
style="fill:#ff0300;fill-opacity:1;stroke:#000000;stroke-width:2.61414862;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path815"
cx="50.813805"
cy="321.11777"
rx="46.103001"
ry="46.603001" />
<ellipse
style="fill:#ff0300;fill-opacity:1;stroke:#000000;stroke-width:2.61414862;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path817"
cx="36.543827"
cy="300.3129"
rx="10.153636"
ry="10.818553" />
id="layer1">
<path
style="fill:#67029f;fill-opacity:0.999176;stroke:#b239ff;stroke-width:3.08523;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 13.985267,46.363484 24.269396,36.079355 H 34.553525 L 44.837654,46.363484 V 87.5 L 34.553525,97.784128 Z"
id="path835" />
<ellipse
style="fill:#ff0300;fill-opacity:1;stroke:#000000;stroke-width:2.61414862;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path819"
cx="65.220993"
cy="301.42252"
rx="10.56527"
ry="11.37335" />
style="fill:none;fill-opacity:0.501961;stroke:#ffcc39;stroke-width:3.08523;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path897"
cx="49.979717"
cy="10.369031"
rx="23.13929"
ry="7.7130966" />
<circle
style="fill:#67029f;fill-opacity:0.999176;stroke:#b239ff;stroke-width:3.08523;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path839"
cx="49.979717"
cy="20.653164"
r="14.39778" />
<path
style="fill:none;stroke:#000000;stroke-width:0.84572905px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 20.901739,326.66579 c 0,1.01712 0,2.03423 0,3.05138 0,0.73971 -0.09672,1.48594 0,2.21919 0.14914,1.13066 0.904862,2.8799 1.372113,3.88358 0.435469,0.93539 0.825993,1.8999 1.372113,2.77398 0.556937,0.89139 1.322856,1.6329 1.920958,2.49659 2.988164,4.3151 0.745416,1.84999 4.116341,5.82539 0.336754,0.39713 0.731793,0.73971 1.097688,1.10958 0.731794,0.73974 1.447512,1.49609 2.195383,2.21919 1.356321,1.31143 2.680681,2.66149 4.116338,3.88358 0.312903,0.26642 0.75731,0.32542 1.097691,0.55482 1.309466,0.88243 2.5113,1.92445 3.841917,2.77398 0.41649,0.26577 0.921964,0.35257 1.372113,0.55478 1.19683,0.53769 2.336634,1.21197 3.567495,1.6644 0.792574,0.29117 1.644541,0.37919 2.469801,0.55482 0.912849,0.19411 1.829485,0.36984 2.744225,0.55479 0.457372,0.0926 0.909778,0.215 1.372116,0.27735 0.91124,0.12276 1.830543,0.17482 2.744225,0.27734 3.490942,0.39211 0.976784,0.27735 4.939608,0.27735 0.731794,0 1.477798,0.14494 2.19538,0 0.683119,-0.13819 1.274137,-0.57067 1.920958,-0.8322 0.725658,-0.29342 1.487148,-0.49813 2.19538,-0.8322 0.66129,-0.31205 2.946271,-1.7054 3.567495,-2.21919 1.26666,-1.04761 1.801355,-1.95209 2.744226,-3.32879 0.657191,-0.95959 1.755786,-2.49528 2.195382,-3.60617 0.107428,-0.27156 0.182935,-0.55482 0.274434,-0.8322 0.09147,-0.27735 0.217684,-0.54547 0.274434,-0.8322 0.03586,-0.18126 -0.04438,-0.3754 0,-0.55482 0.0496,-0.20054 0.240798,-0.35085 0.274434,-0.55479 0.07519,-0.45603 0,-0.92466 0,-1.38699 0,-0.27734 0.08679,-0.56902 0,-0.8322 -0.02893,-0.0877 -0.233517,0.0826 -0.274434,0 -0.0818,-0.1655 0.05786,-0.37935 0,-0.55478 0.421529,-0.9497 -0.58473,-0.90477 -0.823267,-1.38699 -0.04092,-0.0826 0.02893,-0.18961 0,-0.27735 -0.06467,-0.19604 -0.209736,-0.35865 -0.274434,-0.55479 -0.05764,-0.17482 0,-1.45264 0,-1.66439 0,-0.64728 -0.07942,-1.29954 0,-1.94181 0.04677,-0.37829 0.1926,-0.73743 0.274434,-1.10958 0.101196,-0.46027 0.208465,-0.92025 0.274434,-1.38702 0.02575,-0.18318 -0.03589,-0.37343 0,-0.55479 -0.06298,-0.55703 0.429369,-0.90389 0.548843,-1.38698 0.04438,-0.17933 -0.04438,-0.3754 0,-0.55479 0.0496,-0.20054 0.182935,-0.36987 0.274434,-0.55482 0.09147,-0.27735 0.204267,-0.54852 0.274434,-0.8322 0.04438,-0.17933 -0.0818,-0.38938 0,-0.55479 0.05786,-0.11698 0.233517,-0.15329 0.274434,-0.27734 0.05786,-0.17548 0,-0.36987 0,-0.55483 0,-0.0926 -0.04092,-0.19475 0,-0.27734 0.05786,-0.11698 0.216571,-0.16037 0.274434,-0.27735 0.04174,-0.0845 0,-0.70728 0,-0.8322"
id="path821"
inkscape:connector-curvature="0" />
style="fill:#67029f;fill-opacity:0.999176;stroke:#b239ff;stroke-width:3.08523;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 85.97417,46.363484 75.690041,36.079355 H 65.405912 L 55.121784,46.363484 V 87.5 l 10.284128,10.284128 z"
id="path901" />
</g>
</svg>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment