FreeBasic
Главная
Вход
Регистрация
Пятница, 29.03.2024, 08:59Приветствую Вас Гость | RSS
[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
Форум » Freebasic » Исходники » Игра Jackpot (простейшая игрушка для начинающих кодеров.)
Игра Jackpot
electrikДата: Воскресенье, 15.09.2013, 00:58 | Сообщение # 1
Полковник
Группа: Друзья
Сообщений: 180
Репутация: 3
Статус: Offline
Взял из Dev-Cpp

Код
declare sub Start ()
declare sub GetResults ()
dim shared as integer  i, j, life, maxrand
dim shared as byte c
' program start
print "** Jackpot game **"
print "The goal of this game is to guess a number. You will be ask to type"
print "a number (you have 5 guess)"
print "Jackpot will then tell you if this number is too big of too small compared to the secret number to find"
print
      Start()
end
sub Start ()
      i = 0
      j = 0
      life = 0
      maxrand = 6
print "Select difficulty mode:" ' the user has to select a difficulty level
print "1 : Easy (0-15)"
print "2 : Medium (0-30)"
print "3 : Difficult (0-50)"
print "or type another key to quit"
      c = 30
input ">",c                   ' read the user's choice
print
select case c
         case 1 : maxrand = 15  ' the random number will be between 0 and maxrand
         case 2 : maxrand = 30
         case 3 : maxrand = 50
         case else: end 0
end select
      life = 5         ' number of lifes of the player
randomize timer
      j = rnd * maxrand ' j get a random value between 0 and maxrand
      GetResults()
end sub

sub GetResults ()
      if (life <= 0) then
         ' if player has no more life then he lose
    print "You lose !"
print
         Start()
      end if
print "Type a number:"
input ">",i          ' read user's number
      if ((i>maxrand) orelse (i<0)) then ' if the user number isn't correct, restart
    print "Error : Number not between 0 and ";maxrand
         GetResults()
      end if
      if (i = j) then
    print "YOU WIN !" ' the user found the secret number
print
         Start()
      ElseIf (i>j) then
    print "Too BIG"
         life = life - 1    ' -1 to the user's "life"
    print "Number of remaining life: ";life
print
         GetResults()
      ElseIf (i<j) then
    print "Too SMALL"
         life = life - 1
    print "Number of remaining life: "; life
print
         GetResults()
      end if
end sub
 
haavДата: Воскресенье, 15.09.2013, 07:39 | Сообщение # 2
Генералиссимус
Группа: Администраторы
Сообщений: 1361
Репутация: 49
Статус: Offline
Нормальная консольная штука! Сегодня выложу на своем сайте.

Вы сохраняете власть над людьми покуда оставляете им что-то…Отберите у человека все, и этот человек уже будет неподвластен вам…
 
Форум » Freebasic » Исходники » Игра Jackpot (простейшая игрушка для начинающих кодеров.)
  • Страница 1 из 1
  • 1
Поиск: