Begining HTML5 game part 1

OK. Let's start .

Do you know HTML ?
Create file game.html with content :
       
 <!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

</head>

<body>



</body>

</html> 

Adding some javascript as framework
       
<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

<script type="text/javascript">

    function update()

    {

        // Game UPDATE login

    }

    function draw()

    {

        // game DRAW

       

    }

    function setup()

    {

       

        setInterval(draw, 21);

        setInterval(update, 21);

    }

</script>

</head>

<body onload="setup()">

    <canvas id="gameCanvas" width="800"  height="550">



</canvas>

</body>

</html>


You can see a HTML5 Canvas tag . We will create game , and draw all thing on this canvas
function setup  some variables and create game loop .

Now we will addling some object to game . A image may be good for begin .
I will draw this image on canvas :


you can download and reset name for image is "monday.jpg" in same location of html file aaaa
       
function draw()
{

        // game DRAW

        var gameCanvas = document.getElementById("gameCanvas");

        var graphic =  gameCanvas.getContext('2d');

        var monday = new Image(); 
        // you can download and reset name for image is "monday.jpg"

            monday.src="monday.jpg";

             graphic.drawImage(monday,100, 100);

} 
               
 Open browser and you can see this image show on canvas .

OK.  For now we implement simple event mouse event .
       

          function setup()

    {

        var gameCanvas= document.getElementById("gameCanvas");

        gameCanvas.addEventListener("click", canvasClicked,true);

        //setInterval(draw, 21);

        setInterval(update, 21);

        

    }

    function canvasClicked(e)

    {

        

        var gameCanvas = document.getElementById("gameCanvas");

        var graphic =  gameCanvas.getContext('2d');

        var monday = new Image();

        monday.src="monday.jpg";

         graphic.drawImage(monday,e.clientX, e.clientY);

    }     
 

