Gå til innhold

Lage spill i Visual Basic :) hvordan og hva?


Anbefalte innlegg

Videoannonse
Annonse
  • 3 uker senere...
  • 3 måneder senere...

Du kan prøve å lage Stein saks papir i Batch :)

 

Rock, Paper, Scissors!
@echo off
set tp=star
set uscore=0
set cscore=0
cls
:start
Title Rock paper scissors
COLOR f0
cls
echo.
echo. Computer score = %cscore%
echo. Your score =     %uscore%
echo.
Echo. Pick and type either 'rock' 'paper' or 'scissors' and press Enter
Set /p tp= :
if %tp% equ rock set g=1
if %tp% equ paper set g=2
if %tp% equ scissors set g=3
Set /a Number=(%Random% %%3)+1
If %Number% equ 1 set h=rock
If %Number% equ 2 set h=paper
If %Number% equ 3 set h=scissors
if %h% equ rock set a=1
if %h% equ paper set a=2
if %h% equ scissors set a=3
if %a% equ %g% goto tie
if %a%%g% equ 13 goto lost
if %a%%g% equ 21 goto lost
if %a%%g% equ 32 goto lost
if %a%%g% equ 12 goto winner
if %a%%g% equ 23 goto winner
if %a%%g% equ 31 goto winner
if /i %tp% EQU rosk (
  Title WINNER!
  set /a uscore=%uscore%+1
  cls
  echo.
  Echo. Your Guess was rock and I picked scissors. That meens you won!
  echo.
  echo.
  pause
  goto start
)
if /i %tp%==star goto :wtfno
else (
  :wtfno
  cls
  echo.
  echo. You didn't choose anything.
  echo.
  echo. Please type either 'rock' 'paper' or 'scissors' and
  echo. press Enter.
  echo.
  echo.Press any key to start playing again. . .
  pause > nul
  goto :start
)

:winner
Title WINNER!
set /a uscore=%uscore%+1
cls
echo.
Echo. Your Guess was %tp% and I picked %h%. That meens you won!
echo.
echo.
pause
goto start

: tie
Title TIE
cls
echo.
Echo. Your Guess was %tp% and I picked %h%. That meens we tied
echo.
echo.
pause
goto start

: lost
Title LOST!
set /a cscore=%cscore%+1
cls
echo.
Echo. You picked %tp% and I picked %H% so I won!
echo.
echo.
pause
goto start

Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...