How to use html5 to realize Wechat jerking off game
This article will explain in detail how to use html5 to achieve Wechat masturbation games. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Html5 to achieve Wechat masturbation game, use this Mini Game to learn a HTML5 bar, this is a direction of WEB development
The code is as follows:
/ / JavaScript document varc=document.getElementById ("dotu"); varcxt=c.getContext ("2d"); varimg=newImg (". / assets/bg_01.jpg"); varfps;cxt.drawImage (img,0,0480800); varflivverLog=0;varflivver1=newImg (". / assets/flivver.png"); varflivver2=newImg (". / assets/flivver2.png"); varflivver3=newImg (". / assets/flivver3.png"); / / used to record the time of the game, the faster vartime1=0;vartime2=80;// points varjifen=0 Function getSudu () {varnumber=parseInt (Math.random () * 10); if (number 0) {return number;} return1
Function flivverObj (hp,ewidth,eheight,eimg,esudu) {/ / Random Xthis.x=parseInt (Math.random () * 460x1); this.y=0;// Blood Volume this.hp=hp;// whether this.hit=0;// is killed or not this.over=0;this.width=ewidth;this.height=eheight;this.img=eimg;this.sudu=esudu;} / / get aircraft function getFlivver (type) {switch (type) {case 1: return the new flivverObj (100, 50, 10, 50, 10, 10, 50, 10, 10, 10, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, Case 2: return the new flivverObj (500, 70, 90, flivver2, getSudu ()); case 3:
Return the new flivverObj (1000 window.clearTimeout 110 fps);}} function box (xmeme y) {this.x=x;this.y=y;} function gameover () {window.clearTimeout (fps); / / $('# dotu'). FadeOut (); $('. Content'). Css ('position','relative'); $('. Content'). Append ('); $('# sil'). Html (you). Hide (). FadeIn (1000 technology function () {$(this) .html ('shit'). Hide (). FadeIn (1000 fadeIn function () {$(this) .html ('780) {flivver.splice (amem1);} / / draw a small plane on the canvas / / small plane death if (flivver.over > 0) {flivver.over -; if (flivver.over > 20) {cxt.drawImage (boo1, flivver.x+ flivver.width / 2-20, flivver.y + flivvera] .height / 2-10performance 41MAA 39) Otherwise if (flivver [a]. Over > 2) {cxt.drawImage (over, flivver [a]. X + flivver [a] .width / 2-20, flivver [a] .y + flivver [a]. Height / 2-10, 40, 43);} other {
Flivver.splice [a];}} else {cxt.drawImage (flivver.img, flivver.x, flivver.y, flivver.width, flivver.height); / / judge whether you are dead if (me.x > (flivver.xflivver.xflivver.width + 20) & (me.x) 0) {cxt.drawImage (boo1, flivvera] .width / 2-20, flivver.y + flivver.height / 2-10 4139) / / cxt.drawImage (boo1, flivver [a] .x + 5, flivver [a] .y
Flivver [a] .hit--;} / / Update your distance dotu.setMe=function () {cxt.drawImage (meImg,me.x,me.y,64,72);} / / Update bullet method dotu.cartridge=function () {if (dotu.nums%10==0) {ettes.push (hit (me.x+30,me.y));} for (iincarts) {/ / fly to the top and delete OBJ if (cartridges.y0) {continue } if (cartridges [I] .x > flivver [j] .x & & ink cartridge [I] .xflivver [j] .y & & magazine [I]. Y-flivver [j]. Height 1) {flivver [j] .hp-= 80;} else {flivver [j] .over = 40
Giffin + = 50000; / / bullet disappears cartridges.splice (iMagin1); break;} / / bind mouse event c.addEventListener ('mousemove', function onMouseMove (evt) {me.x=evt.layerX-$ (' # dotu'). Offset (). Left-32;, I... Yawevt.layerYmi 36% ('# sbX'). Html (me.x); $('# sbY'). Html (me.y);}); fps=setInterval (dotu.update,1000/100);} (cxt)) function newImg (src) {varobj=newImage (); obj.src=src; returns obj
} / / setInterval (h.updateMagol 1000lap65)
Copy the code
The code is as follows:
Masturbation-multi-path body {padding:0; deposit: 0Texttextualigndisplay center} .content {border:1px#000 solid; width: 480pxMacedanza 0 automatic; height: 800PX; display: block; font-size:72px;} .info, .blog {border:1px#000solid; position: fixed top:5px; right: 5px; width: 150pxtextscapalignleft} .blog {left:10px; background: # 000 Text-align:center;width:100px} .bloga {color:#FFF; text modifier: none; font-size:15px;}
Back to the home page of the blog, mouse X: mouse Y: number of small planes: number of bullets: hit: time to generate aircraft:
This is the end of the article on "how to use html5 to achieve Wechat jerking off". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.