Developing TicToe HTML5/Implementing Client Entities: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
imported>Hendrik Brummermann
imported>Hendrik Brummermann
No edit summary
Line 131: Line 131:
== Drawing players ==
== Drawing players ==


Our main goal is to get the core game working. Therefore we do not bother to create full player avatars, yet. Instead we just display the name at the correct position. We override the draw method as follows:
{{TODO|write this sub-section}}

<source lang="javascript">
marauroa.rpobjectFactory.player.draw = function() {
if (typeof(this.div) == "undefined") {
this.div = document.createElement('div');
document.getElementsByTagName("body")[0].appendChild(this.div);
}
this.div.innerHTML = this.playerName;
this.div.style.position = "absolute";
this.div.style.zIndex = this.z;
this.div.style.left = this.x + "px";
this.div.style.top = this.y + "px";
}
</source>

This does have some redundancy with the code in the draw method of the Entity prototype. But we will completely rewrite it at a later time. Therefore it is okay for now, not to refactor it now.


== Actions ==
== Actions ==