[Programming Game] presents a gift at the age of a new year. (Ignition of yh_random fireworks on the first floor of the resumed post)
Last Update:2018-12-04
Source: Internet
Author: User
[Programming Game] presents a gift at the age of a new year. (The first prize is 10000 available points)
Author:
Ignition[Ctrl + A select all tips: you can modify some code and then press run]
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br/> <HTML xmlns = "http://www.w3.org/1999/xhtml"> <br/> <pead> <br/> <SCRIPT type = "text/JavaScript"> <br/> var utils = {}; </P> <p> utils. $ e = function (ID) {<br/> return document. getelementbyid (ID); <br/>}; </P> <p> utils. $ c = function (tagname) {<br/> return document. createelement (tagname ); <Br/>}; </P> <p> utils. getintervalrandom = function (Min, max) {<br/> return parseint (math. random () * (max-min) + min); <br/>}; </P> <p> utils. interval_speed = 30; <br/> If (navigator. appname. tolowercase (). indexof ("Netscape ")! =-1) <br/>{< br/> utils. interval_speed = utils. interval_speed + (utils. interval_speed/6); <br/>}</P> <p> string. prototype. padleft = function (slen, padchar) {<br/> var result = This; <br/> for (I = This. length; I <slen; I ++) {<br/> result = padchar + result; <br/>}< br/> return result; <br/> }; </P> <p> var firework = function (x, shotheight, radius, participant count, color, speed) {<br/> This. shotheight = shotheight | 200; <br/> This. radius = radius | 100; <br/> This. particle count = maid | 10; <br/> This. color = color | "# ff0000"; <br/> This. parentelement = document. body; <br/> This. X = x; <br/> This. shottingspeed = speed | 3; <br/> This. isshoted = false; <br/> This. isflash = true; </P> <p> This. _ participant = []; <br/> This. _ particle shape = Unescape ("% u25cf"); <br/> This. _ shottingshape = "|"; <br/> This. _ depth = 3; <br/> This. _ shottin G = utils. $ C ("Div"); <br/> This. _ flashing = utils. $ C ("Div"); <br/> This. _ disposecount = 0; </P> <p> VaR _ this = This; </P> <p> void function initialize () {<br/> for (VAR I = 0; I <_ this. particle count; I ++) {<br/> _ this. _ participant [I] = utils. $ C ("Div"); <br/> _ this. _ participant [I]. style. position = "absolute"; <br/> _ this. _ participant [I]. style. left = _ this. X + "PX"; <br/> _ this. _ participant [I]. style. top = _ this. shotheight + "PX"; <br/> _ This. _ participant [I]. style. zindex = 100; <br/> _ this. _ participant [I]. style. color = _ this. color; <br/> _ this. _ participant [I]. style. display = "NONE"; <br/> _ this. _ participant [I]. innerhtml = _ this. _ participant shape; <br/> _ this. _ participant [I]. distance = utils. getintervalrandom (1, _ this. radius-parseint (I % _ this. _ depth) * (_ this. RADIUS/_ this. _ depth); <br/> _ this. _ participant [I]. speed = utils. getintervalrandom (1, 4) * _ this. _ Parti Cles [I]. distance * 0.06; <br/> _ this. parentelement. appendchild (_ this. _ participant [I]); <br/> _ this. _ setsize (_ this. _ participant [I], 5); <br/>}</P> <p> _ this. _ shotting. speed = _ this. shottingspeed; <br/> _ this. _ shotting. innerhtml = _ this. _ shottingshape; <br/> _ this. _ shotting. style. position = "absolute"; <br/> _ this. _ shotting. style. fontweight = "900"; <br/> _ this. _ shotting. style. left = _ this. X + "PX"; <br/> // _ this. _ sho Invalid. style. top = _ this. parentelement. offsettop + _ this. parentelement. offsetheight-_ this. _ shotting. offsetheight + "PX"; <br/> _ this. _ shotting. style. top = "700px"; <br/> _ this. _ shotting. style. zindex = 100; <br/> _ this. _ shotting. style. color = _ this. color; <br/> _ this. _ setsize (_ this. _ shotting, 15); <br/> _ this. parentelement. appendchild (_ this. _ shotting); </P> <p> _ this. _ flashing. style. width = "100%"; <br/> _ this. _ flas Hing. style. height = "100%"; <br/> _ this. _ flashing. style. left = "0"; <br/> _ this. _ flashing. style. top = "0"; <br/> _ this. _ flashing. style. backgroundcolor = "# ffffee"; <br/> _ this. _ flashing. style. position = "absolute"; <br/> _ this. _ flashing. style. zindex = 200; <br/> _ this. _ flashing. style. display = "NONE"; <br/> _ this. _ flashing. style. required opacity = 0.5; <br/> _ this. _ flashing. style. filter = "alpha (opacity = 50)"; <br/> _ this. Parentelement. appendchild (_ this. _ flashing); </P> <p >}(); <br/>}; </P> <p> firework. prototype. shot = function () {<br/> VaR _ this = This; <br/> _ this. isshoted = true; <br/> var shotinterval = Window. setinterval (function () {<br/> If (parseint (_ this. _ shotting. style. top)> _ this. shotheight) {<br/> _ this. _ shotting. style. top = parseint (_ this. _ shotting. style. top)-_ this. _ shotting. speed + "PX"; <br/>}< br/> else {<br/> wi Ndow. clearinterval (shotinterval); <br/> _ this. parentelement. removechild (_ this. _ shotting); <br/> _ this. bomb (); <br/> _ this. _ shotting = NULL; <br/>}< br/>}, utils. interval_speed); <br/>}; </P> <p> firework. prototype. bomb = function () {<br/> VaR _ this = This; <br/> If (_ this. isflash) {<br/> _ this. _ flashing. style. display = ""; <br/> var flashtimeout = Window. setTimeout (function () {<br/> _ this. parentelement. remov Echild (_ this. _ flashing); <br/> window. cleartimeout (flashtimeout); <br/>}, 10); <br/>}< br/> else {<br/> _ this. parentelement. removechild (_ this. _ flashing); <br/>}</P> <p> for (VAR I = 0; I <_ this. _ participant. length; I ++) {<br/> _ this. _ moveparticle (_ this. _ participant [I], utils. getintervalrandom (0,360); <br/>}< br/>}; </P> <p> firework. prototype. _ setsize = function (OBJ, value) {<br/> obj. style. fontsize = P Arseint (value) + "PX"; <br/>}; </P> <p> firework. prototype. _ moveparticle = function (particle, angle) {<br/> VaR _ this = This; <br/> var initx = parseint (particle. style. left); <br/> var inity = parseint (particle. style. top); <br/> var currentdistance = 0; <br/> var currentx = initx; <br/> var currenty = inity; <br/> particle. style. display = ""; </P> <p> particle. intervalid = Window. setinterval (function () {<br/> If (currentd Istance <particle. distance) {<br/> var newx, newy; <br/> var xangle = angle * (2 * Math. PI/360); <br/> var xdirection = math. ABS (math. cos (xangle)/math. cos (xangle); <br/> var ydirection = math. ABS (math. sin (xangle)/math. sin (xangle); </P> <p> If (math. ABS (math. tan (xangle) <= 1) {<br/> var deltax = math. ABS (particle. speed * Math. cos (xangle) * xdirection; <br/> newx = currentx + deltax; <br/> newy =-(newx-initx) * Math. tan (Xang Le) + inity; <br/> currentdistance + = math. ABS (deltax); <br/>}< br/> else {<br/> var deltay = math. ABS (particle. speed * Math. sin (xangle) * ydirection; <br/> newy = currenty-deltay; <br/> newx =-(newy-inity)/math. tan (xangle) + initx; <br/> currentdistance + = math. ABS (deltay); <br/>}< br/> currentx = newx; <br/> currenty = newy; <br/> particle. style. left = currentx + "PX"; <br/> particle. style. top = currenty + "PX"; <br/>}< Br/> else {<br/> window. clearinterval (particle. intervalid); <br/> _ this. parentelement. removechild (particle); <br/> particle = NULL; <br/> If (++ _ this. _ disposecount = _ this. particle count) {<br/> _ this. _ participant. length = 0; <br/> _ this. parentelement = NULL; <br/> _ this = NULL; <br/>}< br/>}, utils. interval_speed); <br/>}; <br/> function test () {<br/> var fireworks = []; <br/> var Total = 15; <br/> win Dow. setinterval (function () {<br/> for (VAR I = 0; I <total; I ++) {<br/> If (! Fireworks [I] |! Fireworks [I]. parentelement) {<br/> var x = utils. getintervalrandom (50, document. body. offsetWidth-50); <br/> var shotheight = utils. getintervalrandom (100,450); <br/> var radius = utils. getintervalrandom (50,200); <br/> var participant COUNT = utils. getintervalrandom (40, 80); <br/> var speed = utils. getintervalrandom (10, 20); <br/> var color = "#" + utils. getintervalrandom (0, 16777215 ). tostring (16 ). padleft (6, "F"); <br/> F Ireworks [I] = new firework (x, shotheight, radius, participant count, color, speed); <br/>}< br/>}, 100 ); </P> <p> window. setinterval (function () {<br/> var currentindex = utils. getintervalrandom (0, total); <br/> If (Fireworks [currentindex] & fireworks [currentindex]. parentelement &&! Fireworks [currentindex]. isshoted) {<br/> fireworks [currentindex]. shot (); <br/>}< br/>}, 500 ); <br/>}< br/> </SCRIPT> <br/> </pead> <br/> <body bgcolor = "#000000" onLoad = "test (); "Style =" overflow: hidden; "> <br/> <Div style =" width: 100%; text-align: center; Font: 100px 'comic sans Ms', Arial, sans-serif; color: yellow; "> happy new year </div> <br/> <Div style =" width: 100%; text-align: center; Font: 100px 'comic sans Ms', Arial, sans-serif; color: red; "> 2009 </div> <br/> <a href =" http://random.cnblogs.com "target =" newwindow "> <Div style =" width: 100%; font-size: 12px; text-align: center; color: # fff "> copyright by random 2009 all rights reserved </div> </a> <br/> </body> <br/> </ptml>
Ignition[Ctrl + A select all tips: you can modify some code and then press run]