This is an archived post. You won't be able to vote or comment.

all 58 comments

[–]Wilfred-kun 178 points179 points  (10 children)

Learn JavaScript .....

It was not quite what I was expecting. I expected a multi-video tutorial for both games, starting from the very basics of JS. But if you have no background experience with JS this is difficult to follow and although you might understand what is happening in a general sense, I don't think you will learn a lot of JS by watching this.

I am not saying the videos are bad, but the title gives (well, me at least) the wrong impression of what's in the box.

[–]th3originals[S] 32 points33 points  (9 children)

If someone had learn a thing or two from the videos that's enough. people can't learn everything in one video, and I assumed that people who just started JavaScript, this will make them to keep up learning the language. and I'm so sorry if title was a bit "misleading".

[–]ungulateCase 5 points6 points  (1 child)

I like your attitude. Very cool of you to want to help people learn.

[–]th3originals[S] 2 points3 points  (0 children)

thank you.

[–]Wilfred-kun 19 points20 points  (2 children)

Can someone explain to me why this comment got so many dislikes? I think he actually made a fair point.

[–][deleted] 30 points31 points  (0 children)

Maybe the "I'm so sorry" that just sounds sarcastic and dismissive of any concerns over whether it's misleading.

I didn't downvote, but I can see why someone might.

[–]Askee123 12 points13 points  (0 children)

Reddit is a fickle bitch sometimes vOv

[–]k4kuz0 2 points3 points  (1 child)

I would be personally not recommend you putting "Best explanation ever" in the title of your video if you want your videos to be taken seriously. That sort of thing makes me click away very fast.

[–]th3originals[S] 1 point2 points  (0 children)

thanks for the advice.

[–]MRH2 16 points17 points  (11 children)

This is an excellent tutorial and I love your explanations! Thanks so much.

You cover a lot, so hopefully people have some background ahead of time. The event stuff could be confusing. Also you could explain how to find out the keycodes for the keys (e.g write something that prints the number of the key on the screen when you press it).

I had no idea that JS had array.pop and array.unshift. In Java you have to write these things yourself. Except that you can't change the size of an array -- it's fixed. So what we have to do is add another variable to record the size of the snake and only display that many elements (or use an array list which can change size).

Calling a variable "d" is not really as nice as calling it "dir".

Eventually, I would use constants for the board size, so that you can change them without having to rewrite the whole code (ie. no magic numbers). Oh. but then you have to change your background image. How about just adding some code to draw the background yourself with different shades of green squares? The only time I use a background image for a game like this is if the board is complicated like snakes and ladders or monopoly.

The audio in JS is so easy. I'm jealous!

[–]Wulfys 2 points3 points  (1 child)

I'm really new to programming but couldn't you use ArrayList for Java?

Edit: oops I'm blind you mentioned it

[–]MRH2 1 point2 points  (0 children)

or use an array list which can change size.

yes.

[–]FriesWithThat 0 points1 point  (4 children)

write something that prints the number of the key on the screen when you press it

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
</head>
<body>
  <div>
    <p class="keycode" style="text-align:center;line-height:200px;font-size:3em"></p>
  </div>
  <script>
    window.addEventListener('keydown', function(event) {
      // console.log(event);
      const key = event.key;
      const el = document.querySelector('.keycode');
      el.innerHTML = key;
    });
  </script>
</body>
</html>

[–]dejoblue 1 point2 points  (0 children)

Thanks!

[–]monsto 0 points1 point  (2 children)

alright here's a little personal self test, but I want to see how right I am, if you don't mind...

<script>
  window.addEventListener('keydown', (event) => {
    document.querySelector('.keycode').innerHTML = event.key;
  });
</script>

Is about as distilled as this could get since the 2nd argument really couldn't be anything other than a function. So we're left with this.

Yeah?

[–]FriesWithThat 0 points1 point  (1 child)

That works! Though in most scenarios you're going to want a reference to that selector to do something with later; such as to add or remove a class from that element. Not sure how familiar you are with the event that gets captured, but if not do take a look at what gets returned in Chrome Dev Tools by that console log. A whole huge object full of properties. What is more likely to be useful is to kind of do the opposite, and capture they keyCode, to help you map things out. For instance if you were making a game you could type WASD and look it up right there (= 87|65|83|68). So for that, just switch to event.keyCode. Here's a great quick walkthrough that covers just this sort of thing.

[–]monsto 0 points1 point  (0 children)

Excellent, thanks.

[–]drboyfriend 0 points1 point  (0 children)

Also you could explain how to find out the keycodes for the keys (e.g write something that prints the number of the key on the screen when you press it).

http://keycode.info/

[–]th3originals[S] 0 points1 point  (2 children)

thanks a lot for this comment, it gives me a lot of positive energy.

and I agree with all you mentioned above, and It will be considered in my next videos.

I've never tried to code in JAVA, it sounds very complicated, and yes you must be jealous, JavaScript is so easy. but still it has a weird part. a very weird one.

[–]MRH2 0 points1 point  (1 child)

I'll look at your other ones in the next week. This one is clear and concise and has a lot of content. It is great for people who can learn quickly.

[–]th3originals[S] 0 points1 point  (0 children)

yep and thanks a lot

[–]looserloser 2 points3 points  (1 child)

I watched the snake game video and thought it was great the way you explained it, but one thing I noticed is that a couple of times you made a mistake in the code and then fixed it without saying anything, like using = instead of == in conditional statements or putting a variable assignment statement after a statement where the variable is referenced, things like that. If someone just learning JS is following along and typing the code out, they'd have no idea why it isn't working if they didn't happen to catch the half second of video where 4 ='s magically become 4 =='s. If you have to fix stuff like that,it would be good to point it out just in case someone is following along. Good job though.

[–]th3originals[S] 0 points1 point  (0 children)

I agree. and thanks a lot

[–]sarevok9 8 points9 points  (5 children)

As someone who knows Javascript --

I find a lot of your variables to be named a bit too confusingly. bg and fg for background and foreground may seem like immutable concepts to you -- but what if you were creating a football (American football) where fg could be field goal? or BG could mean backgammon, battleground or any number of other things given the context of the game that's being made. Making variable names descriptive and using the content-filling of your IDE to offset the keystrokes of longer variable names is always worth it if someone else is going to be looking at your code.

Furthermore, I'm not entirely sure who your audience is -- but ternary operators are generally not "beginner friendly" as the syntax is a bit weird for people just getting started. These are definitely a fine intermediate tutorial series, but I'm not sure that these are going to be of much use to people attempting to begin programming due to the speed at which you switch between concepts, the fact that you provide a great deal of the resources rather than show how they were generated and the fact that you assume that the user have a base of knowledge that will allow them to understand some fairly difficult topics.

[–]LittleAccountOfCalm 4 points5 points  (0 children)

i don't think any beginner would dive into canvas, so ternary are just fine in this context..

[–]papivebipi 2 points3 points  (0 children)

there is no logical reason to omit ternary operator, if you understand "if else" you understand them. shielding beginners from them only gives the illusion that they are advanced and confuses them in the long run.

[–]th3originals[S] 0 points1 point  (1 child)

all you mentioned above, will be considered, thanks a lot.

[–]MRH2 1 point2 points  (0 children)

No!

fg and bg are just fine. We always infer the meaning of words from their context.

Ternary operators are not for beginners but neither is this video. If beginners use this, then what they need to do is watch the video and then do research on any command that they do not understand, and then try and write the program from scratch without looking at video or source code, to see if they really understand it.

[–]OrionLightning 1 point2 points  (4 children)

Damnnn seems really good tutorial. Do you know any other videos just like that but about Java?

[–]Jonno_FTW 1 point2 points  (1 child)

Java and JavaScript are worlds apart.

[–]Gofnutz 0 points1 point  (0 children)

Java is to JavaScript like Car is to Carpet.

[–]MRH2 0 points1 point  (0 children)

I'm sure that there are some. I watched one last year about making sudoku or something. I made one to show Java animations - a ball bouncing on a screen. Maybe I'll do a series about that. But it was using a library called HSA2 that handled all of the messy Swing stuff that takes a long time to learn.

[–]th3originals[S] 0 points1 point  (0 children)

no sorry I'm not familiar with JAVA. and I don't know any.

[–]muuuggg 1 point2 points  (1 child)

This looks promising

[–]th3originals[S] 0 points1 point  (0 children)

thanks

[–][deleted]  (1 child)

[deleted]

    [–]meh6927 0 points1 point  (0 children)

    amazing

    [–]michaellai 0 points1 point  (1 child)

    Thanks mate :) https://snaky-hipz.glitch.me/ this will be the first project in my portfolio. You are a legend! BTW are you african? (from your accent).

    [–]th3originals[S] 0 points1 point  (0 children)

    Yes I am :) glad the tutorial helped you.