game not working anymore ... (solved)

Monkey Targets Forums/HTML5/game not working anymore ... (solved)

Yoda(Posted 2014) [#1]
I compiled my game (same code as before) and it runs well in the browser, but when I upload it, it doesn't do anything.

It worked fine with the version before.
What changed?


ziggy(Posted 2014) [#2]
Can you give us more details? Where are you uploading it? Are you also uploading all the required datafolder, javascript files, etc? Are you sure you've cleared your browser cache?


nikoniko(Posted 2014) [#3]
Yoda wrote:
What changed?


Changed build folder (now contains monkey version in tail), changed html template...


Yoda(Posted 2014) [#4]
Yes, but does that affect anything if I just upload the updated main.js + data folder?

As I said, the old version (compiled with monkey version before) worked. No changes. Just compiled again and uploaded main.js and data-folder.

Do I have to change anything in my html file now to make it work again?


dawlane(Posted 2014) [#5]
If the HTML that you originally up loaded was from one of the old versions, then yes. The new version has a bit of JavaScript start up code.


Yoda(Posted 2014) [#6]
This is the html (basically). What do I have to add, so it will run, but not change the look of anything?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<style type="text/css">
body{
height: 100%;
background-color: #000;
padding:0px;
margin:0px;
}
canvas:focus{
outline:none;
}
</style>
</head>

<body bgcolor="black" link="white">
<div align="center">
<table width="800" border="0" cellspacing="0" cellpadding="0" background="back-hurdlejumper.gif" height="849">
<tr height="480">
<td width="640" height="480">
<canvas id="GameCanvas" onclick="javascript:this.focus();" width=640 height=480 tabindex=1></canvas>
<br>
<script language="javascript" src="main.js">Javascript not supported!</script>
</td>
</tr>
</table>
</div>
</body>
</html>


MikeHart(Posted 2014) [#7]
You need to use the new html file. Like it was sadi before. It has changed.


dawlane(Posted 2014) [#8]
For a starter HTML5 doc type is now <!DOCTYPE html> you need to read this to see the difference.

This is the stub that I use
<!DOCTYPE html>

<html>
<head>
<script>

var CANVAS_RESIZE_MODE=0;	//0=locked, 1=stretch, 2=resize

var CANVAS_WIDTH=640;
var CANVAS_HEIGHT=480;

window.onload=function( e ){

	var canvas=document.getElementById( "GameCanvas" );

	canvas.width=CANVAS_WIDTH;
	canvas.height=CANVAS_HEIGHT;

	BBMonkeyGame.Main( canvas );
};
</script>
</head>

<body>

<div><canvas id="GameCanvas" tabindex=1></canvas></div>

<!-- language attribute isn't necessary any more with the latest browsers -->
<script language="javascript" src="main.js"></script><noscript><img src="/images/site/nojava.png" /></noscript>

</body>
</html>
Try it.

If you are having problems running Monkey HTML5 stuff as part of another page. Then use the stub above in the location of your Monkey Game and use an iframe to wrap your MonkeyGame from that page. e.g. <div id="css_id_of_game_win"><iframe src="/path_to_my_html_game/mygame.html"></iframe></div>
You may have to change the size of the iframe to make it fit.


Yoda(Posted 2014) [#9]
Thanks! That worked!

Here's a little gift: Code for Hurdlejumper - 636497

Apply it on:
http://www.yodasvideoarcade.com/game-hurdlejumper/hurdlejumper.php