Changeset 84


Ignore:
Timestamp:
01/01/11 14:42:26 (13 years ago)
Author:
atzm
Message:

fixed messaging

Location:
pycodeshooter/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pycodeshooter/trunk/index.html

    r83 r84  
    1616 
    1717    function start(id, list) { 
     18        var msg    = document.getElementById("message"); 
    1819        var player = { 
    1920            "name":         document.getElementById("name").value, 
     
    3132                continue; 
    3233            if (!player[n] || player[n] < 0) { 
    33                 debugMsgSet("Invalid Input Data"); 
     34                setMessage(msg, "Invalid Input Data"); 
    3435                return; 
    3536            } 
     37        } 
     38 
     39        if (titleIntervalId) { 
     40            clearInterval(titleIntervalId); 
     41            titleIntervalId = 0; 
    3642        } 
    3743 
     
    4046        document.onkeypress = function (ev) { setKeyPress(ev.charCode); }; 
    4147 
    42         initGame(document.getElementById("screen"), id, list[id], player); 
     48        initGame(document.getElementById("screen"), msg, id, list[id], player); 
    4349    } 
    4450 
     
    5460 
    5561        document.getElementById("bossSelection").onchange = function (ev) { 
    56             if (titleIntervalId) { 
    57                 clearInterval(titleIntervalId); 
    58                 titleIntervalId = 0; 
    59             } 
    6062            start(this[this.selectedIndex].value, list); 
    6163        }; 
    62     } 
    63  
    64     function debugMsgSet(msg) { 
    65         document.getElementById("message").innerHTML = msg; 
    66     } 
    67  
    68     function debugMsgAdd(msg) { 
    69         document.getElementById("message").innerHTML += msg; 
    7064    } 
    7165 
  • pycodeshooter/trunk/shooter/system.js

    r81 r84  
    2121        "height": 0 
    2222    }, 
     23    "message":          null, 
    2324    "boss":             null, 
    2425    "player":           null, 
     
    9697} 
    9798 
     99function setMessage(elem, msg) { 
     100    if (elem) 
     101        elem.innerHTML = msg; 
     102} 
     103 
     104function addMessage(elem, msg) { 
     105    if (elem) 
     106        elem.innerHTML += msg; 
     107} 
     108 
    98109 
    99110/* 
     
    189200 *  Initializer 
    190201 */ 
    191 function initGame(canvas, bossId, bossData, playerData) { 
     202function initGame(canvas, msg, bossId, bossData, playerData) { 
    192203    System.screen.canvas = canvas; 
     204    System.message       = msg; 
    193205    System.screen.ctx    = System.screen.canvas.getContext("2d"); 
    194206    System.screen.width  = System.screen.canvas.width; 
     
    252264    var brrgs   = new Array(); 
    253265 
    254     debugMsgSet("ActionsIdx:"); 
     266    setMessage(System.message, "ActionsIdx:"); 
    255267 
    256268    for (i = 0; i < numAct; i++) { 
     
    258270        acts.push(new EnemyActions[idx](new shot())); 
    259271 
    260         debugMsgAdd(String(idx) + ","); 
    261     } 
    262  
    263     debugMsgAdd("<br>"); 
     272        addMessage(System.message, String(idx) + ","); 
     273    } 
     274 
     275    addMessage(System.message, "<br>"); 
    264276 
    265277    for (i = 0; i < numBrrg; i++) { 
     
    267279        var brrgCls = EnemyBarrages[idx]; 
    268280 
    269         debugMsgAdd("BarragesIdx:" + String(idx) + " / BulletsIdx:"); 
     281        addMessage(System.message, 
     282                   "BarragesIdx:" + String(idx) + " / BulletsIdx:"); 
    270283 
    271284        for (k = 0; k < numBlt; k++) { 
     
    283296            ); 
    284297 
    285             debugMsgAdd(String(iidx) + ","); 
     298            addMessage(System.message, String(iidx) + ","); 
    286299        } 
    287300 
    288         debugMsgAdd("<br>"); 
     301        addMessage(System.message, "<br>"); 
    289302    } 
    290303 
Note: See TracChangeset for help on using the changeset viewer.