From 7e04c3a9ef31a704c1f82dd0a92924b2d761f099 Mon Sep 17 00:00:00 2001 From: Daniel <59575049+lumijiez@users.noreply.github.com> Date: Wed, 17 Jan 2024 21:53:56 +0200 Subject: [PATCH] Add files via upload --- Balloon.pde | 28 +++++++++++++++++----------- Block.pde | 9 +++++++++ Butterfly.pde | 2 +- Config.pde | 8 ++++---- Main.pde | 26 +++++++++++++++++++------- Particle.pde | 33 +++++++++++++++++++++++++++++++++ Terrain.pde | 19 +++++++++++++++++-- sketch.properties | 1 + 8 files changed, 101 insertions(+), 25 deletions(-) create mode 100644 Particle.pde create mode 100644 sketch.properties diff --git a/Balloon.pde b/Balloon.pde index bb2c6b8..21a2d71 100644 --- a/Balloon.pde +++ b/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(); diff --git a/Block.pde b/Block.pde index 986007f..e73a51c 100644 --- a/Block.pde +++ b/Block.pde @@ -6,11 +6,20 @@ class Block { boolean isFlower; int treeSize; color treeColor; + ArrayList 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)); } } diff --git a/Butterfly.pde b/Butterfly.pde index d3172b1..7ab7e48 100644 --- a/Butterfly.pde +++ b/Butterfly.pde @@ -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); diff --git a/Config.pde b/Config.pde index 16f293f..ce09b51 100644 --- a/Config.pde +++ b/Config.pde @@ -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; diff --git a/Main.pde b/Main.pde index 28a2e11..a337901 100644 --- a/Main.pde +++ b/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(); } diff --git a/Particle.pde b/Particle.pde new file mode 100644 index 0000000..cc9f825 --- /dev/null +++ b/Particle.pde @@ -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(); + } +} diff --git a/Terrain.pde b/Terrain.pde index 031bc2d..8e2048c 100644 --- a/Terrain.pde +++ b/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(); + } } diff --git a/sketch.properties b/sketch.properties new file mode 100644 index 0000000..1457bbd --- /dev/null +++ b/sketch.properties @@ -0,0 +1 @@ +main=Main.pde