Thursday 13 November 2014

Week 13:

We've gotten to the point where we have data to put into the webpage, so that's pretty good. There's nothing to complex going on at this point, but Angus gave me the javascript for loading character information, so I've got that being output onto the screen (Angus wrote the javascript to assign variables to stuff on the webpage, I just had to set up the CSS ID's for each value, and put it into the  character select page). I also had to write some code so that once a selection is made, the current page is changed to the battle page, and the selected characters information is sent along with it. I sent the character information along in the URL, since this was the easiest method, and the information isn't sensitive.

Code for sending character information:

(part of a larger function, runs when the player selects a character)

{
charinfo='';
charinfo=charname + ',' + charclass + ',' + charrank

}

Function that runs when the player confirms their choice:

       function battle(charclass) {
window.location = "battle.html?"+charinfo;
}

Code for recieving character information:

var query = window.location.search;

 if (query.substring(0, 1) == '?') {
query = query.substring(1);
 }

          var data = query.split(',');
charname=unescape(data[0])
clas=data[1]
rank=data[2]

No comments:

Post a Comment