| This board has been archived and is no longer accepting new questions. If you have a support question for your ZetaBoard, please visit us at the new support board. Registration is free and easy. Visit the NEW ZetaBoards Support forum! |
- Pages:
- 1
- 2
| How do I make this random? | |
|---|---|
| Topic Started: Jun 21 2008, 12:08 PM (624 Views) | |
| Thunder | Jun 21 2008, 12:08 PM Post #1 |
|
Thunder
![]() ![]() ![]() ![]() ![]()
|
I'm creating this game where you can pick a number between 1 and 10, but if someone guesses the right number, they'll always know it. How do I make it so that it will choose a different number everytime? Here's the code:
|
![]() |
|
| Fission | Jun 21 2008, 01:08 PM Post #2 |
![]()
I am really awesome
![]() ![]() ![]() ![]() ![]()
|
Google is awesome.
You could probably find a better solution than that somewhere on Google, but that is what I could find. |
![]() |
|
| WeirdAdz | Jun 21 2008, 01:14 PM Post #3 |
|
You cant go through life without saying something is Weird.
![]() ![]() ![]() ![]()
|
This is what i use which is fairly similar. Its Javascript. But you could take out parts which arent needed. The code basically allows the member to use the option of using the Random feature, and after they have posted the number comes up inbetween the text either side 'Your attack did' & 'damage!'
Change the Number to the maximum number. Edited by WeirdAdz, Jun 21 2008, 01:17 PM.
|
![]() |
|
| Fission | Jun 21 2008, 01:20 PM Post #4 |
![]()
I am really awesome
![]() ![]() ![]() ![]() ![]()
|
The basic formula for getting a range is Math.random()*(max-min)+min. And, if you want a whole number, us Math.floor, Math.round, etc. to round it. |
![]() |
|
| WeirdAdz | Jun 21 2008, 01:33 PM Post #5 |
|
You cant go through life without saying something is Weird.
![]() ![]() ![]() ![]()
|
Fission.. you don't need a minimum number unless you want it from 10-20, Also the code which i posted is already Whole Numbers, no decimals etc. |
![]() |
|
| Thunder | Jun 22 2008, 11:02 AM Post #6 |
|
Thunder
![]() ![]() ![]() ![]() ![]()
|
I want to know who's right. All I want is place to put part of a code that makes it do a random number between 1 and 10.
Where would I put this? |
![]() |
|
| Viral | Jun 22 2008, 11:06 AM Post #7 |
|
i'm stanley nao
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
They're both right, just Fission's example allows the range to be between y and x, not 1 and [x. You can put that wherever you want. |
![]() |
|
| WeirdAdz | Jun 22 2008, 03:47 PM Post #8 |
|
You cant go through life without saying something is Weird.
![]() ![]() ![]() ![]()
|
Fission's method is useless if you are going from 1 - another number. However it is great for when you are trying to go from say number 5 to number 8. My method just goes from number 1 - another number. |
![]() |
|
| Thunder | Jul 9 2008, 11:11 AM Post #9 |
|
Thunder
![]() ![]() ![]() ![]() ![]()
|
Sorry for bumping this back... None of these things are working for me. When ever I type in 5, it always says it's right, instead of picking a different number. Can someone give me the code I created, with the added part that will make it a random number each time? |
![]() |
|
| RyuraGS | Jul 9 2008, 02:22 PM Post #10 |
![]()
Member
![]() ![]() ![]() ![]() ![]()
|
What's your code look like right now? |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| Go to Next Page | |
| « Previous Topic · jQuery Help · Next Topic » |
- Pages:
- 1
- 2




![]](http://209.85.62.24/static/1/pip_r.png)





11:33 AM Dec 8