
JavaScript Snake Game Tutorial Using Functional Programming
freeCodeCamp.org
Views: 145983
Like: 3168
Build a Snake Game in JavaScript using Functional Programming concepts. No libraries are used in this JavaScript tutorial.
💻 Source code:
Created by Christopher Okhravi.
🔗Check out his YouTube channel:
—
Learn to code for free and get a developer job:
Read hundreds of articles on programming:
And subscribe for new videos on technology every day:
04.06.2022
awesome! watched several snake video on youtube, they all pretty shitty in comparison to this one. good job.
Thanks I made this http://www.sketchalgorithms.com/games/snake-game
This exercise was amazing, i learned functional programming basics while watching!
thanks for this video? could you please tell me how to show grid lines in snake's background, so to predict in which row it is.
in short, To show rows and columns cells/squares.
"The interwebs."
He said "The Interwebs."
9/10 video, needs more snakes
I think I know javascript, sorry, my bad 🙂
Could someone please explain me line 'const step = t1 => t2 => {…'
are t1 and t2 both arguments of step fucntion and if they were, why wasnt it written line 'const step = (t1, t2) => {…'
Thanks.
Any reason for not using webpack? That will handle your import export and then use Babel to compile your code for cross browser support
I'm interested in learning more about functional programming.
Are there any performance implications of using functional programming for games?
https://github.com/KarthikNedunchezhiyan/MultiLevel-Snake-Game share your suggestions, i have made snake game using js
It's not a game but I implemented a simple application using FP concepts with JavaScript. It's a pomodoro timer
PomoLambda: https://github.com/leandrotk/pomo-lambda
Gotta love this channel 😍
You are a great speaker 👍
This guy run a great YouTube channel. He is able to elucidate difficult stuff.
You could make millions marketing Red Bull or Coffee:-)
Haha that's a good one man! =)
Oh anyway, can I seek your advice in this open source android app I have posted below? I will be happy to get feedback about this app. Greatly appreciate!…
You can search ' pub:Path Ahead ' in Android Play Store (P & A are case sensitive).
thanks a-hundred-times !!
Pretty tough way, actually! Great stuff, awesome energy, dude!
Very nice implementation, but in javascript games, reuse of objects and objects pooling is key for a decent performance, try a space shooter or a bullet hell shooter to see the limits and witness the garbage collector rampage. I'm not very familiar with functional programming, but why returning a new function each frame while you could use two variables to get the deltaT and set the frame rate at the value you want ?
so what's difference if I declare validMove like this
const vaildMove = (move, state) =>
instead of that form
const validMove = move => state =>
!! using two parameters instead of using two nested functions !!!
9 hours of work to implement 90 mins 😅
listen to this while he is talking. Is like a new kind of music.
https://www.youtube.com/watch?v=8XJ6r4U171I
Thumbs up for the Slavoj Zizek of programming! 💪
Great!!! Thanks for including some conceptual ideas, they make programing so much more understandable, useful and enjoyable!
Very well explained tutorial. Why do you use multiple arrows for multiple input arguments for function? like p1 => p2 => and not (p1, p2) => ?
Edit: I understand currying now!
you talk too much nonsense..
This dude is legend! I love his php design patterns series
Who is your target group for this? I came in thinking Snake was a newbie tutorial but it looks super complicated so me as a beginner is not the target group.
Why you dont speak faster?
Smooth snake
Grid to tiny pixel
Why don't you get a stack overflow from calling requestAnimationFrame recursively? Is it async?
You look like Oscar Isaac mixed with Mr. Bean.
This is some beautiful code
It's an A++ from me.
Brilliant.
Hey, Interesting tutorial, but requestAnimationFrame should be running apprx every 16ms, limiting or trying to hard code this to instead run at 100ms for each frame seems a bit counter-intuative. Still learnt quite a lot from this video. But this implementation seems very convoluted.. Maybe you could make a remake of this using the new .animate() Javascript api…
oh modules? thats really funny
Thank you for doing this! Cannot wait to try this tutorial
JavaScript isn't a functional programming language.
Is it a porn video cover on the wall or my eyes deceives me?
I ve seen Chris coding walks and this is great too
That is a great tutorial! I work as scala developer and I'm currently learning elm for fun, so I'm familiar with FP.
You really have a talent creating readable code imho. I was wondering all the time how you would have implemented the nextSnake function and was expecting some complicated mapping over accumulated moves or whatever. But your "remove the tail and append a new head" approach is super elegant. I haven't thought about the problem enough to come up with this elegant solution.
I'll try to reimplement your solution with elm if I have time.
code for ludo game in javascript
Hi thank you for the nice example. I did not get the spec() function how does it work without any parameter – the state, how does it knows about, how orks map / apply, and how to understand the spec function in itself. Thanks you
for example o => x => , x is never referenced,
This guys is awesome
14:00
Watching this on 1.5x is keeping a smile on my face
Me: trying to learn javascript
Ad: "Pythons where its at"
Business Opportunity in Ruvol
I have invented a Board Game [still unpublished and not yet out in the market] that I believe is guaranteed to be as challenging and exciting as CHESS. I called it “RUVOL.”
It is my hope that one day Ruvol may surpass chess as the “Number One Board Game in the World.”
The weakness of chess is it always starts in fixed positions that the opening moves become “memorizable.” In fact, not a few have so mastered the moves that they can play against their opponents “blindfolded.” It is for this very reason that the great Bobby Fischer introduced his so-called “Fischer Random Chess,” where the starting position of the pieces is “randomized” to make the memorization of openings impracticable. Fortunately, it is also for this reason that I invented Ruvol where “every game” has been calculated to be a challenging one to play.
HOW IS RUVOL PLAYED and HOW YOU CAN MONETIZE IT?
I detailed everything in my YouTube video. Here is the link: https://www.youtube.com/watch?v=jcqth0m3-R0
BIG MONEY POTENTIAL IN RUVOL!
It is worthwhile to note that the people who play chess will be the same people who will play Ruvol. In my Google search, I learned there are around 800 million chess players in the world. Even just a small percentage of these 800 million is good enough to earn big money from Ruvol either as an ONLINE GAME BUSINESS or as a PHYSICAL PRODUCT DISTRIBUTOR.
You may contact me at: rodolfovitangcol@gmail.com.
Thanks and God bless!
RODOLFO MARTIN VITANGCOL
The Ruvol Inventor
state.moves should not be an array. The snake is only able to move one direction at a time. If you spam multiple keys, the snake remains moving around even after releasing all keys. Also state.snake should not be an array of the coordinates where the snakes body would be. It should be the length of the snake.
Is he Maltese?
Finally! Done right the hard way