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 Discussion / wow this is brain wreking......

Author
Message
sorcre
22
Years of Service
User Offline
Joined: 13th Dec 2002
Location: United States
Posted: 20th Jun 2003 04:12
i have a random variable which is called damage#
how do i make damage# which lets say equals 30 to be damage$="-30"
the problem is that damage# keeps on changing...... anyone know how to?
never achive your goals... cause if you do then what is next????
andrew11
22
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 20th Jun 2003 04:20
damage$ = STR$(damage#)

"All programmers are playwrites and all computers are lousy actors" -Anon
Click Here!!!
TKF15H
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: Rio de Janeiro
Posted: 21st Jul 2003 16:35
damage$=STR$(damage#*-1)

Ag3ntSm1th
22
Years of Service
User Offline
Joined: 13th May 2003
Location:
Posted: 22nd Jul 2003 03:38
TKF15H has it. first you are negating the random number, then turning it into a string. EZ

"The secret to creativity is knowing how to hide your sources." - Einstein
my DarkBasic creations - http://www.sixurbanninjas.tk
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 22nd Jul 2003 04:51
Or this:

damage$=STR$(abs(damage#))

would work also i think

---Mattman
DID YOU KNOW THAT ???
Drifter
21
Years of Service
User Offline
Joined: 24th Jun 2003
Location:
Posted: 22nd Jul 2003 06:26
I thinks abs only makes neg into pos

"Sun makes me sneeze but thats a different story"
Ag3ntSm1th
22
Years of Service
User Offline
Joined: 13th May 2003
Location:
Posted: 22nd Jul 2003 10:17
yeah

"The secret to creativity is knowing how to hide your sources." - Einstein
my DarkBasic creations - http://www.sixurbanninjas.tk
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 22nd Jul 2003 12:21
take away its result from (itself x2).

result = 4
rev = (result-(result*2))

print result
print rev
sync
suspend for key
end

TKF15H
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: Rio de Janeiro
Posted: 23rd Jul 2003 02:56
its simpler to multiply by -1.
and you forgot to use the STR$(), indi.

I need an animator!!! HELP ME!!
Chiwawa
22
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 23rd Jul 2003 03:57
or simply

damage$ = STR$(0-damage#)

or

damage$ = STR$(sqrt(1)*(0-((asin(sin(sqrt(abs(damage#)^2))))&(asin(sin(sqrt(abs(damage#)^2)))))))

TKF15H
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: Rio de Janeiro
Posted: 23rd Jul 2003 15:40
hahaha.
That is one slow peace of code! lets take a look at that:

First you got the string, no problem there,

then you got the square of 1 (which is 1) and multiplied it by the stuff after it...(in other words you did nothing)

with the 0-... you made the number a negative. OK.

then the asin of the sin. Thats funny. I never thought about that one. It probably just returns the same value it had before.

then you got the square root of the following value times it self. (in other words you did nothing)

Nice code!! :-d

I need an animator!!! HELP ME!!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Jul 2003 01:50
ABS gives you the ABSolute value of a value - in other words, it removes the sign, (as Drifter said).

ABS(-34) = 34

It's use is mainly when you want to find out the difference between two values and you don't know which is the larger.

X=300
Y=200
Diff=X-Y ... Diff = 100

But if:

X=200
Y=300
Diff=X-Y ... Diff = -100

Using Diff=ABS(X-Y) means you always get a positive difference value - regardless of the size of the two values.

TDK
kevil
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 24th Jul 2003 01:54
How about:
damage$="-"+str$(damage#)

There are so many ways!

Kevil

HZence
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 24th Jul 2003 04:40
actually kevil that will only work if he doesn't actually need the variable to be a negative number. if ya do it that way it just appears to be negative and it is in fact positive

SW Games - www.freewebs.com/swgames

Yeah, I know, I only have one game. Yeah, I know it sucks. But I made it! Me!
TKF15H
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: Rio de Janeiro
Posted: 24th Jul 2003 05:31
And if damage$ is already negative (lets say -1) I think you'll get: "--1"

I need an animator!!! HELP ME!!

Login to post a reply

Server time is: 2025-05-20 01:46:09
Your offset time is: 2025-05-20 01:46:09