Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
CC Attribution ShareAlike
Archived Sketch
This sketch is created with an older version of Processing,
and doesn't work on browsers anymore.
View Source Code
Spin Maze
Schafer
xxxxxxxxxx
class Board
{
/* terrain (walls) */
private MazeNode nodes[][];
public Board(MazeNode nodes[][])
{
this.nodes = nodes;
}
public void rotateTerrain(float rotAmt)
{
mazeAng -= rotAmt;
mazeAng = mazeAng % (2*PI);
// linear transformation with matrix T = [[cos, -sin],[sin, cos]]
// Matrix Theory was a helpful class, yay!
PVector transX = new PVector(cos(rotAmt), -sin(rotAmt));
PVector transY = new PVector(sin(rotAmt), cos(rotAmt));
for (FBody fb : rotateUs)
{
fb.adjustRotation(rotAmt);
PVector v = new PVector(fb.getX() - width/2, fb.getY() - height/2);
fb.setPosition(v.dot(transX) + width/2, v.dot(transY) + height/2);
}
}
public void initTerrain()
{
int row,col;
// fill in north and west walls for every node
for (row = 0; row < ROWS; ++row)
{
for (col = 0; col < COLS; ++col)
{
if (nodes[row][col].walls[0] == 1) // north wall exists
{
FBox fb = new FBox(GAP, 2);
fb.setPosition(col * GAP + offsetX, row * GAP - (GAP/2) + offsetY);
fb.setStatic(true);
//fb.setGrabbable(false); // <-- THIS COULD PROVIDE INTERESTING OPPORTUNITIES
rotateUs.add(fb);
world.add(fb);
}
if (nodes[row][col].walls[3] == 1) // west wall exists
{
FBox fb = new FBox(2, GAP);
fb.setPosition(col * GAP - (GAP/2) + offsetX, row * GAP + offsetY);
fb.setStatic(true);
//fb.setGrabbable(false); // <-- THIS COULD PROVIDE INTERESTING OPPORTUNITIES
rotateUs.add(fb);
world.add(fb);
}
}
}
// fill in the east walls for the last column
col = COLS - 1;
for (row = 0; row < ROWS; ++row)
{
if (nodes[row][col].walls[1] == 1) // east wall exists
{
FBox fb = new FBox(2, GAP);
fb.setPosition(col * GAP + (GAP/2) + offsetX, row * GAP + offsetY);
fb.setStatic(true);
//fb.setGrabbable(false); // <-- THIS COULD PROVIDE INTERESTING OPPORTUNITIES
rotateUs.add(fb);
world.add(fb);
}
}
// fill in the south walls for the last row
row = ROWS - 1;
for (col = 0; col < COLS; ++col)
{
if (nodes[row][col].walls[2] == 1) // south wall exists
{
FBox fb = new FBox(GAP, 2);
fb.setPosition(col * GAP + offsetX, row * GAP + (GAP/2) + offsetY);
fb.setStatic(true);
//fb.setGrabbable(false); // <-- THIS COULD PROVIDE INTERESTING OPPORTUNITIES
rotateUs.add(fb);
world.add(fb);
}
}
}
}
See More Shortcuts