JS 디지털 복권 게임 구현 방법_javascript 기술
이 글의 예시에서는 JS 디지털 복권 게임의 구현 방법을 설명합니다. 참고할 수 있도록 모든 사람과 공유하세요. 구체적인 구현 방법은 다음과 같습니다.
<!doctype html> <html> <head> <meta charset="utf-8"> <title>新年网页抽奖程序</title> <style type="text/css"> * {margin:0; padding:0;} ul,li {list-style-type:none;} body {overflow:hidden;} #back {width:100%; height:100%; background:#f5f5f5; position:absolute; z-index:1; } #box {width:360px; height:100px; position:absolute; z-index:3; top:50%; left:50%; margin-top:-50px; margin-left:-180px; text-align:center; } #box1,#box2,#box3 {width:100px; height:100px; line-height:100px; float:left; background:#321c24; border:10px #321c24 solid; border-radius:50%; position:relative; overflow:hidden; } #box1 ul,#box2 ul,#box3 ul {color:#fff; font-size:68px; font-family:"Arial Black"; text-align:center; width:100px; height:100px; line-height:100px; position:absolute; top:0; left:0; } #box1 ul li,#box2 ul li,#box3 ul li { width:100px; height:100px; background:red; border-radius:50%; } </style> <script type="text/javascript"> var AIR = { $: function (id) { return typeof id === "string" ? document.getElementById(id) : id; }, $$: function (elem, oParent) { return (oParent || document).getElementsByTagName(elem); }, addEvent: function (oElement, sEvent, fnHandler) { oElement.addEventListener ? oElement.addEventListener(sEvent, fnHandler, false) : oElement.attachEvent("on" + sEvent, fnHandler) }, removeEvent: function (oElement, sEvent, fnHandler) { oElement.removeEventListener ? oElement.removeEventListener(sEvent, fnHandler, false) : oElement.detachEvent("on" + sEvent, fnHandler) }, getElementClient: function (){ var arr = []; if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth){ arr.push(document.documentElement.clientWidth); arr.push(document.documentElement.clientHeight); return arr; } }, getStyle: function (obj, attr) { return parseFloat(obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj, null)[attr]) }, startMove: function (obj, pos, onEnd) { clearInterval(obj.timer); var _this = this; obj.timer = setInterval(function () { _this.doMove(obj, pos, onEnd) }, 30) }, doMove: function (obj, pos, onEnd) { var iCurL = this.getStyle(obj, "left"); var iCurT = this.getStyle(obj, "top"); var iSpeedL = (pos.left - iCurL) / 5; var iSpeedT = (pos.top - iCurT) / 5; iSpeedL = iSpeedL > 0 ? Math.ceil(iSpeedL) : Math.floor(iSpeedL); iSpeedT = iSpeedT > 0 ? Math.ceil(iSpeedT) : Math.floor(iSpeedT); if (pos.left == iCurL && pos.top == iCurT) { clearInterval(obj.timer); onEnd && onEnd() } else { obj.style.left = iCurL + iSpeedL + "px"; obj.style.top = iCurT + iSpeedT + "px"; } } } function Draw (obj, num) { this.obj = obj; this.num = num; this.data = []; this.result = []; this.show = 0; this.btn = true; this.timer = true; this.h = 0; this.uh = 0; this.initialize(); } Draw.prototype = { initialize: function () { this.createArr (); this.createElement (); this.closeEvent (); this.startDraw (); }, createElement: function () { for(var j=0; j<this.obj.length; j++){ var ul = document.createElement("ul"); for(var i=0; i<10; i++){ var li = document.createElement("li"); li.innerHTML = i; ul.appendChild(li) } this.obj[j].appendChild(ul); this.obj[j].btn = true; AIR.$$("ul",this.obj[j])[0].innerHTML += AIR.$$("ul",this.obj[j])[0].innerHTML; } var UL = AIR.$$("ul",this.obj[0])[0]; this.h = AIR.getStyle(AIR.$$("li",UL)[0],"height"); this.uh = AIR.$$("li",UL).length * this.h }, randomSort: function (a, b) { return Math.random()>.5 ? -1 : 1; }, createArr: function () { for(var i=0; i<this.num+1; i++){ this.data.push(i); } this.data.sort(this.randomSort); }, closeEvent: function () { document.onmousedown=document.onmousemove=document.oncontextmenu=function() { return false; } }, startDraw: function () { var _this = this; document.onkeyup = function ( ev ) { var ev = ev || window.event; if(ev.keyCode == 13 || ev.keyCode == 32){ if(_this.btn && _this.timer){ if(_this.obj[_this.obj.length-1].btn){ _this.Play (); _this.btn = !_this.btn; _this.timer = !_this.timer; } }else{ if(_this.obj[_this.obj.length-1].btn){ _this.Stop (); _this.btn = !_this.btn; _this.timer = !_this.timer; } } return false; }else{ return false; } } }, Play: function () { if(this.timer && this.btn){ var t = 0; for(var i=0; i<this.obj.length; i++){ this.obj[i].btn = false; this.playTimer (this.obj[i],t); t += 1500; } }else{ return false; } }, playTimer: function (obj,t) { var _this = this; setTimeout(function(){ _this.Move (obj); },t) }, Del: function (a) { for(var i=0; i<this.data.length; i++){ if(a == this.data[i]){ this.data.splice(i,1); } } }, Stop: function () { if(!this.timer && !this.btn){ var n = this.num + 1; var r = this.data[Math.floor(Math.random() * (0-n) + n)]; this.show = r; this.Del (r); r = r.toString().split(""); var c = this.obj.length - r.length; if(r.length < this.obj.length){ for(var i=0; i<c; i++){ r.unshift(0) } } this.result = r; //document.title = r+" : "+this.data; var t = 0; for(var i=0; i<this.obj.length; i++){ this.obj[i].btn = false; this.obj[i].index = i; this.obj[i].num = this.result[this.obj[i].index]; this.stopTimer (this.obj[i],t); t += 1500; } } }, stopTimer: function (obj,t) { var _this = this; setTimeout(function(){ _this.showResult (obj); },t) }, showResult: function (obj) { var _this = this; this.timer = true; this.btn = true; obj.btn = false; obj.vh = -obj.num * this.h; obj.timeOut = setInterval(function(){ obj.speed -= 1; if(obj.speed == 1){ clearInterval(obj.timeOut); clearInterval(obj.timer); obj.timer = setInterval(function(){ if(obj.ul.offsetTop >= obj.vh){ clearInterval(obj.timer); AIR.startMove(obj.ul,{left:0,top:obj.vh},function(){ obj.btn = true; var set = true; for(var i=0; i<_this.obj.length; i++){ if(!_this.obj[i].btn){ set = false; } } if(set){ _this.Open(_this.show) } }); } obj.ul.style.top = obj.ul.offsetTop + obj.speed +"px"; },30); } },100); }, Open: function (num) { document.title += " "+ num; }, Move: function (obj) { var _this = this; var obj = obj; obj.btn = false; obj.timer = null; obj.speed = 1; obj.ul = AIR.$$("ul",obj)[0]; obj.ul.style.height = this.uh +"px"; obj.timer = setInterval(function(){ if(obj.ul.offsetTop > 0){ obj.ul.style.top = -(_this.uh/2) +"px"; } obj.ul.style.top = obj.ul.offsetTop + obj.speed +"px"; },30); obj.timeOut = setInterval(function(){ obj.speed += 1; if(obj.speed == 30){ clearInterval(obj.timeOut); obj.btn = true; } },300) } } var initialize = function () { new Draw ([AIR.$("box1"),AIR.$("box2"),AIR.$("box3")],100); reSize (); } var reSize = function () { var v = AIR.getElementClient(); AIR.$$("img",AIR.$("back"))[0].width = v[0]; AIR.$$("img",AIR.$("back"))[0].height = v[1]; } AIR.addEvent(window,"load",initialize); AIR.addEvent(window,"resize",reSize); </script> </head> <body> <div id="box"> <div id="box1"></div> <div id="box2"></div> <div id="box3"></div> <div style="clear:both"></div> </div> <div id="back"> <img src="images/20153291274950386.jpg" /> </div> <div id="showback">100</div> </body> </html>
이 기사가 모든 사람의 JavaScript 프로그래밍 설계에 도움이 되기를 바랍니다.

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











얼굴 검출 및 인식 기술은 이미 상대적으로 성숙하고 널리 사용되는 기술입니다. 현재 가장 널리 사용되는 인터넷 응용 언어는 JS입니다. 웹 프런트엔드에서 얼굴 감지 및 인식을 구현하는 것은 백엔드 얼굴 인식에 비해 장점과 단점이 있습니다. 장점에는 네트워크 상호 작용 및 실시간 인식이 줄어 사용자 대기 시간이 크게 단축되고 사용자 경험이 향상된다는 단점이 있습니다. 모델 크기에 따라 제한되고 정확도도 제한됩니다. js를 사용하여 웹에서 얼굴 인식을 구현하는 방법은 무엇입니까? 웹에서 얼굴 인식을 구현하려면 JavaScript, HTML, CSS, WebRTC 등 관련 프로그래밍 언어 및 기술에 익숙해야 합니다. 동시에 관련 컴퓨터 비전 및 인공지능 기술도 마스터해야 합니다. 웹 측면의 디자인으로 인해 주목할 가치가 있습니다.

PHP와 JS를 사용하여 주식 캔들 차트를 만드는 방법 주식 캔들 차트는 주식 시장에서 흔히 사용되는 기술 분석 그래픽으로 시가, 종가, 최고가 등의 데이터를 그려서 투자자가 주식을 보다 직관적으로 이해할 수 있도록 도와줍니다. 주식의 최저 가격. 이 기사에서는 특정 코드 예제와 함께 PHP 및 JS를 사용하여 주식 캔들 차트를 만드는 방법을 설명합니다. 1. 준비 시작하기 전에 다음 환경을 준비해야 합니다. 1. PHP를 실행하는 서버 2. HTML5 및 Canvas를 지원하는 브라우저 3

