Jump to content
  • Advertisement
Sign in to follow this  
Taran Shiro

Simple programming help

This topic is 4064 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well, I recently bought Game Programming for Teens which teaches you the language BlitzPlus. Everything so far has been easy to understand, yet when I attempted something of my own, it didn't work. My code is to generate a simple input/output procedure, just like that of an old DOS adventure game. So far the only input I can make which will make a response is a number. I'm trying to make it so that you can enter a line of text, or String$, as a choice. Here is my code: answer = Input$("you find yourself in a room with a cat. what will you do?") If answer = "pet cat" Then Print "You pick up the cat. The cat bites your face off. You are Dead." ElseIf answer = "kick the cat" Then Print "You kick the cat. The cat runs away crying. You win." EndIf Delay 10000 When the program loads and I put in my answer, nothing happens. I tried using String$ instead of Input$ for the answer variable, but that doesn't work. I know this may seem like a pathetic problem, and I'm sure I will learn how solve it as I progress in the book, but for now I'd like to get a quick response. -Thanks! [Edited by - Taran Shiro on June 2, 2007 1:14:05 PM]

Share this post


Link to post
Share on other sites
Advertisement
Never heard of the language "BlitzPlus", though it does look a bit like BASIC.

I would guess that your tests (i.e. "If answer =") are wrong. It depends on what the "=" does, one would guess.

It may also be that what you input isn't what the variable is being set to. It may be including a carriage return at the end, for instance.

Without knowing the syntax of "BlitzPlus" it's hard to say.

For a simple debugging step, try:

Print answer

right after the input and see if it looks the same. Beyond that you'll just have to study the syntax of that language some more.

Share this post


Link to post
Share on other sites
Actually just a little Google search turned up this:

http://www.blitzmax.com/bpdocs/command.php?name=If&ref=2d_cat


; IF THEN Example

; Input the user's name
name$=Input$("What is your name? ")

; Doesn't the person's name equal SHANE?
If name$ = "Shane" Then

Print "You are recognized, Shane! Welcome!"

Else

Print "Sorry, you don't belong here!"

; End of the condition checking
End If



Seems you need to change your code to

...
answer$ = Input$("you find yourself in a room with a cat. what will you do?")

If answer$ = "pet cat" Then
Print "You pick up the cat. The cat bites your face off. You are Dead."

ElseIf answer$ = "kick the cat" Then

...

You were missing the "$" at the end of your variable name.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!