Skip to content

Commit

Permalink
create initial screen and update select screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Fel1324 committed Dec 23, 2023
1 parent 0fa62c5 commit 4c0577f
Show file tree
Hide file tree
Showing 3 changed files with 297 additions and 41 deletions.
112 changes: 71 additions & 41 deletions web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,93 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CHIP-8</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
</head>

<body>
<form id="select-rom">
<fieldset>
<legend>Select ROM</legend>
<section class="initial-screen">
<div class="initial-screen__content">
<div class="initial-screen__group-line">
<div class="initial-screen__line"></div>
<div class="initial-screen__line"></div>
</div>

<div>
<input type="radio" id="pong" name="rom" value="PONG.ch8" checked />
<label for="PONG">Pong</label>
<details open>
<summary>Keyboard</summary>
<ul>
<li>↑ = <kbd>1</kbd></li>
<li>↓ = <kbd>Q</kbd></li>
</ul>
</details>
</div>
<div>
<h1 class="initial-screen__title">chip-8</h1>
<button class="initial-screen__btn">Click here to Start</button>
<!-- Press any key to start -->
</div>

<div>
<input type="radio" id="snake" name="rom" value="SNAKE.ch8" />
<label for="snake">Snake [steveRoll]</label>
<details open>
<summary>Keyboard</summary>
<ul>
<li>↑ = <kbd>2</kbd></li>
<li>→ = <kbd>E</kbd></li>
<li>↓ = <kbd>S</kbd></li>
<li>← = <kbd>Q</kbd></li>
<li>Restart = <kbd>V</kbd></li>
</ul>
</details>
<div class="initial-screen__group-line">
<div class="initial-screen__line"></div>
<div class="initial-screen__line"></div>
</div>
</div>
</section>

<form id="select-rom" class="select-screen">
<fieldset>
<div class="select-screen__header">
<legend class="select-screen__title">Select ROM</legend>
<hr class="select-screen__line">
</div>

<div>
<input type="radio" id="space-invaders" name="rom" value="SPACE_INVADERS.ch8" />
<label for="space-invaders">Space Invaders [David Winter]</label>
<details open>
<summary>Keyboard</summary>
<ul>
<li>Shoot = <kbd>W</kbd></li>
<li>← = <kbd>Q</kbd></li>
<li>→ = <kbd>E</kbd></li>
<li>Start/Restart = <kbd>W</kbd></li>
</ul>
</details>
<div class="select-screen__games">
<div>
<input class="select-screen__chose-game" type="radio" id="pong" name="rom" value="PONG.ch8" checked />
<label for="PONG">Pong</label>
<details>
<summary class="select-screen__keyboard">Keyboard</summary>
<ul>
<li>> ↑ = <kbd>1</kbd></li>
<li>> ↓ = <kbd>Q</kbd></li>
</ul>
</details>
</div>

<div>
<input class="select-screen__chose-game" type="radio" id="snake" name="rom" value="SNAKE.ch8" />
<label for="snake">Snake [steveRoll]</label>
<details>
<summary class="select-screen__keyboard">Keyboard</summary>
<ul>
<li>> ↑ = <kbd>2</kbd></li>
<li>> → = <kbd>E</kbd></li>
<li>> ↓ = <kbd>S</kbd></li>
<li>> ← = <kbd>Q</kbd></li>
<li>> Restart = <kbd>V</kbd></li>
</ul>
</details>
</div>

<div>
<input class="select-screen__chose-game" type="radio" id="space-invaders" name="rom" value="SPACE_INVADERS.ch8" />
<label for="space-invaders">Space Invaders [David Winter]</label>
<details>
<summary class="select-screen__keyboard">Keyboard</summary>
<ul>
<li>> Shoot = <kbd>W</kbd></li>
<li>> ← = <kbd>Q</kbd></li>
<li>> → = <kbd>E</kbd></li>
<li>> Start/Restart = <kbd>W</kbd></li>
</ul>
</details>
</div>
</div>
</fieldset>

<p>When running game press <kbd>ESC</kbd> to reload</p>
<p>When running game press <kbd><strong>ESC</strong></kbd> to reload</p>