Function draw is not loop (commented //setInterval function call), to you can see when click to canvas , new Image is drawn.

As you see HTML5 not so hard as you think , it very simple .

Result : when you click mouse, you could see  monday.jpg draw :D
Full source
<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

<script type="text/javascript">

    function update()

    {

        // Game UPDATE login

    }

    function draw()

    {

        // game DRAW

        var gameCanvas = document.getElementById("gameCanvas");

        var graphic =  gameCanvas.getContext('2d');

        var monday = new Image();

        monday.src="monday.jpg";

         graphic.drawImage(monday,100, 100);

        

    }

    function setup()

    {

        var gameCanvas= document.getElementById("gameCanvas");

        gameCanvas.addEventListener("click", canvasClicked,true);

        //setInterval(draw, 21);

        setInterval(update, 21);

        

    }

    function canvasClicked(e)

    {
        var gameCanvas = document.getElementById("gameCanvas");

        var graphic =  gameCanvas.getContext('2d');

        var monday = new Image();

        monday.src="monday.jpg";

         graphic.drawImage(monday,e.clientX, e.clientY);

        

    }

</script>

</head><body onload="setup()">
    <canvas id="gameCanvas" width="800"  height="550">



</canvas>

</body>

</html>


part 2 is for next post .
Part 3

Share this

Related Posts

Previous
Next Post »

311 comments

comments «Oldest   ‹Older   201 – 311 of 311   Newer›   Newest»
December 5, 2019 at 11:00 PM delete

I found a lot of interesting information here. A really good post. keep updating.No: 1 MBA Project Center in Chennai|

Reply
avatar
December 6, 2019 at 2:54 AM delete

I have read your blog. Good and more informationuseful for me, Thanks for sharing

this information keep it up....
No.1 Python Project Center in Chennai








Reply
avatar
December 6, 2019 at 5:21 AM delete

I am very happy after find this post and really helpful. Thanks for sharing this Informative content. Well explained. Got to learn new things from your Blog. your site really helps me for searching the new and great stuff.
ECE Project Center in Chennai

Reply
avatar
December 6, 2019 at 5:26 AM delete

Quite Interesting post!!! Thanks for posting such a useful post. I wish to read your upcoming post to enhance my skill set, keep blogging.No: 1 BBA Project Center in Chennai|

Reply
avatar
December 7, 2019 at 10:27 PM delete

Great post. Wonderful information and really very much useful. Thanks for sharing and keep updating.No: 1 MBA Project Center in Chennai|

Reply
avatar
December 8, 2019 at 1:47 AM delete

Very nice blog. It is very useful for me. I read your blog completely. I gather lot of information in this post. Thanks for sharing. No: 1 BBA Project Center in Chennai |

Reply
avatar
December 8, 2019 at 6:37 AM delete

Wonderful post with great piece of information. I'm learning a lot from your blog. Keep sharing. No: 1 CCNA Training Center in Kanchipuram|

Reply
avatar
December 8, 2019 at 11:39 PM delete

Nice Post! It is really interesting to read from the beginning & I would like to share your blog to my circles, keep your blog as updated.
No.1 ANDROID Training Institute In Kanchipuram








Reply
avatar
December 8, 2019 at 11:47 PM delete

This was a worthy blog. I enjoyed reading this blog and got an idea about it. Keep sharing more like this.
JAVA Training Center in Kanchipuram

Reply
avatar
December 8, 2019 at 11:52 PM delete

Thanks for giving great kind of information. Thanks for your excellent blog, nice work keep it up thanks for sharing the knowledge. No: 1 Graphic Designing Course in Kanchipuram|

Reply
avatar
December 9, 2019 at 4:51 AM delete

Your Blog is really amazing with smart and unique content..Its very useful to everyone to understand the information clearly.. No: 1 CCNA Training Center in Kanchipuram|

Reply
avatar
December 9, 2019 at 5:31 AM delete

Thanks for making me this Blog. You have done a great job by sharing this content here. Keep writing blog like this
MBA Project Center in Kanchipuram

Reply
avatar
December 9, 2019 at 11:05 PM delete

What a fantastic blog you should written in well manner.Iam really happy to read this
blog.Thanks for sharing.keep sharing more blogs.
No.1 Tally Training Institute In Kanchipuram

Reply
avatar
December 10, 2019 at 1:46 AM delete

You post explain everything in detail and it was very interesting to read.Thank you for Sharing.
IEEE Project Center in Kanchipuram

Reply
avatar
December 10, 2019 at 2:18 AM delete

Very nice post here and thanks for it .I always like and such a super blog of these post.Excellent and very cool idea and great blog of different kinds of the valuable information's. No: 1 IOS Training Center in Kanchipuram|

Reply
avatar
December 10, 2019 at 11:13 PM delete

Quite Interesting post!!! Thanks for posting such a useful post. I wish to read your upcoming post to enhance my skill set, keep blogging
ISTQB Certification Academy in Kanchipuram

Reply
avatar
December 10, 2019 at 11:27 PM delete

Congratulations guys, quality information you have given!!!..Its really useful blog. Thanks for sharing this useful information.
No.1 Selenium Training Center In Kanchipuram

Reply
avatar
December 11, 2019 at 4:15 AM delete

Well Said, you have furnished the right information that will be useful to anyone at all time... No: 1 Tally Erp 9.0 Training Center in Kanchipuram|

Reply
avatar
December 11, 2019 at 4:22 AM delete

I found a lot of interesting information here. A really good post. keep updating.
ISTQB Certification Academy in Kanchipuram

Reply
avatar
December 11, 2019 at 10:35 PM delete


This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information, this is useful to me…
Machine Learning Training Center In Chennai

Reply
avatar
December 11, 2019 at 11:45 PM delete

Good blog. I gained more information about your post. keep updating. No: 1 MS OFFICE Training Center in Chennai|

Reply
avatar
December 12, 2019 at 10:32 PM delete

Great Article. Thank you for sharing! Really an awesome post for every one.

IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai

Reply
avatar
December 12, 2019 at 11:07 PM delete

What a fantastic blog you should written in well manner.Iam really happy to read this
blog.Thanks for sharing.keep sharing more blogs.
No.1 python Training center in Kanchipuram

Reply
avatar
December 13, 2019 at 2:12 AM delete

Your article is really an wonderful with useful content, thank you so much for sharing such an informative information. keep updating.
IOS Training Academy in Kanchipuram

Reply
avatar
December 13, 2019 at 4:25 AM delete

Your article is really an wonderful with useful content, thank you so much for sharing such an informative information. keep updating.
IOS Training Academy in Kanchipuram

Reply
avatar
December 13, 2019 at 10:53 PM delete

Thanks for your informative blog. Your post helped me to understand the future and

career prospects. Keep on updating your blog with such awesome blog.
Software Testing Training institute in

Kanchipuram

Reply
avatar
December 13, 2019 at 11:08 PM delete

Awesome Post!!! With unique content, I really get interest to read this post. I hope this article help many of them who looking this pretty information.
No.1 Android Training institute in Kanchipuram

Reply
avatar
December 14, 2019 at 9:08 PM delete

Really it was an awesome blog...very interesting to read..You have provided an nice information....Thanks for sharing..
BBA Project Center in Chennai

Reply
avatar
December 14, 2019 at 10:23 PM delete

Very happy to see this blog. Gives a wonderful information with coded explanation. Thank you for this blog. very useful to me. No: 1 JAVA Training Institute in Kanchipuram|

Reply
avatar
December 15, 2019 at 1:19 AM delete

Really it was an awesome blog...very interesting to read..You have provided an nice information....Thanks for sharing..
MBA Project Center in Chennai

Reply
avatar
December 15, 2019 at 3:15 AM delete

Very nice post here and thanks for it .I always like and such a super blog of these post.Excellent and very cool idea and great blog of different kinds of the valuable information's. No: 1 .Net Training Institute in Kanchipuram|

Reply
avatar
December 15, 2019 at 6:43 AM delete

Wonderful!! this is really one of the most beneficial blogs I’ve ever browsed on this subject. I am very glad to read such a great blog and thank you for sharing this good info with us.Keep posting stuff like this.. No: 1 MS Office Training Center in Chennai|

Reply
avatar
December 15, 2019 at 9:02 PM delete

Thanks for your informative blog.Your post helped me to understand the future and career prospects. Keep on updating your blog with such awesome blog.
No.1 Android Training institute in Kanchipuram

Reply
avatar
December 15, 2019 at 11:44 PM delete

Thanks for sharing this unique and informative post. This blog which provided me the required information No: 1 Academic Project in Chennai|

Reply
avatar
December 16, 2019 at 10:49 PM delete

This information is impressive. I am inspired with your post writing style.Thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..
No.1 VMware Course in Chennai

Reply
avatar
December 16, 2019 at 11:35 PM delete

Thanks for your informative blog.Your post helped me to understand the future and career prospects. Keep on updating your blog with such awesome blog. Best Hardware and Networking Training institute In Chennai |

Reply
avatar
December 17, 2019 at 2:07 AM delete

I am following your blog from the beginning, it was so distinct & I had a chance to collect conglomeration of information that helps me a lot to improvise myself. I hope this will help many readers who are in need of this vital piece of information. Thanks for sharing & keep your blog updated. No: 1 Blue Prism Training Institute in Chennai|

Reply
avatar
December 17, 2019 at 4:59 AM delete

You have done really great job. Your blog is very unique and informative. Thanks. No: 1 Automation Anywhere Training Institute in Chennai|

Reply
avatar
December 17, 2019 at 11:43 PM delete

Its really an Excellent post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog. Thanks for sharing…
No.1 Python Course in Kanchipuram

Reply
avatar
December 18, 2019 at 1:26 AM delete

your blog contain very useful information. Really hereafter I am very big follower of your blog.. No: 1 Best Photoshop in Kanchipuram|

Reply
avatar
December 18, 2019 at 10:23 PM delete

I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.Best Microsoft .Nets Training institute in Kanchipuram|

Reply
avatar
December 19, 2019 at 1:05 AM delete

Thanks for sharing such a nice blog. Its so informative concept and easy to understand also, kindly keep updating such a nice blog.. No: 1 Tally Training Institute in Kanchipuram|

Reply
avatar
December 19, 2019 at 2:32 AM delete

Good post. happy to visit your blog. Thanks for sharing.
Android Training Institute in Kanchipuram

Reply
avatar
December 19, 2019 at 11:23 PM delete

Nice..You have clearly explained about it ...Its very useful for me to know about

new things..Keep on blogging..
Embedded Systems Training in

Kanchipuram

Reply
avatar
December 19, 2019 at 11:24 PM delete

I have read all the articles in your blog; was really impressed after reading it.Thanks for giving nice information from your blog.. No: 1 Advanced MATLAB Course in Kanchipuram|

Reply
avatar
December 20, 2019 at 4:14 AM delete

your way of expressing views and ideas are really awesome. thus it is exclusive and very much interesting. i like your encryption and thanks a lot. No: 1 Best CLOUD COMPUTING Training Institute in Kanchipuram|

Reply
avatar
December 20, 2019 at 9:25 PM delete

the blog is very useful, interesting and informative. thank you for sharing the blog with us. keep on updating.
Tally ERP Certification in Kanchipuram

Reply
avatar
December 20, 2019 at 10:42 PM delete

I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon. No: 1 Linux Certification in Kanchipuram|

Reply
avatar
December 21, 2019 at 3:41 AM delete

Thank you for sharing in this information. can learn a lot and could also be a reference, I hope to read the next your blog updates. No: 1 Software Testing Certification in Kanchipuram|

Reply
avatar
December 22, 2019 at 10:30 PM delete


I ever had seen this information over the blog sites; actually I am looking forward for this information. Here I had an opportunity to read, it was crystal clear keep sharing…I have an expectation about your upcoming post.
Regards, No: 1 Adobe Photoshop Training Institute in Kanchipuram|

Reply
avatar
December 23, 2019 at 2:16 AM delete

Very nice post here and thanks for it .I always like and such a super blog of these post.Excellent and very cool idea and great blog of different kinds of the valuable information's.
No.1 Tally Training Institute In Chennai

Reply
avatar
December 23, 2019 at 3:42 AM delete

Great post. This blog is really very interesting and enjoyable. I think it’s must be helpful and informative for us. Thanks for sharing your nice post. No: Adobe Photoshop Training Institute in Chennai

Reply
avatar
December 23, 2019 at 10:13 PM delete

Excellent Blog!!! Such an interesting blog with clear vision, this will definitely help for beginner to make them update.
No.1 Java Training Center in Chennai

Reply
avatar
December 23, 2019 at 11:02 PM delete

I really enjoyed while reading your blog, the information you have delivered in this post was damn good. Keep sharing your post with efficient news.Regards, No: 1 Adobe Illustrator Training Institute in Kanchipuram|

Reply
avatar
December 25, 2019 at 10:34 PM delete

This was a worthy blog. I enjoyed reading this blog and got an idea about it. Keep sharing more like this.
HTML and CSS Training Institute in Chennai

Reply
avatar
December 26, 2019 at 10:24 PM delete


What a fantastic blog you should written in well manner.Iam really happy to read this
blog.Thanks for sharing.keep sharing more blogs.
No.1 CCNA Institute In Kanchipuram

Reply
avatar
December 27, 2019 at 2:10 AM delete

great blog, you have provided the right information that will be beneficial to somebody at all time. Thanks for sharing such valuable Ideas to our vision. No: 1 Adobe Illustrator Training Institute in Kanchipuram|

Reply
avatar
December 29, 2019 at 10:36 PM delete

Attractive blog post! I should read from some useful news for this blog section, It 's a great content Keep it useful sharing.
Tally Training center in Kanchipuram

Reply
avatar
December 30, 2019 at 10:37 PM delete

Thanks for sharing this valuable information.and I gathered some information from this blog.
Java Training center in Kanchipuram

Reply
avatar
December 31, 2019 at 4:32 AM delete

Very nice post here and thanks for it .I always like and such a super blog of these post.Excellent and very cool idea and great blog of different kinds of the valuable information's.Keep Sharing Best Adobe Premier Pro Training Institute in Kanchipuram|

Reply
avatar
January 1, 2020 at 11:07 PM delete

information to our vision. You have posted a trust worthy blog keep sharing....
No.1 PHP project center In kanchipuram

Reply
avatar
January 1, 2020 at 11:10 PM delete

Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.
Advanced MATLAB Course in Kanchipuram

Reply
avatar
January 2, 2020 at 1:16 AM delete

I really enjoyed by reading your blog post.I too always learn something new from your post.. Best Adobe Photoshop Training Institute in Kanchipuram|

Reply
avatar
January 3, 2020 at 3:50 AM delete

Nice Post! It is really interesting to read from the beginning & I would like to share your blog to my circles, keep your blog as updated.
C, C++ Training Center in Kanchipuram

Reply
avatar
January 3, 2020 at 10:53 PM delete

information to our vision. You have posted a trust worthy blog keep sharing....
No.1 MBA project center In kanchipuram

Reply
avatar
January 5, 2020 at 5:59 AM delete

Good job! Fruitful article. I like this very much. It is very useful for my research. It shows your interest in this topic very well. I hope you will post some more information about the software. Please keep sharing!!
SEO Training in Chennai
SEO Training in Bangalore
SEO Training in Coimbatore
SEO Training in Madurai
SEO Course in Chennai
SEO Course in Chennai
SEO Course in Bangalore
SEO Course in Coimbatore

Reply
avatar
January 5, 2020 at 10:50 PM delete

Nice blog. Thank you for sharing. The information you shared is very effective for learners I have got some important suggestions from it.
Best Web Designing and Development Training Institute in Kanchipuram

Reply
avatar
January 5, 2020 at 10:53 PM delete

Really very Nice and Wonderful love useful Blog Post. Thanks for

sharing this interesting post...
Best Android Training Institute in Chennai









Reply
avatar
January 6, 2020 at 10:19 PM delete

Congratulations guys, quality information you have given!!!..Its really useful blog. Thanks for sharing this useful information.
Data Mining project Center in Kanchipuram

Reply
avatar
January 6, 2020 at 10:47 PM delete

The information you shared is very effective for learners. I learnt this technology very well with the help of this article.Thanks for this useful

information.Keep updating.
Best Tally Training Institute in Chennai









Reply
avatar
January 7, 2020 at 11:53 PM delete

Nice blog. Thank you for sharing. The information you shared is very effective for learners I have got some important suggestions from it.
Best Graphic Designing Training Course in Kanchipuram

Reply
avatar
January 8, 2020 at 1:33 AM delete

Wow it is really wonderful and awesome thus it is very much useful for me to understand many information and helped me a lot. it is really explainable very well and i got more information from your blog.
Best PHP Training Institute in Kanchipuram



Reply
avatar
January 9, 2020 at 12:59 AM delete

Thank you for such a great Blog with us. hope it will be much useful for us. please keep on updating..
Best Adobe Photoshop Training in Kanchipuram

Reply
avatar
January 10, 2020 at 1:50 AM delete

I have read your blog. Good and more information useful for me, Thanks for sharing this information keep it up....
Best VLSI project center in Chennai

Reply
avatar
January 10, 2020 at 2:39 AM delete

Great blog.you put Good stuff.All the topics were explained briefly.so quickly understand for me.I am waiting for your next fantastic blog.Thanks for sharing.
Selenium Certification Courses in Kanchipuram

Reply
avatar
January 10, 2020 at 3:32 AM delete

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge.
Best VLSI project center in kanchipuram

Reply
avatar
January 10, 2020 at 9:34 PM delete

Your blog is awesome..You have clearly explained about it ...Its very useful for me to know about new things..Keep on blogging…
Best Computer courses Training institute in Chennai

Reply
avatar
January 11, 2020 at 12:54 AM delete

The best thing is that your blog really informative thanks for your great information!
Best Data mining project center in kanchipuram

Reply
avatar
January 12, 2020 at 10:42 PM delete

This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information, this is useful to me…
Best Android project center in kanchipuram

Reply
avatar
January 12, 2020 at 11:01 PM delete

Very nice blog. It is very useful for me. I read your blog completely. I gather lot of information in this post. Thanks for sharing.
Linux Certification Courses in Chennai

Reply
avatar
January 13, 2020 at 5:25 AM delete

This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information, this is useful to me…
Best Android project center in chennai



Reply
avatar
January 13, 2020 at 11:01 PM delete

The best thing is that your blog really informative thanks for your great information! I have got some important suggestions from it.
No.1 JAVA Training institute in Chennai

Reply
avatar
January 14, 2020 at 1:42 AM delete

great blog, you have provided the right information that will be beneficial to somebody at all time. Thanks for sharing such valuable Ideas to our vision. Best Premier Pro Training Institute in Kanchipuram|

Reply
avatar
January 16, 2020 at 10:39 PM delete

Nice..You have clearly explained about the conept..Its very useful for

me to undertand..Keep on sharing..
Best Robotics project

center in kanchipuram






Reply
avatar
January 16, 2020 at 10:51 PM delete

your way of expressing views and ideas are really awesome. thus it is exclusive and very much interesting. i like your encryption and thanks a lot.
Best JAVA J2EE Training Institute in Kanchipuram

Reply
avatar
January 18, 2020 at 1:26 AM delete

Very informative blog. This helps the freshers to prepare for their interview. Thanks for posting this information
Advanced MATLAB Training Course in Chennai

Reply
avatar
«Oldest   ‹Older   201 – 311 of 311   Newer›   Newest»