JSWARRIOR

By June 4, 2015 Creative No Comments
jswarrior

jswarrior-background

Would you like to try your hand at a little programming? Well recently I’ve discovered a pretty cool game that you can play, instead of using conventional keyboard/mouse controls you have to steer your character through perils and dangers using only Java…

The first two levels are completed for you but after that you’re on your own!

Here’s my solution to level 3 to get you started…

Click to reveal solution

jsWarrior.turn = function(warrior) {
if(warrior.check() == "enemy") {
if (warrior.getHealth() < 10) {
warrior.walk('backward');
} else {
warrior.attack();
}
}
else {
if (warrior.getHealth() < 20) {
warrior.rest();
} else {
warrior.walk();
}
}
}
Other topics of interest...

Agent Marketing
Agent Marketing
X
Agent help to develop brands through insight and collaboration - we connect people through a unique, united, multidisciplinary approach to marketing. In this era of constant change we do what's absolutely necessary to help you transform and unleash potential.

It's an experience that we love, it's what we do and by meticulously guiding you through our process we'll create success that you'll be proud to communicate.
LIVERPOOL
LONDON
X