Computer Science Canada

moving back...

Author:  magicman [ Wed Jun 29, 2005 4:13 pm ]
Post subject:  moving back...

Im making a text base game, and im asking if something is ok, and of corse its in an if statement, something like..

code:

if ans="y"|ans="Y" then
%it will continue the game.
end if
if ans="n"|ans="N" then
%it will go to the begining.
end if

so what do i do?

Author:  Cervantes [ Wed Jun 29, 2005 4:16 pm ]
Post subject: 

Good thing you posted that code, or I would have had NO idea what you were asking about.
Put your program in a loop. If no, then exit. Otherwise, you continue.

Author:  magicman [ Wed Jun 29, 2005 4:22 pm ]
Post subject: 

all right, thanks Very Happy

Author:  Delos [ Wed Jun 29, 2005 5:28 pm ]
Post subject: 

I did not know one could use pipe as an or operator. Interseting...

Author:  magicman [ Wed Jun 29, 2005 6:18 pm ]
Post subject: 

what are you talking about "pipe"?? are you talking about this thing "|"

Author:  magicman [ Wed Jun 29, 2005 6:57 pm ]
Post subject: 

i also have another delema,

code:

 put "There is a,"
    put "Equipment Shop (N)"
    put "Bar (E)"
    put "Galactic Police (S)"
    put "Apartments (W)"
    put "Jedi Academy (NE)"
    get ans
    delay (500)
    cls
    if ans = "n"| ans = "N" then
        put "What do you want you ", race, "??"
        put "(B)uy"
        put "(E)xit"
        get ans
        if ans = "b"| ans = "B" then
        elsif ans = "e"| ans = "E" then
            exit
        end if
end if

i want it to, when ans="e", that it will go back to the
code:

put "There is a,"
    put "Equipment Shop (N)"
    put "Bar (E)"
    put "Galactic Police (S)"
    put "Apartments (W)"
    put "Jedi Academy (NE)"
    get ans

part. how can i do that?

Author:  Bacchus [ Wed Jun 29, 2005 7:45 pm ]
Post subject: 

Stick that part in a loop.
As for the pipe -->|, yes it can be used as 'or' the same as & can be used as 'and'. I'm surprised you didn't know that...

Author:  Delos [ Wed Jun 29, 2005 8:21 pm ]
Post subject: 

I'm not omniscient you know Laughing.

As for your dilema, magicman, I would highly recommend looking into procedures. You will find that once you're able to box up bits of your code, everything will flow a lot smoother.

Author:  Cervantes [ Wed Jun 29, 2005 8:36 pm ]
Post subject: 

Delos wrote:

I'm not omniscient you know Laughing.

Well, you were a newbe God at one point. Maybe you shouldn't have given that up! Very Happy

The other way to look at this is to have a variable store the player's location. This way, you just have one loop and one if .. elsif .... end if statement.

code:

loop %main loop
  if player.location = "weapon shop " then
    %options.  Would be good to proceduralize this
    %buy, sell, talk
  elsif player.location = "bar" then
    %buy drinks, talk
  elsif player.location = "live8" then
    player.fun = "very yes"
  end if
end loop

Author:  Delos [ Wed Jun 29, 2005 11:03 pm ]
Post subject: 

And of course that construct itself can be boxed up as well! You might even want to make a dynamic construct that is similar to that! It would be rather challenging though - making a procedure that gives a variable number of options to choose from and reacts differently depending on the chosen response...
It's possible though, using the all-powerful flexiblie array!

Newbe God. Keep that ?! Umm...no thanks. I like my current rank much better Very Happy.

Author:  magicman [ Thu Jun 30, 2005 8:02 am ]
Post subject: 

its been awhile, what are procedures... i never realy got them, when i got taught them... Embarassed

Author:  Cervantes [ Thu Jun 30, 2005 8:21 am ]
Post subject: 

Click!

Author:  MysticVegeta [ Thu Jun 30, 2005 1:35 pm ]
Post subject: 

Bacchus wrote:
Stick that part in a loop.
As for the pipe -->|, yes it can be used as 'or' the same as & can be used as 'and'. I'm surprised you didn't know that...


I didnt know that either, i thought it worked only for C++, Confused by the way, just for my stupidity, which key types the "pipe"?

Author:  Cervantes [ Thu Jun 30, 2005 1:58 pm ]
Post subject: 

Shift + \. In and around the backspace and enter/return buttons.

It's also in Java.

Author:  magicman [ Tue Jul 05, 2005 4:28 pm ]
Post subject: 

so will procedures work for the monsters also?? on what my friends say, is that i might not, but i dont know.

Author:  Delos [ Tue Jul 05, 2005 5:12 pm ]
Post subject: 

Procedures can be customized to work for practically anything. I would really suggest playing around with parameters to see what they can do for you. Take a look at Cervantes' update Str. module posted in the 'New Turing' commands thread. It has some good examples of what paramter-usage can accomplish.

Author:  magicman [ Tue Jul 05, 2005 6:02 pm ]
Post subject: 

alright, any thing else?

Author:  Cervantes [ Tue Jul 05, 2005 8:37 pm ]
Post subject: 

I'm responding to very few details here, but here goes:
You're trying to use procedures to organize your program. You intend to use procedures to do various things with the player. Now you're looking at how to do things with the monsters. You may want to make your procedures more general so they can correspond to both monster and player. For example, you could have a procedure to attack in battle. The parameters would be the attacker and the target. If you build the player and the monsters out of the same type then you can interchange the target and the attacker.

Just think about what you're trying to accomplish; then think about the tools at your disposal. Think about generalizing your subroutines (procedures and functions).
If you want some more specific help, post some more details. Smile
You may also want to check out the Turing Source Code forum to get some ideas.


: