Page 1 of 2

Draw actor reality problem

PostPosted: Fri Oct 26, 2007 6:49 pm
by Troodon
This is my code
Code: Select all
if (ENERGY > 10)
{
    ChangeAnimation("Event Actor", "LightdogRunRight", FORWARD);
    CON -= 0.001;
    xvelocity = 0.3*ENERGY;
    ENERGY -= 0.0001;
}

if (ENERGY > 0 && ENERGY <= 10)
{
    xvelocity = 2;
    CON -= 0.001;
    ENERGY -= 0.001;
}


I think you see what I'm trying to do. I'm trying to make the ENERGY variable go down slowly. This event is in the key down event of right arrow.
However, for some unknown reason the ENERGY ends very quickly. I've tried to add zeros in the line ENERGY -= 0.0001; and it always ends with the same speed. Then when I add enough zeros it stops declining. Is this a bug or why there is this kind of behaviour? The motion compression is off. :|

Re: Draw actor reality problem

PostPosted: Sat Oct 27, 2007 2:38 am
by Fuzzy
If you add enough zeros you will get outside the accurate range of the float variable. It will round to zero. Try make the variables into integers, use larger numbers, and only divide it right before you apply it to the velocity.

Re: Draw actor reality problem

PostPosted: Sat Oct 27, 2007 4:01 am
by Bee-Ant
Ummm...yeah Fuzzy right, maybe you could change it into integer...float is just make a trouble if you can't manage it carefully... 8)
Oh...is it your new game Mikey??? :D :mrgreen:

Re: Draw actor reality problem

PostPosted: Sat Oct 27, 2007 3:57 pm
by Troodon
Darkboy: Yeah, I'm working on a demo called Lightdog.

Fuzzy: What do you mean of using integer? It is already integer variable. Or do you mean I should avoid values starting 0,n? How could I modify my code dynamically? Because it is calculating the xspeed "in flight" so I must use variables shown in the code. Solid values aren't enough.

Re: Draw actor reality problem

PostPosted: Sat Oct 27, 2007 4:00 pm
by Kalladdolf
just to inform u:
we better not call bee-ant darkboy anymore, there's another fake darkboy around, spying on bee-ant and me
(whatever)

Re: Draw actor reality problem

PostPosted: Sat Oct 27, 2007 4:12 pm
by Troodon
Ah, I tought it was his new account or something. :P

Re: Draw actor reality problem

PostPosted: Sat Oct 27, 2007 4:21 pm
by Kalladdolf
nono, he's annoyed by that "darkboy".
at first that guy named himself "dark kalladdolf" and used my avatar in the opposite colors!

Re: Draw actor reality problem

PostPosted: Sat Oct 27, 2007 4:24 pm
by Troodon
Oh, weird. :wink:

Re: Draw actor reality problem

PostPosted: Sun Oct 28, 2007 12:44 am
by Fuzzy
ENERGY -= 0.001;
is an integer tekdino?

if so, that isnt good.

For those of you that want to convert a float, or a integer to the opposite, on the fly, try this in your code:

lets say that you want to have a speed variable, and its stored as a float, for whatever reason. in global code, you would define it like this

double speed;

double means double precision float. its a 32 bit number, and will store floating point values more accurately.

so at some point in your code, you set it..

speed = 10.567;

now lets say you want to show that to the player in a text actor. But you dont want to show the .567. Here is how you do it.

textNumber = (int)speed;

what you would see is "10", not "10.567", although the variable would continue to hold the whole value.

Thats called typecasting. it doesnt actually change the variable, it just treats it differently in that exact instance. This is a bit different than the rounding functions.

If you do the opposite with an int(lets use health):

health = 19;
textNumber = (double)health;

this will not display "19" in the text actor. you will actually see "19.0"

I hope thats all clear!

Re: Draw actor reality problem

PostPosted: Sun Oct 28, 2007 8:06 pm
by Troodon
Thanks for info T.F Pete!
I changed the variable from integer to real. :)

Re: Draw actor reality problem

PostPosted: Tue Oct 30, 2007 12:25 pm
by Bee-Ant
I think it's fine call me Darkboy...because he has changed his name again...
Wooww...Lightdog???Why you didn't choose Lightboy as it name??? :lol:
Btw, where's that boy???

Re: Draw actor reality problem

PostPosted: Tue Oct 30, 2007 2:41 pm
by Troodon
:D
Perhaps he got banned? His age is 5 and I tought that phpBB limit is 13. So perhaps Makslane banned him?

Re: Draw actor reality problem

PostPosted: Tue Oct 30, 2007 2:44 pm
by Bee-Ant
:shock: 5???
:wink:
I think he just make a sensation...
just joined, but he could popular like this...

Re: Draw actor reality problem

PostPosted: Tue Oct 30, 2007 4:00 pm
by Troodon
Perhaps he will stop when his mother finds out his roleplaying. :lol:
Seriously, it can be also a bot haxed inside the forum server. Or a real member who created a new account just to tease you and Kalladdolf.

Re: Draw actor reality problem

PostPosted: Tue Oct 30, 2007 4:20 pm
by Troodon
Now when you are here: are you actually a GE user? Or just on the forums to have fun? Also have you got another user account?