JS Guide-Drawing Function

298 1 0
                                        

Ok. Now, let's begin. Say you were making a game with levels. I would use a draw function for the level like this: var draw = function(){
}; Place the code set in there to do this: fill(0,255,0); ellipse(200,200,200,200); var draw = function(){
rect(200,200,200,200);
}; The fill and shape that is outside the draw function will not appear unless placed in the draw function. Of course, it does not need to say "draw." It can say anything you want. If you put these variables: var drawx = 0; var draw y = 0; Then place it in here: var draw = function(drawx,drawy){
ellipse(drawx,drawy,200,200);
}; The ellipse will not pull up unless you type this: draw(200,200); The numbers are simply examples. Well, that's some basic on draw functions. Now you need to learn what those variables we used mean. And what variables are! Next chapter!

Learning JS Programming LanguageWhere stories live. Discover now