
-----------------------------------
Jonnu
Thu Mar 27, 2008 3:50 pm

Buttons
-----------------------------------
hey i am trying to make a game and decided to use buttons.
My question is is it possible to use buttons so that a get stament isn't used but still can make a var have a value.
I tried but after then button screen went off the procedure stopped and the var didn't have a vaule

-----------------------------------
Mackie
Thu Mar 27, 2008 3:52 pm

RE:Buttons
-----------------------------------
Sorry, I don't know exactly what your asking about. Do you have any code so far?

-----------------------------------
darkangel
Thu Mar 27, 2008 5:00 pm

Re: Buttons
-----------------------------------
.....I think your talking bout the getch() or the Input.KeyDown() commands, but not sure.
Can you be a little bit more specific or provide your code?

-----------------------------------
Jonnu
Thu Mar 27, 2008 6:18 pm

Re: Buttons
-----------------------------------
umm ok i'll try and explain i don't have the code because i didn't save it due to the fact that it didn't work soo here it goes.

My game is a Text base RPG where the user is given a situation and has to decide what to do.

this is a situation in the beginning of the game where the user has to chose what there greatest strength will be which is Power Speed or Smart

this is the code

put "What is your greatest strength"
put "Power,Speed or Smart"
get mainS
cls
    if mainS= ('Power')
        then put "Choose your weapon"
        put "Fists, GiantHammer or Claymore" 
        get weapon
    elsif mainS= ('Speed')
        then put "Choose your weapon"
        put "Legs, Claws or Bow" 
        get weapon
    elsif mainS= ('Smart')
        then put "Choose your weapon"
        put "Hands, Wand or Staff"
        get weapon
        end if
cls

this lets the user choose which is there main stat then what weapon they want to use


if you look at it when the user is prompt to give and answer it has to be exactly right
for example if the user wants Power then they have to type Power not power and in the later game a simple mess up will cause and error and the user has to restart


now what i want is to make these choices as buttons instead on having to type them i and wondering if i can change

put "What is your greatest strength"
put "Power,Speed or Smart"
get mainS

i understand how to make the buttons just not how i can get an answer from the user so that when they click the button the variable is that for the rest of the game.

if you still don't understand i will try and get it to the version where i had the buttons.  :D

-----------------------------------
jinjin
Thu Mar 27, 2008 6:41 pm

Re: Buttons
-----------------------------------
I'm not sure how to make buttons myself in Turing as I am still in Gr.10, which is year 1 programming. However, for this problem:

if you look at it when the user is prompt to give and answer it has to be exactly right
for example if the user wants Power then they have to type Power not power

You can change that by adding an 'or' to the if statement. For example 


get (input)
if (input) = "Power" or (input) = "power" then (perform action) 


Now the user can input "Power" or "power" to perform the next action.

-----------------------------------
Sean
Thu Mar 27, 2008 6:53 pm

Re: Buttons
-----------------------------------
Your wanting those choices as buttons?

If so, Draw a box around the words which are coded with Draw.Text

Look up Mouse.Where if you are wanting to use your own buttons. You would need to check the between the boundaries of the Box and then have it do what you want, by using an if statement.

-----------------------------------
Mackie
Thu Mar 27, 2008 6:59 pm

RE:Buttons
-----------------------------------
Check out my latest post, there is a really simple button in there, but I suggest learning it your self before you use it.

http://compsci.ca/v3/viewtopic.php?p=157366#157366

-----------------------------------
Jonnu
Thu Mar 27, 2008 7:27 pm

Re: Buttons
-----------------------------------
I'm not sure how to make buttons myself in Turing as I am still in Gr.10, which is year 1 programming. However, for this problem:

if you look at it when the user is prompt to give and answer it has to be exactly right
for example if the user wants Power then they have to type Power not power

You can change that by adding an 'or' to the if statement. For example 


get (input)
if (input) = "Power" or (input) = "power" then (perform action) 


Now the user can input "Power" or "power" to perform the next action.


yea but also this won't work becuase they might spell it incorrect

and ty i will see with Draw.Text and everything else TY for your help and

jinjin fyi i am in Gr.10 too but since we are barly in school for march i decided to start a game for fun just to as you can say flex my muscles

-----------------------------------
Sean
Fri Mar 28, 2008 6:28 am

Re: Buttons
-----------------------------------
That's why you give them what the inputs should be in an put statement like you did above. Or, you can have it check to see if it is not correct, then loop back to the beginning. Meaning you will need a main loop for the entire game.


loop

%Your Code Here

end loop

