Beyond my Ability, Part 2
By Jesse Morgan
So I have two ways to go about implementing this- read through Amit’s actionscript and try to implement it in java, or read though his article and randomly mishmash internet code together to get a working prototype. While it’s tempting to just swipe other people’s code, that won’t help me understand how it works.
So, I guess the first part is to start with a simple HTML5 page with a canvas.
<html>
<head>
<script src="map.js">
</script>
<script>
window.onload = function(){
var canvas = document.getElementById("worldmap");
var context = canvas.getContext("2d");
};
</script>
<title> CityGenerator's Worldmap</title>
</head>
<body>
<canvas id="worldmap" style="height:600px;width:800px;border:1px solid black;">
</canvas>
</body>
</html>
There we go. So pretty. The next step (I think) is to come up with an object to represent the map; While the canvas is pretty, it’s just output. Amit seems to have done exactly this with Map.as. Do I try a full blown reimplementation of his code without understanding it, or do I aim for a skeleton that can output to the canvas, and the build up from there? For now, I think I’ll get more out of the latter. I’ll start with a simple map.js and try to port over the basic functionality. I’m not sure how successful this will actually be seeing as how he uses external libraries, which I will either need to emulate (no chance) or find a similar js version (slim chance).
Adding to the complexity is my lack of js-fu; I feel like someone who kind of knows Spanish trying to translate a Portuguese document to find out where Vasco De Gama hid his gold.
I’m currently in the process of stepping through the actionscript and replacing individual methods with javascript, while at the same time comprehending how they work. It’s a lot of effort; I’ve been at it for well over an hour and I’m only 9% complete. I need to take a break.