使用 SVG.js 进行乒乓球比赛 Pong Game with SVG.js
我们最近被介绍到SVG.js,这是一个用于操作和动画 SVG(可缩放矢量图形)的库。该库以没有依赖关系而自豪,旨在成为同类中最精简的,可以做 Snap.svg 和 Raphael 可以做的事情,但代码量只有一半。 We were recently introduced to SVG.js, a library for manipulating and animating SVG (Scalable Vector Graphics). The library boasts of having no dependencies and aims to be the leanest of its kind, doing the same things that Snap.svg and Raphael can do, but with half the amount of code. 为了突出 SVG.js 库的某些方面,它的创建者为我们提供了关于如何在其框架内制作 Pong 游戏的简洁教程。看看绘制两个不同颜色的桨的代码有多短:To highlight some aspects of the SVG.js library, its creators have given us a neat tutorial on how to make a Pong game within their framework. Look how short the code is for drawing two paddles with different colors: 这个版本的经典街机游戏有一些很酷的效果。 例如,球在向另一侧移动时将其颜色变为对手的颜色。 This version of the classic arcade game has some cool effects. For example, the ball changes its color into that of the opponent while moving towards the other side. 此外,当对手未能将球击回时,会产生巨大的色彩爆炸。
Also, there is a huge color blast when the opponent fails to hit the ball back. You can try the game yourself here. Check out the tutorial here.
|