html全局变量接收局部数据,只能通过获取html里的代码或者创建全局变量来使用吗?或者能在两个函数之间调数据吗?...

Math

background-color:#eee; width:90px;border: 1px solid black;}

button{border: 1px solid black;}

function gu(monsterHealth,monsterAttack,playerHealth,playerAttack){//生命不息整活不止

var monsterName=["亡灵","血骷髅","炸弹人"];

var monster = monsterName[Math.round(Math.random()*2)];//生命不息整活不止

monsterHealth=Math.ceil(Math.random()*200);

monsterAttack=Math.ceil(Math.random()*30);//生命不息整活不止

playerHealth=Math.ceil(Math.random()*200);//生命不息整活不止

playerAttack=Math.ceil(Math.random()*30);

document.getElementById("monsterName").value=monster;//生命不息整活不止

document.getElementById("monsterHealth").value=monsterHealth;//生命不息整活不止

document.getElementById("monsterAttack").value=monsterAttack;

document.getElementById("playerName").value="GULAO";

document.getElementById("playerHealth").value=playerHealth;

document.getElementById("playerAttack").value=playerAttack;

}

function Attack(){

console.log("fffff");

var monsterHealth=document.getElementById("monsterHealth").value;

var playerAttack=document.getElementById("playerAttack").value;

var playerHealth=document.getElementById("playerHealth").value;

var monsterAttack=document.getElementById("monsterAttack").value;

console.log("monsterAttack:"+monsterAttack);

document.getElementById("monsterHealth").value=monsterHealth-playerAttack;

document.getElementById("playerHealth").value=playerHealth-monsterAttack;

playerHealth=playerHealth-monsterAttack;

monsterHealth=monsterHealth-playerAttack;

if(monsterHealth<=0&&playerHealth<=0){

var result="平局";

document.getElementById("result").value=result;

}else if(monsterHealth<=0){

var result="获胜";

document.getElementById("result").value=result;

}else if(playerHealth<=0){

var result="失败";

document.getElementById("result").value=result;

}

}

「」

血量:

攻击:


「」

血量:

攻击:

重制

攻击

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值