View Full Version : ranking?
mario_hater
March 24th, 2007, 10:52 AM
i have finally finished nearly finished my shooting game but need a way to give the player a rank. The current code doesn't work but i'm sure its something like this.
[code]onLoad = function () {
if (time<60) {
rank = "OMG!!";
break;
}
if (time<65) {
rank = "woooo";
break;
}
if (time<70) {
rank = "It's a good-a";
break;
}
if (time>75) {
rank = "don't quit your day job";
break;
}
if (time<80) {
rank = "practice was made for people like you";
break;
}
if (time<95) {
rank = "press ALT+F4. NOW";
break;
}
};[as/]
It is supposed to work like if you get a time less than 60 then it says the first one.
Joppe
March 24th, 2007, 12:41 PM
Try
onLoad = function () {
if (time<60) {
rank = "OMG!!";
} else if (time<65) {
rank = "woooo";
} else if (time<70) {
rank = "It's a good-a";
} else if (time<75) {
rank = "don't quit your day job";
} else if (time<80) {
rank = "practice was made for people like you";
} else if (time<95) {
rank = "press ALT+F4. NOW";
}
};
ajcates
March 24th, 2007, 01:10 PM
i wrapped it up into a function and took care of some bugs, because what if the user gets a score higher then 95? rank will get an undefined
//telling what ever this is, when it loads, it needs to run this block of code
this.onLoad = function() {
//asigns rank based on what getRanking returns
rank = getRanking(time);
};
//declareing the getranking function
function getRanking(time:Number):String {
//goes thur the condtions
if (time<60) {
return "OMG!!";
} else if (time<65) {
return "woooo";
} else if (time<70) {
return "It's a good-a";
} else if (time<75) {
return "don't quit your day job";
} else if (time<80) {
return "practice was made for people like you";
} else if (time>=80) {
//i changed this up, becuase what if the user gets a score bigger then 95? it will throw out an undefined
return "press ALT+F4. NOW";
}
}
hybrid101
March 25th, 2007, 01:54 AM
^excellent code, now all you have to do is call the function;)
and of course, modify the trace to the text box where you want it to display;)
mario_hater
March 25th, 2007, 03:28 PM
thanks
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.