-
Notifications
You must be signed in to change notification settings - Fork 14
Create a basic simple Rock Paper Scissor game #8
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| *, | ||
| *:Before, | ||
| *:After{ | ||
| Padding: 0; | ||
| Margin: 0; | ||
| Box-Sizing: Border-Box; | ||
| } | ||
| Body{ | ||
| Height: 100vh; | ||
| Background: Linear-Gradient( | ||
| 135deg, | ||
| #1bcaff, | ||
| #231bff | ||
| ); | ||
| } | ||
| .Container{ | ||
| Width: 45%; | ||
| Min-Width: 500px; | ||
| Background-Color: #Ffffff; | ||
| Padding: 40px 30px; | ||
| Position: Absolute; | ||
| Transform: Translate(-50%,-50%); | ||
| Top: 50%; | ||
| Left: 50%; | ||
| Border-Radius: 10px; | ||
| Box-Shadow: 0 15px 25px Rgba(0,0,0,0.15); | ||
| } | ||
| .Scores{ | ||
| Margin-Bottom: 50px; | ||
| Text-Align: Right; | ||
| } | ||
| .Details{ | ||
| Margin-Top: 30px; | ||
| Text-Align: Center; | ||
| } | ||
| .Scores,.Details{ | ||
| Font-Family: 'Poppins',Sans-Serif; | ||
| Font-Weight: 400; | ||
| Font-Size: 15px; | ||
| } | ||
|
|
||
| #User_choice, | ||
| #Computer_choice{ | ||
| Font-Weight: 400; | ||
| Margin-Bottom: 10px; | ||
| } | ||
| Span{ | ||
| Font-Weight: 600; | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
| .btn { | ||
| border: 2px solid black; | ||
| background-color: white; | ||
| color: black; | ||
| padding: 14px 28px; | ||
| font-size: 16px; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .success { | ||
| border-color: #04AA6D; | ||
| color: green; | ||
| } | ||
|
|
||
| .success:hover { | ||
| background-color: #04AA6D; | ||
| color: white; | ||
| } | ||
| /* Orange */ | ||
| .warning { | ||
| border-color: #ff9800; | ||
| color: orange; | ||
| } | ||
|
|
||
| .warning:hover { | ||
| background: #ff9800; | ||
| color: white; | ||
| } | ||
|
|
||
| /* Red */ | ||
| .danger { | ||
| border-color: #f44336; | ||
| color: red; | ||
| } | ||
|
|
||
| .danger:hover { | ||
| background: #f44336; | ||
| color: white; | ||
| } | ||
| .center { | ||
| text-align: center; | ||
| padding: 10px; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <!DOCTYPE html> | ||
| <Html Lang="En"> | ||
| <Head> | ||
| <Title>Rock Paper Scissor Game</Title> | ||
| <!--Stylesheet--> | ||
| <Link Rel="Stylesheet" Href="task1.css"> | ||
| </Head> | ||
| <Body> | ||
| <Div Class="Container"> | ||
| <h1 class="center">Rock Paper & Scissor Game</h1> | ||
| <Div Class="Scores"> | ||
| <P>Computer : | ||
| <Span Id="computer_score">0</Span> | ||
| </P> | ||
| <P> | ||
| You : | ||
| <span Id="user_scores">0</Span> | ||
| </P> | ||
| </Div> | ||
| <div class="center"> | ||
| <h2 id="status"></h2> | ||
| </div> | ||
| <Div Class="center"> | ||
| <Button type="button" Onclick="rock()" class="btn danger">Rock</Button> | ||
| <Button type="button" Onclick="paper()" class="btn success">Paper</Button> | ||
| <Button type="button" Onclick="scissor()" class="btn warning">Scissor</Button> | ||
| </Div> | ||
| </Div> | ||
| <!--Script--> | ||
| <Script Src="task1.js"></Script> | ||
| </Body> | ||
| </Html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| const choices=['Rock','Paper','Scissor']; | ||
| var user_scores=0,computer_score=0; | ||
| function rock() | ||
| { | ||
| let computer_choice=Math.floor(Math.random() * choices.length); | ||
| console.log(choices[computer_choice]) | ||
|
|
||
| if(choices[computer_choice]=='Rock') | ||
| { | ||
| // console.log("helllllllo") | ||
|
||
| document.getElementById("status").textContent="Draw"; | ||
| } | ||
| else if (choices[computer_choice]=='Paper') | ||
| { | ||
| document.getElementById("status").textContent="Computer Wins"; | ||
| computer_score+=1; | ||
| document.getElementById("computer_score").textContent=computer_score; | ||
| console.log(computer_score) | ||
| } | ||
| else if(choices[computer_choice]=='Scissor') | ||
| { | ||
| document.getElementById("status").textContent="You Win"; | ||
| user_scores+=1; | ||
| document.getElementById("user_scores").textContent=user_scores; | ||
| console.log(user_scores) | ||
| } | ||
| } | ||
| function paper() | ||
| { | ||
| let computer_choice=Math.floor(Math.random() * choices.length); | ||
| console.log(choices[computer_choice]) | ||
| if(choices[computer_choice]=='Paper') | ||
| { | ||
| document.getElementById("status").textContent="Draw"; | ||
| } | ||
| else if (choices[computer_choice]=='Scissor') | ||
| { | ||
| document.getElementById("status").textContent="Computer Wins"; | ||
| computer_score+=1; | ||
| document.getElementById("computer_score").textContent=computer_score; | ||
| } | ||
| else if(choices[computer_choice]=='Rock') | ||
| { | ||
| document.getElementById("status").textContent="You Win"; | ||
| user_scores+=1; | ||
| document.getElementById("user_scores").textContent=user_scores; | ||
| } | ||
| } | ||
| function scissor() | ||
| { | ||
| let computer_choice=Math.floor(Math.random() * choices.length); | ||
| console.log(choices[computer_choice]) | ||
| if(choices[computer_choice]=='Scissor') | ||
| { | ||
| document.getElementById("status").textContent="Draw"; | ||
| } | ||
| else if (choices[computer_choice]=='Rock') | ||
| { | ||
| document.getElementById("status").textContent="Computer Wins"; | ||
| computer_score+=1; | ||
| document.getElementById("computer_score").textContent=computer_score; | ||
| } | ||
| else if(choices[computer_choice]=='Paper') | ||
| { | ||
| document.getElementById("status").textContent="You Win"; | ||
| user_scores+=1; | ||
| document.getElementById("user_scores").textContent=user_scores; | ||
| } | ||
| } | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Give proper spacing while assignment:
const choices = ['Rock','Paper','Scissor'];
update it for all cases in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay sir