Draw actor reality problem

Non-platform specific questions.

Draw actor reality problem

Postby Troodon » Fri Oct 26, 2007 6:49 pm

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. :|
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: Draw actor reality problem

Postby Fuzzy » Sat Oct 27, 2007 2:38 am

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.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: Draw actor reality problem

Postby Bee-Ant » Sat Oct 27, 2007 4:01 am

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:
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Draw actor reality problem

Postby Troodon » Sat Oct 27, 2007 3:57 pm

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.
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: Draw actor reality problem

Postby Kalladdolf » Sat Oct 27, 2007 4:00 pm

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)
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: Draw actor reality problem

Postby Troodon » Sat Oct 27, 2007 4:12 pm

Ah, I tought it was his new account or something. :P
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: Draw actor reality problem

Postby Kalladdolf » Sat Oct 27, 2007 4:21 pm

nono, he's annoyed by that "darkboy".
at first that guy named himself "dark kalladdolf" and used my avatar in the opposite colors!
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: Draw actor reality problem

Postby Troodon » Sat Oct 27, 2007 4:24 pm

Oh, weird. :wink:
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: Draw actor reality problem

Postby Fuzzy » Sun Oct 28, 2007 12:44 am

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!
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: Draw actor reality problem

Postby Troodon » Sun Oct 28, 2007 8:06 pm

Thanks for info T.F Pete!
I changed the variable from integer to real. :)
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: Draw actor reality problem

Postby Bee-Ant » Tue Oct 30, 2007 12:25 pm

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???
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Draw actor reality problem

Postby Troodon » Tue Oct 30, 2007 2:41 pm

:D
Perhaps he got banned? His age is 5 and I tought that phpBB limit is 13. So perhaps Makslane banned him?
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: Draw actor reality problem

Postby Bee-Ant » Tue Oct 30, 2007 2:44 pm

:shock: 5???
:wink:
I think he just make a sensation...
just joined, but he could popular like this...
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Draw actor reality problem

Postby Troodon » Tue Oct 30, 2007 4:00 pm

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.
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: Draw actor reality problem

Postby Troodon » Tue Oct 30, 2007 4:20 pm

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?
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron