Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    New Coder
    Join Date
    Aug 2005
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    game preloading pix||bgcolor

    ive been working on this game in javascript and i have a couple of questions.

    1)how can i make it run faster by either preloading the pix or just using colors(cant figure out anything that can change colors with javascript) when its online? (try it out online and from your comp to see the speed difference)

    2)is it possable to make a random level generator that will check if its possable to win?


    here's a link to download it
    http://www.startbeat.com/games/ColorPuzzle.rar

    here it is online
    http://games.startbeat.com OR http://www.startbeat.com/games/

    please dont rip it off and take credit for it

    thanx in advance for any help you can give me
    Last edited by iamabe666; 08-15-2005 at 03:54 PM.

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    your game does not work in FireFox, however It loads fine in IE.

    Good Work soo far, btw the colour thingy you wanted is easy.

    I havn't looked at the code so i don't know what your using for the blocks. i'm assuming you could use div tags or table cells.

    so in javascript

    var element = document.getElementById('cellId');
    element.style.backgroundColor = "#0000ff";
    or just
    element.backgroundColor = "#0000ff";

    depending on how your making the 'blocks'
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #3
    New Coder
    Join Date
    Aug 2005
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what do i name, the "td" or "tr" or "table"?

    thanx

  • #4
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the 'TD' tag.

    <table....>
    <tr ..>
    <td id="someID" name="someName" class="someClass" .....>
    .....
    </table>

    then document.getElementById('someID');

    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #5
    New Coder
    Join Date
    Aug 2005
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    GOT IT!!! thanx!

  • #6
    New Coder
    Join Date
    Aug 2005
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmm, ran into a small problem. can i make the td's into an array?

  • #7
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you should be able to make the td id values into an array.

    var tdId = new Array('tdId1','tdId2','tdId3'.....);

    I think there is a better way of doing this using DOM but i'm unsure of the exact code right now. i'l look into it if i get the time and post something later.
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #8
    New Coder
    Join Date
    Aug 2005
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    didnt work, ill look around

  • #9
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    maybe post some code here for me to look at, I'm a little busy at the moment and cannot load your game up and scan the source for the applicable area's.
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #10
    New Coder
    Join Date
    Aug 2005
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    heres a test page i made with everything i need from the game:

    <html>
    <head><script language=javascript>
    function cc(tdidnum, colornum) {
    var tdidar = new Array('document.getElementById(tdid1)','document.getElementById(tdid2)');
    var element = tdidar[tdidnum];
    element.style.backgroundColor = colornum;
    }
    </script>
    </head>
    <body>
    <table><tr><td id="tdid1" bgcolor="red" width="50" height="50"></td><td id="tdid2" bgcolor="#FF0000" width="50" height="50"></td></tr></table>
    <input type="button" onClick="cc('1','#0000FF')">
    </body>
    </html>

    thanx for ur help

  • #11
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <html>
    <head><script language=javascript>
    function cc(tdidnum, colornum) {
    var tdidar = new Array('tdid1','tdid2');
    var element = document.getElementById([tdidnum]);
    element.style.backgroundColor = colornum;
    }
    </script>
    </head>
    <body>
    <table><tr><td id="tdid1" bgcolor="red" width="50" height="50"></td><td id="tdid2" bgcolor="#FF0000" width="50" height="50"></td></tr></table>
    <input type="button" onClick="cc('1','#0000FF')">
    </body>
    </html>


    also, I think you might need to place something in there for the <td> element to take the background color. I would suggest using the same image file for them all. Make the image a fully transparent gif 1px*1px

    <td id="tdid1"...><img src="path/to/blank.gif" alt="" height="50px" width="50px" border="0"></td>
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #12
    New Coder
    Join Date
    Aug 2005
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    didnt work
    error line 6: object required

  • #13
    New Coder
    Join Date
    Aug 2005
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nvr mind, got it

    thanx!!!

  • #14
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry, I messed up a line there

    <html>
    <head><script language=javascript>
    function cc(tdidnum, colornum) {
    var tdidar = new Array('tdid1','tdid2');
    var element = document.getElementById(tdidar[tdidnum]);
    element.style.backgroundColor = colornum;
    }
    </script>
    </head>
    <body>
    <table><tr><td id="tdid1" bgcolor="red" width="50" height="50"></td><td id="tdid2" bgcolor="#FF0000" width="50" height="50"></td></tr></table>
    <input type="button" onClick="cc('0','#0000FF')">
    </body>
    </html>

    Also, rememember when using the Array that the first element is actually number '0' not number '1'.

    tip:
    to return the actuall number of elements in the array you would use

    var num_of_elements = ArrayName.length-1;

    you minus one because it registers 0 as a number.
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #15
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also, for the random level thing.

    I'm assuming there is a seperate page / function for the new levels?

    If so, you should only need to generate a random number to distinguish between them and navigate to them.. so...

    var randomNum = (Math.Random()*(numberYouWant-1))+1;

    the random number will be between 0 and the number you times it by.

    so if you wanted a random number between 1 and 9 you would use the following.

    var rnd = Math.Round(Math.Random()*8)+1;
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •