ZFGC

Resources => Coding => Topic started by: ZoSo on June 21, 2006, 05:10:21 am

Title: [Request / Listing] deku baba [GM6]
Post by: ZoSo on June 21, 2006, 05:10:21 am
Need help coding a deku baba. so far all I have is "if distance_to_object(objchara_link) < 4".
I need help with things like ,how you make the baba attack left if link is to the left of it.
Title: Re: deku baba [GM6]
Post by: pxl_moon (dotyue) on June 21, 2006, 05:40:41 am
i'm not a coder but maybe something like that?

Code: [Select]
objchara_link.x -4 then { sprite_index = sprdekubaba_attack_left }
Title: Re: deku baba [GM6]
Post by: Fox on June 24, 2006, 12:53:20 pm
More like...
Code: [Select]
if distance_to_object(objchara_link.x)<4
{
sprite_index="sprdekubaba_attack_left"
}
And under sprite_index-stuff you might want to add the function that calls the Baba to attack.
Title: Re: deku baba [GM6]
Post by: litium on June 24, 2006, 02:03:12 pm
i think it will be easier if you are using global.dir or gloabl.face variables this:
Code: [Select]
if if distance_to_object(objchara_link.x)<4
{
if gloabl.dir="left"{
sprite_index="sprdekubaba_attack_left"
}
}
and fot the others the same but changin the x value to engative and then for up and down y instead of x so you'll have 4 pices of code.

i think this would work, but no sure
Title: Re: deku baba [GM6]
Post by: sjegtp on June 29, 2006, 10:53:34 pm
Code: [Select]
if (distance_to_object(objchara_link) < 4 && objchara_link.x - x < -2/*Or any value between -4 and 0*/)
{
//attack on the left
}



Code: [Select]
if if distance_to_object(objchara_link.x)<4
{
if gloabl.dir="left"{
sprite_index="sprdekubaba_attack_left"
}
}
sprdekubaba_attack_left should be without the "".
Title: Re: deku baba [GM6]
Post by: Goodnight on June 29, 2006, 11:07:04 pm
Code: [Select]
if distance_to_object(objchara_link.x)<4Nerp, that function calls for an object's name, not one of its variables.

Here's what I'd suggest:
Code: [Select]
var dir;
dir=point_direction(x,y,objLink.x,objLink.y)

if distance_to_object(objLink)<16 {
    if dir>=315 || dir<45 {
        sprite_index=(attacking right)
    } else if dir>=45 && dir<135 {
        sprite_index=(attacking up)
    } else if dir>=135 && dir<225 {
        sprite_index=(attacking left)
    } else {
        sprite_index=(attacking down)
    }
} else {
    sprite_index=(not attacking)
}

First that makes a new variable called dir, which is the angle from the Deku Baba to Link (0 to 360 degrees).

If the Link object is within 16 pixels (you might even want to make that higher, like around 40), then check which range the angle falls into, and set the corresponding sprite.
Title: Re: deku baba [GM6]
Post by: litium on July 01, 2006, 01:20:40 pm
prety cool
Title: Re: deku baba [GM6]
Post by: moree on July 12, 2006, 02:40:44 pm
Need help coding a deku baba. so far all I have is "if distance_to_object(objchara_link) < 4".
I need help with things like ,how you make the baba attack left if link is to the left of it.

O so manny thanx!!, I didn't know the code"if distance_to_object()"
It's realy helpfill thanx!

Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved