Twin Matrix
Member
Does anyone have a version of the def move_toward_player in Game_Character 3 to have 8 directions?
I came up with this:
It's very noob-ish and laggy, plus: the character moves around like a headless chicken. Sure, he follows the hero, but he also randomly walks around in the progress. I hope some expert around here can shed some light on things.
I came up with this:
Code:
if sx == 0 or sx == 1 and sy == 0 or sy == 1
case rand(2)
when 0
rand(2) == 0 ? sx += 1 : sy += 1
when 1
rand(2) == 0 ? sx -= 1 : sy -= 1
end
end
if sx == 0 or sx == -1 and sy == 0 or sy == -1
case rand(2)
when 0
rand(2) == 0 ? sx += 1 : sy += 1
when 1
rand(2) == 0 ? sx -= 1 : sy -= 1
end
end
if sx < 0 and sy > 0
move_upper_right
elsif sx < 0 and sy < 0
move_lower_right
elsif sx > 0 and sy > 0
move_upper_left
elsif sx > 0 and sy < 0
move_lower_left
elsif sx < 0 and sy == 0
move_right
elsif sx > 0 and sy == 0
move_left
elsif sx == 0 and sy < 0
move_down
elsif sx == 0 and sy > 0
move_up
end
It's very noob-ish and laggy, plus: the character moves around like a headless chicken. Sure, he follows the hero, but he also randomly walks around in the progress. I hope some expert around here can shed some light on things.