Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added buttons/1A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added buttons/1B.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added buttons/2A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added buttons/2B.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added buttons/3A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added buttons/3B.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added buttons/4A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added buttons/4B.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 changes: 104 additions & 17 deletions engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function drop(e) {
e.preventDefault();
const data = e.dataTransfer.getData('text/plain');
const option = document.getElementById(data);
const targetSquare = e.target;
const targetSquare = e.currentTarget;

if (targetSquare.style.backgroundColor || !isCorrectSquare(counter, targetSquare.id)) {
return;
Expand All @@ -78,50 +78,137 @@ function drop(e) {
switch (option.id) {
case 'blue':
targetSquare.style.backgroundColor = 'blue';
document.getElementById("top-left-text").innerHTML = "💻";
document.getElementById("top-left-text").style.fontSize = "100px";

var img = document.createElement('img');
img.src = 'buttons/1A.png';
img.alt = 'Blue Image';
img.style.width = '150px';
img.style.height = '150px';
img.style.borderRadius = '10px';

var topLeftText = document.getElementById("top-left-text");
topLeftText.innerHTML = '';
topLeftText.appendChild(img)

toggleOptions('blue', 'green', ['red', 'yellow']);
break;

case 'green':
targetSquare.style.backgroundColor = 'green';
document.getElementById("top-left-text").innerHTML = "🏛";
document.getElementById("top-left-text").style.fontSize = "100px";

var img = document.createElement('img');
img.src = 'buttons/1B.png';
img.alt = 'Blue Image';
img.style.width = '150px';
img.style.height = '150px';
img.style.borderRadius = '10px';

var topLeftText = document.getElementById("top-left-text");
topLeftText.innerHTML = '';
topLeftText.appendChild(img)

toggleOptions('blue', 'green', ['red', 'yellow']);
break;

case 'red':
targetSquare.style.backgroundColor = 'red';
document.getElementById("top-right-text").innerHTML = "⚽️";
document.getElementById("top-right-text").style.fontSize = "100px";

var img = document.createElement('img');
img.src = 'buttons/2A.png';
img.alt = 'Blue Image';
img.style.width = '150px';
img.style.height = '150px';
img.style.borderRadius = '10px';

var topLeftText = document.getElementById("top-right-text");
topLeftText.innerHTML = '';
topLeftText.appendChild(img)

toggleOptions('red', 'yellow', ['purple', 'brown']);
break;

case 'yellow':
targetSquare.style.backgroundColor = 'yellow';
document.getElementById("top-right-text").innerHTML = "⛏";
document.getElementById("top-right-text").style.fontSize = "100px";

var img = document.createElement('img');
img.src = 'buttons/2B.png';
img.alt = 'Blue Image';
img.style.width = '150px';
img.style.height = '150px';
img.style.borderRadius = '10px';

var topLeftText = document.getElementById("top-right-text");
topLeftText.innerHTML = '';
topLeftText.appendChild(img)

toggleOptions('red', 'yellow', ['purple', 'brown']);
break;

case 'purple':
targetSquare.style.backgroundColor = 'purple';
document.getElementById("bottom-left-text").innerHTML = "👾";
document.getElementById("bottom-left-text").style.fontSize = "100px";

var img = document.createElement('img');
img.src = 'buttons/3A.png';
img.alt = 'Blue Image';
img.style.width = '150px';
img.style.height = '150px';
img.style.borderRadius = '10px';

var topLeftText = document.getElementById("bottom-left-text");
topLeftText.innerHTML = '';
topLeftText.appendChild(img)

toggleOptions('purple', 'brown', ['pink', 'cyan']);
break;

case 'brown':
targetSquare.style.backgroundColor = 'brown';
document.getElementById("bottom-left-text").innerHTML = "💼";
document.getElementById("bottom-left-text").style.fontSize = "100px";

var img = document.createElement('img');
img.src = 'buttons/3B.png';
img.alt = 'Blue Image';
img.style.width = '150px';
img.style.height = '150px';
img.style.borderRadius = '10px';

var topLeftText = document.getElementById("bottom-left-text");
topLeftText.innerHTML = '';
topLeftText.appendChild(img)

toggleOptions('purple', 'brown', ['pink', 'cyan']);
break;

case 'pink':
targetSquare.style.backgroundColor = 'pink';
document.getElementById("bottom-right-text").innerHTML = "👨‍💻";
document.getElementById("bottom-right-text").style.fontSize = "100px";

var img = document.createElement('img');
img.src = 'buttons/4A.png';
img.alt = 'Blue Image';
img.style.width = '150px';
img.style.height = '150px';
img.style.borderRadius = '10px';

var topLeftText = document.getElementById("bottom-right-text");
topLeftText.innerHTML = '';
topLeftText.appendChild(img)

toggleOptions('pink', 'cyan', []);
break;

case 'cyan':
targetSquare.style.backgroundColor = 'cyan';
document.getElementById("bottom-right-text").innerHTML = "👨‍⚖️";
document.getElementById("bottom-right-text").style.fontSize = "100px";

var img = document.createElement('img');
img.src = 'buttons/4B.png';
img.alt = 'Blue Image';
img.style.width = '150px';
img.style.height = '150px';
img.style.borderRadius = '10px';

var topLeftText = document.getElementById("bottom-right-text");
topLeftText.innerHTML = '';
topLeftText.appendChild(img)

toggleOptions('pink', 'cyan', []);
break;
}
Expand Down
17 changes: 14 additions & 3 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ body {
line-height: 150px;
height: 150px;
background-color: rgba(255, 255, 255, 0.5);
color: white;
font-size: 100px;
}

#options {
Expand All @@ -83,13 +85,22 @@ body {

.option {
margin: 10px;
padding: 20px;
padding: 0px;
border: 1px solid #000;
border-radius: 10px;
box-shadow: 10px 10px 5px lightblue;
width: auto;
text-align: center;
width: 150px;
height: 150px;
cursor: grab;
display: flex;
justify-content: center;
align-items: center;
}

.option-img {
width :150px;
height: 150px;
border-radius: 10px;
}

.option:active {
Expand Down
24 changes: 12 additions & 12 deletions web-app.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@
</div>

<div id="big-square">
<div class="small-square" id="top-left"><div id="top-left-text"></div></div>
<div class="small-square" id="top-right"><div id="top-right-text"></div></div>
<div class="small-square" id="bottom-left"><div id="bottom-left-text"></div></div>
<div class="small-square" id="bottom-right"><div id="bottom-right-text"></div></div>
<div class="small-square" id="top-left"><div id="top-left-text">1</div></div>
<div class="small-square" id="top-right"><div id="top-right-text">2</div></div>
<div class="small-square" id="bottom-left"><div id="bottom-left-text">3</div></div>
<div class="small-square" id="bottom-right"><div id="bottom-right-text">4</div></div>
</div>
<div id="options">
<div class="option" id="blue" draggable="true">💻</div>
<div class="option" id="green" draggable="true">🏛</div>
<div class="option" id="blue" draggable="true"><img src="buttons/1A.png" alt="Blue Piece" class = "option-img" draggable="false"></div>
<div class="option" id="green" draggable="true"><img src="buttons/1B.png" alt="Green Piece" class = "option-img" draggable="false"></div>

<div class="option" id="red" draggable="true">⚽️</div>
<div class="option" id="yellow" draggable="true">⛏</div>
<div class="option" id="red" draggable="true"><img src="buttons/2A.png" alt="Red Piece" class = "option-img" draggable="false"></div>
<div class="option" id="yellow" draggable="true"><img src="buttons/2B.png" alt="Blue Piece" class = "option-img" draggable="false"></div>

<div class="option" id="purple" draggable="true">👾</div>
<div class="option" id="brown" draggable="true">💼</div>
<div class="option" id="purple" draggable="true"><img src="buttons/3A.png" alt="Blue Piece" class = "option-img" draggable="false"></div>
<div class="option" id="brown" draggable="true"><img src="buttons/3B.png" alt="Blue Piece" class = "option-img" draggable="false"></div>

<div class="option" id="pink" draggable="true">👨‍💻</div>
<div class="option" id="cyan" draggable="true">👨‍⚖️</div>
<div class="option" id="pink" draggable="true"><img src="buttons/4A.png" alt="Blue Piece" class = "option-img" draggable="false"></div>
<div class="option" id="cyan" draggable="true"><img src="buttons/4B.png" alt="Blue Piece" class = "option-img" draggable="false"></div>
</div>
</div>
<script src="engine.js"></script>
Expand Down