Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
311 changes: 123 additions & 188 deletions lajik/lajik.pde
Original file line number Diff line number Diff line change
Expand Up @@ -220,204 +220,21 @@ void gameSetup() {

myLevel = new Level();

float units = width/30;

world.setEdges(-width/2, -height, units*159, units*60);

//InitPlayerModel
playerModel = new FBox(units, units);
playerModel = new FBox(width/30, width/30);

//Setup playermodel
playerModel.setBullet(true);
playerModel.setNoStroke();
playerModel.setFill(255, 255, 255);
playerModel.setPosition(width/2, height/2);
playerModel.setPosition(0, 0);
playerModel.setFriction(0.01);
playerModel.setDensity(2.0);
playerModel.setRestitution(0.0);

createGround();

//starter platform
/*groundTest = new FBox(width, 50);
groundTest.setFillColor(#303030);
groundTest.setFriction(0.1);
groundTest.setStatic(true);
groundTest.setPosition(width/2, height-50);

myLevel.static_objects.add(groundTest);

//starter platform bottom and sides.
groundTest = new FBox(width+2, 50+1);
groundTest.setFriction(0.1);
groundTest.setStatic(true);
groundTest.setPosition(width/2, height-50+2);
groundTest.setFill(0, 0, 0, 0);
groundTest.setNoStroke();
myLevel.static_objects_walls.add(groundTest);

groundTest = new FBox(3072, 25);
groundTest.setFillColor(#303030);
groundTest.setFriction(0.1);
groundTest.setStatic(true);
groundTest.setPosition(512, 1501);

myLevel.static_objects.add(groundTest);*/

/*groundTest = new FBox(30, 500);
groundTest.setFillColor(#303030);
groundTest.setFriction(0.1);
groundTest.setStatic(true);
groundTest.setPosition(15, 993);

myLevel.static_objects_walls.add(groundTest);*/

//create the steps

/*for (int i = 0;i < 4;i++) {
groundTest = new FBox(100, 10);
groundTest.setFillColor(#303030);
groundTest.setFriction(0.1);
groundTest.setStatic(true);
groundTest.setPosition(-150-205*i, 900+185*i);

myLevel.static_objects.add(groundTest);

groundTest = new FBox(104, 11);
groundTest.setFriction(0.1);
groundTest.setStatic(true);
groundTest.setPosition(-150-205*i, 900+185*i+2);
//groundTest.setStroke(255,0,0);
groundTest.setFill(0, 0, 0, 0);
groundTest.setNoStroke();
myLevel.static_objects_walls.add(groundTest);
}*/

for (int i=0;i<myLevel.static_objects.size();i++) {
world.add(myLevel.static_objects.get(i));
}
for (int i=0;i<myLevel.static_objects_walls.size();i++) {
world.add(myLevel.static_objects_walls.get(i));
}

world.add(playerModel);


//Fisica.setScale(1);

rectMode(RADIUS);
}

void introScreenDraw() {
if (keyEnter) {
current_state = STATE_CREDITS;
introScreenSetup();
}
else {
physics.update();

for (VParticle p : physics.particles) {
drawRectangle(p);
}
textSize(100);

fill(12);
text("läjik", (width/2)-(150)+5, (height/2)+5);

fill(225, 223, 222);
text("läjik", (width/2)-(150), (height/2));
textSize(30);

fill(12);
text("Press Enter", (width/2)-(95)+3, (height*3/4)+3);

fill(225, 223, 222);
text("Press Enter", (width/2)-(95), (height*3/4));

fill(30, 12);
rect(0, 0, width, height);
}
}

void creditsDraw() {
if (keyEnter) {
current_state = STATE_GAME;
gameSetup();
}
else {
fill(255, 255);

physics.update();

for (VParticle p : physics.particles) {
drawRectangle(p);
}

fill(12);
text("By:", (width/2)-20+3, (height*1/8)+3);

fill(225, 223, 222);
text("By:", (width/2)-20, (height*1/8));

textSize(30);

fill(12);
text("Nicholas Hylands", (width/2)-(125)+3, (height*1/5)+3);

fill(225, 223, 222);
text("Nicholas Hylands", (width/2)-(125), (height*1/5));

fill(12);
text("Katrina Vetzal", (width/2)-(105)+3, (height*2/5)+3);

fill(225, 223, 222);
text("Katrina Vetzal", (width/2)-(105), (height*2/5));

fill(12);
text("Matthew McMurray", (width/2)-(125)+3, (height*3/5)+3);

fill(225, 223, 222);
text("Matthew McMurray", (width/2)-(125), (height*3/5));

fill(12);
text("Press Enter", (width/2)-(95)+3, (height*4/5)+3);

fill(225, 223, 222);
text("Press Enter", (width/2)-(95), (height*4/5));

fill(30, 12);
rect(0, 0, width, height);
}
}

int y = 0;

void drawRectangle(VParticle p) {
stroke(255, 0);

fill(255, 150);
float deform = p.getVelocity().mag();
float rad = p.getRadius();
deform = map(deform, 0, 1.5f, rad, 0);
deform = max (rad *.2f, deform);

float rotation = p.getVelocity().heading();

pushMatrix();
translate(p.x, p.y);
rotate(HALF_PI*.5f+rotation);
beginShape();
vertex(-rad, +rad);
vertex(deform, deform);
vertex(rad, -rad);
vertex(-deform, -deform);
endShape(CLOSE);
popMatrix();
}

void createGround() {
float units = width/30;
FBox oldBox;
float units = playerModel.getWidth();

world.setEdges(-width/2, -height, units*159, units*60);

float boxWidth = units*30;
float boxHeight = units*60;
Expand Down Expand Up @@ -542,6 +359,17 @@ void createGround() {
boxX = oldBox.getX()-(oldBox.getWidth()/2)-(units*30)+(boxWidth/2);
boxY = oldBox.getY()+(oldBox.getHeight()/2);
oldBox = makeBox(boxWidth, boxHeight, boxX, boxY);

for (int i=0;i<myLevel.static_objects.size();i++) {
world.add(myLevel.static_objects.get(i));
}
for (int i=0;i<myLevel.static_objects_walls.size();i++) {
world.add(myLevel.static_objects_walls.get(i));
}

world.add(playerModel);

rectMode(RADIUS);
}

FBox makeBox(float boxWidth, float boxHeight, float boxX, float boxY) {
Expand All @@ -560,3 +388,110 @@ FBox makeBox(float boxWidth, float boxHeight, float boxX, float boxY) {
myLevel.static_objects_walls.add(wall);
return box;
}

void introScreenDraw() {
if (keyEnter) {
current_state = STATE_CREDITS;
introScreenSetup();
}
else {
physics.update();

for (VParticle p : physics.particles) {
drawRectangle(p);
}
textSize(100);

fill(12);
text("läjik", (width/2)-(150)+5, (height/2)+5);

fill(225, 223, 222);
text("läjik", (width/2)-(150), (height/2));
textSize(30);

fill(12);
text("Press Enter", (width/2)-(95)+3, (height*3/4)+3);

fill(225, 223, 222);
text("Press Enter", (width/2)-(95), (height*3/4));

fill(30, 12);
rect(0, 0, width, height);
}
}

void creditsDraw() {
if (keyEnter) {
current_state = STATE_GAME;
gameSetup();
}
else {
fill(255, 255);

physics.update();

for (VParticle p : physics.particles) {
drawRectangle(p);
}

fill(12);
text("By:", (width/2)-20+3, (height*1/8)+3);

fill(225, 223, 222);
text("By:", (width/2)-20, (height*1/8));

textSize(30);

fill(12);
text("Nicholas Hylands", (width/2)-(125)+3, (height*1/5)+3);

fill(225, 223, 222);
text("Nicholas Hylands", (width/2)-(125), (height*1/5));

fill(12);
text("Katrina Vetzal", (width/2)-(105)+3, (height*2/5)+3);

fill(225, 223, 222);
text("Katrina Vetzal", (width/2)-(105), (height*2/5));

fill(12);
text("Matthew McMurray", (width/2)-(125)+3, (height*3/5)+3);

fill(225, 223, 222);
text("Matthew McMurray", (width/2)-(125), (height*3/5));

fill(12);
text("Press Enter", (width/2)-(95)+3, (height*4/5)+3);

fill(225, 223, 222);
text("Press Enter", (width/2)-(95), (height*4/5));

fill(30, 12);
rect(0, 0, width, height);
}
}

int y = 0;

void drawRectangle(VParticle p) {
stroke(255, 0);

fill(255, 150);
float deform = p.getVelocity().mag();
float rad = p.getRadius();
deform = map(deform, 0, 1.5f, rad, 0);
deform = max (rad *.2f, deform);

float rotation = p.getVelocity().heading();

pushMatrix();
translate(p.x, p.y);
rotate(HALF_PI*.5f+rotation);
beginShape();
vertex(-rad, +rad);
vertex(deform, deform);
vertex(rad, -rad);
vertex(-deform, -deform);
endShape(CLOSE);
popMatrix();
}