View Full Version : Help with If/Else
general
06-19-2006, 03:39 PM
Ok, so I have this game that I'm making. What I want to do is when Mana steps into the portal, she will be transported to another place. So I used if/else. If mana is within 2 meters of portal, she will move. It works if I start the world and Mana is within 2 meters of the portal. But what I want to do is have the user move mana towards the portal. I can move her just fine but when I reach the portal, nothing happens. I tried using while but the same thing happened.
I'll attach the file but it's pretty big. I'll upload it to a hosting site if I can't get it on here. I left it at the portal moving up when mana is within 3 meters to test it.
http://www.yousendit.com/transfer.php?action=download&ufid=525DAC775F5607EF
lanceA
06-19-2006, 06:11 PM
Start with something like this:
while true
if Mana within 3 meters of gardenportal
gardenportal moveup 5 meters
I tried it and it works here.
If you need to, create a boolean variable for your while-statement. You can change it to it's opposite value if you fall into the if-statement in order that you gracefully exit the while-statement.
Play with that code.
general
06-19-2006, 11:42 PM
That works great. But I must be able to explain why I did it that way. What should I say?
lanceA
06-20-2006, 07:59 AM
Uh-oh :o The name of your world gave it away - PRSPAssignment.a2w ;)
Unless they specifically tell you otherwise when the assignment is issued, most teachers will accept your work as long as when it is handed in you tell them personally or in some document you include with your work that you were stumped with a particular algorithm and assistance was provided by someone else.
For instance in your main method, world.myfirstmethod, place a comment at the very top that looks something like this:
// Author: <your name> Date: 06/20,2006
// The purpose of this program is to .....................<you complete this >
//
/* Assistance with the algorithm for Mana and the rising of the gardenportal in the Mana.walknow method, (or which ever method it was in), was provided by "others" <-- a name(s) would normally go here
*/
Seriously, that works plus in some other instances it protects you from plagerism/code copying, etc. allegations.
24 megs is a very large program - I'm sure others would be interested in viewing it when it is completed. I especially will be interested in how you tie the multiple scenes in the scenario together.
Good luck !!
general
06-21-2006, 03:35 AM
ok I'll do that. And yeah, I'll share the world once I'm done with it. I'm pretty much just writing lines now. I should be done by the end of the week.