Address: http://www.script-tutorials.com/html5-game-development-lesson-2/
Today, we will continue to develop the HTML5 game series. This article continues to learn basic knowledge (which may include some advanced knowledge ). We will show you how to fill the image with gradient, draw text with a specific font, as well
Angry Birds are a popular puzzle game. Now I try to use the lufylegend library and Box2dWeb physical engine to see how to make such a classic physical game in html5.
Prerequisites 1
First, you need to download the lufylegend library 1.4.1
For how to use the lufylegend library, you can take a look at some of my previous articles and tutorials or the following api
, the triangle as an exampleContext.beginpath (); Context.moveto (100,100); Context.lineto (50,200); Context.lineto (150,200); Context.closePath () ; context.fillstyle= "Green"; Context.fill ();Get the triangles like.Three, round the drawingIn fact, the computer is drawing an arc, and finally through the Closepath ().The function that needs to be used is Context.arc (x,y,r,sangel,eangel,countclockwise);where x is the center axis, y is the center ordinate, R is the radius, the Sangel is the start
What are the general effects of a complete game?
First, we certainly need full screen, and 3D games also have the mouse lock function.
A large part of these features are built in Html5, but some features, such as canvas yoy scaling, need to be implemented manually.
Next, I will write them in detail to the audience.
Fullscreen Api
The API is divided into two parts: full screen access and full screen exit.
T
example to show you what a big image is like with a small map:
What is the effect we want to accomplish? I put it here to check the implementation degree:
2. How to Implement preparation:
First, you need to download lufylegend. The latest version is 1.7.5. You can use 1.7.3.
: Http://lufylegend.com/lufylegend
There are APIs and forums on them. You can check them out.
We also recommend a related book, written by lufy, called HTML5 canvas
following:SOURCE ~/.bash_profileconsole_path= $COCOS 2dx_root "/tools/cocos2d-console/console/"; target_dir= $BUILT _products_dir "/" $PRODUCT _name ". app/"; js_dir= $TARGET _dir "/script/"/usr/bin/python $CONSOLE _path/cocos2d.py jscompile-s $JS _dir- D $JS _dir;find $JS _ Dir-type f-name "*.js" | Xargs RM-RF;The script is invoked on its own initiative at compile time. (You need to define the root folder of the cocos2dx in. Bash_profile.) And the variable name is Cocos2dx_root)Compile JS as
if(dir== +) Alert (" Down"); Else if(dir==Panax Notoginseng) Alert (" Left") Else if(dir== the) Alert (" Right");} Script>Head> Bodyonkeydown= "Functionkeydown (event)">Body>Second, use the keyboard cursor to move the graphicNow that we've learned to capture a keyboard keystroke, we can use it to move the graphics on the screen!The basic method is this: is through the keyboard keys to change the coordinates, such as the right, let the x-coordinate larger, if it is downward, let the y-coordin
In the previous article, I have explained in detail how to add a map and a game character. Now let's add control events and let the little hero move around.
For more information about the previous article, see here
HTML5 game development-Zero-basic development RPG games-Open Source lecture (1)
Http://blog.csdn.net/lufy_legend/article/details/7063316
We have cr
at this small map of the big picture is what kind of:
What kind of effect are we going to finish? I'll put it here, and when I'm done, I'll see how much of it is implemented:
two, how to achievepreparatory work:
First you need to download Lufylegend, the latest version is 1.7.5, with 1.7.3 all line.
Download Address: Http://lufylegend.com/lufylegend
The above has its API and forum, you can see.
Also recommend a related book, Lufy wrote, called "HTML5
A good example is found in reading a book about the development of a HTML5 game, which allows for a more in-depth understanding of object-oriented development. This object is implemented by drawing an image from a CSS sprite into the canvas. First create a Spritesheet object with the following code:var spritesheet = new function () {This.map = {};this.load = function (spritedata,callback) {this.image = new
Want to turn HTML5 game open, this is to learn practicing things, the first is to use the process-oriented approach, followed by the object-oriented approach to achieve (was the pit) ...
Demo Address: HTTP://RUNJS.CN/DETAIL/SS8PKZRC
HTML code
Demo pictures
The above mentioned is the whole content of this article, hope to be able to learn js+html5 to
This article describes how to use the canvas canvas to make a simple maze game: When the user presses the arrow keys, the smiley face icon will move in the corresponding direction (animation effect when moving), when encountering the wall (collision detection) will stop.
1, online sampleloaded with difficult maze loading simple maze
2, the principle of realization(1) Maze generation: We use a maze picture here, and then draw the whole picture onto
RequestAnimationFrame events being cached, so that the RequestAnimationFrame can be animated Based on the browser capabilities.For the second problem, the only way is to minimize Repaint and Reflow events. Although the principle is simple, the optimization is very difficult, requiring readers to be familiar with every function of Dom rendering. Several articles are listed below for your reference only:ClassList for great good.Breakdown of repaint.Learning from Twitter(To be continued)
The abov
Knowledge points involved in this game include:
1. Draw the ball, image, and Gradient
2. Scheduled event and Collision Detection
[Html]Your browser doesn' t support the HTML5 element canvas.Horizontal velocity Vertical velocity The running result is as follows:
Ball play games are generally implemented using html5. In fact, js can also achieve similar results. The following is a good example. For more information, see, I hope it will help you to get started with the html page
Html game interface after start
The source code of the index.html file is as follows:
The Code is as follows:
Pinball games
Score:0
Ball play games are generally implemented using html5. In fact, js can also achieve similar results. The following is a good example. For more information, see, I hope it will help you to get started with the html page
Html game interface after start
The source code of the index.html file is as follows:
The Code is as follows:
Pinball games
Score:0
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.