html
<!doctype html> <head> <title>My First Game</title> <link rel="stylesheet" type="text/css" href="main.css" /> <script src="game.js"></script> </head> <body> <div id="wrapper"> <div id="mainpage"> <img src="main.jpg" id="mimg"> <br> <font id="title" color="red" size="6"> <center> THE PLAGUE </center> </font> <center> <img src="start.jpg" id="startbutton" type="button" onclick="virusName()"> </center> <center> <font color="red" size="6"> <img src="instructions.jpg" onclick="gameInst()"> </font> </center> </div> <div id="instructions"> <font color="red" size="5"> You have gone mad with rage and have decided that you are the one true ruler of the world. Your job is to unleash a deadly virus upon the world to show your strength and fearlessness. Show everyone your absolute power by destroying all those that oppose you! </font> <div id="bottom"> <img src="back.jpg" type="button" onclick="returnMain()"> </div> </div> </div> </body> </html>
css
*
{
margin:0px;
padding:0px;
}
#wrapper
{
position:relative;
width:500px;
height:500px;
top:50px;
margin-left:auto;
margin-right:auto;
background:black;
}
#mainpage
{
position:relative;
background:black;
width:100%;
height:400px;
}
#instructions
{
position:relative;
text-align:justify;
padding:1.5%;
background:black;
width:97%;
height:500px;
display:none;
}
#bottom
{
position:absolute;
bottom:0px;
left:0px;
}
#mimg
{
position:relative;
display:block;
margin-left:auto;
margin-right:auto;
}
#startbutton
{
width:100px;
height:100px;
}
javascript
function virusName()
{
document.getElementById('mainpage').style.display = 'none';
}
function gameInst()
{
document.getElementById('instructions').style.display = 'block';
document.getElementById('mainpage').style.display = 'none';
}
function returnMain()
{
document.getElementById('mainpage').style.display = 'block';
document.getElementById('instructions').style.display = 'none';
}
so far all this code does is show the main screen with 2 buttons a instructions button and a start button. clicking on the instructions button will hide the main page div and show the instructions div which has a back button in it. the back button of course using javascript to hide the instructions page and show the main page div. the start button does not doing anything right now other than hide the main page div. i have already thought out the functions of the game and how i want it to work. i suppose all i want to know is, from those more experienced in javascript, if i am going about creating this game the right way. this method is just something that i came up with and not something that i learned from a tutorial so i wanna make sure im not wasting my time. thanks!

New Topic/Question
Reply


MultiQuote





|