阴阳师模拟抽卡[含源码]
实现⽅式
HTML+JavaScript
实现效果
概率可⾃⾏在代码中修改,默认为概率UP
为了好看我加⼊了⿏标插件,⿏标按住右键不放画图案,仅仅是画图⽽已
(实际单击右键抽卡)
单击右键进⾏抽卡
抽到SSR/SP时,播放动画
实现⽅式
1.准备图⽚⽂件(式神头像和背景图)
/SP召唤动画
3.编写代码
body
{
width:1200px;
margin-left:auto;
margin-right:auto;
background-image:url('yys_');
color:white;
}
#result_t
{
width:1200px;
float:left;
position:absolute;
top:150px;
}
}
#shilian
{
display:none;
width:1200px;
float:left;
position:absolute;
top:500px;
}
.home-video{
z-index:100;
position:absolute;
top:50%;
left:50%;
min-width:100%;
min-height:100%;
object-fit:fill;/*这⾥是关键*/
width:auto;
height:auto;
-ms-transform:translateX(-50%)translateY(-50%);
-webkit-transform:translateX(-50%)translateY(-50%);
transform:translateX(-50%)translateY(-50%);
background-size:cover;
}
#info
{
font-size:20px;
font-weight:bold;
font-family:ComicSansMs;
}
varSP_SET=newArray("炼狱茨⽊童⼦","稻荷神御馔津","少⽻⼤天狗","⾚影妖⼑姬","苍风⼀⽬连","御怨般若","骁浪荒川之主");
varSSR_SET=newArray("⼤天狗","酒吞童⼦","荒川之主","阎魔","⼩⿅男","茨⽊童⼦","青⾏灯","妖⼑姬","⼀⽬连","花鸟卷","辉夜姬","荒","彼岸花","雪童⼦","
⼭风","⽟藻前","御馔津","⾯灵⽓","⿁切","⽩藏主","⼋岐⼤蛇","不知⽕","⼤岳丸");
varSR_SET=newArray("桃花妖","雪⼥","⿁使⽩","孟婆","⽝神","⿁⼥红叶","傀儡师","判官","凤凰⽕","吸⾎姬","妖狐","妖琴师","⾷梦貘","清姬","镰鼬","姑获鸟
","⽩狼","樱花妖","惠⽐寿","络新妇","般若","青坊主","夜叉","⿊童⼦","⽩童⼦","烟烟罗","⾦鱼姬","鸩","以津真天","匣中少⼥","书翁","百⽬⿁","追⽉神","薰","弈","猫
掌柜","於菊⾍","⼀反⽊绵","⼊殓师","化鲸","久次良","蟹姬");
varR_SET=newArray("三尾狐","座敷童⼦","鲤鱼精","九命猫","狸猫","河童","童男","童⼥","饿⿁","巫蛊师","鸦天狗","⾷发⿁","武⼠之灵","⾬⼥","跳跳弟弟","
跳跳妹妹","兵俑","丑时之⼥","独眼⼩僧","铁⿏","椒图","管狐","⼭兔","萤草","蝴蝶精","⼭童","⾸⽆","觉","青蛙瓷器","古笼⽕","⾍师");
varall_SET=newArray();
vararr=newArray();
vartemp=0;
vartimer;
//把式神集放⼊卡池
add_pool(SP_SET,15);//UP->15
add_pool(SSR_SET,15);//UP->15
add_pool(SR_SET,200);//UP->200
add_pool(R_SET,770);//UP->770
//打乱卡池,保证随机性
all_(randomsort);
//计算概率
count_chance();
varvid=mentById("vid");
extmenu=function(){returnfal};
ntListener("ended",function()
{
$('#vid').css('display','none');
$('#vid').css('display','none');
$('#vid').removeClass('home-video');
timer=tInterval(func,1000);
});
//放⼊卡池
functionadd_pool(list_t,num){
for(vari=0;i
{
all_(list_t);
}
(num);
}
//计算概率
functioncount_chance()
{
varinfo=mentById("info");
vartot=0;
for(vari=0;i<;i++)
{
tot+=arr[i];
}
TML+="SP/SSR:"+((arr[0]+arr[1])/tot*100).toFixed(2)+"%
";
TML+="SR:"+(arr[2]/tot*100).toFixed(2)+"%
";
TML+="R:"+(arr[3]/tot*100).toFixed(2)+"%
";
}
//抽卡
functionaction_random()
{
t=0;
varresult_t=mentById('result_t');
result_TML="";
timer=tInterval(func,1000);
}
vart=0;
functionfunc()
{
varresult_t=mentById('result_t');
if(t<10){
varrand=getRndInteger(0,all_-1);
varnew_rand=getRndInteger(0,all_SET[rand].length-1);
varstr=all_SET[rand][new_rand];
varstyle=arch(str);
result_TML+="
if(style=="color:#FFCC00;"||style=="color:#CC0033;")
{
$('#vid').css('display','block');
$('#vid').attr('src',str+'.mp4');
();
$('#vid').addClass('home-video');
clearInterval(timer);
}
t++;
}
el
{
clearInterval(timer);
$("#shilian").show(800);
}
}
//判断式神是SP/SSR/SR/R
functionarch(shiShen)
{
for(vari=0;i
{
if(shiShen==SP_SET[i])
{
return"color:#CC0033;";
}
}
for(vari=0;i
{
if(shiShen==SSR_SET[i])
if(shiShen==SSR_SET[i])
{
return"color:#FFCC00;";
}
}
for(vari=0;i
{
if(shiShen==SR_SET[i])
{
return"color:#CC00FF;";
}
}
for(vari=0;i
{
if(shiShen==R_SET[i])
{
return"color:skyblue;";
}
}
}
//以下函数返回min(包含)~max(包含)之间的数字:
functiongetRndInteger(min,max)
{
(()*(max-min+1))+min;
}
//⽤()函数⽣成0~1之间的随机数与0.5⽐较,返回-1或1
functionrandomsort()
{
()>0.5?-1:1;
}
varimage=mentById("image");
eup=function(e)
{
if(==2)
{
if(temp==0)
{
$('#image').hide(800);
$('#image').fadeIn(800);
$('#image').attr('src','');
temp++;
}
$("#shilian").hide();
action_random();
}
}
本文发布于:2023-03-03 12:38:02,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/1677818283123164.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:巫蛊师哪里多.doc
本文 PDF 下载地址:巫蛊师哪里多.pdf
留言与评论(共有 0 条评论) |