

-----------------------------------

battleroyale

Fri Apr 15, 2005 4:55 pm


how to make a counter?

-----------------------------------

OK......how do you make a counter for a lottery game or w/e. Like you have money and if you win you get w/e. and if you lose you lose w/e. 
plz help


-----------------------------------

Delos

Fri Apr 15, 2005 5:29 pm



-----------------------------------

A 'counter' is a fancy name for a variable.


var iAmNotACounter : int := 0
% Note the initialization before anything else is done.

for i : 1..5
put i
iAmNotACounter += 1
end for

put iAmNotACounter


Oh, in case you're wondering, 'iAmNotACounter' is a counter.


-----------------------------------

battleroyale

Fri Apr 15, 2005 5:48 pm



-----------------------------------

ok...how would i use that too make a score chart...like you start off with a number..and if you win..the number goes up..but if you lose the number goes down...can you use if statements?


-----------------------------------

[Gandalf]

Fri Apr 15, 2005 5:59 pm



-----------------------------------

Of course (and I showed the same thing as above on your previous post :|).  

if result := win then
score += 1
elsif result := loss then
score -= 1
end if



-----------------------------------

battleroyale

Fri Apr 15, 2005 6:27 pm



-----------------------------------

sorry gandalf for using up your time...ill stick with this thread now..
ok...for your code

if result := win then 
score += 1 
elsif result := loss then 
score -= 1 
end if 


how would i start it...cuz i dont know how to declare result (cuz im a noob  :D ) here is the code i have written so far 


var number : int
var number2 : int
var number3 : int


var numpick : int
var numpick2 : int
var numpick3 : int

proc theend
    cls
    put "Thank you for playing Woodbridge lotto"
    delay (2000)
    put "Kevin Nguyen"
    delay (2000)
    quit
end theend
proc Q2
    randint (number, 1, 50)
    randint (number2, 1, 50)
    randint (number3, 1, 50)
 
    put "Your numbers are "
    delay (750)
    locate (5, 25)
    put numpick
    delay (750)
    locate (5, 30)
    put numpick2
    delay (750)
    locate (5, 35)
    put numpick3
   

    put skip
    put "The lottery numbers are "
    delay (750)
    locate (15, 25)
    put number
    delay (750)
    locate (15, 30)
    put number2
    delay (750)
    locate (15, 35)
    put number3

    if numpick = number or numpick = number2 or numpick = number3
            or numpick2 = number or numpick2 = number2 or numpick2 = number3
            or numpick3 = number or numpick3 = number2 or numpick3 = number3 then
        put skip
        put "Goodjob, you won!"
        put skip
            var yorn1 : string
            put "Want to try again? y or n"
            get yorn1
            if yorn1 = "n" then
            theend
            end if

        else
            put "try again"
            put skip
            var yorn : string
            put "Want to try again? y or n"
            get yorn
            if yorn = "n" then
                theend
            else
end if


            end if

   
end Q2

loop

cls
    put "Pick 3 numbers between 1 and 50."

    get numpick, numpick2, numpick3
   
    var yorn : string
    put "Are you sure? y or n"
    get yorn : *
    cls
    if yorn = "y" then
        Q2
    end if
end loop







I want to add somewhere the money you start off with ($5) and if you win..you add 10 bucks and if you lose you lose a buck (or w/e) the stuff that iv tried kept resetting the start money to 5....help

ps. as you can see...i dont understand arrays so its really long and repetitive...


-----------------------------------

[Gandalf]

Fri Apr 15, 2005 7:06 pm



-----------------------------------

To declare you use something like this
result := "win"
after already identifying result as a string.

So, for an example:

var result : string
var score : int := 10
if this := that then
put "you won"
score += 10 %adds 10 to the current score
result := win  %says that the result is now "win"
elsif this := notthat then
put "you lost"
score -= 10
result := lost
end if
put score

Try adapting that to your program.

Also, to make your program more efficient and neat when declaring many similar variables use this:

var num1, num2, num3 : int

Or later on, to improve this idea further research arrays, you might want to check one of the tutorials for that.

Hope this helps!


-----------------------------------

battleroyale

Sat Apr 16, 2005 12:36 pm



-----------------------------------

thanks..it did...all i need to do is clean it up and add some colour... THANKS again


-----------------------------------

shlitiouse

Mon Apr 18, 2005 8:22 am



-----------------------------------

Hi, I noticed that you had asked about giving the user a set amount of money that they could use, I read through the advice and didn't see anyone mention anything about it. It would just be a simple question of adding


var money:int:=5

if result=win then
   money +=1
else
   if result=loss then
      money -=1
   end if
end if

This is basicaly what you were doing before, except you're giving the variable a set number. If you want to make the game a little more interesting, you could make different difficulty levels that would let the user start out with more or less money, depending on the difficulty selected. This can be done with a "difficulty" variable, a couple more IF statements, and a get statement at the beggining. I'll let you have fun trying out these suggestions, rather than posting how to do it. But if you get stuck feel free to ask[/code]


-----------------------------------

[Gandalf]

Mon Apr 18, 2005 9:57 pm



-----------------------------------

Ya, if you looked more closely you would see I did have that.
var score : int := 10

score += 10 %etc, etc...

Anyways, if you did want to have a difficulty setting, or just allow the user to input the amount of starting money then (according to my code):

get input
score := input

and then just work with that, its pretty simple once you understand it...

Now I suggest you look up arrays - the earlier you learn them the less trouble you're going to have (trust me :o).

