Welcome to SomaliNet Forums, a friendly and gigantic Somali centric active community. Login to hide this block

You are currently viewing this page as a guest. By joining our community you will have the ability to post topics, ask questions, educate others, use the advanced search, subscribe to threads and access many, many other features. Registration is quick, simple and absolutely free. Join SomaliNet forums today! Please note that registered members with over 50 posts see no ads whatsoever! Are you new to SomaliNet? These forums with millions of posts are just one section of a much larger site. Just visit the front page and use the top links to explore deep into SomaliNet oasis, Somali singles, Somali business directory, Somali job bank and much more. Click here to login. If you need to reset your password, click here. If you have any problems with the registration process or your account login, please contact us.

LONG SERIES OF HTML5 GAMES: chapter1 part12

Qaybta Xirfada Sayniska iyo iwm

Moderators: Moderators, Junior Moderators

OUR SPONSOR: LOGIN TO HIDE
User avatar
afisoone
SomaliNet Super
SomaliNet Super
Posts: 5387
Joined: Wed Jul 22, 2009 9:46 pm
Location: We all want to become president even though Amisom controls Mogadishu

LONG SERIES OF HTML5 GAMES: chapter1 part12

Postby afisoone » Sat May 23, 2015 7:51 pm

Hello Markale.. Last question was how to keep the image inside the canvaska...

Ok let's do it.

First our plane image in the keyboarding tutorial. we will test first if plan.x is less the zero. Then set it to zero.

here how you do it?
if(plane.x < 0)
{

plane.x=0;


}
Then we do similar to plane.y
if(plane.y < 0)
{

plane.y=0;

}
to get the exact leading each we add the width of the plane to see if over pass the canvaska.
if(plane.x + plane.width >canvaska.width)

{
//then we return back. actually it stops when it reached there.
plane.x=canvaska.width - plane.width;



}
then we do the samething to plane.y
if(plane.y +plane.height >canvaska.height)

{
plane.y=canvaska.height -plane.height;

}
Beautiful: Now let's add these codes to updateStageka();
function updateStageka()
{
window.requestAnimationFrame(updateStageka, canvaska);

if(korUsoco && !hoosUsoco)
{
plane.vy=-5;


}
if(hoosUsoco && !korUsoco)
{
plane.vy=5;


}
if(midigUsoco && !bidixUsoco)
{
plane.vx=-5;


}
if(bidixUsoco && !midigUsoco)
{
plane.vx=5;


}
if(!hoosUsoco && !korUsoco)
{
plane.vy=0;


}
if(!bidixUsoco && !midigUsoco)
{
plane.vx=0;


}
plane.x+=plane.vx;
plane.y+=plane.vy;

//control the canvas

if(plane.x<0)
{
plane.x=0;
}
if(plane.y<0)
{
plane.y=0;
}
if(plane.x+plane.width>canvaska.width)
{
plane.x=canvaska.width-plane.width;
}
if(plane.y+plane.height>canvaska.height)
{
plane.y=canvaska.height-plane.height;
}







hadbaSawir();


}
Here we go. Now the plane will not cross the canvaska.. Actually it will stop much less than the edge..

Let's test in our server on this one keyboard with boundaries


The Quiz
Student: Macalin Afisoone, How to put camera in this canvaska so the plane can fly on the sky passing the cload?

Macalin Afisoone: It is called scaling and I will do it our next lesson. Inshallah!

<<<Previous Lesson

OUR SPONSOR: LOGIN TO HIDE

Hello, Has your question been answered on this page? We hope yes. If not, you can start a new thread and post your question(s). It is free to join. You can also search our over a million pages (just scroll up and use our site-wide search box) or browse the forums.

  • Similar Topics
    Replies
    Views
    Last post

Return to “Careers - Engineering, Science & Computers”

Who is online

Users browsing this forum: No registered users and 6 guests