주식 분석을 위한 필수 도구: PHP 및 JS에서 캔들 차트를 그리는 단계를 배우십시오. 인터넷과 기술의 급속한 발전으로 주식 거래는 많은 투자자에게 중요한 방법 중 하나가 되었습니다. 주식분석은 투자자의 의사결정에 있어 중요한 부분이며 캔들차트는 기술적 분석에 널리 사용됩니다. PHP와 JS를 사용하여 캔들 차트를 그리는 방법을 배우면 투자자가 더 나은 결정을 내리는 데 도움이 되는 보다 직관적인 정보를 얻을 수 있습니다. 캔들스틱 차트는 주가를 캔들스틱 형태로 표시하는 기술 차트입니다. 주가를 보여주네요

인터넷 금융의 급속한 발전으로 인해 주식 투자는 점점 더 많은 사람들의 선택이 되었습니다. 주식 거래에서 캔들 차트는 주가의 변화 추세를 보여주고 투자자가 보다 정확한 결정을 내리는 데 도움이 되는 일반적으로 사용되는 기술적 분석 방법입니다. 이 기사에서는 PHP와 JS의 개발 기술을 소개하고 독자가 주식 캔들 차트를 그리는 방법을 이해하도록 유도하며 구체적인 코드 예제를 제공합니다. 1. 주식 캔들 차트의 이해 주식 캔들 차트를 그리는 방법을 소개하기 전에 먼저 캔들 차트가 무엇인지부터 이해해야 합니다. 캔들스틱 차트는 일본인이 개발했습니다.

js와 vue의 관계: 1. 웹 개발의 초석인 JS 2. 프론트엔드 프레임워크로서의 Vue.js의 등장 3. JS와 Vue의 상호 보완적인 관계 4. JS와 Vue의 실제 적용 Vue.

5월 7일, 당사 휴대폰 제조사는 당사의 GTNeo6 출시 컨퍼런스가 5월 9일로 예정되어 있다고 공식 발표했습니다. GTNoe6는 중급 머신 상황을 뒤흔드는 것을 목표로 하는 '성능 폭풍'으로 자리매김했습니다. 아울러 이번 컨퍼런스는 휴대폰 업계 최초의 AI 디지털 휴먼 컨퍼런스이기도 하다. 이때 Realme 부사장 겸 글로벌 마케팅 사장, Xu Qi 중국 사장이 디지털 휴먼의 모습으로 기자회견장에 등장할 예정입니다. Digital man Xu Qi 공식 소개에 따르면 코드명 "Hurricane"인 Realme GTNoe6는 더 빠르고 강력하며 가장 강력한 3세대 Snapdragon 8s 플래그십이자 동급 최강 제품에 도전할 것입니다. 최근 Realme GTNeo6가 전자상거래 플랫폼에 직접 있는 것으로 밝혀져 일부 핵심 구성이 노출되어 이 기기에 Snapdragon 8s 프로세서가 탑재되었을 뿐만 아니라 120W 플래시 충전도 지원하는 것으로 나타났습니다.

현재 페이지를 새로 고치는 js 메소드: 1. location.reload(); 2. location.href; 4. window.location. 자세한 소개: 1. location.reload(), 현재 페이지를 다시 로드하려면 location.reload() 메소드를 사용하십시오. 2. location.href, location.href 속성 등을 설정하여 현재 페이지를 새로 고칠 수 있습니다.

Golang에서 문자열을 숫자로 변환하는 방법 Golang에서는 일부 계산 작업을 수행하기 위해 문자열을 숫자로 변환해야 하는 경우가 많습니다. 문자열을 숫자로 변환하는 과정은 상대적으로 간단하며 주로 Golang 표준 라이브러리의 strconv 패키지에 의존합니다. 이 기사에서는 strconv 패키지를 사용하여 문자열을 숫자로 변환하는 방법을 자세히 소개하고 몇 가지 구체적인 코드 예제를 제공합니다. 문자열을 정수로 변환 문자열을 정수로 변환하려면 strconv 패키지의 Atoi 함수를 사용할 수 있습니다. 아토
