Coding Challenge #4: Purple Rain in Processing

preview_player
Показать описание


Related Coding Challenges:

Timestamps:
00:00 Introduction to the challenge
00:37 Setup the sketch
01:08 Create a Drop class
02:45 Set initial values and create a Drop object
03:23 Create an array of drops
04:27 Randomize initial values
05:30 Reset raindrop location when offscreen
06:11 Few more improvements
06:56 Add gravity
08:26 Add z value for 3d illusion
11:29 Final Version!

Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound

#purplerain #processing
Рекомендации по теме
Комментарии
Автор

I can't believe how easy he makes coding look.

TheJaredtheJaredlong
Автор

As a complete noob at this with no knowledge about the programmer language or something this little code really facinated me! Even though I couldnt code this in years I could follow your explanation through the whole video. Great work!

max
Автор

Idk what's going on but I'm very interested

ar_x
Автор

Why do programmers need glasses? Because they can't C#.

Random-ydoh
Автор

7:23 every programmer after 10 second of coding

Автор

Why am I here watching a man making a purple rain I don't even know coding

nguyenthanhdat
Автор

So glad I just ran into this channel. The personality he brings into his work is a breath of fresh air and feels a lot more engaging than other channels that explore programming. Might actually find myself binge watching this guy instead of Netflix haha

TheNewVoxel
Автор

To get a better 3D effect you should map more raindrops further away than raindrops closer by. This is because the further away something is the more of it you see, if you stand 2in in front of a house you will see only a small portion of the wall. step a mile away and you will see the house and the neighborhood. That would make the 3D effect you were gunning for more pronounced

unpronouncable
Автор

The thing I love about programmers is that they see the entire world in a different perspective. instead of "wow that's a fun game" they wonder how it was made :)

iamLucid
Автор

I once made some realistic rain in after effects using Javascript expressions. Making rain and watching it fall makes you feel something, man.

davidm.johnston
Автор

you forgot that there should be much more drops in the back than in the front. thats why it doesnt look realistic.

nasekiller
Автор

um, rain is falling at terminal velocity - you don't need acceleration due to gravity

spoonikle
Автор

I know this is late but I translated this to [c++/sfml]

#include <SFML\Graphics.hpp>
#include <Windows.h>
#include <iostream>
#include <ctime>
#include <thread>

#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600

unsigned random(unsigned max) {
static int seed = 22;
srand((unsigned)time(NULL));
seed += rand() % 1000;
srand(seed);
return rand() % max;
}

class Drop
{
sf::RectangleShape* drop;
int dropSpeed;
int l, w;
public:
Drop(int x, int y, int l, int w) {
drop = new sf::RectangleShape(sf::Vector2f(w, l));
drop->setPosition(sf::Vector2f(x, y));

dropSpeed = random(6) + 1;
this->l = l;
}
void fall() { drop->move(sf::Vector2f(0, dropSpeed * (random(5) + 1))); }
void boundary() {
if (drop->getPosition().y > SCREEN_HEIGHT)
drop->setPosition(random(SCREEN_WIDTH), 0 - l);
}
sf::RectangleShape dropObj() {
return *drop;
}
};

int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "Window");


const int numOfDrops = 250;

Drop* drop[numOfDrops];
for (int i = 0; i < numOfDrops; i++) {
drop[i] = new Drop(random(SCREEN_WIDTH) + random(100), random(SCREEN_HEIGHT) + random(100), random(40) + 20, 3);
}

while (window.isOpen())
{
sf::Event e;
while (window.pollEvent(e))
{
if (e.type == sf::Event::Closed)
window.close();
}

for (int i = 0; i < numOfDrops; i++) {
drop[i]->fall();
drop[i]->boundary();
}




for (int i = 0; i < numOfDrops; i++)


window.display();

}

}


Thanks for the heart!

rizzutohd
Автор

I don't know why you added gravity, by the time we see rain it's long reached its terminal velocity.

KrazeeCain
Автор

Why is this recommended? Ive never watched a video on coding and this is 7 months old

bark
Автор

ohh man.. your creativity and problem solving is amazing.

khoeraine
Автор

This is actually the first time a java code seemed clear to me.

titarch
Автор

This fast way of showing when you are programming is really educational because it shows the way you are 'figuring out' how to solve the problems. Thanks for the video and great job.

Nonehasthisnamekek
Автор

I'm amazed you made programming actually entertaining to watch.

agaaquino
Автор

i think visually it makes more sense to have fewer closer objects. Not sure how you would do that, but the parallax effect would be a lot clearer that way (also makes sense for there to be fewer closer objects as the area you see is smaller closer)

benman