Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / random number generator

Author
Message
Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 18th Oct 2004 07:03
i want to use this code


but i want to add a random number generator in there so when the timer reaches 100 it will randomly pick one of the four pictures which are going to be a frog, snake, human, turtle and for the frog i want it to say it was making a frog and for the snake it would say it was making a snake ect... could someone help

anyone can be a hero, but a soldier can be a hero five minuets longer....
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 18th Oct 2004 07:39
chuck:
randomize timer()

at the top.. This tells the seed for the generator to be based on time. So the set of random numbers u use will be different every time.

THEN.. use the 'rnd()' function to get a random number. Check the manual for syntax.

Then you can either use a select case scenario to pick the image:




Or just use lots of IF's..

Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 18th Oct 2004 07:44
ok so for this code i go

if time=100
goto i
endif

or is that wrong

anyone can be a hero, but a soldier can be a hero five minuets longer....
Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 18th Oct 2004 08:17 Edited at: 18th Oct 2004 08:17
anyone is it right?

anyone can be a hero, but a soldier can be a hero five minuets longer....
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 18th Oct 2004 08:23
err.....

wrong..



Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 18th Oct 2004 08:27
oh ok but how do i make it so when the timer goes up to 100 it runs the code?

anyone can be a hero, but a soldier can be a hero five minuets longer....
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 18th Oct 2004 08:48 Edited at: 18th Oct 2004 08:50
if time >= 100 then gosub LOAD_NEW_IMAGE

See Gosub is different from GOTO...

Goto just GOES to a new line.. Whereas gosub makes a note of where it came from and when you say return it takes that and goes back.

IT does a stack of positions. So multiple goesubs know where to go back to.

In the old days, if you did lots of gosubs then you did a goto that interrupted the flow of returning back up the stack using returns then you got STACK OVERFLOW errors.

Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 18th Oct 2004 09:15 Edited at: 18th Oct 2004 09:17
it get to 100 then the models stop but i dont see any image do i have to delete the objects before the image comes up? also when it does do i put this in the gosub after every load bitmap

wait 1000
goto 29

<edit> heres the code so far...


anyone can be a hero, but a soldier can be a hero five minuets longer....
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 18th Oct 2004 09:23
Rite.. Sorry what EXACTLY do you want to do with the image?

Do you want to texture the object, show it as a sprite or what?

Nick

Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 18th Oct 2004 09:25
i wanted eveything off the screen so you could see it..fit to the screen...then it would go back to the begining sry if i wasnt more specific

anyone can be a hero, but a soldier can be a hero five minuets longer....
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 18th Oct 2004 09:27
so when time >= 100 you want to load a random image, display it full screen for a specified amount of time and then go back to the normal loop?

Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 18th Oct 2004 09:29
yes

anyone can be a hero, but a soldier can be a hero five minuets longer....
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 18th Oct 2004 09:41 Edited at: 18th Oct 2004 09:43
riiiite... Well why didn;t you say so?!





hows that - it was done off the top of my head..

Basically, you have a status flag. When you select your image, you then make a sprite out of it and scale it to full screen.

In the main loop when STATUS = 1 then it will show the sprite over the stuff. Then when timer >=200 it will hide it and reset the timers.. Hows that?

Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 18th Oct 2004 09:47
dang its still the same problem it dosent pick a sprite the whole thing pauses for a moment then it just goes back to norman and it has the frog picture instead of the backdrop picture???

anyone can be a hero, but a soldier can be a hero five minuets longer....
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 18th Oct 2004 09:50
Humm.. Could you please ZIP up the folder with it all in (except the EXE) and attach it to a post.. I cant quite figure out what you mean. It would be easier if I had the project here.

Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 18th Oct 2004 10:04
i cant its 5.44 megs unless you want me to break it up into several downloads?

anyone can be a hero, but a soldier can be a hero five minuets longer....
Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 18th Oct 2004 10:06
but if it would help it is going to be a screen saver

anyone can be a hero, but a soldier can be a hero five minuets longer....
Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 18th Oct 2004 10:34
can anyone hoast? please

anyone can be a hero, but a soldier can be a hero five minuets longer....
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 18th Oct 2004 11:01
USe WinRAR or WinZIP and break it into chunks.. and do 1 post per 1Mb Chunk..

Why is it so large? You got a lot of silly size textures too?

Dont include the EXE - I can make that on my end...

Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 18th Oct 2004 11:01
OR POST A SCREENIE!! Why didn't I think of that..

OR a few screenies...

Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 18th Oct 2004 12:50 Edited at: 18th Oct 2004 20:52
no no i got antdizzle to host for me its at
[href]admiralgames.uni.cc/biologyss.zip[/href]

woho!

anyone can be a hero, but a soldier can be a hero five minuets longer....
Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 18th Oct 2004 20:53
so if anyone wants to help the file is right there

anyone can be a hero, but a soldier can be a hero five minuets longer....
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 18th Oct 2004 21:01
Sorry mate - bad link

Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 19th Oct 2004 01:24
huh it works fine here

www.admiralgames.com/biologyss.zip

try this

anyone can be a hero, but a soldier can be a hero five minuets longer....
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 19th Oct 2004 02:03
Admiralgames.com cannot be found...

I'm on NTL.. Maybe that name aint filtered through to the NTL DNS servers yet...

Are you 100% sure its ok?

Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 19th Oct 2004 06:45
yeah but its all case sensititive

anyone can be a hero, but a soldier can be a hero five minuets longer....
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 19th Oct 2004 07:16
no it isn't... Websites are not case sensitive.. or at least they shouldn't be. I copied and pasted the link anyway.

FILES are case sensitive.. addresses are not. (you think that yahoo registered:
www.yahoo.com
www.Yahoo.com
www.yAhoo.com
www.yaHoo.com
.....

Lol

Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 19th Oct 2004 11:23
oh yeah lol so did you get it because it works fine here?

anyone can be a hero, but a soldier can be a hero five minuets longer....
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 19th Oct 2004 17:12
Nope still cannot be found. You sure the case on the filename is correct?

RougeCat
20
Years of Service
User Offline
Joined: 13th Jul 2004
Location: Xdrome
Posted: 19th Oct 2004 17:20
Page not found error here as well.

Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 20th Oct 2004 01:19
hmm well i got the problem fixed thanks to lost in thought

anyone can be a hero, but a soldier can be a hero five minuets longer....
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 20th Oct 2004 01:38
what was it?

Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 20th Oct 2004 07:06
i couldant get alot of thing to work but he commented it alot so i fiqured out what i did wrong

anyone can be a hero, but a soldier can be a hero five minuets longer....
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 20th Oct 2004 11:46
Which was.....

Osiris
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: Robbinsdale, MN
Posted: 20th Oct 2004 12:32
making things go away and come back when i wanted them to

anyone can be a hero, but a soldier can be a hero five minuets longer....

Login to post a reply

Server time is: 2025-06-05 20:18:15
Your offset time is: 2025-06-05 20:18:15