Using HTML5 and WebGL to create 2D games-

Source: Internet
Author: User
Istrolid is an HTML5 game that uses many new web technologies. The game author treeform uses webGL, WebSocket, AudioContext, and the self-developed responsive HTML framework to render graphics, create network connections, play audio, and design the UI ........ .....,. Istrolid is an HTML5 game that uses many new web technologies. The game author treeform uses webGL, WebSocket, AudioContext, and the self-developed responsive HTML framework to render graphics, create network connections, play audio, and design the UI. In addition, he used Electron to package the game into desktop applications for Windows and Mac. I will share with you the game development experience of Istrolid.


  2D WebGL

When using openGL and WebGL engines, developers usually create multiple mesh and texture objects. However, the author of Istrolid has his own unique construction method. He draws all the game content through a grid and texture object. The ships in the game are made up of very simple polygon, and some are even made up of several triangles. Therefore, the author believes that there is no need to create a Grid Object for every object to be drawn. Instead, create a dynamic grid and adjust the grid by code in each frame. This will greatly accelerate the rendering speed. This method is similar to the immediate Mode of openGL, which is often discarded by developers. We do not recommend that you use a matrix of 3D ModelView. When writing Istrolid, he only transmits a rectangle of the viewpoint to the colorant. Therefore, this game is completely based on the 2D engine.


  

  WebSocket and Server

The authors use CoffeeScript to write server programs and use Node. js to run them. He hopes that the game will support both single-player and multi-player modes. A local server is enabled when a player plays a single player game. The program uses a pseudo WebSocket to connect to the local server. The advantage is that you can test the code in a real network environment to simplify the debugging process. All debugging and one-step debugging are completed in one process. In addition, he can set network latency and jitter in this pseudo WebSocket to simulate a complex network environment.

When developing instant strategy games, developers usually choose the Lock Step method. However, the author of Istrolid does not. He believes that the lock step is outdated and is not easy to write (especially when writing in JavaScript ). Moreover, in this era where personal computers generally have high bandwidth, the advantage of locking is no longer obvious. He uses delta encoding and only transmits changed data from the server to each player's server.


  

Source: http://www.gbtags.com/gb/share/10213.htm

The above section uses HTML5 and WebGL to create 2D game content. For more information, see PHP Chinese website (www.php1.cn )!

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.