Coding Challenge 1: Starfield Simulation
Вставка
- Опубліковано 29 чер 2024
- This is the first in a new series of videos. In this video I attempt to program a "star field" or "warp speed" visualization in Processing. Code: thecodingtrain.com/challenges...
🕹️ p5.js Web Editor Sketch: editor.p5js.org/codingtrain/s...
🎥 Next video: • Coding Challenge #2: M...
🎥 All videos: • Coding Challenges
🔴 Coding Train Live 30: • Code Train Live 30: Cr...
References:
🌟 Inspiration: cs.brynmawr.edu/gxk2013/examp...
Related Coding Challenges:
🚂 #27 Fireworks: • Coding Challenge #27: ...
🚂 #46 Asteroids: • Coding Challenge #46.1...
Timestamps:
0:00 Welcome to a 10 minute coding challenge
0:59 Let's create a star class
2:10 Make an array of stars
3:17 Write the update() and show() functions
3:43 Make the stars move!
5:37 Translate to the middle of the canvas
6:17 Add more stars
7:40 Start to tweak size and speed of stars
9:02 Add trails to stars
10:31 Bonus two minutes!
Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound
🚂 Website: thecodingtrain.com/
👾 Share Your Creation! thecodingtrain.com/guides/pas...
🚩 Suggest Topics: github.com/CodingTrain/Sugges...
💡 GitHub: github.com/CodingTrain
💬 Discord: / discord
💖 Membership: ua-cam.com/users/thecodingtrainjoin
🛒 Store: standard.tv/codingtrain
🖋️ Twitter: / thecodingtrain
📸 Instagram: / the.coding.train
🎥 Coding Challenges: • Coding Challenges
🎥 Intro to Programming: • Start learning here!
🔗 p5.js: p5js.org
🔗 p5.js Web Editor: editor.p5js.org/
🔗 Processing: processing.org
📄 Code of Conduct: github.com/CodingTrain/Code-o...
This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecod...
#space #processing
This guy has to be the happiest developer alive. I write 5 lines of code and it feels like I've been solving math problems for 10 hours straight!
X152535 I
X152535 lol
This guy is practically the "generic" indie developer.
its not really math....trust me, it just look like math. lol. that is like saying roman numeral look like your speaking english but its not english, it just an illusion like V, L, I, X etc. the point is, don't let it intimidate you and keep going!
@@50kforthesauce77 it depends on what you are doing, if you are writing a physics engine or an AI you will surely encounter some maths
you didnt fail, you had a working star field in under 10 minutes but then you suffered from feature creep lol
+TheWeepingCorpse SO TRUE!!
yeah, it's like when you say 3, 2, 1, 0.5, 0.25, 0.125, etc... hahahaha
SO FREAKIN' TRUE!!! LOL
What the hell is "feature creep" anyway?
"Feature creep" is when you finish all the core features but then think of more features that would be nice to add, so you add them, and then you think of more features that would be nice to add, so you add them, and then you think of more features that would be nice to add... It's like a run-on sentence but for programming.
Genius....just pure genius. Make me your apprentice master Kenobi!
Thank you so much!
Any man who can Speak through the Time Space Continuum, who can echo their voice across that of Time-Space; Is a man i would Consider my Master.
The Coding Train - I'm ten years old and I want to learn how to program, should I read a book?
+Nick Jimenez1 yes, and read code and best advice I can give: "know there's no magic - you make the magic happen" try out tools - learn to "talk" to computers.. eventually you'll work with the way you like to talk to your computer..
He is right. I just recently discovered your channel, and I work in IT.
You are a genius.
12:11 I love it when Daniel opens these seemingly demonic portals, and he quickly appreciates them, and then is like "no time!" and moves on. Makes me laugh. Also inspires me to want to pursue creating my own trippy visuals
I applaud at the end like I was watching some kind of an action movie.. DAMN.. 2 VIDEOS INTO YOUR CHANNEL AND I'M LOVIN IT!
This is SO AWESOME!!! I can't thank you enough. You've really inspired me to learn programing with code arts (yes, arts) like this one, showing me this is what I need to do. I'm from Brazil and, unfortunetly, there's not much of programing incentive here yet. Keep doing this! I deeply believe you're changing a lot of people's life. Thank you so much!!
I felt like I was watching an action movie! "oh no! he won't make it on time! D: *bomb explodes* "
dude, same here:)))
Your bomb will never explode if the terrorist don't want to deal with division by 0
Reminded me of Galaxy Quest when the timer "ran out."
lol so funny i did to
Who puts a bomb in a flash drive? Damn terrorists.
Seeing someone coding in Processing is never been this exciting, I loved it
You are absolutely great at stress-coding. I loved watching you work with this challenge.
+Karsten Vestergaard thank you!
Back in, I think, 2014, I heard about your book and decided to support it. I had no idea who you were. Now I've been watching your videos and I must say: thank you! You are an amazing teacher and human being. I'm so glad I've found this. Best wishes!
I JUST found your videos. I have been on a technology break for a few years. I just watched your #1 and #2. Very impressed with the teaching style. NO REPEATING.
I have had a PCS, Stroke, TIAs, TBI, and Seizures. I used to code with my eyes closed, but the combination of everything in my brain has caused about 80% loss in my knowledge.
This has been GREATLY helpful.
"now I could add a P vector"
Me: yeah, you could!
*Has no idea what a p vector is*
God damn true 😂
dammmm!! Me either :))) XD!!!
XD
Processing vector
🤣🤣🤣🤣🤣
You have restored my faith in programming, thank you for everything you do. These are the best thing ever. I am now fully interested in programming again after almost a year
Same here. I got out of programming for almost an entire year. I am committed to learning this skill now!
+Elijah Hamra yay!
I love this guy, It gives me hope that last year I couldn't understand a thing he was doing, now I understand most of it.
I honestly will watch your videos just to put me in a better mood. Like I will literally have no interest in doing the actual project at the time but know that I watch one video of yours, I'm just going to feel better about life in general. Thank you sir.
it should be
Star() {
x = random(-width/2, width/2);
y = random(-height/2, height/2);
}
so you really see all the stars, that are created.
in your code you're only seeing 1/4 of all stars. the rest of the stars is beyond the screen!
therob39 which programing language is that??
@@avinashyallapu32 java
vitor anthés well looks likr c# or c++ as well lmao
I code by Javascript and have problem like that. Because we use translate +1/2 width and +1/2 height, so we need get random positions from -1/2 to 1/2 of width and height.
Example: x = Math.random()*canvas.width - canvas.width/2;
@@vittim1998 it's not java lol, the constructor in java has the public keyword before the class name
Love the explanation in these videos, but i would like to see a "quick code" challenge, where u just have a goal and just code as fast as u can without explaing anything.
But his explanations are what got me interested in coding in the first place :D
Emil Schjerven Brenden 10 mins of silent coding would make a boring video
yeah, i just wanna see how fast he is able to write something ;))
No need to be silent, he could just say what he is coding at the moment, with a few test plays.
Emil Schjerven Brenden - I thought this idea was good, but then I realized it was terrible.
Your channel is a gold mine! I am so glad I discovered you
Wow, can't thank you enough. This actually taught me some core programming thoughtprocesses. I never subbed this fast on UA-cam ^^.
You've just recreated my favorite Windows 3.11 screensaver in less than 15 minutes. You're a hero.
I've watched 2 videos and I've already subscribed :D
But am I the only one who enjoys that you're talking so fast? :'D
If they talk to slow, then double the speed.
Just came across this playlist, and I can feel the energy and enthusiasm, so I'm going to continue watching 👍
That was amazing!!! For real!! Greatings from Colombia, you are amazing dude!
I'm from Syria, we have no proper programming education, I've been watching your vids for a while now. got me so excited I started trying things around and It feels so great to see codes work!! I can't thank you enough, man. I needed this hobby.
a side question if you don't mind. what would you recommend for creating Java desktop apps. I've been playing arround with NW.js and electron and I'm wondering if p5 works well with them?
+Maher F wow! Hello! Do you mean JavaScript? Yes I would recommend electron. I should do a video about it. You can use p5 with it yes.
thank you so much, looking forward to that video. love your channel and your approach to coding in general. I'm a noob that's learning a lot of things and it feels so awesome. really thankful for sharing knowledge. always a fan.
I saw this vidio and i thought well i cant programm like this but i can in Scratch ( scratch.mit.edu ) and i try to meke it in Scratch but after 4 hour of trying and analysing you vidio and the Script i gave up :D
Actually, it would be easier to do this in Processing than in Scratch, because of the built in functions (like map(), etc)
ThePiones I know after many atemps I could replicate this :(
That was pretty amazing. I haven't heard of the Processing IDE before.
Wow this was awesome! You seem so excited to be doing this! I'm not even a JS guy, but I just subscribed because that was so entertaining to watch.
Hahhahah so nice! Nothing in the past month has amused me so hard as this video / your whole series of it did! Great job! Keep on!
This is the first time a programming tutorial vid ever put me on the edge of my seat.
Hah, that's amazing to hear!
12:08 when you try to program something normal but instead open a parallel universe
This is crazy man! Hats off to you, this is some real crazy sh*t ! Amazing
This is so much fun, I’m glad I encountered your channel! I’m a Drupal developer but I’d really like a chance to use more animation in my work. 🙂
Just want to add that x and y should be random (-width/2,width/2) and (-height/2,height/2), respectively, rather than increasing the number of stars as you did. Great tutorial as always!
+Joshua Marris oh good point!
I'm honored you think so!
what also works is: (0, width) - width/2
This looks better than No Man's Sky
Emilio de Vicente Caamaño Everything looks better than no man's sky :3
the best coment ever !
Emilio de Vicente Caamaño this comment aged well..
oof
No it doesn't!
just perfection ,
you're the best teacher i ever seen
you know exactly what you're doing
thank you very mush for those videos
I really like the efforts you put in your videos.I have never seen such a entertaining teacher.
My first thought when clicking on this video was: "Huh? Star Wars?!" lmao
This video was really good! Never stop programming, we need you lol ! :)
Edit: OMG, this is the first time I get a heart, yay! ❤😄
Which programming did he used
I can do a hello world in 10 minutes :)
.
.
.
if im lucky
lol
I can write it under 10 seconds.
in notepad.
#include
using namespace std;
int main() {cout
void setup() {
size(200, 200);
text("Hello World");
}
JavaScript -
text(“hello world”, 100, 100);
P.S. I recommend learning JavaScript on Khan Academy for beginners. Plus while your there you can learn animations, computer science, code, and more. Also, they can help you with with a subject your struggling on in school. It’s free and all you need to do is make an account! I just wanted to tell you.😊
i love your energy man!! awesome video!!
Loved this. This is exactly the type of training I am looking for. Jump right in, total emersion... I want to learn end experiment with simple gfx.
how much for the powder?
I'm 14 and your videos already defined what I am going to be in the future.
+ACWRITES ENTERTAINMENT I'm glad to hear thank you for watching!
A Programmer! Welcome to the world of code.
A lot of coffee :)
DJMAXOfficial tons
You're going to be a starfield?
the funny class than i never had , you are amazing dan , this things that you do pushing me to be better and pratice more and more , thanks 4 all
Awesome video. Very informative especially in the line of thinking that could be used to solve problems quickly. It also makes one want to try similar challenges. Thanks!
he made starfield seven years before bethesda.
"space is what color?"
*stares for a minute *
* giggles *
that made me smile for no reason what so ever :D
Wow, I like a lot the way you do the videos. It's funny, entertaining and very didactic. You just got a new Sub.
These short toots are great. Not too intimidating for those of limited attention span (the vast majority of people these days), and as a visual artist, and not a programmer, they've made Processing more accessible than it seemed before, and I'm now learning faster. Thanks!
I'm so glad to hear this!
this makes my struggles with arduino earlier this semester seem so obsolete .
Subbed! But it would be cool if this is 30 minutes, carefully explained video. You inspired me to become a programmer man!
Dude, you are so awesome, it is pleasure to wach you code. Keep the good work up ;)
Hey great one.. I quite enjoyed the clock coding program that you did. I think u were celebrating your 100th show. Very interesting. Don't know if u have seen my comment on that video. Anyhow keep them great program coming 🤙🏿🤙🏿🤙🏿👌👌🤙🏿🙏🏿🙏🏿🙏🏿🙏🏿👋
If you used polar, you could give each star a random angle and it would be easier to move them radially from the center
New sub here. Two videos watched and amazed. Keep up the good work!!!
+Pedro Lopes thank you!
Okay so first of all, you did NOT fail! That was fricken amazing!!!! Hats off to you bro.
2nd) you should probably read the question first, then start coding @ the 10min mark. It's almost unfair because you talk so much, but yeah, I hope in the future I can 'fail' like you. Outstanding, I've never seen someone code something so fast! Very Impressed!!! I liked AND subscribed as I want to see more (and learn). I just started to pick up Python.
super exciting! please keep doing more challenges!!
I'm a Bachelor of Science Information Technology from here in Philippines,,
i watched 3 of your coding challenge and now, you are my idol for Coding. :)
thanks for this video man :D
That's nice to hear, thank you for watching!
The Coding Train i wish you will teach me in many codings in different c++ and other codings :)
I just foud out this channel. This is great !
welcome!
Me too. And this is indeed great :D
I can totally agree - definitly great!
Excellent video as usual, thx Daniel.
That serie is awesome , continue like that, i want more ^^
+Rrrr Will do! Just released a new menger sponge one! ua-cam.com/video/LG8ZK-rRkXo/v-deo.html
this is really cool, the star field screensaver was one of my favorites to watch
Oh Obi Wan... it will be nice to make the center/star/origin follow the mouse.... ;-)
+Ibit Informatica excellent suggestion!
Watched at 2X speed! :)
Am just a beginner in programming, and am very excited with this train.
Great videos man, you make programming fun again. : )
Thank you so much for this, I just started learning Processing and I'm having so much fun!
So, I was trying to modify the saturation of the stars so that the ones further away would be darker. So I mapped a variable to z and used it for the fill colour.
The function looks like: float c=map(z, 0, width, random(200,255), random(0,100));
This works for greyscale, but not if I want coloured stars. What could I do to fix this?
Which environment are you using to program
I think coding is cool, but I don't think I'll ever get into it. I just watch these videos to watch Daniel lmao.
If you ever have the opportunity I would recommend it, python is one of the best languages to learn as a beginner because you can do almost anything with it
You make it all seem so easy! I'm gonna see if I can do this on the vectrex
Subscribed on the strength of this - brilliant!
Hey Dan can you please explain the line : var sx= map(this.x / this.z , 0,1, 0, width );
What is the "0,1" doing there ?
Thanks!
+Giorgio Martini x has a range from 0 to 400, z has a range from 0 to 400. So x/z has a range from 0 to 1 which I want to map back to 0 to 400.
I realize you made this comment 7 months ago, but I don't think the math works out. Between the instances where you reset a star to z = width, x is essentially a constant from 0 to 400, but z is constantly decreasing. So shouldn't the value of x/z increase well out of the range 0 to 1? Shouldn't the range instead be 1 to 400?
I still can't figure out what you actually want to do by mapping x/z
How this looks like 3d or z-axis
i still don't get this part, x has a range from -400 to 400, and z a range from 0 to 400, so if x/z there is a possible range from -400 ( -400/1) to 400 (400/1)
starts out good I feel like I know coding im understanding everything then after few mins my brain goes: px pz px px pz x y z xy pz py pz xp pp px zp xp xy pz zx px px py pz = START FIELD
I can totally relate with the way in which you are your own greatest critic. However, this is one occasion I must say you are too hard on yourself! The time you spend explaining what you are doing, while much appreciated, is time that you are not coding. Many of your viewers, myself included, declare this a success! All while being fun, informative, and suspenseful! Good job, awesome video!
You da man bro... This is hilarious, informative and inspiring. Booyah~~!
ge NI USSSSSSSSS! dont understand a word but you do
heh, thanks for watching!
This as an animated Desktop background and the speed dependent on the CPU usage. Possible or not ?
Raffy611 oh wow good idea lol
Next challenge: Piano tiles haha
Amazing idea!
+Computteren Yes, great idea!!
That's so cool and intense! I love it.
You are a professional and a good person. Thank you very much for the beautiful work
We benefit from you very much
Help me pls!
Complier say: "Expected an operand but found [" on line 1 (Star[] stars = new Star[800];)
I doubt you still need an answer, but..... you have to remove the ()
Star[] stars=new Star[800]
Wow. A role model is what I can call you. How can I contact you
+Paa kwesi Aidoo twitter is @shiffman
thank you
Excellent !! I love this challenge format
this is awesome Daniel son! I think it's awesome when you emulate 3D in a 2D drawing! love it. That classic Microsoft Windows screensaver is so easy to create!!
Thanks, glad you enjoyed it!
You’re an awesome person!!! Keep doing what you’re doing 😎
Thank you very much, Daniel for doing these interesting and inspiring projects
You just earned yourself a new subscriber. Brilliant!
You're amaaaazing! Super subscribed, greetings from Argentina!
it was hilarious. awesome content :D
And I was proud of my little Fahrenheit and Celsius converter in C++. I wish I were a Java guy. Luckily you inspired me to learn processing so I can do more graphic stuff like this! Thanks for the amazing video.
Are u then a C++ developer?
you did such a good job it really looks 3d thats cool i tryed to do this on my own but it wasent as good but i really enjoy your video thx so much dan!
This is wonderful! Amazing skills! Suscribed.
You sir are awesome. I really enjoy watching these videos. You made me laugh and smile a bunch of times. You are a talented person in many ways.
That was so funny! So interesting to see how your mind conquers the code!
This is actually pretty cool. I wonder though, use this to animate a desktop background, screen saver, or lock screen. That's an awesome take, no matter the other solutions
You're a mad genius. This looks like a magic show to me lol, no idea what language you're using, no main function no project filesystem no ide, Jesus are you making stuff on the fly? I'll explore your channel a bit because this is the first video I'm watching and your program looks like it's written in Java syntax, but really unusual code structure.
dang keep doing what ur doing !!:)) im gonna try and follow these challenges
yay, thank you!
Cool, man. That was fun!
Nice I did mine with python and it looks nice. Your videos give me inspirations and makes me want to do more.
congrats on 100K subs!
I've never seen such an artistic coder on youtube!!!
I'm your Argentinian fan although it costs me a little to understand your English when you speak at the speed of light, haha. I love your videos I have learned a lot, sometimes it costs a little to follow the reasoning that you do to reach a solution but I am excited to continue learning. I am translating some videos so that more Latin Americans can understand them better.
you will always get two minutes bonus time from me !! seeing you code is fun.
This is the most hyped up coding video I have ever seen
Wow!!! So very very Awesome!! Nice Vid, very good at typing, really genius. I'm kinda watching all your vids one by one :D Your really great!! very helpful.
Thank you!