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.

Newcomers DBPro Corner / Texts in a World Sim

Author
Message
flock
18
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 10th Mar 2006 15:52
Alright, I've written a buttload of smaller programs and I've launched my first real one, a World Sim.

How could I code some internal "timer" or another or a random variable puller to implement into my game so real-time things could happen such as a storm or earthquake. A random "picker" to pick out a disaster or something good from an established list.

From the selection of that timer it would also affect a continous string of text. Say the string is at the very top of the screen and says, "Everything is okay." But when something is not okay it displays, "Something is not okay." I've tested this with the code below. So when I start it all up I mouse click and come up with "Something is not okay." But when I hit the space key "Something different" is printed onto "Something is not okay" and it gets all jumbled up. Why isn't it clearing properly? Have I messed something up with the sync?

I'm sorry if this is in any way confusing.

Thanks
The end is near
19
Years of Service
User Offline
Joined: 19th Jun 2005
Location: USA
Posted: 11th Mar 2006 07:52 Edited at: 11th Mar 2006 08:05
`i cant get your code,source is broken so try again
`are you using the rnd() command?
`if you did use it would look something like this:
randomize timer()
do
dp=rnd(10000)
if dp=1 then disaster=1
if dp=2 then disaster=2
if dp=3 then disaster=3
if dp=4 then disaster=4
if diaster=0 then print "everything is fine"
if diaster=1 then if dh=70 then disaster=0 else dh=dh+1 : print "earthquake!"
if diaster=2 then if dh=70 then disaster=0 else dh=dh+1 : print "tornado!"
if diaster=3 then if dh=70 then disaster=0 else dh=dh+1 : print "tsunami!"
if diaster=4 then if dh=70 then disaster=0 else dh=dh+1 : print "hurricane!"
loop

`the probability of there being a disaster is 1/2500
`so about every 4 minutes or so, there will be a disaster for 7 sec.
`dh stands for disaster happening
`dp stands for disaster probability
flock
18
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 11th Mar 2006 10:59
I've actually never thought of it like that with the IF command resetting the arch-variable.

The source code was just example, not the real stuff. I'll be back soon and I'll post some real code after I execute a couple other things to see if anything works.
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 11th Mar 2006 19:39
Quote: "when I hit the space key "Something different" is printed onto "Something is not okay" and it gets all jumbled up."

It sounds like you're not clearing the screen between prints. Is it currently a 2d application without sync? If so, when you change it, you want to use "cls" to clear the screen so it's blank for you to print on.

Mind you, it'll get everything else off the screen too.

You'll find if you move to having a main loop, with sync every frame, that you'll need to print your status string every time you go through the loop anyway, with cls cleaning it before you do.

Hope that helps.

Login to post a reply

Server time is: 2024-09-24 17:35:42
Your offset time is: 2024-09-24 17:35:42