<button type="submit">Confirm</button>
<button class="select-screen__confirm" type="submit">Confirm</button>
</form>

<script src="js/wasm_exec.js"></script>
<script src="js/polyfill.js"></script>
<script src="js/wasm_load.js"></script>
<script src="js/start.js"></script>
</body>

</html>
6 changes: 6 additions & 0 deletions web/public/js/start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const initialScreen = document.querySelector('.initial-screen');
const btnStart = document.querySelector('.initial-screen__btn');

btnStart.addEventListener('click', () => {
initialScreen.classList.add('initial-screen--close');
});
220 changes: 220 additions & 0 deletions web/public/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/* GLOBAL */
* {
padding: 0;
margin: 0;
border: 0;
box-sizing: border-box;
}

:root {
--bg-color: rgba(23, 20, 33, 1);
--selection-bg-color: rgb(0, 0, 0);
--alternative-color: rgb(255, 255, 255);
--default-color: rgba(51, 209, 122, 1);
--font: 'Silkscreen', sans-serif;
}

html,
body {
background-color: var(--bg-color);
color: var(--default-color);

font-family: var(--font);
font-weight: 400;
font-size: 1rem;

width: 100%;
height: 100vh;
}

body{
overflow-y: scroll;
}

button{
cursor: pointer;
}

ul{
list-style: none;
}

::selection {
background-color: var(--selection-bg-color);

color: var(--alternative-color);
}

::-webkit-scrollbar{
width: .75rem;

background: var(--bg-color);
}

::-webkit-scrollbar-thumb{
background: var(--default-color);
}

/* INITIAL SCREEN */
.initial-screen {
background-color: var(--bg-color);

position: fixed;
top: 0;
left: 0;
z-index: 1000;
transform: translateX(0%);

width: 100%;
height: 100vh;

display: flex;
align-items: center;
justify-content: center;
}

.initial-screen--close{
animation: startChip-8 1.2s .4s backwards;
display: none;
}

.initial-screen__content {
width: 80%;
height: 100vh;

display: flex;
flex-direction: column;
justify-content: space-between;
gap: 2rem;

padding-block: 2rem;
}

.initial-screen__group-line {
width: 100%;

display: flex;
flex-direction: column;
gap: 2rem;
}

.initial-screen__line {
width: 100%;
height: 1.5rem;

background-color: var(--default-color);
}

.initial-screen__title {
font-weight: 700;
font-size: 6rem;
text-align: center;

margin-bottom: .75rem;
}

.initial-screen__btn {
display: block;

background: none;
color: var(--default-color);

font-family: var(--font);
font-size: 1rem;

margin: 0 auto;
}

@keyframes startChip-8 {
from{
opacity: 1;
display: flex;
}

to{
opacity: 0;
display: none;
}
}

/* SELECT SCREEN */
.select-screen{
width: 100%;
height: auto;
min-height: 100vh;

display: flex;
flex-direction: column;
align-items: center;

padding: 2rem;
}

.select-screen fieldset{
width: 100%;
max-width: 44.688rem;

margin-bottom: 2rem;
}

.select-screen__header{
display: flex;
align-items: center;
gap: 1rem;

margin-bottom: 1.25rem;
}

.select-screen__line{
width: 59.3%;
height: .125rem;

background: var(--default-color);
}

.select-screen__title{
font-size: 2.5rem;
text-align: center;
}

.select-screen__games{
display: flex;
flex-direction: column;
gap: 2rem;

width: fit-content;
}

.select-screen__chose-game{
appearance: none;
-webkit-appearance: none;

cursor: pointer;

background: transparent;
border: .125rem solid var(--default-color);

width: .75rem;
height: .75rem;

transition: all .3s ease-in-out;
}

.select-screen__chose-game:checked{
background: var(--default-color);
border-radius: 50%;
}

.select-screen__keyboard{
margin-top: .7rem;
}

.select-screen__confirm{
background: transparent;
color: var(--default-color);

font-family: var(--font);
font-size: 1.5rem;

margin-top: 1rem;
}

0 comments on commit 4c0577f

Please sign in to comment.