Piczo

Log in!
Stay Signed In
Do you want to access your site more quickly on this computer? Check this box, and your username and password will be remembered for two weeks. Click logout to turn this off.

Stay Safe
Do not check this box if you are using a public computer. You don't want anyone seeing your personal info or messing with your site.
Ok, I got it
14962 hits
Hits get counted each night
Hinkers The PSPFreak
Snake Game Code
var unit = 15;
var uwh = 20;
var canMove = false;
var dir = 2;
var score = 0;
aPieceList = new Array();
mouseListener = new Object();
mouseListener.onMouseDown = function()
{
        if (!canMove)
        {
                canMove = true;
                startGame();
        }
};
Mouse.addListener(mouseListener);
k = new Object();
k.onKeyDown = function()
{
        var k = Key.getCode();
        if (k == Key.UP && dir != 2 && canMove)
        {
                dir = 0;
                canMove = false;
        }
        else if (k == Key.LEFT && dir != 3 && canMove)
        {
                dir = 1;
                canMove = false;
        }
        else if (k == Key.DOWN && dir != 0 && canMove)
        {
                dir = 2;
                canMove = false;
        }
        else if (k == Key.RIGHT && dir != 1 && canMove)
        {
                dir = 3;
                canMove = false;
        }
};
Key.addListener(k);
function addPiece()
{
        var p = this.attachMovie("piece", "piece" + aPieceList.length, aPieceList.length);
        p._x = aPieceList[aPieceList.length - 1]._x;
        p._y = aPieceList[aPieceList.length - 1]._y;
        aPieceList.push(p);
}
function moveFood()
{
        var moveIt = true;
        while (moveIt)
        {
                food._x = Math.floor(Math.random() * uwh) * unit;
                food._y = Math.floor(Math.random() * uwh) * unit;
                moveIt = false;
                for (var i = 0; i < aPieceList.length; i++)
                {
                        if (aPieceList[i]._x == food._x && aPieceList[i]._y == food._y)
                        {
                                moveIt = true;
                        }
                }
        }
}
function gameOver()
{
        delete this.onEnterFrame;
        tScore.text = "You Lose.   Score: " + score;
        canMove = false;
}
function startGame()
{
        for (var i = aPieceList.length - 1; i >= 0; i--)
        {
                aPieceList[i].removeMovieClip();
                aPieceList.pop();
        }
        score = 0;
        var p = this.attachMovie("piece", "piece" + aPieceList.length, aPieceList.length);
        aPieceList.push(p);
        p._x = 10 * unit;
        p._y = 10 * unit;
        var food = this.attachMovie("food", "food", -1);
        var c = 0;
        moveFood();
        var startingLength = 3;
        for (var i = 1; i < startingLength; i++)
        {
                addPiece();
        }
        this.onEnterFrame = function()
        {
                canMove = true;
                tScore.text = score;
                for (var i = aPieceList.length - 1; i > 0; i--)
                {
                        aPieceList[i]._x = aPieceList[i - 1]._x;
                        aPieceList[i]._y = aPieceList[i - 1]._y;
                }
                if (dir == 0)
                {
                        aPieceList[0]._y -= unit;
                }
                else if (dir == 1)
                {
                        aPieceList[0]._x -= unit;
                }
                else if (dir == 2)
                {
                        aPieceList[0]._y += unit;
                }
                else if (dir == 3)
                {
                        aPieceList[0]._x += unit;
                }
                if (aPieceList[0]._y / unit == 20)
                {
                        aPieceList[0]._y = 0;
                }
                else if (aPieceList[0]._y / unit == -1)
                {
                        aPieceList[0]._y = 19 * unit;
                }
                else if (aPieceList[0]._x / unit == -1)
                {
                        aPieceList[0]._x = 19 * unit;
                }
                else if (aPieceList[0]._x / unit == 20)
                {
                        aPieceList[0]._x = 0;
                }
                if (aPieceList[0]._x == food._x && aPieceList[0]._y == food._y)
                {
                        score += 10 * aPieceList.length / 2;
                        moveFood();
                        addPiece();
                }
                for (var i = 1; i < aPieceList.length; i++)
                {
                        if (aPieceList[0]._x == aPieceList[i]._x && aPieceList[0]._y == aPieceList[i]._y)
                        {
                                gameOver();
                        }
                }
        };
}
You can copy and paste
Digital Clock Code

// Gets the date and time info from the local computers clock
myDate = new Date();

//Gets the hours and adds a zero if the number is a single digit like this: 01
var hours = myDate.getHours()>9 ? myDate.getHours() : "0"+myDate.getHours();

//Gets the minutes and adds a zero if the number is a single digit like this: 01
var minutes = myDate.getMinutes()>9 ? myDate.getMinutes() : "0"+myDate.getMinutes();

//Gets the seconds and adds a zero if the number is a single digit like this: 01
var seconds = myDate.getSeconds()>9 ? myDate.getSeconds() : "0"+myDate.getSeconds();

// Displays the time like this: 00 . 01 : 01
myTime = (hours + " . " + minutes + " : " + seconds);
You can copy and paste