Techious
http://www.techious.com/forums/

ChuChu Rocket!
http://www.techious.com/forums/viewtopic.php?f=8&t=7187
Page 1 of 3

Author:  azcn2503 [ Thu Nov 03, 2011 11:59 am ]
Post subject:  ChuChu Rocket!

Would anybody be interested in helping to make a 100% JavaScript based remake of the game ChuChu Rocket!?

After 1 hour of work...

Image
(blue spawn, green rocket, yellow grid, black walls)

UPDATE some time later (on 10th November 2011) it looks like this...

Image

Update: focus will be on creating, saving and sending puzzles to people. It's coded like a big sexy JSON object.
Example:
Code:
[{"title":"Level One","description":"The first level","grid":[[0,0],[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0],[11,0],[0,1],[1,1],[2,1],[3,1],[4,1],[5,1],[6,1],[7,1],[8,1],[9,1],[10,1],[11,1],[0,2],[1,2],[2,2],[3,2],[4,2],[5,2],[6,2],[7,2],[8,2],[9,2],[10,2],[11,2],[0,3],[1,3],[2,3],[3,3],[4,3],[5,3],[6,3],[7,3],[8,3],[9,3],[10,3],[11,3],[0,4],[1,4],[2,4],[3,4],[4,4],[5,4],[6,4],[7,4],[8,4],[9,4],[10,4],[11,4],[0,5],[1,5],[2,5],[3,5],[4,5],[5,5],[6,5],[7,5],[8,5],[9,5],[10,5],[11,5],[0,6],[1,6],[2,6],[3,6],[4,6],[5,6],[6,6],[7,6],[8,6],[9,6],[10,6],[11,6],[0,7],[1,7],[2,7],[3,7],[4,7],[5,7],[6,7],[7,7],[8,7],[9,7],[10,7],[11,7],[0,8],[1,8],[2,8],[3,8],[4,8],[5,8],[6,8],[7,8],[8,8],[9,8],[10,8],[11,8]],"arrows":[[2,1]],"walls":[[9,2,1],[10,6,2]],"things":{"spawn":[2,2,1],"rocket":[2,6]}}]


Update: More like this:
Code:
"{"title":"lol wat?","grid":[[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7],[0,8],[1,0],[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7],[1,8],[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7],[2,8],[3,0],[3,1],[3,2],[3,3],[3,4],[3,5],[3,6],[3,7],[3,8],[4,0],[4,1],[4,2],[4,3],[4,4],[4,5],[4,6],[4,7],[4,8],[5,0],[5,1],[5,2],[5,3],[5,4],[5,5],[5,6],[5,7],[5,8],[6,0],[6,1],[6,2],[6,3],[6,4],[6,5],[6,6],[6,7],[6,8],[7,0],[7,1],[7,2],[7,3],[7,4],[7,5],[7,6],[7,7],[7,8],[8,0],[8,1],[8,2],[8,3],[8,4],[8,5],[8,6],[8,7],[8,8],[9,0],[9,1],[9,2],[9,3],[9,4],[9,5],[9,6],[9,7],[9,8],[10,0],[10,1],[10,2],[10,3],[10,4],[10,5],[10,6],[10,7],[10,8],[11,0],[11,1],[11,2],[11,3],[11,4],[11,5],[11,6],[11,7],[11,8]],"cc":[[1,4,1]],"kk":[[10,4,3]],"holes":[[4,5],[6,5],[3,7],[4,7],[5,7],[6,7],[7,7],[2,6],[8,6]],"goals":[[5,6]],"walls":[[0,5,3,3],[5,0,0,3],[5,8,2,3],[11,5,1,3],[1,0,2,1],[1,1,0,1],[1,1,1,1],[1,2,1,1],[2,0,2,1],[2,1,0,1],[2,1,3,1],[2,2,3,1],[3,1,1,1],[3,2,1,1],[4,0,2,1],[4,1,0,1],[4,1,3,1],[4,2,2,1],[4,2,3,1],[4,3,0,1],[5,1,1,1],[5,2,1,1],[6,1,1,1],[6,1,2,1],[6,1,3,1],[6,2,0,1],[6,2,1,1],[6,2,3,1],[7,1,1,1],[7,1,3,1],[7,2,3,1],[8,0,2,1],[8,1,0,1],[8,1,2,1],[8,1,3,1],[8,2,0,1],[8,2,1,1],[8,2,2,1],[8,3,0,1],[9,2,3,1]],"arrows":{"available":{"0":0,"1":2,"2":0,"3":2},"placed":{"0":[],"1":[],"2":[],"3":[]}},"ccFrames":12,"kkFrames":8}"


Update: Actually like this:
Code:
{"title":"1 - Where to go?","description":"The actual first level from the REAL game lolwut!","grid":[[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7],[0,8],[1,0],[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7],[1,8],[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7],[2,8],[3,0],[3,1],[3,2],[3,3],[3,4],[3,5],[3,6],[3,7],[3,8],[4,0],[4,1],[4,2],[4,3],[4,4],[4,5],[4,6],[4,7],[4,8],[5,0],[5,1],[5,2],[5,3],[5,4],[5,5],[5,6],[5,7],[5,8],[6,0],[6,1],[6,2],[6,3],[6,4],[6,5],[6,6],[6,7],[6,8],[7,0],[7,1],[7,2],[7,3],[7,4],[7,5],[7,6],[7,7],[7,8],[8,0],[8,1],[8,2],[8,3],[8,4],[8,5],[8,6],[8,7],[8,8],[9,0],[9,1],[9,2],[9,3],[9,4],[9,5],[9,6],[9,7],[9,8],[10,0],[10,1],[10,2],[10,3],[10,4],[10,5],[10,6],[10,7],[10,8],[11,0],[11,1],[11,2],[11,3],[11,4],[11,5],[11,6],[11,7],[11,8]],"arrows":{"available":{"0":1,"1":0,"2":0,"3":0},"placed":{"0":[],"1":[],"2":[],"3":[]}},"walls":[[0,0,2,1],[11,0,2,1],[0,1,2,1],[11,2,2,1],[0,3,2,1],[11,4,2,1],[0,5,2,1],[11,6,2,1],[0,7,2,1]],"cc":[[0,1,1],[1,1,1],[2,1,1],[3,1,1],[4,1,1],[7,2,3],[8,2,3],[9,2,3],[10,2,3],[11,2,3],[0,3,1],[1,3,1],[2,3,1],[3,3,1],[4,3,1],[7,4,3],[8,4,3],[9,4,3],[10,4,3],[11,4,3],[0,5,1],[1,5,1],[2,5,1],[3,5,1],[4,5,1],[7,6,3],[8,6,3],[9,6,3],[10,6,3],[11,6,3],[0,7,1],[1,7,1],[2,7,1],[3,7,1],[4,7,1],[7,8,3],[8,8,3],[9,8,3],[10,8,3],[11,8,3]],"goals":[[1,0],[3,0],[5,0],[7,0],[9,0],[11,0]],"buildItems":["hole","kk","cc","goal"],"frame":0,"frameDelay":10,"ccFrames":12,"kkFrames":8,"gameState":0,"ccSaved":0,"ccRequired":40,"newGrid":{},"newWalls":{"x0y0d2":[0,0,2,1],"x11y0d2":[11,0,2,1],"x0y1d2":[0,1,2,1],"x11y2d2":[11,2,2,1],"x0y3d2":[0,3,2,1],"x11y4d2":[11,4,2,1],"x0y5d2":[0,5,2,1],"x11y6d2":[11,6,2,1],"x0y7d2":[0,7,2,1],"x0y0d0":[0,0,0,2],"x1y0d0":[1,0,0,2],"x2y0d0":[2,0,0,2],"x3y0d0":[3,0,0,2],"x4y0d0":[4,0,0,2],"x5y0d0":[5,0,0,2],"x6y0d0":[6,0,0,2],"x7y0d0":[7,0,0,2],"x8y0d0":[8,0,0,2],"x9y0d0":[9,0,0,2],"x10y0d0":[10,0,0,2],"x11y0d0":[11,0,0,2],"x11y0d1":[11,0,1,2],"x11y1d1":[11,1,1,2],"x11y2d1":[11,2,1,2],"x11y3d1":[11,3,1,2],"x11y4d1":[11,4,1,2],"x11y5d1":[11,5,1,2],"x11y6d1":[11,6,1,2],"x11y7d1":[11,7,1,2],"x11y8d1":[11,8,1,2],"x0y8d2":[0,8,2,2],"x1y8d2":[1,8,2,2],"x2y8d2":[2,8,2,2],"x3y8d2":[3,8,2,2],"x4y8d2":[4,8,2,2],"x5y8d2":[5,8,2,2],"x6y8d2":[6,8,2,2],"x7y8d2":[7,8,2,2],"x8y8d2":[8,8,2,2],"x9y8d2":[9,8,2,2],"x10y8d2":[10,8,2,2],"x11y8d2":[11,8,2,2],"x0y0d3":[0,0,3,2],"x0y1d3":[0,1,3,2],"x0y2d3":[0,2,3,2],"x0y3d3":[0,3,3,2],"x0y4d3":[0,4,3,2],"x0y5d3":[0,5,3,2],"x0y6d3":[0,6,3,2],"x0y7d3":[0,7,3,2],"x0y8d3":[0,8,3,2]},"newArrows":{"placed":{"0":0,"1":0,"2":0,"3":0},"available":{"0":1,"1":0,"2":0,"3":0}},"newCC":{"x0y1":[0,1,1],"x1y1":[1,1,1],"x2y1":[2,1,1],"x3y1":[3,1,1],"x4y1":[4,1,1],"x7y2":[7,2,3],"x8y2":[8,2,3],"x9y2":[9,2,3],"x10y2":[10,2,3],"x11y2":[11,2,3],"x0y3":[0,3,1],"x1y3":[1,3,1],"x2y3":[2,3,1],"x3y3":[3,3,1],"x4y3":[4,3,1],"x7y4":[7,4,3],"x8y4":[8,4,3],"x9y4":[9,4,3],"x10y4":[10,4,3],"x11y4":[11,4,3],"x0y5":[0,5,1],"x1y5":[1,5,1],"x2y5":[2,5,1],"x3y5":[3,5,1],"x4y5":[4,5,1],"x7y6":[7,6,3],"x8y6":[8,6,3],"x9y6":[9,6,3],"x10y6":[10,6,3],"x11y6":[11,6,3],"x0y7":[0,7,1],"x1y7":[1,7,1],"x2y7":[2,7,1],"x3y7":[3,7,1],"x4y7":[4,7,1],"x7y8":[7,8,3],"x8y8":[8,8,3],"x9y8":[9,8,3],"x10y8":[10,8,3],"x11y8":[11,8,3]},"newKK":{},"newGoals":{"x1y0":[1,0],"x3y0":[3,0],"x5y0":[5,0],"x7y0":[7,0],"x9y0":[9,0],"x11y0":[11,0]},"newHoles":{},"gridX":11,"gridY":8,"buildItem":null,"gameMode":"classic","arrowsDamaged":0,"arrowsDestroyed":0,"arrowsFlagged":[],"failDelay":-1,"failCollision":[],"nearMisses":[],"ccMoves":0,"kkKilled":0,"kkGoalFlag":0,"ccFrame":0,"kkFrame":0,"showTrail":0,"trailGrid":[],"dash":0,"collisions":{"cc":{},"kk":{}},"t":"game"}

Author:  Lord Metritutus [ Thu Nov 03, 2011 4:47 pm ]
Post subject:  Re: ChuChu Rocket!

I'm afraid I've never heard of this game before. :(

Author:  azcn2503 [ Thu Nov 03, 2011 5:02 pm ]
Post subject:  Re: ChuChu Rocket!

It was a fun puzzle game for the Sega Dreamcast (I got mine free when I bought my DC) with online play modes.

You basically had to guide the mice in to the rockets while avoiding cats and making sure the cats don't get to the rockets! If you hit a wall you turn clockwise unless the clockwise rotation is blocked by a wall in which case you will go counter-clockwise.

There is already a JS version made with HTML5 canvas, but I really think I could do better and give it back that community feel lol.

Author:  azcn2503 [ Fri Nov 04, 2011 2:47 pm ]
Post subject:  Re: ChuChu Rocket!

Getting somewhere... www.webtagr.com/projects/ccr

Author:  Lord Metritutus [ Fri Nov 04, 2011 4:17 pm ]
Post subject:  Re: ChuChu Rocket!

Neat!

By the way, when it begins for some reason all the dark blue squares (the ones that move) start to the top left of the main game area. Then they rapidly float down to the game area and then it starts. You can notice it if you refresh the page.

Author:  azcn2503 [ Fri Nov 04, 2011 4:23 pm ]
Post subject:  Re: ChuChu Rocket!

Yes indeed, it's because I added some page resizing code but didn't yet add the code to offset the initial placement of the chuchu. Basically they are wrote to the page then instantly moved but because movement is eased out using css3 transitions it does a .25s animation going from top left to correct position. Check out the funky effect if you resize/restore/maximise the window hehe

Author:  Lord Metritutus [ Fri Nov 04, 2011 6:52 pm ]
Post subject:  Re: ChuChu Rocket!

Amusing effect, but sadly it wasn't dynamic enough to allow me to get the blue cubes to escape the grid when they're moving around. :(

Author:  azcn2503 [ Sat Nov 05, 2011 12:24 pm ]
Post subject:  Re: ChuChu Rocket!

I'm actually thinking of completely removing the CSS3 animations and replacing them with JS. I did a brief test and it felt smoother, although the collision detection stopped working.

Update: I had a go at it and it worked. It gives a finer level of control over the speed of the chuchu.

When you load a level (just one level! don't try loading two in one go!) and start the animation, you can type this in the address bar mid-flow: javascript:movements=50;frameMovement=gridSize/movements; and it will make the chuchu move 5x slower.

Author:  Lord Metritutus [ Sat Nov 05, 2011 5:14 pm ]
Post subject:  Re: ChuChu Rocket!

azcn2503 wrote:
don't try loading two in one go!


This breaks it horribly! :D

Author:  azcn2503 [ Sun Nov 06, 2011 1:23 am ]
Post subject:  Re: ChuChu Rocket!

I have finally added the code that allows you to win a game! (It no longer trolls you by making your chuchu effortlessly glide through the rockets lol)

Also: the interface is not complete. It still does not tell you how many arrows you have, or what direction arrows you have to play with. It does not detect left/right arrows (I have not programmed them in yet, you cannot add them). You still need to reload the page if you want to re-try a level or make a change to one that you already started playing. If you place arrows and accidentally click the make level button then try to place arrows again, the arrow placed count does not reset so you cannot place any arrows until you refresh the page. So yes, work in progress! I'm still testing even the most basic things, like collision detection... I found a problem where by if a chuchu was at position 0,0 moving in direction 1 (right) and a kapukapu was at position (0,1) moving in direction 3 (left), when they move, they literally just swap their x coordinates, and never 'collide' because 0 is never 1, and 1 is never 0. I had to put in some code to detect the trajectory, so that when an object was moving in direction 1 and an adjacent object was moving in direction 3, there is going to be a collision. I added in something called deathDelay which holds off the death for half a movement so it looks like they get suitably nommed (otherwise it would say that you have died when you are not actually touching anything on the UI).

I thought that this would be extremely easy! Turns out that I am learning things. Still. At my old age.

Author:  azcn2503 [ Sun Nov 06, 2011 11:40 am ]
Post subject:  Re: ChuChu Rocket!

JS is giving me issues this morning...

I had a great idea last night, to duplicate the chuchu and kapukapu coordinate entries in the object so that there is an original and a current - if you make a mistake you could just reset the level to get the original coordinates back.

The code would be as simple as: newObject=oldObject, then whenever you move the chuchu or the kapukapu, change newObject instead of oldObject, so that when it comes to starting the level again, newObject=oldObject and the coordinates are replaced. Right?

Wrong.

Immediately after setting the coordinates in newObject, they change in oldObject at the same time. As in, without the animation loop going around again, in the very same line of code that sets the x coordinate for what I've called o.chuchuMoving[i][0], it sets the coordinate for o.chuchu[i][0] simultaneously. I cannot figure out why it is doing this. It's almost like the newObject is a shortcut to the oldObject and they are in some way linked...

So basically I'm asking for assistance. Is there some other way I can get around this problem? I don't want to create a global working set for the current level, as I want to be able to have resettable levels even if you go to another level, so they need to be part of the object.

Spoiler:
Line 32: Tells you the current X coordinate of the first chuchu in the level.
Most things between Lines 224 and 267 (movement of chuchu and kapukapu): This is where the 'bug' lies and it is commented in the code.

Code:
function grab(o){
    return document.all?document.all[o]:document.getElementById?document.getElementById(o):"";
}

function faces(n){
    return n==0?"North":n==1?"East":n==2?"South":n==3?"West":false;
}

function makeWalls(o){
    for(var i in o.walls){
        if(o.walls[i][2]==0){ o.walls.push([o.walls[i][0],o.walls[i][1]-1,2]); }
        if(o.walls[i][2]==1){ o.walls.push([o.walls[i][0]+1,o.walls[i][1],3]); }
        if(o.walls[i][2]==2){ o.walls.push([o.walls[i][0],o.walls[i][1]+1,0]); }
        if(o.walls[i][2]==3){ o.walls.push([o.walls[i][0]-1,o.walls[i][1],1]); }
    }
    for(var i in o.grid){
        var hasN=hasE=hasS=hasW=0;
        for(j in o.grid){ if(o.grid[i][1]-1==o.grid[j][1]&&o.grid[i][0]==o.grid[j][0]){ hasN=1; break; } }
        for(j in o.grid){ if(o.grid[i][0]+1==o.grid[j][0]&&o.grid[i][1]==o.grid[j][1]){ hasE=1; break; } }
        for(j in o.grid){ if(o.grid[i][1]+1==o.grid[j][1]&&o.grid[i][0]==o.grid[j][0]){ hasS=1; break; } }
        for(j in o.grid){ if(o.grid[i][0]-1==o.grid[j][0]&&o.grid[i][1]==o.grid[j][1]){ hasW=1; break; } }
        if(!hasN){ o.walls.push([o.grid[i][0],o.grid[i][1],0]); }
        if(!hasE){ o.walls.push([o.grid[i][0],o.grid[i][1],1]); }
        if(!hasS){ o.walls.push([o.grid[i][0],o.grid[i][1],2]); }
        if(!hasW){ o.walls.push([o.grid[i][0],o.grid[i][1],3]); }
    }
    o.madeWalls=1;
}

function animateLevel(o,t){
    o.gameState=1;
    grab("status").innerHTML=o.chuchu[0][0];
    if(o.gameState==1){ grab("playbutton").disabled=true; }
    if(o.frame==1){
        // chuchu/arrow collision
        for(var i in o.arrows.placed){
            if(o.arrows.placed[i].length>0){
                for(var j in o.arrows.placed[i]){
                    for(var k in o.chuchuMoving){
                        if(o.arrows.placed[i][j][0]==o.chuchuMoving[k][0]&&o.arrows.placed[i][j][1]==o.chuchuMoving[k][1]){
                            o.chuchuMoving[k][2]=parseInt(i);
                            continue;
                        }
                    }
                }
            }
        }
        // kapukapu/arrow collision
        for(var i in o.arrows.placed){
            if(o.arrows.placed[i].length>0){
                for(var j in o.arrows.placed[i]){
                    for(var k in o.kapukapuMoving){
                        if(o.arrows.placed[i][j][0]==o.kapukapuMoving[k][0]&&o.arrows.placed[i][j][1]==o.kapukapuMoving[k][1]){
                            o.kapukapuMoving[k][2]=parseInt(i);
                            continue;
                        }
                    }
                }
            }
        }
        // chuchu/hole collision
        for(var i in o.holes){
            for(var j in o.chuchuMoving){
                if(o.holes[i][0]==o.chuchuMoving[j][0]&&o.holes[i][1]==o.chuchuMoving[j][1]){
                    o.gameState=0;
                    alert("You fell in to a hole. Game over!");
                    break;
                }
            }
        }
        // kapukapu/hole collision
        for(var i in o.holes){
            for(var j in o.kapukapuMoving){
                if(o.holes[i][0]==o.kapukapuMoving[j][0]&&o.holes[i][1]==o.kapukapuMoving[j][1]){
                    grab("kapukapu_"+j).className="kapukapu dead";
                    delete o.kapukapuMoving[j];
                    break;
                }
            }
        }
        // chuchu/goal collision
        for(var i in o.goals){
            for(var j in o.chuchuMoving){
                if(o.goals[i][0]==o.chuchuMoving[j][0]&&o.goals[i][1]==o.chuchuMoving[j][1]){
                    o.chuchuSaved++;
                    delete o.chuchuMoving[j];
                    if(o.chuchuSaved==o.chuchuRequired){
                        alert("You have completed the level: "+o.title+"\n\nConglaturations!");
                        o.gameState=0;
                    }
                    continue;
                }
            }
        }
        // kapukapu/goal collision
        for(var i in o.goals){
            for(var j in o.kapukapuMoving){
                if(o.goals[i][0]==o.kapukapuMoving[j][0]&&o.goals[i][1]==o.kapukapuMoving[j][1]){
                    o.gameState=0;
                    alert("The KapuKapu got to your rocket before you! Game over!");
                    break;
                }
            }
        }
        // chuchu wall collisions and direction changing
        for(var i in o.chuchuMoving){
            var hasN=hasE=hasS=hasW=0;
            switch(o.chuchuMoving[i][2]){ // direction
                case 0: // n
                    for(var j in o.walls){
                        if(o.chuchuMoving[i][0]==o.walls[j][0]&&o.chuchuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==3){ hasW=1; continue; }
                        if(o.chuchuMoving[i][0]==o.walls[j][0]&&o.chuchuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==0){ hasN=1; continue; }
                        if(o.chuchuMoving[i][0]==o.walls[j][0]&&o.chuchuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==1){ hasE=1; continue; }
                    }
                    o.chuchuMoving[i][2]=hasW==1&&hasN==1&&hasE==1?2:hasN==1&&hasE==1?3:hasN==1?1:o.chuchuMoving[i][2];
                break;
                case 1: // e
                    for(var j in o.walls){
                        if(o.chuchuMoving[i][0]==o.walls[j][0]&&o.chuchuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==0){ hasN=1; continue; }
                        if(o.chuchuMoving[i][0]==o.walls[j][0]&&o.chuchuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==1){ hasE=1; continue; }
                        if(o.chuchuMoving[i][0]==o.walls[j][0]&&o.chuchuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==2){ hasS=1; continue; }
                    }
                    o.chuchuMoving[i][2]=hasN==1&&hasE==1&&hasS==1?3:hasE==1&&hasS==1?0:hasE==1?2:o.chuchuMoving[i][2];
                break;
                case 2: // s
                    for(var j in o.walls){
                        if(o.chuchuMoving[i][0]==o.walls[j][0]&&o.chuchuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==1){ hasE=1; continue; }
                        if(o.chuchuMoving[i][0]==o.walls[j][0]&&o.chuchuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==2){ hasS=1; continue; }
                        if(o.chuchuMoving[i][0]==o.walls[j][0]&&o.chuchuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==3){ hasW=1; continue; }
                    }
                    o.chuchuMoving[i][2]=hasE==1&&hasS==1&&hasW==1?0:hasS==1&&hasW==1?1:hasS==1?3:o.chuchuMoving[i][2];
                break;
                case 3: // w
                    for(var j in o.walls){
                        if(o.chuchuMoving[i][0]==o.walls[j][0]&&o.chuchuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==2){ hasS=1; continue; }
                        if(o.chuchuMoving[i][0]==o.walls[j][0]&&o.chuchuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==3){ hasW=1; continue; }
                        if(o.chuchuMoving[i][0]==o.walls[j][0]&&o.chuchuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==0){ hasN=1; continue; }
                    }
                    o.chuchuMoving[i][2]=hasS==1&&hasW==1&&hasN==1?1:hasW==1&&hasN==1?2:hasW==1?0:o.chuchuMoving[i][2];
                break;
                default:
                    alert("I'm moving, but I don't know where I'm going! This is pretty much game over.");
                    o.gameState=0;
                break;
            }
            if(o.chuchuMoving[i][0]>o.gridX||o.chuchuMoving[i][1]>o.gridY){
                alert("Invalid move! Game over!");
                o.gameState=0;
                break;
            }
        }
        // kapukapu wall collisions and direction changing
        for(var i in o.kapukapuMoving){
            var hasN=hasE=hasS=hasW=0;
            switch(o.kapukapuMoving[i][2]){ // direction
                case 0: // n
                    for(var j in o.walls){
                        if(o.kapukapuMoving[i][0]==o.walls[j][0]&&o.kapukapuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==3){ hasW=1; continue; }
                        if(o.kapukapuMoving[i][0]==o.walls[j][0]&&o.kapukapuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==0){ hasN=1; continue; }
                        if(o.kapukapuMoving[i][0]==o.walls[j][0]&&o.kapukapuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==1){ hasE=1; continue; }
                    }
                    o.kapukapuMoving[i][2]=hasW==1&&hasN==1&&hasE==1?2:hasN==1&&hasE==1?3:hasN==1?1:o.kapukapuMoving[i][2];
                break;
                case 1: // e
                    for(var j in o.walls){
                        if(o.kapukapuMoving[i][0]==o.walls[j][0]&&o.kapukapuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==0){ hasN=1; continue; }
                        if(o.kapukapuMoving[i][0]==o.walls[j][0]&&o.kapukapuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==1){ hasE=1; continue; }
                        if(o.kapukapuMoving[i][0]==o.walls[j][0]&&o.kapukapuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==2){ hasS=1; continue; }
                    }
                    o.kapukapuMoving[i][2]=hasN==1&&hasE==1&&hasS==1?3:hasE==1&&hasS==1?0:hasE==1?2:o.kapukapuMoving[i][2];
                break;
                case 2: // s
                    for(var j in o.walls){
                        if(o.kapukapuMoving[i][0]==o.walls[j][0]&&o.kapukapuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==1){ hasE=1; continue; }
                        if(o.kapukapuMoving[i][0]==o.walls[j][0]&&o.kapukapuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==2){ hasS=1; continue; }
                        if(o.kapukapuMoving[i][0]==o.walls[j][0]&&o.kapukapuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==3){ hasW=1; continue; }
                    }
                    o.kapukapuMoving[i][2]=hasE==1&&hasS==1&&hasW==1?0:hasS==1&&hasW==1?1:hasS==1?3:o.kapukapuMoving[i][2];
                break;
                case 3: // w
                    for(var j in o.walls){
                        if(o.kapukapuMoving[i][0]==o.walls[j][0]&&o.kapukapuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==2){ hasS=1; continue; }
                        if(o.kapukapuMoving[i][0]==o.walls[j][0]&&o.kapukapuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==3){ hasW=1; continue; }
                        if(o.kapukapuMoving[i][0]==o.walls[j][0]&&o.kapukapuMoving[i][1]==o.walls[j][1]&&o.walls[j][2]==0){ hasN=1; continue; }
                    }
                    o.kapukapuMoving[i][2]=hasS==1&&hasW==1&&hasN==1?1:hasW==1&&hasN==1?2:hasW==1?0:o.kapukapuMoving[i][2];
                break;
            }
            if(o.kapukapuMoving[i][0]>o.gridX||o.kapukapuMoving[i][1]>o.gridY){
                alert("Invalid move! Game over!");
                o.gameState=0;
                break;
            }
        }
        // chuchu/kapukapu collision (needs to be done in same cycle as move)
        for(var i in o.kapukapuMoving){
            for(var j in o.chuchuMoving){
                // direct
                if(o.kapukapuMoving[i][0]==o.chuchuMoving[j][0]&&o.kapukapuMoving[i][1]==o.chuchuMoving[j][1]){
                    o.gameState=0;
                    alert("You got nommed. Game over!");
                    break;
                }
                // half
                if(o.kapukapuMoving[i][2]==0&&o.chuchuMoving[j][2]==2&&o.kapukapuMoving[i][0]==o.chuchuMoving[j][0]&&o.kapukapuMoving[i][1]==o.chuchuMoving[j][1]+1){
                    o.deathDelay=Math.floor(movements/2);
                    break;
                }
                if(o.kapukapuMoving[i][2]==1&&o.chuchuMoving[j][2]==3&&o.kapukapuMoving[i][0]+1==o.chuchuMoving[j][0]&&o.kapukapuMoving[i][1]==o.chuchuMoving[j][1]){
                    o.deathDelay=Math.floor(movements/2);
                    break;
                }
                if(o.kapukapuMoving[i][2]==2&&o.chuchuMoving[j][2]==0&&o.kapukapuMoving[i][0]==o.chuchuMoving[j][0]&&o.kapukapuMoving[i][1]+1==o.chuchuMoving[j][1]){
                    o.deathDelay=Math.floor(movements/2);
                    break;
                }
                if(o.kapukapuMoving[i][2]==3&&o.chuchuMoving[j][2]==1&&o.kapukapuMoving[i][0]==o.chuchuMoving[j][0]+1&&o.kapukapuMoving[i][1]==o.chuchuMoving[j][1]){
                    o.deathDelay=Math.floor(movements/2);
                    break;
                }
            }
        }
    }
    if(o.gameState==1){
        // chuchu movement
        /*
            There is a glitch in this code causing o.chuchu to update at the same time as o.chuchuMoving
            (even though there is no code telling o.chuchu to update...)
        */
        for(i in o.chuchuMoving){
            if(o.chuchuMoving[i][2]==0){
                grab("chuchu_"+i).style.top=offsetY+o.chuchuMoving[i][1]*gridSize-(o.frame*frameMovement)+"px";
                if(o.frame==movements){ o.chuchuMoving[i][1]--; }
            }
            if(o.chuchuMoving[i][2]==1){
                grab("chuchu_"+i).style.left=offsetX+o.chuchuMoving[i][0]*gridSize+(o.frame*frameMovement)+"px";
                if(o.frame==movements){ o.chuchuMoving[i][0]++; }
            }
            if(o.chuchuMoving[i][2]==2){
                grab("chuchu_"+i).style.top=offsetY+o.chuchuMoving[i][1]*gridSize+(o.frame*frameMovement)+"px";
                if(o.frame==movements){ o.chuchuMoving[i][1]++; }
            }
            if(o.chuchuMoving[i][2]==3){
                grab("chuchu_"+i).style.left=offsetX+o.chuchuMoving[i][0]*gridSize-(o.frame*frameMovement)+"px";
                if(o.frame==movements){ o.chuchuMoving[i][0]--; }
            }
        }
        // kapukapu movement
        for(i in o.kapukapuMoving){
            if(o.kapukapuMoving[i][2]==0){
                grab("kapukapu_"+i).style.top=offsetY+o.kapukapuMoving[i][1]*gridSize-(o.frame*frameMovement)+"px";
                if(o.frame==movements){ o.kapukapuMoving[i][1]--; }
            }
            if(o.kapukapuMoving[i][2]==1){
                grab("kapukapu_"+i).style.left=offsetX+o.kapukapuMoving[i][0]*gridSize+(o.frame*frameMovement)+"px";
                if(o.frame==movements){ o.kapukapuMoving[i][0]++; }
            }
            if(o.kapukapuMoving[i][2]==2){
                grab("kapukapu_"+i).style.top=offsetY+o.kapukapuMoving[i][1]*gridSize+(o.frame*frameMovement)+"px";
                if(o.frame==movements){ o.kapukapuMoving[i][1]++; }
            }
            if(o.kapukapuMoving[i][2]==3){
                grab("kapukapu_"+i).style.left=offsetX+o.kapukapuMoving[i][0]*gridSize-(o.frame*frameMovement)+"px";
                if(o.frame==movements){ o.kapukapuMoving[i][0]--; }
            }
        }
    }
    if(o.frame==o.deathDelay){
        o.gameState=0;
        alert("Congratulations! You have successfully died!");
    }
    if(o.gameState==1){ animation=setTimeout(function(){ o.frame=o.frame==movements?1:o.frame+1; animateLevel(o,t); },frameDelay); }
}

function positionLevel(o,t){
    var el=t.getElementsByTagName("div");
    for(var i in el){
        if(typeof(el[i].style)!="undefined"){
            var currentX=parseInt(el[i].style.left);
            var currentY=parseInt(el[i].style.top);
            el[i].style.left=currentX-offsetX+"px";
            el[i].style.top=currentY-offsetY+"px";
        }
    }
    offsetX=offsetY=0;
    var levelW=(o.gridX+1)*gridSize;
    var levelH=(o.gridY+1)*gridSize;
    var docW=document.width;
    var docH=document.height;
    var diffX=docW-levelW;
    var diffY=docH-levelH;
    offsetX=Math.floor(diffX/2);
    offsetY=Math.floor(diffY/2);
    var el=t.getElementsByTagName("div");
    for(var i in el){
        if(typeof(el[i].style)!="undefined"){
            var currentX=parseInt(el[i].style.left);
            var currentY=parseInt(el[i].style.top);
            el[i].style.left=currentX+offsetX+"px";
            el[i].style.top=currentY+offsetY+"px";
        }
    }
}

function makeLevel(o,t){
    t.innerHTML="";
    offsetX=offsetY=0;
    o.frame=0;
    o.gameState=0;
    o.deathDelay=-1;
    o.chuchuSaved=0;
    o.chuchuRequired=o.chuchu.length;
    o.chuchuMoving=[];
    for(var i in o.chuchu){ o.chuchuMoving.push(o.chuchu[i]); }
    o.kapukapuMoving=[];
    for(var i in o.kapukapu){ o.kapukapuMoving.push(o.kapukapu[i]); }
    if(typeof(o.madeWalls)=="undefined"){ makeWalls(o); }
    gridObject={}; // required for grid click function
    o.gridX=o.gridY=0;
    for(var i in o.grid){
        var _grid=document.createElement("div");
            _grid.id="grid_"+o.grid[i][0]+"_"+o.grid[i][1];
            _grid.className="grid col"+Math.floor(Math.random()*4);
            _grid.style.width=gridSize+"px";
            _grid.style.height=gridSize+"px";
            _grid.style.left=o.grid[i][0]*gridSize+"px";
            _grid.style.top=o.grid[i][1]*gridSize+"px";
            //_grid.innerHTML=o.grid[i][0]+","+o.grid[i][1];
            _grid.onselectstart=function(){ return false; };
            gridObject[_grid.id]={x:o.grid[i][0],y:o.grid[i][1],o:o};
            _grid.onclick=function(){ gridActions(gridObject[this.id],t); };
        t.appendChild(_grid);
        o.gridX=o.grid[i][0]>o.gridX?o.grid[i][0]:o.gridX;
        o.gridY=o.grid[i][1]>o.gridY?o.grid[i][1]:o.gridY;
    }
    for(var i in o.walls){
        var _wall=document.createElement("div");
            _wall.className="wall";
            _wall.style.width=(o.walls[i][2]==0||o.walls[i][2]==2?gridSize:wallSize)+"px";
            _wall.style.height=(o.walls[i][2]==1||o.walls[i][2]==3?gridSize:wallSize)+"px";
            _wall.style.left=o.walls[i][0]*gridSize+(o.walls[i][2]==1?gridSize-Math.floor(wallSize/2):o.walls[i][2]==3?-Math.floor(wallSize/2):0)+"px";
            _wall.style.top=o.walls[i][1]*gridSize+(o.walls[i][2]==2?gridSize-Math.floor(wallSize/2):o.walls[i][2]==0?-Math.floor(wallSize/2):0)+"px";
            _wall.onselectstart=function(){ return false; };
        t.appendChild(_wall);
    }
    for(var i in o.chuchu){
        var _chuchu=document.createElement("div");
            _chuchu.id="chuchu_"+i;
            _chuchu.className="chuchu";
            _chuchu.style.width=gridSize+"px";
            _chuchu.style.height=gridSize+"px";
            _chuchu.style.left=o.chuchu[i][0]*gridSize+"px";
            _chuchu.style.top=o.chuchu[i][1]*gridSize+"px";
            _chuchu.onselectstart=function(){ return false; };
            gridObject[_chuchu.id]={x:o.chuchu[i][0],y:o.chuchu[i][1],o:o};
            _chuchu.onclick=function(){ gridActions(gridObject[this.id],t); };
        t.appendChild(_chuchu);
    }
    for(var i in o.kapukapu){
        var _kapukapu=document.createElement("div");
            _kapukapu.id="kapukapu_"+i;
            _kapukapu.className="kapukapu";
            _kapukapu.style.width=gridSize+"px";
            _kapukapu.style.height=gridSize+"px";
            _kapukapu.style.left=o.kapukapu[i][0]*gridSize+"px";
            _kapukapu.style.top=o.kapukapu[i][1]*gridSize+"px";
            _kapukapu.onselectstart=function(){ return false; };
            gridObject[_kapukapu.id]={x:o.kapukapu[i][0],y:o.kapukapu[i][1],o:o};
            _kapukapu.onclick=function(){ gridActions(gridObject[this.id],t); };
        t.appendChild(_kapukapu);
    }
    for(var i in o.goals){
        var _goal=document.createElement("div");
            _goal.className="goal";
            _goal.style.width=gridSize+"px";
            _goal.style.height=gridSize+"px";
            _goal.style.left=o.goals[i][0]*gridSize+"px";
            _goal.style.top=o.goals[i][1]*gridSize+"px";
            _goal.onselectstart=function(){ return false; };
        t.appendChild(_goal);
    }
    for(var i in o.holes){
        var _holes=document.createElement("div");
            _holes.id="holes_"+i;
            _holes.className="hole";
            _holes.style.width=Math.floor(gridSize/4*3)+"px";
            _holes.style.height=Math.floor(gridSize/4*3)+"px";
            _holes.style.left=o.holes[i][0]*gridSize+Math.floor(gridSize/8)+"px";
            _holes.style.top=o.holes[i][1]*gridSize+Math.floor(gridSize/8)+"px";
            _holes.onselectstart=function(){ return false; };
        t.appendChild(_holes);
    }
    positionLevel(o,t);
    window.onresize=function(){ positionLevel(o,t); };
}

function gridActions(o,t){
    if(o.o.gameState==0){
        canDoActions=1;
        // check if hole
        for(var i in o.o.holes){
            if(o.x==o.o.holes[i][0]&&o.y==o.o.holes[i][1]){
                canDoActions=0;
                break;
            }
        }
        // check if goal
        for(var i in o.o.goals){
            if(o.x==o.o.goals[i][0]&&o.y==o.o.goals[i][1]){
                canDoActions=0;
                break;
            }
        }
        // check if arrow placed already
        for(var i in o.o.arrows.placed){
            if(o.o.arrows.placed[i].length>0){
                for(var j in o.o.arrows.placed[i]){
                    if(o.o.arrows.placed[i][j][0]==o.x&&o.o.arrows.placed[i][j][1]==o.y){
                        alert("There is an arrow here already pointing "+faces(i));
                        canDoActions=0; // TEMPORARY - will add options to change direction of arrows if available
                    }
                }
            }
        }
        if(canDoActions==1){
            if(o.o.arrows.available[2]>0){
                o.o.arrows.placed[2].push([o.x,o.y]);
                o.o.arrows.available[2]--;
                var _arrow=document.createElement("div");
                    _arrow.className="arrow";
                    _arrow.style.left=o.x*gridSize+offsetX+"px";
                    _arrow.style.top=o.y*gridSize+offsetY+"px";
                    _arrow.style.width=gridSize+"px";
                    _arrow.style.height=gridSize+"px";
                    _arrow.style.backgroundPosition="-100px 0px";
                    _arrow.onclick=function(){ gridActions(o,t); };
                t.appendChild(_arrow);
                return;
            }
            if(o.o.arrows.available[0]>0){
                o.o.arrows.placed[0].push([o.x,o.y]);
                o.o.arrows.available[0]--;
                var _arrow=document.createElement("div");
                    _arrow.className="arrow";
                    _arrow.style.left=o.x*gridSize+offsetX+"px";
                    _arrow.style.top=o.y*gridSize+offsetY+"px";
                    _arrow.style.width=gridSize+"px";
                    _arrow.style.height=gridSize+"px";
                    _arrow.style.backgroundPosition="0px 0px";
                    _arrow.onclick=function(){ gridActions(o,t); };
                t.appendChild(_arrow);
                return;
            }
        }
    }
}

var levels=[
    {
        title:"Level One",
        description:"The first level",
        grid:[
            [0,0],[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0],[11,0],
            [0,1],[1,1],[2,1],[3,1],[4,1],[5,1],[6,1],[7,1],[8,1],[9,1],[10,1],[11,1],
            [0,2],[1,2],[2,2],[3,2],[4,2],[5,2],[6,2],[7,2],[8,2],[9,2],[10,2],[11,2],
            [0,3],[1,3],[2,3],[3,3],[4,3],[5,3],[6,3],[7,3],[8,3],[9,3],[10,3],[11,3],
            [0,4],[1,4],[2,4],[3,4],[4,4],[5,4],[6,4],[7,4],[8,4],[9,4],[10,4],[11,4],
            [0,5],[1,5],[2,5],[3,5],[4,5],[5,5],[6,5],[7,5],[8,5],[9,5],[10,5],[11,5],
            [0,6],[1,6],[2,6],[3,6],[4,6],[5,6],[6,6],[7,6],[8,6],[9,6],[10,6],[11,6],
            [0,7],[1,7],[2,7],[3,7],[4,7],[5,7],[6,7],[7,7],[8,7],[9,7],[10,7],[11,7],
            [0,8],[1,8],[2,8],[3,8],[4,8],[5,8],[6,8],[7,8],[8,8],[9,8],[10,8],[11,8]
        ],
        arrows:{
            available:{
                0:0,1:0,2:2,3:0
            },
            placed:{
                0:[],1:[],2:[],3:[]
            }
        },
        walls:[
            [1,2,2],
            [7,2,1],
            [11,8,3],
            [10,6,2],
            [11,5,0],[8,5,3],[8,3,0],[11,3,2],[8,3,3],[8,5,2],[9,4,0],[10,4,1]
        ],
        chuchu:[
            [1,2,1]
        ],
        kapukapu:[
            [2,2,1]
        ],
        goals:[
            [1,6]
        ],
        holes:[
            [6,4],[6,5]
        ]
    },
    {
        title:"Where to go?",
        description:"The actual first level from the REAL game lolwut!",
        grid:[
            [0,0],[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0],[11,0],
            [0,1],[1,1],[2,1],[3,1],[4,1],[5,1],[6,1],[7,1],[8,1],[9,1],[10,1],[11,1],
            [0,2],[1,2],[2,2],[3,2],[4,2],[5,2],[6,2],[7,2],[8,2],[9,2],[10,2],[11,2],
            [0,3],[1,3],[2,3],[3,3],[4,3],[5,3],[6,3],[7,3],[8,3],[9,3],[10,3],[11,3],
            [0,4],[1,4],[2,4],[3,4],[4,4],[5,4],[6,4],[7,4],[8,4],[9,4],[10,4],[11,4],
            [0,5],[1,5],[2,5],[3,5],[4,5],[5,5],[6,5],[7,5],[8,5],[9,5],[10,5],[11,5],
            [0,6],[1,6],[2,6],[3,6],[4,6],[5,6],[6,6],[7,6],[8,6],[9,6],[10,6],[11,6],
            [0,7],[1,7],[2,7],[3,7],[4,7],[5,7],[6,7],[7,7],[8,7],[9,7],[10,7],[11,7],
            [0,8],[1,8],[2,8],[3,8],[4,8],[5,8],[6,8],[7,8],[8,8],[9,8],[10,8],[11,8]
        ],
        arrows:{
            available:{0:1,1:0,2:0,3:0},
            placed:{0:[],1:[],2:[],3:[]}
        },
        walls:[
            [0,0,2],[11,0,2],[0,1,2],[11,2,2],[0,3,2],[11,4,2],[0,5,2],[11,6,2],[0,7,2]
        ],
        chuchu:[
            [0,1,1],[1,1,1],[2,1,1],[3,1,1],[4,1,1],[7,2,3],[8,2,3],[9,2,3],[10,2,3],[11,2,3],[0,3,1],[1,3,1],[2,3,1],[3,3,1],[4,3,1],[7,4,3],[8,4,3],[9,4,3],[10,4,3],[11,4,3],[0,5,1],[1,5,1],[2,5,1],[3,5,1],[4,5,1],[7,6,3],[8,6,3],[9,6,3],[10,6,3],[11,6,3],[0,7,1],[1,7,1],[2,7,1],[3,7,1],[4,7,1],[7,8,3],[8,8,3],[9,8,3],[10,8,3],[11,8,3]
        ],
        goals:[
            [1,0],[3,0],[5,0],[7,0],[9,0],[11,0]
        ]
    },
    {
        title:"Roundabout",
        description:"Level 2 - Roundabout",
        grid:[
            [0,0],[1,0],[2,0],[3,0],[4,0],[5,0],[6,0],[7,0],[8,0],[9,0],[10,0],[11,0],
            [0,1],[1,1],[2,1],[3,1],[4,1],[5,1],[6,1],[7,1],[8,1],[9,1],[10,1],[11,1],
            [0,2],[1,2],[2,2],[3,2],[4,2],[5,2],[6,2],[7,2],[8,2],[9,2],[10,2],[11,2],
            [0,3],[1,3],[2,3],[3,3],[4,3],[5,3],[6,3],[7,3],[8,3],[9,3],[10,3],[11,3],
            [0,4],[1,4],[2,4],[3,4],[4,4],[5,4],[6,4],[7,4],[8,4],[9,4],[10,4],[11,4],
            [0,5],[1,5],[2,5],[3,5],[4,5],[5,5],[6,5],[7,5],[8,5],[9,5],[10,5],[11,5],
            [0,6],[1,6],[2,6],[3,6],[4,6],[5,6],[6,6],[7,6],[8,6],[9,6],[10,6],[11,6],
            [0,7],[1,7],[2,7],[3,7],[4,7],[5,7],[6,7],[7,7],[8,7],[9,7],[10,7],[11,7],
            [0,8],[1,8],[2,8],[3,8],[4,8],[5,8],[6,8],[7,8],[8,8],[9,8],[10,8],[11,8]
        ],
        arrows:{available:{0:0,1:0,2:1,3:0},placed:{0:[],1:[],2:[],3:[]}},
        walls:[[5,8,1]],
        chuchu:[[5,0,2],[5,1,2],[5,2,2],[5,3,2],[5,4,2],[5,5,2],[5,6,2],[5,7,2],[6,0,2],[6,1,2],[6,2,2],[6,3,2],[6,4,2],[6,5,2],[6,6,2],[6,7,2]],
        goals:[[4,7],[7,7]]
    }
];

var gridSize=50;
var wallSize=gridSize/10;
var offsetX=offsetY=0;
var frameDelay=20;
var movements=10;
var frameMovement=gridSize/movements;

Author:  Skillers [ Sun Nov 06, 2011 12:40 pm ]
Post subject:  Re: ChuChu Rocket!

Not sure how Java works and what you're doing exactly (not wading through all that code), but in C if you do array1=array2, they will both be accessing the same memory as the array variables are pointers, so array1=array2 will set the pointer of array1 to the same as array2. What you would need to do in C is to allocate new memory for an array then copy the data element by element.

Author:  Harry [ Sun Nov 06, 2011 1:08 pm ]
Post subject:  Re: ChuChu Rocket!

*Javascript ;o

And I believe Array2 will only point to Array1 if you do Array2 = *Array1 (or vice-versa).

Author:  azcn2503 [ Sun Nov 06, 2011 1:12 pm ]
Post subject:  Re: ChuChu Rocket!

I understand what you're saying, however the bug persists even if I recreate the array by looping through the old array items and adding them to the new array. Imagine this:

old=[1,2,3,4,5];
new=[];
for(i in old){ new.push(old[i]); }

new ends up being the same as old, although I haven't done a simple new=old. I'd be surprised if they still occupied the same memory space under this scenario.

Also Harry, they should be unique.

If I had this:

a=1;
b=a;
b++;

b would be 2, but a would still be 1.

In my code, I am doing almost exactly the same thing (but the value is an array within an object) yet it doesn't follow this rule. (in this example, according to my bug, a becomes 2)

Author:  kyhas [ Sun Nov 06, 2011 2:54 pm ]
Post subject:  Re: ChuChu Rocket!

where does old/new come from? is it input? if so why dont you have
input1 = (input)

old = input1

new = input1

input doesnt change but you should be able to change new and old irrespective of each other.... even if its not an input you want one to stay the same right?

Author:  azcn2503 [ Sun Nov 06, 2011 7:36 pm ]
Post subject:  Re: ChuChu Rocket!

old is already preset (actual name o.chuchu) new is the duplicate of old (actual name o.chuchuMoving)

Basically old is not input.

Update: found a fix.

Update: fix didn't work.

Update: found new fix to fix broken fix. Basically, it's fixed.

Author:  azcn2503 [ Tue Nov 08, 2011 5:47 pm ]
Post subject:  Re: ChuChu Rocket!

I would definitely recommend those that haven't checked this out yet to check it out and provide feedback! Kind regards.

Author:  azcn2503 [ Thu Nov 10, 2011 12:29 am ]
Post subject:  Re: ChuChu Rocket!

This is coming along very well. Please check it out.

Author:  azcn2503 [ Thu Nov 10, 2011 12:09 pm ]
Post subject:  Re: ChuChu Rocket!

I added a new level last night! It's quite challenging ;) hope you like it.
I'm continuing to work on an editor, but it's going to take some time.

Author:  Hawke [ Thu Nov 10, 2011 2:30 pm ]
Post subject:  Re: ChuChu Rocket!

I'll get to work on some music this weekend hopefully Aaron. What kind of instrumentation would you prefer and what style? Or shall I just throw notes at the piano roll and see what sticks? :)

Author:  azcn2503 [ Thu Nov 10, 2011 4:39 pm ]
Post subject:  Re: ChuChu Rocket!

Hey Hawke, I really appreciate your input :)

Put together anything you'd like and I'll put it up for people to listen to. I will have to massively compress whatever you send to me however! It is likely that any subtleties will be lost in this compression so simple is best!

Update: puzzle games pride themselves on repetitive digital sounding music (think TETRIS!) so anything like this is good. Although the music in Tetris is quite powerful (you could probably march an army to it) and in CCR I feel it is quite important to have something quite easy on the ears, especially as one can spend an enormous amount of time trying to solve just one puzzle.

Author:  azcn2503 [ Fri Nov 11, 2011 3:30 pm ]
Post subject:  Re: ChuChu Rocket!

3 new levels added. Give them a try :)

Author:  Harry [ Sun Nov 13, 2011 2:41 am ]
Post subject:  Re: ChuChu Rocket!

+1

Author:  azcn2503 [ Sun Nov 13, 2011 10:51 pm ]
Post subject:  Re: ChuChu Rocket!

New sprites added!

Sorry, they're very small.

Image
Image

These are coded up as animations :)

Author:  Harry [ Mon Nov 14, 2011 2:12 am ]
Post subject:  Re: ChuChu Rocket!

Did your friend draw those?!

Page 1 of 3 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/