Wha's Me Freekin Number?

Game development specific discussions.
Post Reply
hartnell
Posts: 170
Joined: Aug 15, 2006 3:21
Contact:

Wha's Me Freekin Number?

Post by hartnell »

Just putting some fun back into coding.

Code: Select all

'wha's me freekin' number for FreeBASIC
'a simple evil leprechaun number guesssing game
'yes, this example is so well known and so overdone we included an evil
'leprechaun.

dim a as integer
dim freekinNumber as integer
dim gameOver as integer = 0

print "You were wandering in the woods one day, taking in the sights, minding"
print "your own business, when you found that you had rudely intruded upon the"
print "drunken leprechaun area of the forest."
print
print "As sure as leprechaun's are an ugly shade of green, one of them appears"
print "and says :"
print
print "Ye hav' stepped upon me' house, and me hav'n jus' painted 'er a purty"
print "shade of green. If ye wants ter git outta 'is forest alive, yer gonna"
print "haf'ta answer me riddle:"
print
print "Me gives ye a hint. 'Tis betwixt 1 and 100."
randomize timer
freekinNumber = int(rnd(1)*100)+1
do
    print
    print "Wha's me freekin' number?"
    print
    input ">",a
    print
    if a > freekinNumber then print "Tha's not me freekin' number! 'Tis lower."
    if a < freekinNumber then print "Tha's not me freekin' number! 'Tis higher."
    if a = freekinNumber then
        print "Tha's me freekin' number!"
        print "'Tis true, I'm the ";freekinNumber;" son o' me father."
        print "Me half father. Now git!"
        print
        print "Press any key to end game."
        gameOver = 1
    end if
loop until gameOver
sleep
badmrbox
Posts: 664
Joined: Oct 27, 2005 14:40
Location: Sweden
Contact:

Post by badmrbox »

We all need to put the fun back into coding some times and I have always wanted to play the guessing game with an evil leprechaun. :)
hartnell
Posts: 170
Joined: Aug 15, 2006 3:21
Contact:

Post by hartnell »

Thanks. I've decided to use him as much as possible in old examples and simple games. I've already written him into a primitive random name generator and he's soon to become a BlackJack dealer. I've named him Evile, the drunken leprehcaun.

-hartnell
aetherFox
Posts: 100
Joined: Jun 23, 2005 16:48

Post by aetherFox »

Nice.

I used to put a pirate in my programs. I wrote a game in Batch once, and he was the narrator.

Never named him. I'm thinking Barmy Bumbleboot.
hartnell
Posts: 170
Joined: Aug 15, 2006 3:21
Contact:

Post by hartnell »

Barmy Bumbleboot is a fine name and bears repetition. - hartnell
E.K.Virtanen
Posts: 785
Joined: May 28, 2005 9:19
Location: Finland

Post by E.K.Virtanen »

Ok, story on a number guessing game. I like that. Programming should never be too serious ;D

But as you told, some things is fun to do...just because of fun.

Code: Select all

' MystMobile DEMO
' Public Domain, lurah, www-ascii-world.com
'
' Hopefully this awesome MystMobile brings some good sleepingsand to MysticShadows,
'  so he can sleep like a baby for now on :D

Randomize Timer
DIM AS Integer a = 1, x = 10, Rock = 1, Rock2 = 15, UpDown = 0, Speed = 150, Cloud = 4, Cloud2 = 39
DIM AS Integer Star(20,2), Counter
   For Counter = 1 TO 20
      Star(Counter,1) = INT(RND * 18) + 1
      Star(Counter,2) = INT(RND * 79) + 1
   Next Counter

DIM AS String KeyPress

DO
IF Rock > 26 AND Rock < 31 OR Rock > 60 AND Rock < 65 AND x > 8 Then UpDown = 1
IF Rock2 > 26 AND Rock2 < 31 OR Rock2 > 60 AND Rock2 < 65 AND x > 8 Then UpDown = 1
IF UpDown = 1 AND x > 2 THEN x = x - 1
IF UpDown = 2 AND x < 10 THEN x = x + 1
IF x = 2 THEN UpDown = 2

Color 0, 0 :CLS

Color 15,0
For Counter = 1 TO 20
   LOCATE Star(Counter,1), Star(Counter,2)
   Print "."
   Star(Counter,2) = Star(Counter,2) + 1
   IF Star(Counter,2) = 80 Then Star(Counter,2) = 1
Next Counter



Color 6, 0
LOCATE (20),Rock : Print "/##\";
LOCATE (20),Rock2 : Print "/##\";
Color 1, 0
LOCATE 2, Cloud : Print " _,,,,_";
LOCATE 3, Cloud : Print "(__   _)";
LOCATE 4, Cloud : Print "   ---";
LOCATE 7, Cloud2 : Print " _--_-_";
LOCATE 8, Cloud2 : Print "(__   _)";
LOCATE 9, Cloud2 : Print " ''---";

Color 4, 0
LOCATE x, 41       : Print"___________";
LOCATE (x + 1), 40 : Print"/          |";
LOCATE (x + 2), 39 : Print"/           |";
LOCATE (x + 3), 38 : Print"/            |";
LOCATE (x + 4), 27 : Print"__________/_____________|_____________________";
LOCATE (x + 5), 27 : Print"|         |             |  THE MystMobile     |";
LOCATE (x + 6), 27 : Print"|  _____  |          == |             _____   |";
LOCATE (x + 7), 27 : Print"| /     \ |             |            /     \  |";
LOCATE (x + 8), 27 : Print"||       ||_____________|___________|       |_|";
LOCATE (21),1 : Print"------------------------------------------------------------------------------";


Color 14, 0
IF a = 1 THEN
   LOCATE (x + 7), 31 : Print "___"
   LOCATE (x + 8), 30 : Print "/\ /\"
   LOCATE (x + 9), 29 : Print "|  x  |"
   LOCATE (x + 10), 29 : Print " \/_\/"
   LOCATE (x + 7), 66 : Print "___"
   LOCATE (x + 8), 65 : Print "/\ /\"
   LOCATE (x + 9), 64 : Print "|  x  |"
   LOCATE (x + 10), 64 : Print " \/_\/"
END IF

IF a = 2 THEN
   LOCATE (x + 7), 31 : Print "___"
   LOCATE (x + 8), 30 : Print "/ | \"
   LOCATE (x + 9), 29 : Print "|--+--|"
   LOCATE (x + 10), 29 : Print " \_|_/"
   LOCATE (x + 7), 66 : Print "___"
   LOCATE (x + 8), 65 : Print "/ | \"
   LOCATE (x + 9), 64 : Print "|--+--|"
   LOCATE (x + 10), 64 : Print " \_|_/"
END IF


IF Speed >25 THEN Speed = Speed - 1
a = a + 1
   IF a = 3 Then a = 1

Cloud = Cloud + 1
   IF Cloud = 72 Then Cloud = 1
Cloud2 = Cloud2 + 1
   IF Cloud2 = 72 Then Cloud2 = 1
Rock = Rock + 1
   IF Rock = 75 Then Rock = 1
Rock2 = Rock2 + 1
   IF Rock2 = 75 Then Rock2 = 1
SLEEP Speed
KeyPress = INKEY$
Loop Until KeyPress <> "" 
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Post by 1000101 »

"half father?"

How do you have a "half father????"
jevans4949
Posts: 1186
Joined: May 08, 2006 21:58
Location: Crewe, England

Post by jevans4949 »

Nice one, lurah!

Slight enhancement to hartnell's code.

Code: Select all

'wha's me freekin' number for FreeBASIC
'a simple evil leprechaun number guesssing game
'yes, this example is so well known and so overdone we included an evil
'leprechaun.

Dim a As Integer
Dim freekinNumber As Integer
Dim gameOver As Integer = 0

Print "You were wandering in the woods one day, taking in the sights, minding"
Print "your own business, when you found that you had rudely intruded upon the"
Print "drunken leprechaun area of the forest."
Print
print "As sure as leprechaun's are an ugly shade of green, one of them appears"
Print "and says :"
Print
print "Ye hav' stepped upon me' house, and me hav'n jus' painted 'er a purty"
Print "shade of green. If ye wants ter git outta 'is forest alive, yer gonna"
Print "haf'ta answer me riddle:"
Print
print "Me gives ye a hint. 'Tis betwixt 1 and 100."
Randomize Timer
freekinNumber = Int(Rnd(1)*100)+1
Do
    Print
    Print "Wha's me freekin' number?"
    Print
    Input ">",a
    Print
    If a > freekinNumber Then Print "Tha's not me freekin' number! 'Tis lower."
    If a < freekinNumber Then Print "Tha's not me freekin' number! 'Tis higher."
    If a = freekinNumber Then
        x$ = str$(freekinnumber)
        select case right$(x$,1)
        case "1"
            y$ = "st"
        case "2"
            y$ = "nd"
        case "3"
            y$ = "rd"
        case else
            y$ = "th"
        end select
        Print "Tha's me freekin' number!"
        Print "'Tis true, I'm the ";x$;y$;" son o' me father."
        Print "Me half father. Now git!"
        Print
        Print "Press any key to end game."
        gameOver = 1
    End If
Loop Until gameOver
Sleep
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Post by counting_pine »

(There's only a 3 in 100 chance that he'll be the 11st, 12nd or 13rd son o' his father, so hopefully noone'll notice any problems with the enhancement)
jevans4949
Posts: 1186
Joined: May 08, 2006 21:58
Location: Crewe, England

Post by jevans4949 »

Good Spot - result of insufficient testing

Code: Select all

'wha's me freekin' number for FreeBASIC
'a simple evil leprechaun number guesssing game
'yes, this example is so well known and so overdone we included an evil
'leprechaun.

Dim a As Integer
Dim freekinNumber As Integer
Dim gameOver As Integer = 0

Print "You were wandering in the woods one day, taking in the sights, minding"
Print "your own business, when you found that you had rudely intruded upon the"
Print "drunken leprechaun area of the forest."
Print
print "As sure as leprechaun's are an ugly shade of green, one of them appears"
Print "and says :"
Print
print "Ye hav' stepped upon me' house, and me hav'n jus' painted 'er a purty"
Print "shade of green. If ye wants ter git outta 'is forest alive, yer gonna"
Print "haf'ta answer me riddle:"
Print
print "Me gives ye a hint. 'Tis betwixt 1 and 100."
Randomize Timer
freekinNumber = Int(Rnd(1)*100)+1
Do
    Print
    Print "Wha's me freekin' number?"
    Print
    Input ">",a
    Print
    If a > freekinNumber Then Print "Tha's not me freekin' number! 'Tis lower."
    If a < freekinNumber Then Print "Tha's not me freekin' number! 'Tis higher."
    If a = freekinNumber Then
        x$ = Str$(freekinnumber)
        y$ = "th"
        if freekinnumber<10 or freekinnumber>13 then
            Select Case Right$(x$,1)
            Case "1"
                y$ = "st"
            Case "2"
                y$ = "nd"
            Case "3"
                y$ = "rd"
            End Select
        end if
        Print "Tha's me freekin' number!"
        Print "'Tis true, I'm the ";x$;y$;" son o' me father."
        Print "Me half father. Now git!"
        Print
        Print "Press any key to end game."
        gameOver = 1
    End If
Loop Until gameOver
Sleep
E.K.Virtanen
Posts: 785
Joined: May 28, 2005 9:19
Location: Finland

Post by E.K.Virtanen »

Maybe we are soon goin to arrange an compo of re-creating a guess the number game :D

I made this "mod" of guessnumber game few months a go.

RED: Number is bigger than your guess.
YELLOW: Number is smaller than your guess.
GREEN: That number guessed correctly.

Code: Select all

' Guess what number. Version 0.001
' Simple stuff, just compile and run.
' you get the thrill.
' Created by lurah. Copy, modifye, edit, eat, drink or what ever with this

' You can quit, by goin over Max or under Min values.
' Basicly its 0 or > 100

Randomize Timer
Color 0,0 : CLS

' Lets set Min and Max values just to make code look bit better
Dim Min,Max AS INTEGER
    Min = 1 : Max = 100

' 5 randomed numbers on array. These are what we are tying to guess.
DIM Numbers(5,2) AS INTEGER
   For i = 1 TO 5
      Numbers(i,1) = INT(RND * 100) + 1
      Numbers(i,2) = 1
   Next i

' This is what player types at each round and how many rounds played. Guessed is number of correctly guessed numbers.
Dim Guess, Rounds, Guessed AS INTEGER
      Rounds = 0 : Guessed = 0
DO
Rounds = Rounds + 1 : Guessed = 0
   Color 15
   LOCATE 18,10 : Print "Round playing now:"; Rounds
   LOCATE 20,10 : Input "Enter your guess. Between 1 to 100";Guess
   CLS
     IF Guess < Min OR Guess > Max Then END
    
   For i = 1 TO 5
      IF Guess = Numbers(i,1) Then Numbers(i,2) = 0
      IF Numbers(i,1) < Guess Then Color 14
      IF Numbers(i,1) > Guess Then Color 12
      IF Numbers(i,2) = 0 Then
      Color 10 : Guessed = Guessed + 1
      END IF
           LOCATE i+5, 15 : Print "Number:"; i;
   Next i
        IF Guessed = 5 Then EXIT DO
Loop

CLS
For i = 1 TO 5
   LOCATE i,5, 15 : Print "Number:"; i ; " was "; Numbers(i,1);
Next i
Locate 15,15 : Print "Total rounds needed:"; Rounds
Sleep 
hartnell
Posts: 170
Joined: Aug 15, 2006 3:21
Contact:

Post by hartnell »

jevans, thnx.

lurah, that version of guess the number is absolutely mindbending. My "guess cache" quickly dries up so it's a real challenge.

-hartnell
Post Reply