It might be better to not use a loop here, because the movements needed aren’t obviously the same in the two loop iterations. That said, nice thinking for using one!
Soon I’ll be adjusting it such that when you attack an enemy, you return to your starting position before moving on, so it should be less messy.
Thanks Nick! I finally finished all the beginner courses! I look forward to beginner-intermediate courses! ^^ This is really inspiring me to go back to college and get my degree in programming. Once I got a hold of the “loop” and "self.moveXY(.__), really bloomed!
I have been having a lot of difficulty with this level. I am able to kill the first ogre, but no matter how I code to kill the second ogre my avatar just stands there and lets it kill him. Any suggestions would really help! My code looks something like this:
Hey @Josiah, sorry for the difficulty. We’re going to try to make this part easier soon. The problem is that you need to assign the result of self.findNearestEnemy() to the target variable. Otherwise, you still have the old target and are trying to attack that instead of trying to attack the new nearest enemy.
To assign target again, look at how you assigned it the first time:
target = self.findNearestEnemy()
You’ll want to do that again before you attack the second ogre, once you can see her.
I am working in Java. My browser is Firefox. I used all the codes I have learn so far and nothing happens.
this.moveRight();
// You should recognize this from the last level.
enemy = this.findNearestEnemy();
// Now attack the variable.
// And there's another room to clear!
Give code: Line 1, time 0.0: tmp2[tmp3] is not a function
I’ve tried this.moveXY(11, 34);
I’ve tried this.say("Hey there!");
I’ve tried every code I know and the guy won’t move or say anything.
Also, while this is probably considered a minor detail, you are using JavaScript, not Java. JavaScript is a Scripting language (duh ) used in websites along with html and css. Java is full programming language, which is origanally designed to be used on any computer, and is actually quite different, (and, in my opinion, harder to learn,) than JavaScript.