setInterval(isFishOnScreen(),50);
function isFishOnScreen()
{
if(checkiffishisonscreen() == false)
newFish();
else
newFish();
}
function checkiffishisonscreen()
{
if(fishyPos < 400 && fishyPos > 1)
return false;
else
return true;
}
function newFish()
{
var numb = Math.floor(Math.random()*500);
var x = numb;
var dy = 5;
context2D.drawImage(fish,numb,fishyPos);
if(fishyPos < 400)
{
fishyPos += dy;
canvas.width = canvas.width;
context2D.drawImage(fish,x,fishyPos);
}
}
so if you couldnt tell based on the code, what im trying to do is create a random fish location x-value with the random function, and draw the fish. but i only want 1 fish on the screen at a time, so i have to test if there is already a fish based on the yposition. the fish will move off the screen only by moving downward until they are off the screen, they i want to remake a new fish.
any ideas? :D
thanks in advance,
madskillsmonk
Edited by dargueta, 30 April 2011 - 06:49 PM.
Please use [code][/code] tags next time


Sign In
Create Account


Back to top









