Add files via upload
This commit is contained in:
28
Balloon.pde
28
Balloon.pde
@@ -7,11 +7,13 @@ class Balloon {
|
||||
PVector velocity;
|
||||
PVector acceleration;
|
||||
float lastWindChangeTime;
|
||||
PShape s;
|
||||
|
||||
Balloon(float x, float y, float z) {
|
||||
Balloon(float x, float y, float z, PShape s) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.s = s;
|
||||
this.radius = 50;
|
||||
this.velocity = new PVector(0, 0, 0);
|
||||
this.acceleration = new PVector(0, 0, 0);
|
||||
@@ -46,19 +48,23 @@ class Balloon {
|
||||
z += 2;
|
||||
|
||||
translate(x, y, z);
|
||||
rotateY(PI);
|
||||
scale(4);
|
||||
|
||||
fill(255, 0, 0);
|
||||
noStroke();
|
||||
sphere(radius);
|
||||
stroke(1);
|
||||
//fill(255, 0, 0);
|
||||
//noStroke();
|
||||
//sphere(radius);
|
||||
//stroke(1);
|
||||
|
||||
drawLeg(-radius / 2, -radius / 2);
|
||||
drawLeg(radius / 2, -radius / 2);
|
||||
drawLeg(-radius / 2, radius / 2);
|
||||
drawLeg(radius / 2, radius / 2);
|
||||
//drawLeg(-radius / 2, -radius / 2);
|
||||
//drawLeg(radius / 2, -radius / 2);
|
||||
//drawLeg(-radius / 2, radius / 2);
|
||||
//drawLeg(radius / 2, radius / 2);
|
||||
|
||||
translate(0, 0, -75);
|
||||
box(70, 70, 25);
|
||||
//translate(0, 0, -75);
|
||||
//box(70, 70, 25);
|
||||
|
||||
shape(s);
|
||||
|
||||
applyBuoyancy();
|
||||
applyDamping();
|
||||
|
||||
@@ -6,11 +6,20 @@ class Block {
|
||||
boolean isFlower;
|
||||
int treeSize;
|
||||
color treeColor;
|
||||
ArrayList<Particle> particles = new ArrayList<>();
|
||||
Block(int x, int y, float h, color treeColor, int treeSize) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.h = h;
|
||||
this.treeColor = treeColor;
|
||||
this.treeSize = treeSize;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
float angleInRadians = map(i, 0, 10, 0, TWO_PI);
|
||||
particles.add(new Particle(cubeWidth * cos(angleInRadians), cubeWidth * sin(angleInRadians), 0, this, random(0.5, 1), h/2));
|
||||
}
|
||||
}
|
||||
|
||||
void drawParticles(float posZ) {
|
||||
particles.forEach(particle -> particle.display(posZ));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class Butterfly {
|
||||
void draw() {
|
||||
pushMatrix();
|
||||
rotateX(HALF_PI);
|
||||
|
||||
// (terrainLength / 10)
|
||||
z = map(noise(perlinOffsetX, millis() * 0.0002), 0, 1, 400, 600);
|
||||
x = map(noise(perlinOffsetY, millis() * 0.0001), 0, 1, 0, terrainLength * cubeWidth);
|
||||
y = map(noise(perlinOffsetZ, millis() * 0.0001), 0, 1, 0, terrainWidth * cubeWidth);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
int terrainLength = 1000;
|
||||
int terrainWidth = 1000;
|
||||
int terrainLength = 100;
|
||||
int terrainWidth = 100;
|
||||
|
||||
int minTreeHeight = 20;
|
||||
int maxTreeHeight = 70;
|
||||
|
||||
float noiseStep = 0.02;
|
||||
float noiseScale = 5;
|
||||
long randomSeedValue = 55;
|
||||
long noiseSeedValue = 254;
|
||||
long randomSeedValue = 45;
|
||||
long noiseSeedValue = 2544;
|
||||
int noiseOctaves = 4;
|
||||
float noiseFalloff = 0.5;
|
||||
|
||||
|
||||
26
Main.pde
26
Main.pde
@@ -1,8 +1,9 @@
|
||||
PVector camPosition = new PVector(1000, -700, 700);
|
||||
PVector camPosition1 = new PVector(1000, -700, 700);
|
||||
PVector lookAt = new PVector(0, 0, -1);
|
||||
PVector wind = new PVector(5, -8, 0);
|
||||
Terrain terra = new Terrain();
|
||||
Balloon balloon = new Balloon(50 * 20, 50 * 20, 20 * 20);
|
||||
PImage skyboxImage;
|
||||
|
||||
void setup() {
|
||||
fullScreen(P3D);
|
||||
@@ -13,6 +14,8 @@ void setup() {
|
||||
noiseSeed(noiseSeedValue);
|
||||
noiseDetail(noiseOctaves, noiseFalloff);
|
||||
|
||||
skyboxImage = loadImage("hot.jpg");
|
||||
|
||||
terra.setup();
|
||||
terra.reloadTrees();
|
||||
}
|
||||
@@ -61,9 +64,9 @@ void draw() {
|
||||
PVector right = lookAt.cross(new PVector(0, -1, 0));
|
||||
camPosition.sub(PVector.mult(right, camSpeed));
|
||||
}
|
||||
|
||||
if (key == 'r') terra.blocks.get(0).x += 1;
|
||||
if (key == 'f') terra.blocks.get(0).y += 1;
|
||||
|
||||
if (key == 'r') terra.blocks.get(0).x += 1;
|
||||
if (key == 'f') terra.blocks.get(0).y += 1;
|
||||
}
|
||||
|
||||
camera(camPosition.x, camPosition.y, camPosition.z, camPosition.x + lookAt.x, camPosition.y + lookAt.y, camPosition.z + lookAt.z, 0, 1, 0);
|
||||
@@ -71,7 +74,16 @@ void draw() {
|
||||
|
||||
terra.drawTerrain(camPosition);
|
||||
|
||||
PVector windForce = wind.copy().mult(0.1);
|
||||
balloon.applyForce(windForce);
|
||||
balloon.draw();
|
||||
// Draw the skybox
|
||||
//drawSkySphere(500);
|
||||
}
|
||||
|
||||
void drawSkySphere(float radius) {
|
||||
pushMatrix();
|
||||
noStroke();
|
||||
translate(camPosition1.x, camPosition1.y, camPosition1.z);
|
||||
textureMode(NORMAL);
|
||||
texture(skyboxImage);
|
||||
sphere(radius);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
33
Particle.pde
Normal file
33
Particle.pde
Normal file
@@ -0,0 +1,33 @@
|
||||
class Particle {
|
||||
float x, y, z;
|
||||
float speed;
|
||||
color col;
|
||||
float permOffset;
|
||||
float offset = 0;
|
||||
Block block;
|
||||
|
||||
Particle(float x, float y, float z, Block block, float speed, float treeSize) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.block = block;
|
||||
this.speed = speed;
|
||||
this.permOffset = -150 - treeSize;
|
||||
}
|
||||
|
||||
void update() {
|
||||
offset -= speed;
|
||||
if (offset < -100) offset = 0;
|
||||
}
|
||||
|
||||
void display(float posZ) {
|
||||
pushMatrix();
|
||||
translate(x, y, posZ + permOffset + offset);
|
||||
fill(block.treeColor);
|
||||
float scaleDown = map(offset, 0, -150, 1, 10);
|
||||
box(10/scaleDown, 8/scaleDown, 8/scaleDown);
|
||||
scale(offset);
|
||||
popMatrix();
|
||||
update();
|
||||
}
|
||||
}
|
||||
19
Terrain.pde
19
Terrain.pde
@@ -3,6 +3,7 @@ class Terrain {
|
||||
ArrayList < Bird > birds = new ArrayList < > ();
|
||||
ArrayList < Butterfly > butterflies = new ArrayList < > ();
|
||||
float blue = 100;
|
||||
float particleOffset;
|
||||
float bluedirection = -0.25;
|
||||
|
||||
void addButterfly() {
|
||||
@@ -24,6 +25,8 @@ class Terrain {
|
||||
if (random(0, 1) < 0.001) addButterfly();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void reloadTrees() {
|
||||
@@ -76,7 +79,7 @@ class Terrain {
|
||||
float posY = block.y * cubeLength;
|
||||
float posZ = blockHeight / 2.0;
|
||||
|
||||
if (dist(posX, 0.0, posY, position.x, 0.0, position.z) > 1500) return;
|
||||
if (dist(posX, 0.0, posY, position.x, 0.0, position.z) > 2000) return;
|
||||
|
||||
pushMatrix();
|
||||
|
||||
@@ -84,7 +87,10 @@ class Terrain {
|
||||
translate(posX, posY, posZ);
|
||||
box(cubeWidth, cubeLength, blockHeight);
|
||||
|
||||
if (block.isTree && blockHeight < 350) drawNormalTree(block, posZ);
|
||||
if (block.isTree && blockHeight < 350) {
|
||||
drawNormalTree(block, posZ);
|
||||
block.drawParticles(posZ);
|
||||
}
|
||||
else if (block.isTree) drawPineTree(block, posZ);
|
||||
|
||||
else if (block.isFlower && blockHeight < 350) drawFlower(block, posZ);
|
||||
@@ -139,4 +145,13 @@ else if (block.isFlower && blockHeight < 350) drawFlower(block, posZ);
|
||||
sphere(10);
|
||||
stroke(1);
|
||||
}
|
||||
|
||||
void drawParticle(float x, float y, float z, color col) {
|
||||
pushMatrix();
|
||||
translate(x, y, particleOffset);
|
||||
particleOffset -= random(0, 0.001);
|
||||
fill(col);
|
||||
box(10, 10, 10);
|
||||
popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
1
sketch.properties
Normal file
1
sketch.properties
Normal file
@@ -0,0 +1 @@
|
||||
main=Main.pde
|
||||
Reference in New Issue
Block a user