Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 moving back...
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
magicman




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Wed Jun 29, 2005 4:16 pm   Post subject: (No 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.
magicman




PostPosted: Wed Jun 29, 2005 4:22 pm   Post subject: (No subject)

all right, thanks Very Happy
Delos




PostPosted: Wed Jun 29, 2005 5:28 pm   Post subject: (No subject)

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




PostPosted: Wed Jun 29, 2005 6:18 pm   Post subject: (No subject)

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




PostPosted: Wed Jun 29, 2005 6:57 pm   Post subject: (No 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?
Bacchus




PostPosted: Wed Jun 29, 2005 7:45 pm   Post subject: (No 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...
Delos




PostPosted: Wed Jun 29, 2005 8:21 pm   Post subject: (No 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.
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Wed Jun 29, 2005 8:36 pm   Post subject: (No 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
Delos




PostPosted: Wed Jun 29, 2005 11:03 pm   Post subject: (No 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.
magicman




PostPosted: Thu Jun 30, 2005 8:02 am   Post subject: (No subject)

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




PostPosted: Thu Jun 30, 2005 8:21 am   Post subject: (No subject)

Click!
MysticVegeta




PostPosted: Thu Jun 30, 2005 1:35 pm   Post subject: (No 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"?
Cervantes




PostPosted: Thu Jun 30, 2005 1:58 pm   Post subject: (No subject)

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

It's also in Java.
magicman




PostPosted: Tue Jul 05, 2005 4:28 pm   Post subject: (No subject)

so will procedures work for the monsters also?? on what my friends say, is that i might not, but i dont know.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 18 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: