Skip to content

Commit

Permalink
add background animation on game start, needs turn flip
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill-the-dev committed Feb 13, 2022
1 parent fc781d3 commit db893ad
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 10 deletions.
39 changes: 36 additions & 3 deletions dist/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,43 @@

body {
background-color: #aee1f9;
background-image: linear-gradient(315deg, #aee1f9 0%, #f6ebe6 74%);
margin: 1px;
background-image: linear-gradient(45deg, #aee1f9 0%, #f6ebe6 74%);
background-size: 400%;
margin: 0px;
background-position: center;
}

/* idea: animate 5s transition on turn flip */
.turn-blue {
animation: bg-animationBlue 5s;
animation-fill-mode: forwards;
}

.turn-red {
animation: bg-animationBlue 5s;
animation-fill-mode: forwards;
}

.turn-null {
animation: bg-animationNull 2s;
animation-fill-mode: forwards;
}

@keyframes bg-animationRed {
100% {
background-position: left;
}
}
@keyframes bg-animationBlue {
100% {
background-position: left;
}
}
@keyframes bg-animationNull {
100% {
background-position: center;
}
}
#container {
width: 100%;
height: 100%;
Expand All @@ -22,7 +55,7 @@ body {
height: 100%;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: 0.25fr 1fr 2fr 1fr 0.25fr;
grid-template-rows: 0.1fr 1fr 2fr 1fr 0.25fr;
/* grid-auto-rows: minmax(100px, auto); */
/* flex-direction: column; */
}
Expand Down
2 changes: 1 addition & 1 deletion dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
rel="stylesheet">
<title>Onitama JS</title>
</head>
<body>
<body class="body">
<div class="modal__howTo">
<div class="modal">
<div class="modal__fill" style="list-style: circle"></div>
Expand Down
3 changes: 3 additions & 0 deletions notes_bugs.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
- designed to set grid attr to the winning color on true
- have not decided where to call, issue with place and remove methods need resolution first

*How to Play modal*
- HTML formatting not correct. Font issue? Pojo issue?




Expand Down
15 changes: 13 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,27 @@ document.addEventListener("DOMContentLoaded", () => {

// Start / End game dynamic
addGlobalEventListener("click", "#start", e => {
let body = document.querySelector(".body");
let startEle = document.querySelector(".start-inactive");

if (game.activeGame === false) {
console.log("You clicked start");
game.start();
let startEle = document.querySelector(".start-inactive");

startEle.classList.remove("start-inactive");
startEle.classList.add("start-active");
body.classList.remove("turn-null");
body.classList.add("turn-blue");
startEle.innerText = "End Game";
} else {
console.log("You clicked end game");
history.go(0);
body.classList.add("turn-null");

setTimeout(() => {
body.classList.remove("turn-blue");
body.classList.remove("turn-red");
history.go(0);
}, 3001);
}

});
Expand Down
50 changes: 47 additions & 3 deletions src/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,54 @@

body {
background-color: #aee1f9;
background-image: linear-gradient(315deg, #aee1f9 0%, #f6ebe6 74%);
margin: 1px;
background-image: linear-gradient(45deg, #aee1f9 0%, #f6ebe6 74%);
background-size: 400%;
margin: 0px;
background-position: center;
}

/* idea: animate 5s transition on turn flip */

.turn-blue {
animation: bg-animationBlue 5s;
animation-fill-mode: forwards;
}

.turn-red {
animation: bg-animationBlue 5s;
animation-fill-mode: forwards;
}

.turn-null {
animation: bg-animationNull 2s;
animation-fill-mode: forwards;
}

@keyframes bg-animationRed {
0% {

}
100% {
background-position: left;
}
}

@keyframes bg-animationBlue {
0% {

}
100% {
background-position: left;
}
}

@keyframes bg-animationNull {
0% {}
100% { background-position: center; }
}



#container {
width: 100%;
height: 100%;
Expand All @@ -21,7 +65,7 @@ body {
height: 100%;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: .25fr 1fr 2fr 1fr .25fr;
grid-template-rows: .1fr 1fr 2fr 1fr .25fr;
/* grid-auto-rows: minmax(100px, auto); */
/* flex-direction: column; */

Expand Down

0 comments on commit db893ad

Please sign in to comment.