«

»

Aug 12

Realistic Marine Fish Tank

Marine FishTank Attempt 1.


Code for the fish to move. © Craig Lowe – www.loweonline.co.uk

SwishScript
onLoad () {
//fish movement by craig lowe www.loweonline.co.uk
//
© Craig Lowe
speed=1.5; // starting speed of fish
du=0.5; //speed of the direction up and down movement
moveleft=true;
moveright=false;
moveup=false;
movedown=true;
}
onEnterFrame() {
if(dir<5){ this.moveleft=true; this.moveright=false; }if(dir>5){
this.moveright=true;
this.moveleft=false;
}
if(this.moveleft==true){
this._x=this._x-=speed;
this.moveright=false;
}
if(this.moveright==true){
this._x=this._x+=speed;
this.moveleft=false;
}
if(this.movedown==true && this._y<430){ this._y=this._y+=du; } if(this.moveup==true && this._y>30){
this._y=this._y-=du;
}
if(this._x<-30){ this._x=650; } if(this._x>650){
this._x=-30
}
}
OnEnterFrame(){
updwn=random(60);
if(this.updwn==25){
this.moveup=true;
this.movedown=false;
}
if(this.updwn==7){
this.moveup=false;
this.movedown=true;
}/*if(this.updwn>50){
this.moveup=false;
this.movedown=false;
}*/
}
OnFrame(125){ // alter this (125) for quicker movement change
speed=randomRange(0,6); // speed range 0, 6 random speed from 0 to 5 pixels, o means fish will stop/ hover
dir=random(10);
if(this.dir<5 && this.moveright==true){ this._xscale *= -1; } if(this.dir>5 && this.moveleft==true){
this._xscale *= -1;
}

}

code for swishmax 2 and 3 below

onSelfEvent (load) {
//fish movement by craig lowe www.loweonline.co.uk
speed=1.5;
du=0.5;
moveleft=true;
moveright=false;
moveup=false;
movedown=true;
}
onSelfEvent (enterFrame) {
if(dir<5) {
this.moveleft=true;
this.moveright=false;
}
if(dir>5) {
this.moveright=true;
this.moveleft=false;
}
if(this.moveleft==true) {
this._x=this._x-=speed;
this.moveright=false;
}
if(this.moveright==true) {
this._x=this._x+=speed;
this.moveleft=false;
}
if(this.movedown==true && this._y<400) {
this._y=this._y+=du;
}
if(this.moveup==true && this._y>60) {
this._y=this._y-=du;
}
if(this._x<-50) {
this._x=650
}
if(this._x>650) {
this._x=-50
}
}
onSelfEvent (enterFrame) {
updwn=random(60);
if(this.updwn==5) {
this.moveup=true;
this.movedown=false;
}
if(this.updwn==3) {
this.moveup=false;
this.movedown=true;
}
/*if(this.updwn>50){
this.moveup=false;
this.movedown=false;
}*/
}
onFrame (250) {
speed=randomRange(1,3);
dir=random(10);
if(this.dir<5 && this.moveright==true) {
this._xscale *= -1;
}
if(this.dir>5 && this.moveleft==true) {
this._xscale *= -1;
}
}


VN:F [1.9.22_1171]
Rating: 5.0/5 (5 votes cast)
VN:F [1.9.22_1171]
Rating: +5 (from 5 votes)
Realistic Marine Fish Tank, 5.0 out of 5 based on 5 ratings

Leave a Reply

9 visitors online now
5 guests, 4 bots, 0 members
Max visitors today: 14 at 12:32 am UTC
This month: 27 at 05-17-2013 01:24 pm UTC
This year: 39 at 01-01-2013 12:46 pm UTC
All time: 109 at 12-07-2012 11:00 pm UTC