Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 random movement like fish
Index -> Graphics and Design, Web Design -> Flash MX Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Biohazzrd




PostPosted: Tue Nov 28, 2006 6:19 pm   Post subject: random movement like fish

for school we are making a fish tank in flash where we each make a fish and I have been entrusted with duty to program the random movement like fish do i have some code but it doesent work. Here it is:
code:
Object.prototype.move = function  () {
        rotAdd = (random(100-(vita*rot))-50)/100;
        rot += rotAdd;
        _rotation  += rot;
        posX = this.tempo * Math.sin((_rotation/180)*Math.PI);
        posY = -this.tempo * Math.cos((_rotation/180)*Math.PI);
        _x += posX;
        _y += posY;
        if ((((_x < -20) or (_x > 550)) or (_y < -20)) or (_y > 500)) {
            _rotation += 180;
        }
};

This is supposed to go into the first frame of the root time line and the this bit of code goes to themovie clip on the root timeline:
code:

onClipEvent(enterFrame){
move;
}


this is supposed to be what it looks like, go to this link (http://friendsofed.infopop.net/2/OpenTopic?a=tpc&s=989094322&f=3953051263&m=6483039495)
and go to the "fish V1" in examples in the first post
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Graphics and Design, Web Design -> Flash MX Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: