Developing TicToe HTML5/Implementing Client Entities: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>Hendrik Brummermann No edit summary |
imported>Hendrik Brummermann No edit summary |
||
| Line 48: | Line 48: | ||
== Drawing the gameboard == |
== Drawing the gameboard == |
||
Okay, now we have (stupid) prototypes of all the important objects. Let's add a method to the gameboard prototype, which will draw it onto the screen: |
|||
{{TODO|write this subsection}} |
|||
<source lang="javascript"> |
|||
marauroa.rpobjectFactory.gameboard.draw = function() { |
|||
// Unless we already have done this, add an "img" object to the HTML document |
|||
if (typeof(this.img) == "undefined") { |
|||
this.img = document.createElement('img'); |
|||
document.getElementsByTagName("body")[0].appendChild(this.img); |
|||
} |
|||
// set the properties of the img-tag based on the data stored in this object by the server |
|||
this.img.src = "images/board.png"; |
|||
this.img.style.position = "absolute"; |
|||
this.img.style.zIndex = this.z; |
|||
this.img.style.left = this.x + "px"; |
|||
this.img.style.top = this.y + "px"; |
|||
} |
|||
</source> |
|||