What's wrong with this code?

Non-platform specific questions.

What's wrong with this code?

Postby Troodon » Tue Jan 02, 2007 9:04 pm

I'm very confused.
I can't understand where is the error in this code:
Code: Select all
if(distance(x, y, monster.x, monster.y)<=150)
{
   angle=direction(monster.x, monster.y, sini.x, sini.y); +180;
   directional_velocity=2;
}


That should make sini named actor move from the monster actor when closer than 150 pixels. It's not working
:cry:
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

Postby marathon332 » Tue Jan 02, 2007 9:36 pm

It's a typo...

You have an extra semi-colon on this line:

angle=direction(monster.x, monster.y, sini.x, sini.y); +180;

it should be:

angle=direction(monster.x, monster.y, sini.x, sini.y) +180;

--Steve
User avatar
marathon332
 
Posts: 57
Joined: Tue Sep 06, 2005 4:00 am
Score: 2 Give a positive score

Postby Troodon » Tue Jan 02, 2007 9:54 pm

Thanks but it's still not working:
angle=direction(monster.x, monster.y, sini.x, sini.y) +180;
directional_velocity=2;

It makes the sini jump over the monster and then wait.
:?
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

Postby Game A Gogo » Tue Jan 02, 2007 10:40 pm

maybe if you remove the +180 t the end, cuz since you flipped the two actor name it done it right and because of the +180, it resets back, well, i cant even understand what i said, just try it!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Troodon » Tue Jan 02, 2007 10:52 pm

I removed the +180 but it has no effect.
This code worked in another game but with different actor names. That's why I don't see where is the error. :cry:
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

Postby Joshua Worth » Tue Jan 02, 2007 11:22 pm

which actor is this code in?
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score

Postby Troodon » Wed Jan 03, 2007 9:37 am

This code is in sini actor. I also tried to change the actor name places in the code but it's not still working.
Currently the sini actor just makes strange jumps over the monster and then wait getting eated.
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

Postby Joshua Worth » Wed Jan 03, 2007 1:00 pm

it should work with the following code

Code: Select all
if(distance(x, y, monster.x, monster.y) <= 150)
{
   angle=direction(monster.x, monster.y, x, y) + 180;
   directional_velocity = 2;
}


but if it doesn't, either i have no idea what is going on, or there is some other script acting at the same time as that one, changing something
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score

Postby Troodon » Wed Jan 03, 2007 1:13 pm

Joshua Worth wrote:it should work with the following code

Code: Select all
if(distance(x, y, monster.x, monster.y) <= 150)
{
   angle=direction(monster.x, monster.y, x, y) + 180;
   directional_velocity = 2;
}


but if it doesn't, either i have no idea what is going on, or there is some other script acting at the same time as that one, changing something


It's making the SINI actor run towards monster when closer than 150 pixels.
I tried to remove the +180 and it's still not working.
I tried to export as exe to see if there is difference but it's still not working.

There is many other scripts working the same time but not something crossing this script.
Is there any max draw actor script limit in GE?
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

Postby makslane » Wed Jan 03, 2007 1:29 pm

Try swap the values in the direction function:

Code: Select all
angle=direction(x, y, monster.x, monster.y) + 180;
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Troodon » Wed Jan 03, 2007 1:52 pm

Still not working :( .

Here is the whole draw actor script:
(maybe there is something that's distracting the code)
Code: Select all
if (ActorCount("karkki"));
{
    MoveTo("Event Actor", 0.000000, 0.000000, nopeus, "karkki");
}

if  ( ActorCount("karkki") == 0)
{
    xvelocity = 0;
    yvelocity = 0;
}

if (geeni > 8.5)
{
    CreateActor("myrkky", "myrkky", "no parent", "no path", 0, 0, false);
}

if(geeni >= 1.5 && geeni <= 2)
{
  ChangeAnimation("Event Actor", "sinigen2albino", FORWARD);
  r = 255;
  g = 255;
  b = 255;
}

if(geeni >= 4 && geeni <= 4.3)
{
  ChangeAnimation("Event Actor", "geneylihormoni", FORWARD);
}

if(geeni >= 6 && geeni <=6.3)
{
    ChangeAnimation("Event Actor", "genealihormoni", FORWARD);
}

if(geeni == 0 )
{
    ChangeAnimation("Event Actor", "genetauti", FORWARD);
    CreateTimer("Event Actor", "tauti", 20000);
}

if(distance(x, y, monster.x, monster.y)<=150)
{
    angle=direction(x, y, monster.x, monster.y) + 180;
    directional_velocity = 2;
}


if(muurari == 50)
{
    CreateTimer("Event Actor", "muuraa", 4000);
}
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


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest