Skip to content

Commit

Permalink
Added H prefix to shape class names to avoid namespace collisions wit…
Browse files Browse the repository at this point in the history
…h standard library
  • Loading branch information
rdlester committed Jul 14, 2014
1 parent 7f268bc commit 3b16180
Show file tree
Hide file tree
Showing 43 changed files with 261 additions and 261 deletions.
2 changes: 1 addition & 1 deletion examples/BulletCurtain/Shot.pde
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Shot extends Being {

Shot(float x, float y, float shotWidth, float shotHeight, float travel) {

super(new Rectangle(x, y, shotWidth, shotHeight));
super(new HRectangle(x, y, shotWidth, shotHeight));
this.travel = travel;
this.shotWidth = shotWidth;
this.shotHeight = shotHeight;
Expand Down
2 changes: 1 addition & 1 deletion examples/Level0/Ball.pde
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Ball extends MassedBeing {

Ball() {
super(new Circle(new PVector((canvasLeftX+balli*cellSideLength)+cellSideLength/2,
super(new HCircle(new PVector((canvasLeftX+balli*cellSideLength)+cellSideLength/2,
(containerTopY+ballj*cellSideLength)+cellSideLength/2), ballRadius),
new PVector(0, 0), ballMass, ballElasticity, 35, 8);
world.register(this, true);
Expand Down
2 changes: 1 addition & 1 deletion examples/Level0/Bubble.pde
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Bubble extends MassedBeing {

Bubble(PVector position) {
super(new Circle(position, ballRadius/2), new PVector(0, 0), ballMass, ballElasticity, 35, 8);
super(new HCircle(position, ballRadius/2), new PVector(0, 0), ballMass, ballElasticity, 35, 8);
world.register(this, true);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/Level0/Canvas.pde
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Canvas extends MassedBeing {
PostOffice _po;

Canvas(PostOffice po) {
super(new Rectangle(new PVector(canvasLeftX, containerTopY),
super(new HRectangle(new PVector(canvasLeftX, containerTopY),
new PVector(canvasWidth, containerHeight)),
new PVector(0,0), Float.POSITIVE_INFINITY, 1);
_po = po;
Expand Down
2 changes: 1 addition & 1 deletion examples/Level0/Cell.pde
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Cell extends Being {
int _j;

Cell(PVector cellTopLeft, int i, int j) {
super(new Rectangle(cellTopLeft, new PVector(cellSideLength, cellSideLength)));
super(new HRectangle(cellTopLeft, new PVector(cellSideLength, cellSideLength)));
_flowDir = INIT_DIR;
_flowStr = INIT_STR;
_tool = null;
Expand Down
2 changes: 1 addition & 1 deletion examples/Level0/Goal.pde
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
class Goal extends Being {
Goal() {
super(new Rectangle(new PVector((canvasLeftX+goali*cellSideLength),
super(new HRectangle(new PVector((canvasLeftX+goali*cellSideLength),
(containerTopY+goalj*cellSideLength)),
new PVector(cellSideLength, cellSideLength)),
new PVector(0, 0));
Expand Down
2 changes: 1 addition & 1 deletion examples/Level0/RandomButton.pde
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RandomButton extends Being {
boolean _keyPressed = false;

RandomButton(Canvas c, PostOffice po) {
super(new Rectangle(randomButtonX,randomButtonY,randomButtonSide,randomButtonSide));
super(new HRectangle(randomButtonX,randomButtonY,randomButtonSide,randomButtonSide));
_c = c;
_hover = false;
_po = po;
Expand Down
2 changes: 1 addition & 1 deletion examples/Level0/RunButton.pde
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class RunButton extends Being {
boolean _keyPressed = false;

RunButton(PostOffice po) {
super(new Circle(new PVector(runButtonCenterX, runButtonCenterY), runButtonRadius));
super(new HCircle(new PVector(runButtonCenterX, runButtonCenterY), runButtonRadius));
_po = po;
}

Expand Down
6 changes: 3 additions & 3 deletions examples/Level0/ToolBox.pde
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ToolBox extends Being {
Zero zero;

ToolBox(Canvas canvas) {
super(new Rectangle(new PVector(toolBoxLeftX, containerTopY),
super(new HRectangle(new PVector(toolBoxLeftX, containerTopY),
new PVector(toolBoxWidth, containerHeight)));
_grid = new Cell[toolBoxNumCellsX][toolBoxNumCellsY];
_canvas = canvas;
Expand Down Expand Up @@ -54,11 +54,11 @@ class ToolBox extends Being {
_grid[1][5].setTool(templateHexagon);

//circletool
Tool templateCircleTool = makeTool(CIRCLETOOL,
Tool templateHCircleTool = makeTool(CIRCLETOOL,
new PVector(toolBoxLeftX + 1*cellSideLength+cellSideLength/2,
containerTopY + 7*cellSideLength+cellSideLength/2),
0, PERFECT);
_grid[1][7].setTool(templateCircleTool);
_grid[1][7].setTool(templateHCircleTool);

//wedge
Tool templateWedge = makeTool(WEDGE,
Expand Down
40 changes: 20 additions & 20 deletions examples/Level0/tools.pde
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Tool makeTool(int toolCode, PVector position, double theta, float elasticity) {
break;
case HEXAGON: toReturn = new Hexagon(position, theta, elasticity);
break;
case CIRCLETOOL: toReturn = new CircleTool(position, theta, elasticity);
case CIRCLETOOL: toReturn = new HCircleTool(position, theta, elasticity);
break;
case WEDGE: toReturn = new Wedge(position, theta, elasticity);
break;
Expand All @@ -122,21 +122,21 @@ Tool makeTool(int toolCode, PVector position, double theta, float elasticity) {
class Quadrangle extends Tool {

Quadrangle(PVector center, double theta, float elasticity) {
super(Polygon.createRegularPolygon(center, 4, cellSideLength/2),
super(HPolygon.createRegularHPolygon(center, 4, cellSideLength/2),
new PVector(0, 0), Float.POSITIVE_INFINITY, elasticity, QUADRANGLE);
this.rotate(theta);
}

void rotate(double theta) {
super.rotate(theta);
((Polygon)this.getShape()).rotate(theta);
((HPolygon)this.getShape()).rotate(theta);
}

void draw() {
super.draw();
getShape().draw();
/*if(getElasticity() == STICKY) {
Polygon p = (Polygon) getShape();
HPolygon p = (HPolygon) getShape();
drawCilia(p);
}*/
}
Expand All @@ -152,21 +152,21 @@ class Triangle extends Tool {
boolean _doubleClick = false;

Triangle(PVector center, double theta, float elasticity) {
super(Polygon.createRegularPolygon(center, 3, cellSideLength/2),
super(HPolygon.createRegularHPolygon(center, 3, cellSideLength/2),
new PVector(0, 0), Float.POSITIVE_INFINITY, elasticity, TRIANGLE);
this.rotate(theta);
}

void rotate(double theta) {
super.rotate(theta);
((Polygon)this.getShape()).rotate(theta);
((HPolygon)this.getShape()).rotate(theta);
}

void draw() {
super.draw();
getShape().draw();
/*if(getElasticity() == STICKY) {
Polygon p = (Polygon) getShape();
HPolygon p = (HPolygon) getShape();
drawCilia(p);
}*/
//TODO: add handle
Expand All @@ -179,21 +179,21 @@ class Triangle extends Tool {
class Hexagon extends Tool {

Hexagon(PVector center, double theta, float elasticity) {
super(Polygon.createRegularPolygon(center, 6, cellSideLength/2),
super(HPolygon.createRegularHPolygon(center, 6, cellSideLength/2),
new PVector(0, 0), Float.POSITIVE_INFINITY, elasticity, HEXAGON);
this.rotate(theta);
}

void rotate(double theta) {
super.rotate(theta);
((Polygon)this.getShape()).rotate(theta);
((HPolygon)this.getShape()).rotate(theta);
}

void draw() {
super.draw();
getShape().draw();
/*if(getElasticity() == STICKY) {
Polygon p = (Polygon) getShape();
HPolygon p = (HPolygon) getShape();
drawCilia(p);
}*/
}
Expand All @@ -203,10 +203,10 @@ class Hexagon extends Tool {
/**
* Circular tool
*/
class CircleTool extends Tool {
class HCircleTool extends Tool {

CircleTool(PVector center, double theta, float elasticity) {
super(new Circle(center, cellSideLength/2),
HCircleTool(PVector center, double theta, float elasticity) {
super(new HCircle(center, cellSideLength/2),
new PVector(0, 0), Float.POSITIVE_INFINITY, elasticity, CIRCLETOOL);
}

Expand All @@ -217,7 +217,7 @@ class CircleTool extends Tool {
popMatrix();
/*if(getElasticity() == STICKY) {
stroke(0);
Circle c = (Circle) getShape();
HCircle c = (HCircle) getShape();
float r = c.getRadius();
PVector initDir = new PVector(0,1); //Set the initial direction for silia
initDir.mult(r); // Multiply it out to the edge of the circle
Expand Down Expand Up @@ -247,11 +247,11 @@ class Wedge extends Tool {

void rotate(double theta) {
super.rotate(theta);
((Polygon) getShape()).rotate(theta);
((HPolygon) getShape()).rotate(theta);
/*double rot = (_totalRotation + PI/4) % (2*PI);
int sector = ((Double) (rot/(PI*2))).intValue();
if(sector != _sector) {
Polygon p = (Polygon) getShape();
HPolygon p = (HPolygon) getShape();
int alter = sector - _sector;
p.rotate(PI/2 * alter);
}*/
Expand All @@ -261,7 +261,7 @@ class Wedge extends Tool {
super.draw();
getShape().draw();
/*if(getElasticity() == STICKY) {
Polygon p = (Polygon) getShape();
HPolygon p = (HPolygon) getShape();
drawCilia(p);
}*/
}
Expand All @@ -271,19 +271,19 @@ class Wedge extends Tool {
* Factory method for generating wedge polygons
* Required for super of wedge
*/
Polygon generateWedge(PVector center) {
HPolygon generateWedge(PVector center) {
ArrayList<PVector> points = new ArrayList<PVector>();
points.add(new PVector(cellSideLength/2,cellSideLength/2));
points.add(new PVector(-cellSideLength/2,cellSideLength/2));
points.add(new PVector(-cellSideLength/2,-cellSideLength/2));
return new Polygon(center,points);
return new HPolygon(center,points);
}

/**
* Helper method for drawing cilia on sides of sticky objects
* Currently not used
*/
void drawCilia(Polygon p) {
void drawCilia(HPolygon p) {
stroke(0);
ArrayList<PVector> points = p.getPointsCopy();
int psize = points.size();
Expand Down
2 changes: 1 addition & 1 deletion examples/PlatformExplorer/Platform.pde
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Platform extends MassedBeing {
* makes a Platform with given center and width
*/
Platform(PVector center, float width) {
super(new Rectangle(center, width, HEIGHT), HermesMath.zeroVector(), HermesMath.INFINITY, 1);
super(new HRectangle(center, width, HEIGHT), HermesMath.zeroVector(), HermesMath.INFINITY, 1);

this.width = width;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/PlatformExplorer/PlatformGenerator.pde
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class PlatformGenerator extends Interactor<SectorGrid, HCamera> {
void handle(SectorGrid grid, HCamera cam) {
Sector current = grid.getCurrentSector();
// see which neighbors of this sector the camera overlaps with
Rectangle[] neighbors = current.getNeighborRects();
HRectangle[] neighbors = current.getNeighborRects();
for(int i = 0; i < 8; i++) {
if(cam.getBoundingBox().collide(neighbors[i])) {
int x = (int)neighbors[i].getPosition().x / Sector.SECTOR_SIZE;
Expand Down
2 changes: 1 addition & 1 deletion examples/PlatformExplorer/PlatformGroup.pde
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PlatformGroup extends Group<Platform> {
/**
* fills an area with randomly-placed platforms
*/
void generatePlatforms(Rectangle area, float verticalStep, float density) {
void generatePlatforms(HRectangle area, float verticalStep, float density) {
float boxWidth = area.getWidth();
float boxHeight = area.getHeight();
float maxPlatWidth = boxWidth / 2;
Expand Down
2 changes: 1 addition & 1 deletion examples/PlatformExplorer/Player.pde
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Player extends MassedBeing {
int animIndex;

Player(float x, float y) {
super(new Rectangle(HermesMath.makeVector(x, y), PLAYER_WIDTH, PLAYER_HEIGHT), HermesMath.zeroVector(), 1.0f, 1.0f);
super(new HRectangle(HermesMath.makeVector(x, y), PLAYER_WIDTH, PLAYER_HEIGHT), HermesMath.zeroVector(), 1.0f, 1.0f);

// load the animated character walk cycle
sprite = new AnimatedSprite();
Expand Down
12 changes: 6 additions & 6 deletions examples/PlatformExplorer/Sector.pde
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static class Sector extends Being {
final static int SECTOR_SIZE = 1800; // pixel width of the sectors
final static float VERTICAL_STEP = 120; // vertical space between platforms

Rectangle rectangle; // the rectangle
HRectangle rectangle; // the rectangle

int x, y; // coordinates -- these are in sector space (1 unit per sector), not pixel space

Expand All @@ -23,14 +23,14 @@ static class Sector extends Being {
platforms.generatePlatforms(rectangle, VERTICAL_STEP, density);
}

// the Rectangle defining the sector at this position
static Rectangle rectOfSector(int x, int y) {
return new Rectangle(new PVector((float)(x * SECTOR_SIZE), (float)(y * SECTOR_SIZE), 0), SECTOR_SIZE, SECTOR_SIZE);
// the HRectangle defining the sector at this position
static HRectangle rectOfSector(int x, int y) {
return new HRectangle(new PVector((float)(x * SECTOR_SIZE), (float)(y * SECTOR_SIZE), 0), SECTOR_SIZE, SECTOR_SIZE);
}

// rectangles of the neighbors of this sector
Rectangle[] getNeighborRects() {
Rectangle[] rects = new Rectangle[8];
HRectangle[] getNeighborRects() {
HRectangle[] rects = new HRectangle[8];
rects[0] = rectOfSector(x, y - 1); // north
rects[1] = rectOfSector(x, y + 1); // south
rects[2] = rectOfSector(x + 1, y); // east
Expand Down
4 changes: 2 additions & 2 deletions examples/bouncingpolygonsdemo/BallGroup.pde
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ class BallGroup extends Group<Ball> {
ball = new PolyBall(new PVector(_origX, _origY), new PVector(_origX-_dX, _origY-_dY), _newMass, _newElasticity);
break;
case CIRCLE_MODE:
ball = new CircleBall(new PVector(_origX, _origY), new PVector(_origX-_dX, _origY-_dY), _newMass, _newElasticity);
ball = new HCircleBall(new PVector(_origX, _origY), new PVector(_origX-_dX, _origY-_dY), _newMass, _newElasticity);
break;
case RECT_MODE:
ball = new RectBall(new PVector(_origX, _origY), new PVector(_origX-_dX, _origY-_dY), _newMass, _newElasticity);
break;
default:
System.out.println("In an invalid mode");
ball = new CircleBall(new PVector(_origX, _origY), new PVector(_origX-_dX, _origY-_dY), _newMass, _newElasticity);
ball = new HCircleBall(new PVector(_origX, _origY), new PVector(_origX-_dX, _origY-_dY), _newMass, _newElasticity);
break;
}
getWorld().register(ball);
Expand Down
14 changes: 7 additions & 7 deletions examples/bouncingpolygonsdemo/Balls.pde
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ abstract class Ball extends MassedBeing {

/**
* Creates a polygonal ball
* Uses factory method inside of Polygon to create the polygons
* Uses factory method inside of HPolygon to create the polygons
*/
class PolyBall extends Ball {
PolyBall(PVector center, PVector velocity, float mass, float elasticity) {
super(Polygon.createRegularPolygon(center,polyPoint,ballSize * mass), velocity, mass, elasticity);
((Polygon) getShape()).rotate(polyRot);
super(HPolygon.createRegularHPolygon(center,polyPoint,ballSize * mass), velocity, mass, elasticity);
((HPolygon) getShape()).rotate(polyRot);
}
}

/**
* Creates a circular ball
*/
class CircleBall extends Ball {
CircleBall(PVector center, PVector velocity, float mass, float elasticity) {
super(new Circle(center, ballSize * mass), velocity, mass, elasticity);
class HCircleBall extends Ball {
HCircleBall(PVector center, PVector velocity, float mass, float elasticity) {
super(new HCircle(center, ballSize * mass), velocity, mass, elasticity);
}
}

Expand All @@ -54,6 +54,6 @@ class CircleBall extends Ball {
*/
class RectBall extends Ball {
RectBall(PVector center, PVector velocity, float mass, float elasticity) {
super(new Rectangle(center, ballSize * mass, ballSize * mass), velocity, mass, elasticity);
super(new HRectangle(center, ballSize * mass, ballSize * mass), velocity, mass, elasticity);
}
}
2 changes: 1 addition & 1 deletion examples/bouncingpolygonsdemo/Box.pde
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
class Box extends MassedBeing {
Box() {
super(new Rectangle(new PVector(0,0), new PVector(0,0), new PVector((float)WIDTH,(float)HEIGHT)), new PVector(0,0), Float.POSITIVE_INFINITY, 1);
super(new HRectangle(new PVector(0,0), new PVector(0,0), new PVector((float)WIDTH,(float)HEIGHT)), new PVector(0,0), Float.POSITIVE_INFINITY, 1);
}

void draw() {}
Expand Down
2 changes: 1 addition & 1 deletion examples/bouncingpolygonsdemo/bouncingpolygonsdemo.pde
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Click and release mouse to create shapes
* Drag to give polygon velocity
* Use the '1', '2', and '3' keys to choose shape
* '1' = Rectangle, '2' = Circle, '3' = Polygon
* '1' = HRectangle, '2' = HCircle, '3' = HPolygon
* Use the 'd' key to delete shapes
*
* OSC demo:
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorialA/GlitchySquare.pde
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class GlitchySquare extends Being {
static final int SHAKE_STEP = 10;

GlitchySquare(int x, int y) {
super(new Rectangle(x, y, WIDTH, HEIGHT));
super(new HRectangle(x, y, WIDTH, HEIGHT));
_c = pickColor();
}

Expand Down
Loading

0 comments on commit 3b16180

Please sign in to comment.