Page 1 of 1

LONG SERIES OF HTML5 GAMES: chapter1 part9

Posted: Sat May 23, 2015 6:23 am
by afisoone
Assalamu Caleykum,

Xagee qaxweynta noo mareeysay. Oh waxey noo joogtay inaan soo baranay screeen wrapping. Now how to set and stop at the boundaries for that arrow image.

Ok. Now let' edit again updateStageka ee filekii aan soo suubisanay Object.js

And put this
function updateStageka()
{
window.requestAnimationFrame(updateStageka, canvaska);

arrow.x++;




if (arrow.x + arrow.width > canvaska.width)
{
arrow.x = canvaska.width - arrow.width;
}




hadbaSawir();


}
When the arrow comes from the left it will go to the end of the other side. and stops.

We test if the arrow x iyo balaciisa haduu ka badnaado balaca canvaska. Then stop.
We stop
arrow.x=canvaska.width -arrow.width


Ok let's live what we did... Demo Boundaries stop

Now what?

Let me ask you a question. Now we know how to add an arrow image to the canvaska.
How Do you add a background image to the canvaska?
We will answer in the next lesson. Inshallah!

<<Previous Lesson