# Stars ai

**URL:** <https://forum.kirupa.com/t/stars-ai/326691>\
**Category:** Uncategorized\
**Created:** [January 5, 2012, 3:28pm UTC](https://forum.kirupa.com/t/stars-ai/326691 "2012-01-05T15:28:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 5, 2012, 3:28pm UTC](https://forum.kirupa.com/t/stars-ai/326691/1 "2012-01-05T15:28:07Z")

</div>

hi everyone,  
firstly there are no fullstops since kirupa keep thinking i’m sending links i have a program where multiple stars appear on the screen i have an ai controlled player who tries to collects these stars i wrote:

```auto

public function getDirection(obj2:DisplayObject, obj2:DisplayObject){
return Mathatan2(obj1 y - obj2 y, obj1 x - obj2 x);
}
public function playGame(){
var star:MovieClip;

var star_array = quick starArray; //an array from another class which contains all the stars

for(var i:int = star_array length - 1;i >= 0;i--){
star = star_array*;
var dir:Number = getDirection(icon_movie, star);
if(icon_movie hitTestObject(star)){
star_array splice(i,0);
star = star_array[i + 1];
getDirection(icon_movie, starOne);
playGame(); // trying to repeat the process again
}
}
}

var xstepOne:Number = Math cos(dir)*4;
var ystepOne:Number = Math sin(dir)*4;
icon_movie x -= xstepOne;
icon_movie y -= ystepOne;

```

This works for the first star but then errors appear about the playGame() function Any help would be great
