Java Video Tutorial 10

preview_player
Показать описание


In this tutorial I do something kind of crazy. I try to teach programming logic by writing code right out of my head. You probably won't understand everything in this video, but that's OK.

I continue making a simple game in Java. I specifically make a method that allows my monsters to move on the game board without landing on each other and blocks them from falling off the board.
Рекомендации по теме
Комментарии
Автор

An action that you would assume a Dog object could do would be methods like bark(), scratch(), eat(), etc. An example of a good static method for the Dog class would be getNumberOfDogs. A Dog object in the real world wouldn't be able to count the number of Dogs and so that is why it works as a static method.

derekbanas
Автор

I'm watching these tutorials and smiling with glee watching information just flow delightfully into my head. I can't believe Java is so easy. Other people just don't know how to explain it and start from Java Swing and then everything seems confusing and ridiculously difficult, but your videos make everything clear even for the novice programmers. Though I do notice some things you do new programmers won't understand (though they're clear to me), I really enjoy these tutorials and I'm completely certain that in a week or two I'll have learned Java completely :). I just want to say THANK YOU!

robotica
Автор

Thank you for pointing that out. I used to assume that people get the code from my website and look at it. Since I made this tutorial, I always point out any errors no matter how small during the video.

derekbanas
Автор

Hey Derek, I've been watching your tutorials for the past hour i think (ive been a dev for the past 12 years) and i think you are a great teacher, you have a calm voice and a singsongy way of talking that is very friendly which is important. without being a jerk, I would ask if you could please stop copying and pasting code but use method extract, use switches, and start using builders and SOLID foundations ? please. again . I have a lot of respect for you and your tutorials, And I am definitely enjoying myself. kudos on the effort and channel !

mickeyp
Автор

My Head Is going to :D .. Thanks Derek .. Best Java Teacher on YouTube .. ;) !! 

WaseemSwaileh
Автор

I'm glad you got it. Sorry it took so long, but I get a bunch of comments so it sometimes takes me a bit to get back. I'm very happy that you enjoy the videos :)

derekbanas
Автор

Just finished mine. I programmed attacking, gave the map its own class and let it handle the monster array. Then created 11 ninjas with all random stats and made them fight to the death. I created a tick function that ran through all the monsters and moved them. After that it was simply a matter of using a while loop while the numOfMonsters was more than 1. *Made sure to lower numOfMonsters by one everytime one died. Gonna move on to the next tutorial thing now. Maybe I will come back to this once we get to guis. :D Thanks for the tutorial. So far its been great fun. :D

thacoolest
Автор

I added randomised monsters with randomised names and stats, added fighting alghoritms, boost to stats after kills, traps randomly placed on the map, menu in which you can choose width and height of the map and even create your own character and you can look up stats of your monsters in the game
Its very nice to watch them kill themselves until one remains victorious

samuel
Автор

Derek, you do so much for us, with your lessons, can we help you in some way?

deniskrivchenkov
Автор

Great I'm glad the code has been useful! Yes to learn this stuff well it is best to get my commented code and to take notes in your own words as you watch. Then ask me questions and write down the answers. That way you'll have a little java book at the end that explains most everything.

derekbanas
Автор

Sorry about the confusion. X in this situation is actually the height of the board and y is vertical

derekbanas
Автор

Thank you :) I don't finish it, but I do make the game Asteroids at the end of this tutorial series. I cover just about everything on making that game

derekbanas
Автор

Hi Derek. Best tutorial on Java. I appreciate it. Thank You very much. God Bless You. Keep doing this.

If I am not wrong, maybe one correction. I think instead of:
int maxXBoardSpace = battleBoard.length - 1;
int maxYBoardSpace = battleBoard[0].length - 1;

It should be:
int maxXBoardSpace = battleBoard[0].length - 1;
int maxYBoardSpace = battleBoard.length - 1;

Your code works just because you have the same dimensions for X and Y axis.

You can test it on static char[][] battleBoard = new char[5][10];
With your code you will easily go to

ghh
Автор

That happens when an array index is called for that doesn't exist. I know I have parts of the array definition commented out in the code on my site to explain a bunch of things in this video. I personally wish I wouldn't have covered this topic so early on. You can skip this part and proceed to part 11 and then through 60. Those videos are better laid out. Sorry about the confusion :(

derekbanas
Автор

If this wasn't a tutorial I wouldn't have used this in this situation. At the time I thought it made sense to emphasize that I was saving to a class field. Sometimes I have to make judgement calls on how to do things in tutorials for beginners. Does that make sense?

derekbanas
Автор

Yes I sometimes do strange things just so I can demonstrate different techniques. I'm glad you found it useful :)

derekbanas
Автор

It was just made up at the time. I was trying to teach how a programmer thinks through solving problems. Looking back at parts 8 and 10 of this series I consider them to be bad tutorials. Every once in a while I have to experiment to improve. Feel free to skip parts 8 and 10.

derekbanas
Автор

Someone please confirm I'm getting the logic right in the first place.. Thing that baffled me was the naming of the boolean variable isSpaceOpen. The case when isSpaceOpen == True, represents a state where the space is occupied by another Monster. My intuition says 'open' suggests the space to be empty and so I'd use something like spaceOccupied instead.

Anyway, thank you, Derek, for these awesome tutorials!

tohtorizorro
Автор

IF you get a " NoClassDefFoundError " error from the apache commons library (3.9) inside LessonTen .java, change the arrayItemIndex line from:
int arrayItemIndex = ArrayUtils.indexOf(Monsters, m);
to:
int arrayItemIndex =
This worked for me :D


Great vids so far :D Thanks a lot!

dorky
Автор

thanks for your efforts of theaching us these stuff. You are the best progrramming teacher on youtube.:)

bayraminanc