Super awesome mario game

Home Forums General Chat Super awesome mario game

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #3267
    Joaco
    Participant

    Enjoy!

    Things to try
    -Konami code
    -movement
    -background change
    -winning
    =D

    Updates:
    -First mini-version
    -Konami code addon
    -Typo correction
    -No more multiple wins
    -There’s a real challenge: the box moves every two seconds
    -Box won’t move once you win
    -Background change
    -instant IP trace and FBI goes to your house if you hack this game..

    …okay, that last one isn’t implemented yet.

    Feel free to view the source code (HTML isn’t posted, it’s obvious):

    window.addEventListener("keydown",presiono,false);
    window.addEventListener("load",start,false);
    var left,right,up,down,tops,leftval,val,konami,won,boxBottom,boxLeft,background;
    left = 37;
    right = 39;
    up = 38;
    down = 40;
    won = false;
    function start(e) {
    document.getElementById('multicolor').addEventListener('click',multicolorBG,false);
    document.getElementById('defaultbg').addEventListener('click',defaultBG,false);
    setInterval("locateWinBox()",2000);
    }

    function multicolorBG(e) {
    setBackground('http://i49.tinypic.com/jfxfn4.png');

    }
    function defaultBG(e) {
    setBackground('http://testing-spot.com/ides/illustrator/pincel/abstract_background1.jpg');
    }
    function setBackground(url) {
    document.body.style.background = 'url('+url+')';
    }
    function locateWinBox() {
    if(won == false)
    {
    boxBottom = Math.floor(Math.random() * 500 + 10);
    boxLeft = Math.floor(Math.random() * 700 + 100);
    document.getElementById("won").style.bottom = boxBottom;
    document.getElementById("won").style.left = boxLeft;
    }
    }
    function add2Log(text) {
    var logs = document.getElementById("logs");
    logs.innerHTML=text + 'n' + logs.innerHTML;
    }
    function setPosition(x,y) {
    document.getElementById('character').style.bottom = y;
    document.getElementById('character').style.left = x;
    }
    function moveRandom() {
    var y = Math.floor(Math.random() * 500);
    var x = Math.floor(Math.random() * 980);
    setPosition(x,y);
    }
    function getY() {
    tops = document.getElementById('character').style.bottom;
    tops = tops.replace("px","");
    tops = parseInt(tops);
    return tops;
    }
    function getX() {
    leftval = document.getElementById('character').style.left;
    leftval = leftval.replace("px","");
    leftval = parseInt(leftval);
    return leftval;
    }
    function checkWon() {
    if (getY()>boxBottom && getX() > boxLeft && getY() < boxBottom + 100 && getX() < boxLeft + 100 && won == false) {
    add2Log("-YOU WON!n Refresh the browser to try again.");
    won = true;
    }
    }
    function moveY(val) {
    val = getY() + val;
    document.getElementById('character').style.bottom= val + '';
    checkWon();
    }
    function moveX(val) {
    val = getX() + val;
    eval("document.getElementById('character').style.left='"+val+"'");
    checkWon();
    }
    function presiono(e) {
    switch(e.keyCode) {
    case left:
    moveX(-10);
    break;
    case right:
    moveX(10);
    break;
    case up:
    moveY(10);
    break;
    case down:
    moveY(-10);
    break;
    }
    }
    konami = {
    input:"",
    clear:setTimeout('konami.clear_input()',1000),
    load: function(link) {
    window.document.onkeyup = function(e) {
    konami.input+= e ? e.keyCode : event.keyCode ;
    if (konami.input.indexOf("3838404037393739666513")!=-1) {
    add2Log("-Konami code:n trap activated.");
    setInterval("moveRandom()",100);
    clearTimeout(konami.clear);
    }
    clearTimeout(konami.clear);
    konami.clear = setTimeout("konami.clear_input()",2000);
    }
    },
    code: function(link) { window.location=link},
    clear_input: function() {
    konami.input="";
    clearTimeout(konami.clear);
    }
    }
    konami.load();

    Object-oriented source code is coming soon.

    #18649
    Dest1
    Participant

    THIS GAME FAELS

    #18650
    Joaco
    Participant

    Thank you dest

    #18652
    DarkDragoon
    Participant

    Lol, too easy xp

    #18653
    Joaco
    Participant

    Maybe you want me to change the respawn time to 1ms?

    #18654
    Joaco
    Participant

    Try now.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.