forked from wellsousaaa/Five-Nights-at-Freddys-Web
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.js
65 lines (57 loc) · 1.65 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React, { useState, useEffect } from "react";
import ReactDOM from "react-dom";
import Controller from "./Controller";
import "./css/Game.css";
import * as serviceWorker from "./serviceWorker";
import { Provider } from "react-redux";
import store from "./store/store";
import CustomNight from "./CustomNight";
const stateFromStorage = localStorage.getItem("stages");
const initialState = stateFromStorage ? JSON.parse(stateFromStorage) : {
mode: "NORMAL",
Freddy: 10,
Bonnie: 10,
Chica: 10,
Foxy: 10,
};
const Start = () => {
const [Start, setStart] = useState(false);
const [stages, reactSetStages] = useState(initialState);
function setStages(getNewStages) {
const newStages = getNewStages(stages);
reactSetStages(newStages);
localStorage.setItem("stages", JSON.stringify(newStages));
};
const [hourLength, setHourLength] = useState(89000);
useEffect(() => {
console.log(window.innerHeight > window.innerWidth);
if (window.innerHeight > window.innerWidth) {
window.alert(
"Rotate your phone to landscape mode for a better experience."
);
}
}, []);
return (
<>
{!Start ? (
<div className="custom-night">
<CustomNight
setStart={setStart}
state={{ ranges: stages, setStages, setHourLength }}
hourLength={hourLength}
setHourLength={setHourLength}
/>
</div>
) : (
<Controller stages={stages} setStart={setStart} hourLength={hourLength} />
)}
</>
);
};
ReactDOM.render(
<Provider store={store}>
<Start />
</Provider>,
document.getElementById("root")
);
serviceWorker.register();