Skip to content

Added Ludogame #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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 Ludogame/img/imageG11.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 Ludogame/img/imageG22.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 Ludogame/img/imageR2.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 Ludogame/img/imager1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions Ludogame/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>LUDO-game</title>
</head>
<body>
<div class="top">
<div class="box" id="b1" >
<img src="img/imager1.png" height="50px" width="50px" >
<img src="img/imageR2.png" height="50px" width="50px"align="right">
</div>
<div class="box" id="b2">2</div>
<div class="box" id="b3">3</div>
<div class="box" id="b4">4</div>
<div class="box" id="b5">5</div>
<div class="box" id="b6">6</div>
<div class="box" id="b7">7</div>
<div class="box" id="b8">8</div>
</div>
<div class="side1">
<div class="box" id="b28">28</div>
<div class="box" id="b27">27</div>
<div class="box" id="b26">26</div>
<div class="box" id="b25">25</div>
<div class="box" id="b24">24</div>
<div class="box" id="b23">23</div>
</div>
<div class="side2">
<div class="box" id="b9">9</div>
<div class="box" id="b10">10</div>
<div class="box" id="b11">11</div>
<div class="box" id="b12">12</div>
<div class="box" id="b13">13</div>
<div class="box" id="b14">14</div>
</div>
<div class="bottom">
<div class="box" id="b22">22</div>
<div class="box" id="b21">21</div>
<div class="box" id="b20">20</div>
<div class="box" id="b19">19</div>
<div class="box" id="b18">18</div>
<div class="box" id="b17">17</div>
<div class="box" id="b16">16</div>
<div class="box" id="b15">
<img src="img/imageG11.png" height="50px" width="50px">
<img src="img/imageG22.png" height="50px" width="50px" align="right">
</div>
</div>
<div class="centre">
<div class="boxc">
<h2 class="turno"></h2>
</div>
<div class="boxc" id="last">
<h1 class="randomNumEl"></h1>
</div>
<div class="boxc">
<button type="submit" class="generate" id="roll">Roll Dice!
</div>
</div>

<script src="sandbox.js"></script>
</body>
</html>
127 changes: 127 additions & 0 deletions Ludogame/sandbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
const generate = document.querySelector('.generate');
generate.addEventListener("click",main);

var num;
function generateRandomNum() {
var randomNum = Math.ceil(Math.random()*6);
var randomNumEl = document.querySelector('.randomNumEl');
randomNumEl.innerHTML = randomNum;
num=randomNum;
}
function poi(){
console.log('Number:',num);
}

function main(){
generateRandomNum();
poi();
turnof();
locker();
pn_red();
pn_green();
pn_red_board();
pn_green_board();
/*clean();*/
}

let turns=['Red Player Obtained','Green Player Obtained'];
if(num==null){
turnw= turns[0];
turno = document.querySelector('.turno');
turno.innerHTML = turnw;
}
let i=0;
let j=0;
function turnof(){
if(num!=6){

turnw= turns[i++];
turno = document.querySelector('.turno');
turno.innerHTML = turnw;
if(i>1){
i=0;
}
j=i;
}
else{
turnw = turns[j];
turno = document.querySelector('.turno');
turno.innerHTML = turnw;
}
}

let r = true;
let g = true;
var p_red = -6;
var p_green = 9;

function locker(){
if(num === 6 && turno.innerHTML ==='Red Player Obtained'){
r=false;
}
else if(num === 6 && turno.innerHTML ==='Green Player Obtained'){
g=false;
}
}


function pn_red(){
if(!r && turno.innerHTML ==='Red Player Obtained'){
if(p_red + num < 27) {
p_red += num;
}
else if(p_red + num == 27){
alert('Red Won, Congrats');
alert('Refresh to start new game!');
const overw = document.querySelector('.turno');
overw.innerHTML = '!! Game over !!';
}
else{
p_red = p_red;
}
}
console.log('R:',p_red);
}

function pn_green(){
if(!g && turno.innerHTML ==='Green Player Obtained'){
if(p_green + num < 41) {
p_green = p_green+num;
}
else if(p_green + num == 41){
alert('Green won, Congrats');
alert('Refresh to start new game!');
const overw = document.querySelector('.turno');
overw.innerHTML = '!! Game over !!';
}
else{
p_green = p_green;
}
}
console.log('G:',p_green);
}
/*var k=0;
var c;*/

function pn_red_board(){
if(!r && turno.innerHTML ==='Red Player Obtained'){
document.querySelector(`#b${p_red+1}`).style.backgroundColor = 'red';
/*c[k] = `#b${p_red+1}`;
k++;*/
}
}

function pn_green_board(){
if(!g && turno.innerHTML ==='Green Player Obtained' && p_green <= 27){
document.querySelector(`#b${p_green}`).style.backgroundColor = 'green';
/*c[k++] = `#b${p_green}`;*/
}
else if(!g && turno.innerHTML ==='Green Player Obtained' && p_green > 27){
document.querySelector(`#b${p_green-27}`).style.backgroundColor = 'green';
/*c[k++] = `#b${p_green-27}`;*/
}
}

/*function clean(){
console.log(typeof c[1]);
}*/
73 changes: 73 additions & 0 deletions Ludogame/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
.top,.bottom{
display: grid;
height:auto;
width:12.5%;
margin-top: auto;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
position: relative;
}
.box{
background-color: #eaf0a6;
border-color:#000000;
height: 100px;
width:100px;
border: 1px dashed #000000;
}
.side1,.side2{
display: grid;
height:auto;
width:12.5%;
margin-top: auto;
grid-template-rows: 1fr;

}
.side2{
padding-left:715px;
position: absolute;
top: 110px;
}
.centre{
display:grid;
height:25%;
width:25%;
position:absolute;
top: 300px;
left:16%;
background-color: #f8f6dc;

}
.boxc{
border: 1px dashed #000000;
}
#b1{
background-color: rgb(221, 24, 24);
text-align: bottom;
}
#b15{
background-color: rgb(11, 237, 64);
text-align: bottom;
}
#turn{
text-align: center;
position:relative;
font-size:40px;
}
#roll{
font-size: larger;
height:100%;
width:100%;
}
.randomNumEl{
text-align: center;
font-size: 50px;
margin: 5px;
}
.turno{
text-align: center;
margin-bottom: 5px;
}
#last{
margin-top: 0px;
font-size: larger;
padding-left: 10%;
}