somebody please help me.. battle simulator
I'm trying to make a battle simulator where you can select classes to fight each other. I can't for the life of me understand what i'm doing wrong!
Code:
<!DOCTYPE html>
<html>
<head>
<title>Register</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="CSS/styles.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
var monsters = {
reaper : { hitpoints: 250, strength : 17, luck : 3 },
dragon : { hitpoints: 1000, strength: 50, luck : 5},
orc : { hitpoints: 100, strength: 12, luck : 2 },
ogre: { hitpoints: 50, strength: 10, luck: 1 }
}
function startFight()
{
charFightHP = charHP;
beastFightHP = beastHP;
fightTrue = 1;
charDmg = charStr - beastDef;
beastDmg = beastStr - charDef;
beastName = document.getElementById("theBName").innerHTML;
if (charDmg < 0)
{
charDmg = 0;
}
else if (beastDmg < 0)
{
beastDmg = 0;
}
while (fightTrue != 0)
{
if (charFightHP > 0 && beastFightHP > 0)
{
charFightHP = beastDmg - charFightHP;
beastFightHP = charDmg - beastFightHP;
alert("You do "+charDmg+" damage to "+beastName+". "+beastName+" does "+beastDmg+" damage to you.");
document.getElementById("theHP").innerHTML = charFightHP;
document.getElementById("theBHP").innerHTML = beastFightHP;
}
else{
fightTrue = 0;
}
}
if (beastFightHP < 0 && charFightHP > 0)
{
fightWin();
}
if (charFightHP < 0)
{
alert("You are dead");
createChar();
}
}
</script>
</head>
<header>
<div style="clear:both;"></div>
</header>
<body>
<div id="content">
<form class="form">
<h2>Simulator</h2>
<field name="fieldName" static="true" type="FieldType" value="code">Strength</field>
<input type = "text" value="300" disabled="disable" id="hitpoints" />
<input type = "text" value="100" disabled="disable" id="strength" />
<input type = "text" value="100" disabled="disable" id="luck" />
<select>
<option>Dragon</option>
<option>Orc</option>
<option>Ogre</option>
<option>Reaper</option>
</select>
<input type="button" value="Fight" onclick="startFight()";/>
</form>
</div>
</body>
<footer>
</footer>
</html>
Most of the Right Hand Side variables in the function startFight() seems to be undefined ?
Yes I pulled that function from the internet and posted it to see if that was helpful. I thought it would steer me in the way of figuring it out but i dont understand it.
This is my code thus far (all of what I coded)
Code:
<!DOCTYPE html>
<html>
<head>
<title>Register</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="CSS/styles.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
var character = { hitpoints: 300, strength: 100, luck: 100}
var monsters = {
reaper : { hitpoints: 250, strength : 17, luck : 3 },
dragon : { hitpoints: 1000, strength: 50, luck : 5},
orc : { hitpoints: 100, strength: 12, luck : 2 },
ogre: { hitpoints: 50, strength: 10, luck: 1 }
}
function battlesim()
{
}
</script>
</head>
<header>
<div style="clear:both;"></div>
</header>
<body>
<div id="content">
<form class="form">
<h2>Simulator</h2>
<field name="fieldName" static="true" type="FieldType" value="code">Strength</field>
<input type = "text" value="300" disabled="disable" id="" />
<input type = "text" value="100" disabled="disable" id="" />
<input type = "text" value="100" disabled="disable" id="" />
<select>
<option>Dragon</option>
<option>Orc</option>
<option>Ogre</option>
<option>Reaper</option>
</select>
<input type="button" value="Fight" onclick='battlesim()';/>
</form>
</div>
</body>
<footer>
</footer>
</html>
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks