I Made a Game in One Line of Code
HTML-код
- Опубликовано: 31 июл 2024
- Making a game in a single line of code be like.
Hire me: www.fiverr.com/n8dev_yt/edit-...
/// SOCIALS
▸ Twitch: / n8dev
▸ Patreon: / n8dev
▸ Discord: / discord
▸ Twitter: / n8dev_yt
/// GEAR ///
▸ Microphone: amzn.to/42mqD6K
▸ Laptop: amzn.to/3JTTt7n
▸ Mac: amzn.to/3lnTmaF
▸ Boom arm: amzn.to/3ljXBUN
▸ Monitor: amzn.to/3loAWGD
▸ Mouse: amzn.to/3LEkWuT
▸ Headphones: amzn.to/40lIl8s
/// TIMESTAMPS
▸ 0:00 Introooooooooo
▸ 0:29 My lawyer gets mad at me
▸ 0:44 Game idea be like
▸ 0:55 Art
▸ 1:16 Setting up my script
▸ 1:48 Basic game loooooooooooooop
▸ 2:13 How this actually works
▸ 2:55 More game stuff lol
▸ 3:30 Outrooooooooooooooo Наука
source code :0
using System.Collections; using UnityEngine; using TMPro; using UnityEngine.SceneManagement; namespace com.N8Dev.Flappy { public sealed class Game : MonoBehaviour { /* PLAYER */ [Header("Player")] [SerializeField] private string PlayerTag = "Player"; [SerializeField] private ParticleSystem PlayerJumpParticles; [SerializeField] private float PlayerJump; [SerializeField] private KeyCode PlayerJumpKey; private Rigidbody2D _playerRigidbody; private bool _isDead; /* PLAYER */ /* SCORE */ [Header("Score")] [SerializeField] private string ScoreTag = "Score"; [SerializeField] private TextMeshProUGUI ScoreText; private int _score; /* SCORE */ /* SPIKES */ [Header("Spikes")] [SerializeField] private string SpikesTag; [SerializeField] private string InstantKillTag = "InstantKill"; [SerializeField] private float SpikeScroll; [SerializeField] private Collider2D SpikeEndCollider; [SerializeField] private Transform SpikeStart; [SerializeField] private float MinY; [SerializeField] private float MaxY; private Rigidbody2D _spikeRigidbody; /* SPIKES */ /* UNITY EVENT METHODS */ private void Awake() { if (gameObject.CompareTag(PlayerTag)) _playerRigidbody = GetComponent(); else if (gameObject.CompareTag(SpikesTag)) _spikeRigidbody = GetComponent(); } private void Update() { if (gameObject.CompareTag(PlayerTag) && Input.GetKeyDown(PlayerJumpKey) && !_isDead) { _playerRigidbody.velocity = new Vector2(_playerRigidbody.velocity.x, PlayerJump); PlayerJumpParticles.Play(); } } private void FixedUpdate() { if (gameObject.CompareTag(SpikesTag)) { _spikeRigidbody.MovePosition(_spikeRigidbody.position - Vector2.right * SpikeScroll); } } private void OnCollisionEnter2D(Collision2D collision) { if (gameObject.CompareTag(PlayerTag)) { if (collision.collider.CompareTag(SpikesTag)) StartCoroutine(Co_Death(0.5f)); else if (collision.collider.CompareTag(InstantKillTag)) StartCoroutine(Co_Death(0f)); } } private void OnTriggerEnter2D(Collider2D collider) { if (gameObject.CompareTag(PlayerTag) && collider.CompareTag(ScoreTag) && !_isDead) { _score++; ScoreText.text = _score.ToString(); } else if (gameObject.CompareTag(SpikesTag) && collider == SpikeEndCollider) { Vector3 __startPosition = SpikeStart.position; __startPosition.y = Random.Range(MinY, MaxY); _spikeRigidbody.position = __startPosition; } } /* UNITY EVENT METHODS */ /* Death */ private IEnumerator Co_Death(float delay) { _isDead = true; yield return new WaitForSeconds(delay); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } /* Death */ } }
oh god
that made me die
@@n8programs733 mb
aa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Unity:
"error occurrred on line : 1"
him:
thank god it tells me
LOL what a relief
tfw the error occurs on line 2
At least “error occurred” shows that there’s an error in the first place
Yeh unity saw 2 lines I guess
you don't know unity
Wait, you mean people usually write code on more than one line?!?
LOL
No people code in only 1 line like shown in this devlog
;)
Depends. If it's a simple game, one line is more than enough, but for more serious projects you might want more cocaine that that.
@@notrohit No no, not woosh, read what he said again :P Specifically the end part lol
As a coding enthusiast myself, I would actually like to hear about the pain this must've given you, scrolling through the Great Wall of China's code.
LMAO glad you can relate
Did you meant line?
@@dinoavenger I was making an exaggeration because it's an entirety of a program's code in a single line, hence the expression "Great Wall of China", since the GWoC is f*cking huge to my knowledge.
If you were just asking if I was exaggerating in the first place, then I'm sorry for possibly making this sound like I was calling you an idiot or... something like that. I don't mean any offense.
Basically imagine this: Your latest english essay, except shorten the paragraphs to one line. good luck reading all that to find your error.
Great Line of Code
I had a professor who told me he once had a blind student who would write their code and then have a text reader read it to them to debug. The result was, they had no reason to properly space code so they'd just write it all on one line
That's actually really interesting
@@n8dev I have no idea whether it was true. The guy was a creep. But it is an interesting story
@@TheMartyredextras why was he a creep?
@@user-rx2oc5tl3u long story
no python i guess
I like how half the shots are of your project, and the other half is completely random stuff
haha thanks
u wiykd kuje but 69 likes
Lol
I did not even realise
test
test
Gotta love how he is lightly stroking random keys rather than typing xD
LOL yes
I still don’t understand what’s happening in those shot
@@EsquisseBeats same
@@n8dev same
@@n8dev same
You know what's crazy? When he showed the little guy without the spikes jumping up and down, my mind still genuinely thought it was moving forward, even though there was nothing moving to the left to signify that, the fact that Flappy Bird had such a big effect on my brain that a small character jumping up and down tells my brain it's also moving right is insane to me
It's like a reverse optical illusion
Yeah fr
I think it's also the eyes of the character, the lines on the triangle are facing right so you've think if it was moving then it's obviously moving to the right and not to the left.
I'm looking at those food scenes and I was asking myself if there was a deeper meaning behind them. Nope. I'm pretty sure N8Dev was hungry while editing and wanted us to see what he was cooking up.
correct, the food was very good :D
@@n8dev I fear nothing, but that thing
That thing:
It scares me
Friend: hey want to join me on making a game?
Me: sure, how much do you have done?
Friend: oh not much, only one script
The script:
LOL
The yandere dev is the friend.
Hhahahha
Only one *line*
I like how to-the-point this was. he literally just went "yea I did it, here's the thing I made, k bye"
thanks :)
well, plus any random clips inbetween. Not a fan of seeing dogs, food and "fake typing" on a video about coding :D
0:12 yes but a "line of code" is specifically defined. Hop into your visual studio and you can actually do a quick diag and it will tell you how many lines it is, ignoring whitespace.
yup; I figured everyone would interpretate “one line” as “one straight line of code”, but I see that’s not the case :D
2:55 I play basketball a lot and I can confirm that white circles do emit from your feet when you jump
LOL good to know
The fact that you didn't call it Flyangle hurts my soul lol.
sorryyyyyyyyyyy haha
Tryangle Flyangle
Man thats way better than High-Velocity Farting Triangle. Hire him not me. lol
Flappy and Triangle can be either Flyangle, or Trippy.... oh wait
lol i vote for Flyangle lmao
We were too busy asking if we could, we never stopped to ask if we should.
LOL so true
LOLOLOLOLLO
@@typicalkhaios2475
What does that stand for?
@@user-hg1zb5te9f the same as rofl
e
I'm impressed that you actually kept this as one line the entire time, rather than writing it normally and then just deleting all the newlines at the end.
;)
This was really fun to watch, I'd love to see more of your coding adventures
🙏
The title: Making a game
The video: Making food
im hungry.
LOL
Yes
"I'm not a good artist" proceeds to make really beautiful art that i vould never get even close
haha thank you
lol when making a game I usually get NO INSPIRATION (0:50) other people's artwork, but anyways I made art from his assets. (I didn't directly copy it, I just had a flame in my heart too use the same concept as him)
I wouldn't get close either.
they're literally just triangles lmao
ITS A TRIANGLE
n8dev: “But you probably don’t care, so moving on.”
Most true AND funniest youtuber😂😂
- program game normally
- find and replace new lines with empty strings
done.
A better challenge would be to create a game with just one statement. While not trivial it should definitely be possible.
yup! maybe I’ll try that in the future ;)
my thoughts exactly. I'm on board, one statement can be indeed a fun challenge..
Giant string of else else else else maybe? I think that'd be a funny one.
"everyone knows that when you jump white particles come out of your feet"
literally died out of laughter
haha love that
you sound sarcastic
@@hexagon8899 really lol?
@@aptrock327 yea isnt sarcasm meant to be when something is false?
@@hexagon8899 yes
The amount of people you replied to is impressive, very genuine good job
the worst part is that since its one line of code with no documentation, it is impossible to and will never be updated
Facts
If a line of code gives you 4 minutes, imagine with the hundreds that a normal game has
LOL yeah, generally I like to keep my videos around 6 or 7 minutes; I just didn't want to spend more time than I needed talking about this ;)
Working on a console based cinema application together with my project team in C# for university. Got over 600 hours total, nearing the finish of the project.
If I hadn't recently started using Unity, I would have said, "Hundreds? Surely a 'normal' game has at least 10,000!" Why did I not start using Unity sooner?!
I love how you randomly edit in scenes of you getting cereal and playing with your dog
haha thank you
Mad props to you for sticking through with it, I would have given up as soon as I had to scroll horizontally xD Very interesting video idea and the game looks really nice!
haha thank you
I subbed just because of how brief and clean the editing is
we love that :D
"Did you do it"
"Yes"
"What did it cost? "
"My sanity'
LOL yeah
As a person who uses two if statements instead of just one long one, this hurts my soul.
LOL sorry
those collisions are really nice :) great job
🙏
Bro your way to Underated. Very good video and Editing
🙏
1:16 with all of the art finished, i figured it was time for me to eat breakfast
LOL
i figured it was time for me to start co -ding- oking
Awesome =D
I just love the "AASDEE" keyboard footage you use on all of your vids lol
LOL thanks :D
The editing, voice over and the video overall is so great that I thought you had hundreds of thousands of subscribers. You have a new one tho ;)
thanks!
he could have wrote it normally, then backspaced the lines js
this was a nice video!! also plus points for the doggo c:
haha thank you
Thanks for the recommended youtube, now i get to enjoy this cursed content
haha yes that's awesome
You wanted to get the eggs in the video because you knew they looked real tasty, and you had no other way of showing that fine art to everybody else. So you snuck it in there. RESPECT EARNED!!! And a sub!
🥳🥳🥳
I love how you randomly add videos of your dog 😂 so cute btw
Hecka professional editing ^w^ Love the random B-roll at times to break up the video just a bit.
:D
You deserve more than 900 subscribers, 900k should do fine! YOU'RE AWSOME!!!!
thanks so much :D
Got this in my recommendation, not disappointed🙃
thanks :D
Great video. Love the foods transitions :)
thanks :D
small creators are often appearing on my recommended recently, and i aint complaining
:D
Fun fact, compilers (including JIT compilers for interpreted languages like Javascript) already condense code to 1 line!
So really, the entire front end of RUclips is probably only 1 line of code too.
Amazing that I've seen you reply to almost every comment I've seen. Also great work on the video. I may try and get into coding just so I can do something similar as a gag.
thanks! I would definitely try and learn programming, it’s opened up a ton of doors for me :)
New sub, great video, nice color palette!
Oh I love that this popped out in my recommendations
I'm glad it did too
Back in high school a teacher was talking about how inefficient my project was due its (aprox) 1500 lines of code it had. I made some jokes about deleting all the spaces between each one with friends but never image someone would actually do it. Congrats for your super efficient game 🤘👍
Lmaooo thank you
i am excited to see this
awesomeeeee
Damn Bro I know im a year late but this vid is awesome! Love the quick IRL shots so now and then (doggo looks very cute) great vid! Earned that sub!
Man these images are actually really nice looking
2:27 "because the player oveesly is not a spike"
That looks like a spike to me......
Triangle != spike 🥲
1:15 thats my favorite cereal lol
idk why im talking about the cereal and not the actual video lol, but good job
It’s my favorite too 🥣
@@n8dev Saaaaammmmmmeeeeeeee
The length of the video is a neat detail
100% intentional
Love the art style lmao
🙏
I saw this 1000 times but still find it funny
haha love that
You could make the game harder as you progress by making the top spike and bottom spike closer together, or by making the spikes appear more frequently, or making them move faster. But that might require another line of code! 😉
Lmaooo right
He successfully makes a game in one line of code, really good, aestetically awesome and in almost no time.
In the meantime, I am stuck because I forgot to add a letter in one of 283662727 lines of code after working for that for 56 years and with the aesthetic resembeling a game made using 2 pixels...
Awesome channel!!!
thank you :D
Yo these game dev challenges are getting out of control 🤣 Nice flappy bir- I mean, jumping triangle ;)
LOL thanks ;)
“Chapters” thing:
0:00 Introooooooooo
0:29 My lawyer gets mad at me
0:44 Game idea be like
0:55 Art
1:16 Setting up my script
1:48 Basic game loooooooooooooop
2:13 How this actually works
2:55 More game stuff lol
3:30 Outrooooooooooooooo
yuppp
Your such a underrated RUclipsr trust me you are going to hav millions of subs soon!!!+1sub
🙏🙏🙏
This is a hilarious nightmare 😂😂. Thanks for making this video so I didn't have to lmao
Lmaooo thank you
Ohohoh yes, I can't wait
:D
lol how the code will look like
one massive line ;)
This video is next level!
thanks!
my humor is broken I laughed so much at the white particles joke 😂
That lawyer’s Aussie accent got to me lol. I wonder how far you could take it with one line of code. Although like you said, I guess technically this game does have more than 1 line of code if you include game engine base code, Post Processing, etc lol. Cool idea though! Can you remake Skyrim in one line of code??
LOL thanks haha, we’ll see about skyrim 👀
Skyrim has multiple objects all with their own code and the game needs one manager object to do everything so it would be even more of a nightmare making more complex behaviours such as pathfinding. You could probably merge an open source engines code with your games making it truly 1 line.
@@nathansnail oh goodness haha, that could be fun (painful). I really appreciate you taking the time to give feedback :)
@@nathansnail haha I was clearly joking by suggesting Skyrim but I like where this is going!
me when he hits 10M:Only OG’s will remember
:D
Just clicked due to the beautiful Thumbnail and Spectacular video. You have used a Super Attractive colour palate. Keep up the Good work.
thanks so much :D
im a big fan of the random shots of u making urself breakfast
0:45 flexing nails or something? KEKW
LOL
damn man this game looks cool!, for real upload it on steam or whatever and let's play it
haha thank you; this game is not good enough for steam though ;)
Bro, thats a sub from me for that clarification at the beginning with unity, we have a hero here!!!
thank you so much :D
This video is getting recommended like crazy. Nice job.
🙏
@@n8dev :D
Although I only code VERY simple stuff I can feel the pain!
LOL
The real fun start when you do one liners in python
haha yeah
Waaaaait.
You can make a loop with a recursive function, there is an inline if and you can store variables as parameters of the function, so its kind of doable
this is the best clickbait ive ever seen, we all needed it
Blinking animation is nice and easy especially when your player's eyes are just straight monochrome lines.
That tiny detail adds so much character imo.
When you get that "Error on line 1" message... You should host a 1 line game jam!
LOL I like that idea :D
People will probably just code everything in one script normally and delete the new-lines in the end. I was actually very surprised that you didn't do that and really developed everything within one line.
@@Niki1A_ I didn't even think about that. Wow. That's smart.
0:55 why is this here
:o
The force is strong with this one
Anger every programmer every any% speedrun.
Honestly though, great video! The debugging must have been worse than in apps script though...
3:52
captions: "like if you dislike"
😂😂
well that’s actually what I said haha
@@n8dev oh nvm😅
The funny thing is yandere dev is basically doing this exact thing for the student ID system 2:31
💀💀💀💀
Great video 👌
thanks :D
This guys a mad lad wth 😭💀🙏🏾
This is a terrible idea and I love it. Very interesting decision to make art before the game itself, heh.
Lmaooo thank you
Cool! The only problem I had with this is that you didn't juggle three Rubik's cubes in one hand solving them while also typing 250 words per minute with your feet and coding all of this in under an hour typing with one hand.
You know other than that this was amazing!
wait who said he didn't do all of this stuff?!
LOL thank you haha
@@n8dev Wow thanks for answering so fast, that usually doesn't happen, I like your content!
thanks :D I try to reply to everyone haha
@@n8dev Well that's good!
waiting to this channel become mainstream, lol good content bro
thank you :D
I did this once in my programming course and my professor said he wasn't even going to dignify that with a response
LMAO
YandereDev: **laughs in 170+ lines for a fucking clock**
LOL
this is why modules exist yandev!
I swear, at some point he just asked himself, sleepdeprived at 4:50am: So, how many if statements can I actually nest and get away with?
ctrl + s moment: 3:28
oh yes
You're insane N8
ikr
Thank you RUclips recommendation gods
yessss we love that
N8, i DARE you to make a game in 0 lines of code.
I bet I could
@@ebrahimmomin7518 do it
@@_MrNoob alr
@@_MrNoob I did it
oh goodness
such a great video, this also blew up
yesssss thanks :D
this is awesome
thanks :D
This channel gonna blow up soon I'm telling you
thanks :D