ZFGC
Resources => Coding => Topic started 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.
-
i'm not a coder but maybe something like that?
objchara_link.x -4 then { sprite_index = sprdekubaba_attack_left }
-
More like...
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.
-
i think it will be easier if you are using global.dir or gloabl.face variables this:
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
-
if (distance_to_object(objchara_link) < 4 && objchara_link.x - x < -2/*Or any value between -4 and 0*/)
{
//attack on the left
}
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 "".
-
if distance_to_object(objchara_link.x)<4
Nerp, that function calls for an object's name, not one of its variables.
Here's what I'd suggest:
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.
-
prety cool
-
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!