You are on page 1of 18

// game.js for Perlenspiel 3.

1
// Please fill out these comments with the appropriate information.

// Name:Edward Blackwood
// Date: 8.7.14

/*
Perlenspiel is a scheme by Professor Moriarty (bmoriarty@wpi.edu).
Perlenspiel is Copyright 2009-14 Worcester Polytechnic Institute.
This file is part of Perlenspiel.

Perlenspiel is free software: you can redistribute it and/or modify


it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Perlenspiel is distributed in the hope that it will be useful,


but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.

You may have received a copy of the GNU Lesser General Public License
along with Perlenspiel. If not, see <http://www.gnu.org/licenses/>.

*/

// The following comment lines are for JSLint. Don't remove them!

/*jslint nomen: true, white: true */


/*global PS */

function GameStart()
{
//head
PS.color ( 16 , 5 , PS.COLOR_YELLOW ) ;
PS.color ( 16 , 6, PS.COLOR_YELLOW ) ;
PS.color ( 17 , 4, PS.COLOR_BLACK ) ;
PS.color ( 17 , 5, PS.COLOR_YELLOW ) ;
PS.color ( 17 , 6, PS.COLOR_YELLOW ) ;
PS.color ( 18 , 4, PS.COLOR_BLACK ) ;
PS.color ( 18 , 5, PS.COLOR_YELLOW ) ;
PS.color ( 19 , 5, PS.COLOR_YELLOW ) ;
PS.color ( 18 , 6, PS.COLOR_YELLOW ) ;
PS.color ( 19 , 6, PS.COLOR_YELLOW ) ;
PS.color ( 17 , 7, PS.COLOR_YELLOW ) ;
PS.color ( 18 , 7, PS.COLOR_YELLOW ) ;
PS.color ( 16 , 8, PS.COLOR_YELLOW ) ;
PS.color ( 17 , 8, PS.COLOR_YELLOW ) ;
//body

PS.color ( 15 , 8, PS.COLOR_YELLOW ) ;
PS.color ( 18 , 8, PS.COLOR_YELLOW ) ;
PS.color ( 19 , 8, PS.COLOR_YELLOW ) ;
PS.color ( 20 , 8, PS.COLOR_YELLOW ) ;
PS.color ( 14 , 8, PS.COLOR_YELLOW ) ;
PS.color ( 21 , 8, PS.COLOR_YELLOW ) ;
PS.color ( 14 , 9, PS.COLOR_YELLOW ) ;
PS.color ( 16 , 9, PS.COLOR_YELLOW ) ;
PS.color ( 17 , 9, PS.COLOR_YELLOW ) ;
PS.color ( 18 , 9, PS.COLOR_YELLOW ) ;
PS.color ( 19 , 9, PS.COLOR_YELLOW ) ;
PS.color ( 21 , 9, PS.COLOR_YELLOW ) ;
PS.color ( 14 , 10, PS.COLOR_YELLOW ) ;
PS.color ( 16 , 10, PS.COLOR_YELLOW ) ;
PS.color ( 17 , 10, PS.COLOR_YELLOW ) ;
PS.color ( 18 , 10, PS.COLOR_YELLOW ) ;
PS.color ( 19 , 10, PS.COLOR_YELLOW ) ;
PS.color ( 21 , 10, PS.COLOR_YELLOW ) ;
PS.color ( 14 , 11, PS.COLOR_YELLOW ) ;
PS.color ( 16 , 11, PS.COLOR_YELLOW ) ;
PS.color ( 17 , 11, PS.COLOR_YELLOW ) ;
PS.color ( 18 , 11, PS.COLOR_YELLOW ) ;
PS.color ( 19 , 11, PS.COLOR_YELLOW ) ;
PS.color ( 21 , 11, PS.COLOR_YELLOW ) ;
PS.color ( 14 , 12, PS.COLOR_YELLOW ) ;

PS.color ( 16 , 12, PS.COLOR_YELLOW ) ;


PS.color ( 17 , 12, PS.COLOR_YELLOW ) ;
PS.color ( 18 , 12, PS.COLOR_YELLOW ) ;
PS.color ( 19 , 12, PS.COLOR_YELLOW ) ;
PS.color ( 21 , 12, PS.COLOR_YELLOW ) ;
//legs
PS.color ( 16 , 13, PS.COLOR_BLACK ) ;
PS.color ( 17 , 13, PS.COLOR_BLACK ) ;
PS.color ( 18 , 13, PS.COLOR_BLACK ) ;
PS.color ( 19 , 13, PS.COLOR_BLACK ) ;
PS.color ( 16 , 14, PS.COLOR_YELLOW ) ;
PS.color ( 17 , 14, PS.COLOR_BLACK ) ;
PS.color ( 18 , 14, PS.COLOR_BLACK ) ;
PS.color ( 19 , 14, PS.COLOR_YELLOW ) ;
PS.color ( 16 , 15, PS.COLOR_YELLOW ) ;
PS.color ( 19 , 15, PS.COLOR_YELLOW ) ;
PS.color ( 16 , 16, PS.COLOR_YELLOW ) ;
PS.color ( 19 , 16, PS.COLOR_YELLOW ) ;
PS.color ( 16 , 17, PS.COLOR_YELLOW ) ;
PS.color ( 19 , 17, PS.COLOR_YELLOW ) ;
PS.color ( 16 , 18, PS.COLOR_YELLOW ) ;
PS.color ( 19 , 18, PS.COLOR_YELLOW ) ;
PS.color ( 16 , 19, PS.COLOR_YELLOW ) ;
PS.color ( 19 , 19, PS.COLOR_YELLOW ) ;
PS.color ( 16 , 20, PS.COLOR_YELLOW ) ;

PS.color ( 19 , 20, PS.COLOR_YELLOW ) ;


PS.color ( 15 , 20, PS.COLOR_YELLOW ) ;
PS.color ( 20 , 20, PS.COLOR_YELLOW ) ;
//boots
PS.color ( 25, 25 , PS.COLOR_BLACK ) ;
PS.color ( 25, 26 , PS.COLOR_BLACK ) ;
PS.color ( 24, 26 , PS.COLOR_BLACK ) ;
PS.color ( 27, 25 , PS.COLOR_BLACK ) ;
PS.color ( 27, 26 , PS.COLOR_BLACK ) ;
PS.color ( 28, 26 , PS.COLOR_BLACK ) ;
//pants
PS.color ( 16, 23 , PS.COLOR_BLACK ) ;
PS.color ( 17, 23 , PS.COLOR_BLACK ) ;
PS.color ( 18, 23 , PS.COLOR_BLACK ) ;
PS.color ( 19, 23 , PS.COLOR_BLACK ) ;
PS.color ( 16, 24 , PS.COLOR_BLACK ) ;
PS.color ( 17, 24 , PS.COLOR_BLACK ) ;
PS.color ( 18, 24 , PS.COLOR_BLACK ) ;
PS.color ( 19, 24 , PS.COLOR_BLACK ) ;
PS.color ( 16, 25 , PS.COLOR_BLACK ) ;
PS.color ( 19, 25 , PS.COLOR_BLACK ) ;
PS.color ( 16, 26 , PS.COLOR_BLACK ) ;
PS.color ( 19, 26 , PS.COLOR_BLACK ) ;
PS.color ( 16, 27 , PS.COLOR_BLACK ) ;
PS.color ( 19, 27 , PS.COLOR_BLACK ) ;

PS.color ( 16, 28 , PS.COLOR_BLACK ) ;


PS.color ( 19, 28 , PS.COLOR_BLACK ) ;
//jacket
PS.color ( 2, 8 , PS.COLOR_BLACK ) ;
PS.color ( 3, 8 , PS.COLOR_BLACK ) ;
PS.color ( 4, 8 , PS.COLOR_BLACK ) ;
PS.color ( 5, 8 , PS.COLOR_BLACK ) ;
PS.color ( 6, 8 , PS.COLOR_BLACK ) ;
PS.color ( 7, 8 , PS.COLOR_BLACK ) ;
PS.color ( 8, 8 , PS.COLOR_BLACK ) ;
PS.color ( 9, 8 , PS.COLOR_BLACK ) ;
PS.color ( 2, 9 , PS.COLOR_BLACK ) ;
PS.color ( 4, 9 , PS.COLOR_BLACK ) ;
PS.color ( 5, 9 , PS.COLOR_BLACK ) ;
PS.color ( 6, 9 , PS.COLOR_BLACK ) ;
PS.color ( 7, 9 , PS.COLOR_BLACK ) ;
PS.color ( 9, 9 , PS.COLOR_BLACK ) ;
PS.color ( 2, 10, PS.COLOR_BLACK ) ;
PS.color ( 4, 10 , PS.COLOR_BLACK ) ;
PS.color ( 5, 10 , PS.COLOR_BLACK ) ;
PS.color ( 6, 10 , PS.COLOR_BLACK ) ;
PS.color ( 7, 10 , PS.COLOR_BLACK ) ;
PS.color ( 9, 10 , PS.COLOR_BLACK ) ;
PS.color ( 2, 11 , PS.COLOR_BLACK ) ;
PS.color ( 4, 11 , PS.COLOR_BLACK ) ;

PS.color ( 5, 11 , PS.COLOR_BLACK ) ;
PS.color ( 6, 11 , PS.COLOR_BLACK ) ;
PS.color ( 7, 11 , PS.COLOR_BLACK ) ;
PS.color ( 9, 11 , PS.COLOR_BLACK ) ;
PS.color ( 4, 12 , PS.COLOR_BLACK ) ;
PS.color ( 5, 12 , PS.COLOR_BLACK ) ;
PS.color ( 6, 12 , PS.COLOR_BLACK ) ;
PS.color ( 7, 12 , PS.COLOR_BLACK ) ;
PS.color ( 5, 7 , PS.COLOR_BLACK ) ;
PS.color ( 6, 7 , PS.COLOR_BLACK ) ;
//festive hat
PS.color ( 3 , 4 , PS.COLOR_RED );
PS.color ( 4 , 4 , PS.COLOR_RED );
PS.color ( 5 , 4 , PS.COLOR_RED );
PS.color ( 6 , 4 , PS.COLOR_RED );
PS.color ( 7 , 4 , PS.COLOR_RED );
PS.color ( 8 , 4 , PS.COLOR_RED );
PS.color ( 6 , 3 , PS.COLOR_RED );
PS.color ( 5 , 3 , PS.COLOR_RED );
//belt
PS.color ( 4 , 14 , PS.COLOR_RED );
PS.color ( 5 , 14 , PS.COLOR_RED );
PS.color ( 6 , 14 , PS.COLOR_RED );
PS.color ( 7 , 14 , PS.COLOR_RED );

//Reset Button
PS.glyph( 0, 31, "R");
PS.glyphColor(0, 31, PS.COLOR_BLACK);
PS.glyph(0, 13, "B");
PS.glyphColor(0, 13, PS.COLOR_BLACK);
}
function GameReset()
{
PS.init();

// This is a template for creating new Perlenspiel games

// All of the functions below MUST exist, or the engine will complain!

// PS.init( system, options )


// Initializes the game
// This function should normally begin with a call to PS.gridSize( x, y )
// where x and y are the desired initial dimensions of the grid
// [system] = an object containing engine and platform information; see documentation for details
// [options] = an object with optional parameters; see documentation for details

PS.init = function( system, options ) {


"use strict";

// Use PS.gridSize( x, y ) to set the grid to


// the initial dimensions you want (32 x 32 maximum)
// Do this FIRST to avoid problems!
// Otherwise you will get the default 8x8 grid

PS.gridSize( 32, 32);

PS.statusText( "Paper Doll: Dress-a-Goth");


GameStart();

// Add any other initialization code you need here


};

// PS.touch ( x, y, data, options )


// Called when the mouse button is clicked on a bead, or when a bead is touched
// It doesn't have to do anything

// [x] = zero-based x-position of the bead on the grid


// [y] = zero-based y-position of the bead on the grid
// [data] = the data value associated with this bead, 0 if none has been set
// [options] = an object with optional parameters; see documentation for details

PS.touch = function( x, y, data, options ) {


"use strict";

// Uncomment the following line to inspect parameters


// PS.debug( "PS.touch() @ " + x + ", " + y + "\n" );

// Add code here for mouse clicks/touches over a bead


var checkColor = (PS.color(x, y) == PS.COLOR_BLACK);
var checkBlue = (PS.color(x, y) == PS.COLOR_BLUE);
var checkSelection = (PS.color(x, y) == PS.COLOR_YELLOW);
var checkRed = (PS.color(x, y) == PS.COLOR_RED);
var checkSection = (PS.color(x, y) == PS.COLOR_WHITE);

if(checkColor || checkSection)
{

if(x== 0 && y==13 || x== 25 && y==25 || x==25 && y==26 || x==24 && y==26)
{
PS.color(25, 25, PS.COLOR_WHITE);
PS.color(25, 26, PS.COLOR_WHITE);

PS.color(24, 26, PS.COLOR_WHITE);


PS.color(16, 19, PS.COLOR_BLACK);
PS.color(16, 20, PS.COLOR_BLACK);
PS.color(15, 20, PS.COLOR_BLACK);
}
if(x== 0 && y==13 || x== 27 && y==25 || x==27 && y==26 || x==28 && y==26)
{
PS.color(27, 25, PS.COLOR_WHITE);
PS.color(27, 26, PS.COLOR_WHITE);
PS.color(28, 26, PS.COLOR_WHITE);
PS.color(19, 19, PS.COLOR_BLACK);
PS.color(19, 20, PS.COLOR_BLACK);
PS.color(20, 20, PS.COLOR_BLACK);
}

//if(x == 16 && y == 23 || x == 17 && y == 23 || x == 18 && y == 23 || x == 19 && y ==


23 || x == 16 && y == 24 || x == 17 && y == 24 || x == 18 && y == 24 || x == 19 && y == 24 || x == 16
&& y == 25 || x == 19 && y == 25 || x == 16 && y == 26 || x == 19 && y == 26 || x == 16 && y == 27 || x
== 19 && y == 27 || x == 16 && y == 28 || x == 19 && y == 28 || )
{
PS.color(16, 23, PS.COLOR_WHITE);
PS.color(17, 23, PS.COLOR_WHITE);
PS.color(18, 23, PS.COLOR_WHITE);
PS.color(19, 23, PS.COLOR_WHITE);
PS.color(16, 24, PS.COLOR_WHITE);
PS.color(17, 24, PS.COLOR_WHITE);
PS.color(18, 24, PS.COLOR_WHITE);

PS.color(19, 24, PS.COLOR_WHITE);


PS.color(16, 25, PS.COLOR_WHITE);
PS.color(19, 25, PS.COLOR_WHITE);
PS.color(16, 26, PS.COLOR_WHITE);
PS.color(19, 26, PS.COLOR_WHITE);
PS.color(16, 27, PS.COLOR_WHITE);
PS.color(19, 27, PS.COLOR_WHITE);
PS.color(16, 28, PS.COLOR_WHITE);
PS.color(19, 28, PS.COLOR_WHITE);

PS.color(16, 13, PS.COLOR_BLACK);


PS.color(17, 13, PS.COLOR_BLACK);
PS.color(18, 13, PS.COLOR_BLACK);
PS.color(19, 13, PS.COLOR_BLACK);
PS.color(16, 14, PS.COLOR_BLACK);
PS.color(17, 14, PS.COLOR_BLACK);
PS.color(18, 14, PS.COLOR_BLACK);
PS.color(19, 14, PS.COLOR_BLACK);
PS.color(16, 15, PS.COLOR_BLACK);
PS.color(19, 15, PS.COLOR_BLACK);
PS.color(16, 16, PS.COLOR_BLACK);
PS.color(19, 16, PS.COLOR_BLACK);
PS.color(16, 17, PS.COLOR_BLACK);
PS.color(19, 17, PS.COLOR_BLACK);
PS.color(16, 18, PS.COLOR_BLACK);

PS.color(19, 18, PS.COLOR_BLACK);

}
if(x == 0 && y == 31)
{
GameReset();

}
}

PS.audioPlay("fx_click");

PS.debug("Selection " + x + ", " + y + " \n"); //Make sure to Uncomment Before turn in.
};

// PS.release ( x, y, data, options )


// Called when the mouse button is released over a bead, or when a touch is lifted off a bead
// It doesn't have to do anything
// [x] = zero-based x-position of the bead on the grid
// [y] = zero-based y-position of the bead on the grid
// [data] = the data value associated with this bead, 0 if none has been set
// [options] = an object with optional parameters; see documentation for details

PS.release = function( x, y, data, options ) {


"use strict";

// Uncomment the following line to inspect parameters


// PS.debug( "PS.release() @ " + x + ", " + y + "\n" );

// Add code here for when the mouse button/touch is released over a bead
};

// PS.enter ( x, y, button, data, options )


// Called when the mouse/touch enters a bead
// It doesn't have to do anything
// [x] = zero-based x-position of the bead on the grid
// [y] = zero-based y-position of the bead on the grid
// [data] = the data value associated with this bead, 0 if none has been set
// [options] = an object with optional parameters; see documentation for details

PS.enter = function( x, y, data, options ) {


"use strict";

// Uncomment the following line to inspect parameters


// PS.debug( "PS.enter() @ " + x + ", " + y + "\n" );

// Add code here for when the mouse cursor/touch enters a bead
};

// PS.exit ( x, y, data, options )

// Called when the mouse cursor/touch exits a bead


// It doesn't have to do anything
// [x] = zero-based x-position of the bead on the grid
// [y] = zero-based y-position of the bead on the grid
// [data] = the data value associated with this bead, 0 if none has been set
// [options] = an object with optional parameters; see documentation for details

PS.exit = function( x, y, data, options ) {


"use strict";

// Uncomment the following line to inspect parameters


// PS.debug( "PS.exit() @ " + x + ", " + y + "\n" );

// Add code here for when the mouse cursor/touch exits a bead
};

// PS.exitGrid ( options )
// Called when the mouse cursor/touch exits the grid perimeter
// It doesn't have to do anything
// [options] = an object with optional parameters; see documentation for details

PS.exitGrid = function( options ) {


"use strict";

// Uncomment the following line to verify operation

// PS.debug( "PS.exitGrid() called\n" );

// Add code here for when the mouse cursor/touch moves off the grid
};

// PS.keyDown ( key, shift, ctrl, options )


// Called when a key on the keyboard is pressed
// It doesn't have to do anything
// [key] = ASCII code of the pressed key, or one of the following constants:
// Arrow keys = PS.ARROW_UP, PS.ARROW_DOWN, PS.ARROW_LEFT, PS.ARROW_RIGHT
// Function keys = PS.F1 through PS.F1
// [shift] = true if shift key is held down, else false
// [ctrl] = true if control key is held down, else false
// [options] = an object with optional parameters; see documentation for details

