MonkeyGame.html

Community Forums/Monkey Talk/MonkeyGame.html

Paul "Taiphoz"(Posted 2011) [#1]
I was getting annoyed with the console window so I made my monkeygame.html file readonly so the ide couldnt replace it, I set its width etc for the game and then added a little javascript to clear the console and to keep its page at the bottom, to show the new items being added.

It saves you from having to scroll down all the time specially when there is tons being printed.

Just thought I would post it in case anyone else like me was getting miffed by it. Oh it's odd but the context textarea does not seem to fire off an onchange when monkey adds a new line so I changed or added a call to update on the canvas. its not idea but it works for my click heavy project.

has anyone else got round to hacking together a better console if so do tell ..

<!DOCTYPE html>

<html>
<head>
<style type="text/css">
body{
	height: 100%;
	overflow: hidden; /* keeps scrollbar off IE */
	font-family: arial,sans-serif;
	font-size: 13px;
	color: #000;
	background-color: #fff;
	padding:0px;
	margin:0px;
}

canvas:focus{
	outline:none;
}

a {
	font-weight:bold;
	color:#000;
	background-color:#999;
	text-decoration:none;
}

a:hover {
	background-color:#000;
	color:#f00;
}

.bar{
	background-color:#999;
	color:#000;
	width=100%;
}



</style>

<script type = "text/javascript">
	function eraseText() {
		document.getElementById("GameConsole").value = "";
	}
	
	function update(){
			
		var Console = document.getElementById('GameConsole');
		var height = Console.scrollHeight;
		
		if(Console.scrollHeight > (height-200))
		  {
			Console.scrollTop = height;
		  }
				
	}
	
</script>

</head>

<body>

<canvas id="GameCanvas" onclick="this.focus();update();" oncontextmenu="return false;" width=800 height=480 tabindex=1></canvas><br>

<div class="bar"><a onclick="eraseText()">Clear</a> | <a onclick="update()">Bottom</a> | <a>Save</a></div><br>
<textarea onchange="update()" id="GameConsole" style="width:800px;height:200px;border:1;padding:0;margin:0" ></textarea><br>

<script language="javascript" src="main.js">Javascript not supported!</script>

</body>
</html>




Dabhand(Posted 2011) [#2]
http://www.monkeycoder.co.nz/Community/posts.php?topic=692

Without having a good look at your code, I've just posted a link to a bit of work therevills put up over at the official forums!

Dabz


Paul "Taiphoz"(Posted 2011) [#3]
Yeah its the same thing although mine does not require you to hack the core files, I'v also added a clear call so you can clear the printed output if you have a lot of crap going on and just wana see a specific thing.

but yeah same thing..

I think I might full develop the code on the generated monkeygame.html file tho, and really tart out the console window if I have time, since it seems to be the only way to debug our code.


therevills(Posted 2011) [#4]
This change is included with the latest version Monkey.


Paul "Taiphoz"(Posted 2011) [#5]
cool.

There are a few things I am thinking about adding to the Print TextArea might be nice if these were also included.

1. Save : saves the textarea text to a log file, some times our text area gets large and we need to see or read the whole thing.
2. filter : a filter option that only shows lines that begin with a given string, I was planning to prefix my Printed debug info with numbers depending on what part of the code its coming from, so that I could then filter out all other prints and only show the stuff coming from a specific method. or function.
like this.
Print "Function:Updatex [ loopcounter : 100 ]

then filtering on Function:Updtatex, would only show the above prints in the text area.

I can do the above as an edit to monkeygame.html but would be cool if I didnt have to.


slenkar(Posted 2011) [#6]
nice ideas taiphoz i would like both


Paul "Taiphoz"(Posted 2011) [#7]
Yeah, will make things a bit simpler when it comes to having to use print as a debug tool, not had a chance to work on it yet but its on my todo list, currently fighting an apache install.