function move(where){
var status = document.querySelector("#status");
var img = document.querySelector("img");
switch(where){
case "north":
if(startingPos>=3){
startingPos -= 3;
status.innerHTML = messages[startingPos];
img.setAttribute("src",images[startingPos]);
}else{
status.innerHTML = blockedPathMsg[startingPos];
}
break;
case "east":
if(startingPos%3!=2){
startingPos += 1;
status.innerHTML = messages[startingPos];
img.setAttribute("src",images[startingPos]);
}else{
status.innerHTML = blockedPathMsg[startingPos];
}
break;
case "west":
if(startingPos%3!=0){
startingPos -= 1;
status.innerHTML = messages[startingPos];
img.setAttribute("src",images[startingPos]);
}else{
status.innerHTML = blockedPathMsg[startingPos];
}
break;
case "south":
if(startingPos<6){
startingPos += 3;
status.innerHTML = messages[startingPos];
img.setAttribute("src",images[startingPos]);
}else{
status.innerHTML = blockedPathMsg[startingPos];
}
break;
default:
status.innerHTML = "I do not know that";
}
}
这是我在游戏中使用的用户可以移动的功能。现在我需要添加一个新功能,用户可以在其中挑选和丢弃物品。项目将位于地图中的某些位置,每当用户到达那里时,我想将与该项目关联的消息附加到status.innerHTML
.
我该怎么做呢?