技术控

    今日:6| 主题:49136
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] HTML Kong

[复制链接]
Re_Star·彅 发表于 2016-10-9 06:11:17
223 9

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
There are two things I’ve always wanted to try in HTML : generating a photorealistic image using CSS , and creating an interactive game without the need for JavaScript. HTML Kong is the end result of those two ambitions – a reproduction of the Game & Watch video game, Donkey Kong , using just HTML and CSS .
   For those of you that haven’t heard of it,  Game & Watch  was a line of LCD handheld video games from the 1980s. The Donkey Kong title was probably one of the most popular in the series, selling more than a million units worldwide. The game was split over two screens and built into a distinctive clamshell casing.
  Casing construction

   My starting point for this project was with the construction of the casing in CSS . There is nothing particularly revolutionary about this procedure⁠, but it was a new experience for me. The basic structure of the body was formed with a set of div elements, then border and box-shadow properties were applied to control the colouring of the edges. For circular elements, a border-radius was used to adjust the shape appropriately.
     
HTML Kong-1 (html空格代码,html,换行)
     When complicated colouring or shading was required, one or more layers of gradient were applied to the background property to produce the necessary effect (typically a linear-gradient ). This part of the process was very much trial-and-error – some of the best results were achieved largely by accident – so I was quite pleased with how it turned out in the end.
  Game screen backgrounds

   When it came to rendering the background screens of the game, I decided to go with SVG , since that was another web technology I had always wanted to try out. I started by sketching the individual components as monochrome bitmaps in Microsoft Paint, then used an image converter from the Online-Convert website to translate those bitmaps into SVG paths.
   Once I had an SVG path for each part of the screen, I manually coloured and combined those fragments, then added appropriate shading and filter effects to produce the final image. I had initially had a separate SVG for each of the screens, but once Chrome eventually agreed to support  SVG stacks  , it became feasible to merge the two images into a single file⁠.
  Liquid-crystal display

   As for the LCD elements of the game ( Mario , Donkey Kong – basically anything that moves), the approach I took here was to create a custom icon font with each entity being a character in that font. This seemed like a perfect fit for LCD , since everything would obviously be a single colour, and I could then create the shadow effect that you get with an LCD just by applying a text-shadow property to the font.

HTML Kong-2 (html空格代码,html,换行)
     As with the game screen backgrounds, the glyphs were initially sketched as monochrome bitmaps in Microsoft Paint, then translated into SVG paths using the Online-Convert website. Once I had an SVG rendering of each glyph, I used the IcoMoon font generator to package them all up into an icon font, which could then be exported as a WOFF font file.
  Mario’s movement

   With all of the assets assembled, the first step towards making a playable game was to develop a mechanism through which Mario could be moved. This was achieved with a set of radio input elements corresponding to the various locations in the game, each linked to a div , which rendered Mario , via a :checked pseudo-class and a general sibling selector. The currently selected radio button would thus control the position and appearance of Mario’s div .
   Navigating through the game could be accomplished by clicking on a label that targeted the radio button of the intended destination. When in position one, a label beneath the right arrow would target the radio button for position two. In position two, the label under the right arrow would target position three, while the left arrow targeted position one. The appropriate labels were activated via the currently selected radio button, in much the same way that Mario was positioned.
  Barrel rolling

   Simulating the barrel movement was somewhat easier. Each barrel location could be represented by a div with an appropriate sprite that turned on and off in sequence using a CSS animation. To keep things simple, the speed and frequency of the barrels never increased, nor did they stop on collision the way they would in the original game. This enabled the use of a finite set of keyframes which simply repeated forever.
   To avoid a lot of repetition, most of the barrel locations shared the same set of keyframes, just with a different animation-delay on each of them. The top screen was a little more complicated, because the barrels could follow a number of different paths, but that still just meant an additional four keyframe sets. One of these low frequency sets was also shared by the iron girders moving overhead on the second level.
  Collision detection

   Detecting when Mario had been hit by these barrels was a little more complicated, though, since now it was necessary for the game to trigger a change of state, rather than simply responding to a player action. The way this was accomplished was with a kind of mechanical key constructed from a stack of floating div elements – these div elements were the teeth of the key and would push out a block of content aligned to the right of them⁠.
12下一页
友荐云推荐




上一篇:The Eidolon Deploy Process
下一篇:Bare Minimum Crates.io Mirror Plus One
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

康林 发表于 2016-10-9 11:00:07
吃饭与ml是第一生产力。  
回复 支持 反对

使用道具 举报

w23354352 发表于 2016-10-9 11:20:06
Re_Star·彅不可怕,就怕Re_Star·彅有文化。  
回复 支持 反对

使用道具 举报

party域名申请 发表于 2016-10-13 03:24:46
鄙视楼下的顶帖没我快,哈哈
回复 支持 反对

使用道具 举报

崔晓亮 发表于 2016-10-16 12:51:14
别和我谈理想,戒了.
回复 支持 反对

使用道具 举报

abc008 发表于 2016-10-27 05:35:49
有谁会在时过境迁之后还在那里等你。
回复 支持 反对

使用道具 举报

nanvin 发表于 2016-11-10 16:52:50
有的人,有一股,让人想一辈子跟他做陌生人的强大的气场。
回复 支持 反对

使用道具 举报

船长-lion 发表于 2016-11-10 22:48:52
Re_Star·彅有品位!
回复 支持 反对

使用道具 举报

电商令狐冲 发表于 2016-11-12 18:02:39
没有不透风的墙,没有不能上吊的梁。
回复 支持 反对

使用道具 举报

sgc 发表于 2016-11-21 14:02:10
说实话,光靠签到升级太慢,所以我复制了这一段话遇贴就回,有人就会说你这不是混经验吗,我TMD转身一巴掌,你这不是废话
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表