Java Video Tutorial 8

[ad_1]
Code is Here:

How to Install Java Libraries:

Best Java Book :

I thought it would be fun to teach Java while I make a video game. This is a simple game, but it will teach a lot of the logic needed to make your own game.

This tutorial will teach you about arrays, class fields, class methods, how to set a default value for an array, and a ton of logic.


Posted

in

by

Tags:

Comments

31 responses to “Java Video Tutorial 8”

  1. Michael DeGuire Avatar

    would this have worked the same if you didnt put monsters into an array in main?

  2. dedZombie Avatar

    The most fun I had learning Java, and it's still so early into tutorials ^_^ I keep looking forward to the stuff waiting me ahead. Thank you so much Derek <3

  3. Samed F. B. Avatar

    randNumX = (int) (Math.random() * maxXBoardSpace);
    // Why maxXBoardSpace (which is 9) and not use battleBoard.length (=10)? Because this code would generate a number from 0 to 8?!

  4. Joseph Yoon Avatar

    @10:04, why did you make "numOfMonsters" static?

  5. Sohail Khan Avatar

    its too hard for beginner

  6. alberto cassio Avatar

    Are you still answering questions?

  7. Brian Smith Avatar

    Hey Derek, amazing videos, you are really good!! two questions: how do you know what you have to import? and all my classes always have package at the top how come yours dont have that? thanks

  8. Evgeni Kuzmov Avatar

    why on is it battleBoard.length – 1; why minus 1
    and why next is [0]?

    19:30 line 38. so are there four two monsters? sound confusing

    what is battleBoard? An object, variable or a method?

  9. Luke Evanshen Avatar

    Derek! YOU ARE THE MAN!!!!! THANKS SOOOOO MUCH!

  10. Shawn Logan Angelo Lapuz Avatar

    @derek

    Error
    import java.util.Arrays cannot be resolved

    im watching all your video tutorial and copying your codes until lesson 8. and it reall helped me. also i followed the steps how to install eclipse and additional libraries you recommended but still i cant resolve the import java.util.Arrays error

  11. Daniel Passy Avatar

    Shouldn't you first create a Monstertwo object and only then call a method upon it?

  12. element74 Avatar

    i just found out there's more than 10 videos of the tutorial lol. How much of it should I watch if I plan to develop android apps, for example?

  13. Ashish Adhikari Avatar

    @3:40, in the buildBattleBoard() method's for each, you refer to char[] row as "individual stars that're gonna go into the cells". Doesn't row refer to each complete row in your 2D array and not each cell? As far as I know, Arrays.fill([] array, value) fills all CELLS in an ARRAY with the given value, i.e. row in the for each must be a row and not a cell.

  14. Evgeni Kuzmov Avatar

    14:23 why is it != "*" ? it should be equal to *

  15. Mingyu Liu Avatar

    You're literally more lovely than my college Professor 😀

  16. Strange ! Avatar

    I've found a mistake in the code, when generating random positions for the monsters
    you set maxXBoardSpace = battleBoard.length – 1, it means maxXBoardSpace would be 9
    But mistake is randNumX = (int) (Math.random() * maxXBoardSpace) , so randNumX would be from 0 to 8 so it's never gonna fill 9'th row and 9th column.

  17. Mr_IzeQ Avatar

    mistake at 7:25, battleboard[i].length will return the length of rows not the columns

  18. shashgo Avatar

    Derek, awesome tutorials. Right now there are two things Im not too clear about. One is the enhanced for loop; I am more comfortable with the use of two variables to do the nested loops, rather than this new for of the for loop. So, is this enhanced for loop just another way of doing the looping, and can I still use the other way of using two variables to nest the loops? The other question I had was about this program; according to me, it just creates the board and puts the four monsters in random spots, am I correct?

    Also, on another tangent, do you also make tutorials on cyber security, like talking about TCP/IP, networking, etc

  19. Dale Goodrich Avatar

    Hey Derek…awesome videos…really enjoying them! One quick question about the Do-While loop you build to find an initial position for the monster in the constructor method. The While statement says while(battleBoard[randNumX][randNumY] != '*'; but then when you find a position that works, exit the loop and assign the monster to that position, the statement says battleBoard[this.yPosition][this.xPosition] = this.nameChar1;Why are the arguments in the while statement randNumX followed by randNumY but then they're switched in the assignment statement to this.yPosition followed by this.Xposition? My gut says the arguments in the while statement should be switched…[ranNumY] followed by [randNumX]. Correct?Thanks!

  20. Ben Avatar

    At 13:56, correct me if I'm wrong, but shouldn't randNumY be in the first brackets of the array. Maybe I had some fluke, but after I finished tutorial 10 my program was having problems with the random placement of the monsters and I'm pretty sure when I flipped the randNumX and randNumY it fixed the problem. Again I'm new to this so I could be wrong.

  21. Sarthak Dash Avatar

    great video!, but why at line 29 you used system.out.println() method?

  22. Johnny Batafljeska Avatar

    import java.util.Arrays could not be resolved… im runing on xp (still).. can somebody help

  23. Janel Logrono Avatar

    what is the difference of battleboard.length vs battleboard[i].length?

  24. Felipe Pagginelli P. Avatar

    What's the use of tempBattleBoard?

  25. Felipe Pagginelli P. Avatar

    Since we've already incremented the number of monsters inside the constructor, why do we have to use the block below?

    public MonsterTwo()
    {
    numOfMonsters++;
    }

  26. Rachana Podaralla Avatar

    HEY, I have java 8, and JRE 1.8 and I'm using the 1.7 compiler. I'm able to import java.util.Scanner but java.util.Arrays cannot be resolved. I tried clean, using alternate build path. What is going wrong here?

  27. BCwithPC Avatar

    @ 10:33 wouldn't you want
    public boolean getAlive()
    {
    return alive;
    }

  28. peter panschick Avatar

    How Eclipse autofill your commands like in 3:53.

    Should i turn something on or press a button for that?

  29. Darren Murphy Avatar

    nothing much goin on here just fartin' out some tuts lol

  30. jayarsh dhumal Avatar

    hey derek thank for awesome tutorial 🙂 …. i m thinking to take a certification course of scjp…… can you guide me and which book you will recommend for it ?

  31. vladi malashevskyy Avatar

    hello, your tutorials are really good, there's just one thing that doesn't make sense to me, why do you write:
    for (char[] row : battleBoard)
    what does "char[] row: battleBoard" mean?

Leave a Reply

Your email address will not be published. Required fields are marked *