-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9ebcad6
Showing
3 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>Movement :D</title> | ||
</head> | ||
<body> | ||
<div class="casing"> | ||
<div class="LR"> | ||
<button class="left">L</button> | ||
<button class="right">R</button> | ||
</div> | ||
<div class="screen"> | ||
<div class="box"></div> | ||
</div> | ||
<div class="UD"> | ||
<button class="up">U</button> | ||
<button class="down">D</button> | ||
</div> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Get elements n stuff | ||
const box = document.querySelector(".box"); | ||
const upB = document.querySelector(".up"); | ||
const downB = document.querySelector(".down"); | ||
const leftB = document.querySelector(".left"); | ||
const rightB = document.querySelector(".right"); | ||
let newT = 0; | ||
let newL = 0; | ||
|
||
// functions | ||
const moveU = () => { | ||
newT -= 10; | ||
box.style.top = newT + "px"; | ||
console.log(newT); | ||
}; | ||
|
||
const moveD = () => { | ||
newT += 10; | ||
box.style.top = newT + "px"; | ||
console.log(newT); | ||
}; | ||
|
||
const moveL = () => { | ||
newL -= 10; | ||
box.style.left = newL + "px"; | ||
console.log(newL); | ||
}; | ||
|
||
const moveR = () => { | ||
newL += 10; | ||
box.style.left = newL + "px"; | ||
console.log(newL); | ||
}; | ||
|
||
//Event listeners | ||
upB.onclick = moveU; | ||
downB.onclick = moveD; | ||
leftB.onclick = moveL; | ||
rightB.onclick = moveR; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
body { | ||
/* background-image: url(bg.jpg); */ | ||
background-color: #717171; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
min-height: 90vh; | ||
} | ||
.casing { | ||
background-color: #ff6a6a; | ||
position: relative; | ||
height: 400px; | ||
width: 900px; | ||
border-radius: 50px; | ||
display: flex; | ||
justify-content: space-around; | ||
align-items: center; | ||
} | ||
.LR, .UD { | ||
background-color: #e04040; | ||
height: 100px; | ||
width: 150px; | ||
border-radius: 20px; | ||
display: flex; | ||
justify-content: space-evenly; | ||
align-items: center; | ||
} | ||
button { | ||
border: none; | ||
background-color: #772727; | ||
height: 60px; | ||
width: 60px; | ||
border-radius: 20px; | ||
} | ||
.screen { | ||
position: relative; | ||
background-color: #c3c3c3; | ||
height: 300px; | ||
width: 500px; | ||
border-radius: 20px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
.box { | ||
height: 100px; | ||
width: 100px; | ||
position: relative; | ||
top: 0; | ||
left: 0; | ||
background-color: #404040; | ||
border-radius: 20px; | ||
transition: top 0.2s ease-in-out, left 0.2s ease-in-out; | ||
} |