Share your repls and programming experiences

← Back to all posts
Rain
matthewproskils (461)

I tried this in python once by doing it by hand, but it was WAYY to hard so I just did this instead.

Anyway, here you go, some satisfying rain.

Edit: kinda snow I guess?

YEEE Trending Boys (and girls) (and non binary people)

Comments
hotnewtop
RoyalCoder1234 (34)

In the Northern Hemisphere, it is so cold that the rain you made became snow. My backyard is now Mt. Everest. Love the work!

HimanshuShekha4 (50)

@RoyalCoder1234 I dont know how do u manage to live at the pole ...

I live in India which is somewhat near the equator and still during this season we are like we dont wanna get out of the bed

firefish (936)

@HimanshuShekha4 no, The poles are at 90 degrees latitude either way.
The furthest north livable terrain is at 78 degrees north, at Svalbard, just north of norway. And they don't have internet there.

RoyalCoder1234 (34)

@firefish Thx for the info. I guess my joke wasn't scientifically correct.

gwynethwingell (55)

@RoyalCoder1234 that is the best joke I have heard from the time I came in to repl.it🤣🤣😂

elipie (372)

@gwynethwingell then you havent been on replit. lol

ia13ru (35)

@RoyalCoder1234 Are you sure it isn't one of those video call backgrounds? XD

BuurmenTennus (7)

@matthewproskils can I have the code. When I copy it it says pharse error on line 12. ALWWAYS!!

matthewproskils (461)

@BuurmenTennus https://repl.it/@BuurmenTennus/Rain#main.py Um.. create a .replit file and then move

lang="cpp"
run="clang++-7 -lcurses -pthread -std=c++17 -o main main.cpp && ./main"

there

matthewproskils (461)

@BuurmenTennus Actually, make a new repl with the language of c++

matthewproskils (461)

@matthewproskils Then paste

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <stdlib.h>
#include <unistd.h>
#include <curses.h>

int main() {
	std::vector<std::pair<int, int>> drops = {}; // x, y;
	while(true){
		std::vector<std::string> map = {};
		for(int i=0; i<30;i++){
			map.push_back("                                                                                                                        ");
		}
		drops.push_back(std::make_pair(rand() % (map[0].length()-1), 0));
		for(size_t i = 0; i < drops.size(); i++){
			map[drops[i].second][drops[i].first] = '|';
			drops[i].second++;
			if(drops[i].second == map.size()){
				drops.erase(drops.begin() + i);
				i--;
			}
		}
		std::string str = "";
		for(size_t  j= 0; j < map.size(); j++){
			str = str + map[j] + "\n";
		}
		std::cout << str.c_str();
		usleep(50000);
		continue;
	}
}

into main.cpp

BuurmenTennus (7)

@matthewproskils then I take the lang="cpp"
run="clang++-7 -lcurses -pthread -std=c++17 -o main main.cpp && ./main" and put it there. And just this code

matthewproskils (461)

@BuurmenTennus No. You can just press the 'run' button. It'll work then

RyanGardiner1 (139)

@BaconErie Whats ur Roblox Name? Im NotDudeactual2121

firefish (936)

@BuurmenTennus Or you can hit the fork button.

firefish (936)

@RyanGardiner1 what? You shouldn't be sharing private information

RhinoRunner (633)

tbh it looks more like snow but i still liek it

much0hackerBOI (2)

Me: I feel like going outside today
Rain: Allow us to introduce ourselves

FloCal35 (358)

S A T I S F Y I N G

KobeFF (1287)

ayyy trending! Saw this on my homepage :)

good work :3

CoderKid123 (0)

Can you add options for snow, hail, and regular rain?

ReyesP (23)

At least you made the "|"'s blue.

Ratoku3 (0)

my option is 6, please help me solve it, forgive me for being in Russian, write me an answer here it's my Yudjil#8570

Ratoku3 (0)

my option is 6, please help me solve it, forgive me for being in Russian, write me an answer here Yudjil#8570 it's my discord

CuriousMonkey (44)

im so happy to finally find a c++ project on the trending page

DeBeast591 (134)

It looks even better now! Congrats on the "animation" (Cant say it is one, but I cant say its not either!)

mintbookworm (25)

This is really cool! 🌧☔💦💧

Pizzaz4me (63)

this rain is really satisfyng. I wish whenever it rained it always looks this good

RishabTirupath1 (0)

I never realized there was a ".replit" file. Now I know that I don't have to type "gcc -lncurses" in the shell all the time. Thank you!

Kingoftheof1 (4)

If you want it to be more accurate you could add "std::cout << "\033[34m";" such that the code becomes

#include <vector>
#include <map>
#include <string>
#include <stdlib.h>
#include <unistd.h>
#include <curses.h>

int main() {
  std::cout << "\033[34m"; //Right Here!
	std::vector<std::pair<int, int>> drops = {}; // x, y;
	while(true){
		std::vector<std::string> map = {};
		for(int i=0; i<30;i++){
			map.push_back("                                                                                                                        ");
		}
		drops.push_back(std::make_pair(rand() % (map[0].length()-1), 0));
		for(size_t i = 0; i < drops.size(); i++){
			map[drops[i].second][drops[i].first] = '|';
			drops[i].second++;
			if(drops[i].second == map.size()){
				drops.erase(drops.begin() + i);
				i--;
			}
		}
		std::string str = "";
		for(size_t  j= 0; j < map.size(); j++){
			str = str + map[j] + "\n";
		}
		std::cout << str.c_str();
		usleep(50000);
		continue;
	}
}

This would just make the rain blue.
Also if you want snowflakes (Probably a better way to do it than this but here you go):

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <stdlib.h>
#include <unistd.h>
#include <curses.h>

int main() {
  std::cout << "\033[34m";
	std::vector<std::pair<int, int>> drops = {}; // x, y;
	while(true){
		std::vector<std::string> map = {};
		for(int i=0; i<30;i++){
			map.push_back("                                                                                                                        ");
		}
		drops.push_back(std::make_pair(rand() % (map[0].length()-1), 0));
		for(size_t i = 0; i < drops.size(); i++){
			map[drops[i].second][drops[i].first] = '|';
			drops[i].second++;
			if(drops[i].second == map.size()){
				drops.erase(drops.begin() + i);
				i--;
			}
		}
		std::string str = "";
		for(size_t  j= 0; j < map.size(); j++){
			str = str + map[j] + "\n";
		}
    for(int a = 0;a < str.length();a++){
      if(str[a] == '|'){
        std::cout << "❄";
      }else{
        std::cout << str[a];
      }
    }
		usleep(50000);
		continue;
	}
}
matthewproskils (461)

@Kingoftheof1 🤔 Unicode escape characters... Good idea! Thank you :)

bellabonura21 (89)

a bunch of the letter I... lol cute :)