PS.keyDown = function( key, shift, ctrl, options ) {


"use strict";

// Uncomment the following line to inspect parameters


//

PS.debug( "DOWN: key = " + key + ", shift = " + shift + "\n" );

// Add code here for when a key is pressed


};

// PS.keyUp ( key, shift, ctrl, options )

// Called when a key on the keyboard is released


// It doesn't have to do anything
// [key] = ASCII code of the pressed key, or one of the following constants:
// Arrow keys = PS.ARROW_UP, PS.ARROW_DOWN, PS.ARROW_LEFT, PS.ARROW_RIGHT
// Function keys = PS.F1 through PS.F12
// [shift] = true if shift key is held down, false otherwise
// [ctrl] = true if control key is held down, false otherwise
// [options] = an object with optional parameters; see documentation for details

PS.keyUp = function( key, shift, ctrl, options ) {


"use strict";

// Uncomment the following line to inspect parameters


// PS.debug( "PS.keyUp(): key = " + key + ", shift = " + shift + ", ctrl = " + ctrl + "\n" );

// Add code here for when a key is released


};

// PS.input ( sensors, options )


// Called when an input device event (other than mouse/touch/keyboard) is detected
// It doesn't have to do anything
// [sensors] = an object with sensor information; see documentation for details
// [options] = an object with optional parameters; see documentation for details

PS.input = function( sensors, options ) {

"use strict";

// Uncomment the following block to inspect parameters


/*
PS.debug( "PS.input() called\n" );
var device = sensors.wheel; // check for scroll wheel
if ( device )
{
PS.debug( "sensors.wheel = " + device + "\n" );
}
*/

// Add code here for when an input event is detected


};

You might also like