New Level: Let's Go Fly a Kite

Very pretty!

An extremely minor spelling correction in the guide:

their’s -> theirs

And I suppose it is better to use

this.remember === undefined

instead of

typeof this.remember === ‘undefined’

but that is also quite minor (and also something I suggested myself :stuck_out_tongue: ).

Otherwise I think the guide and the level are good. I’m very glad your guide shows us how to initialise variables. Maybe there should even be a snippet based on this, or maybe the snippet on functions should contain this.

In addition, I think your description of the obstacles/“playable area” is very good. I like the idea that you leave the square, but that it is easier not to.

Have you decided what you want to do with the cooldown yet? I kind of liked my own myAttack function that kept track of the cooldown.

And how about some fancy vectors too?

Done, not sure about cooldown, did you get yours to work well?

Yeah, my archer Stutter stepped quite nicely. But the attack animation of the archer takes quite long (I’d say 0.4 seconds), so you only get 0.2 seconds of free movement per shot (with a cooldown of 0.6).

The following code will make the archer “stutter”. There is some duplicate logic here, but only because myAttack is meant to always set the cooldown correctly, even when used by somebody who tries to attack when the cooldown is active :P.

if (this.firstTime === undefined){
    this.firstTime = false;
    this.say("first time!");
    this.maxCoolDown = 6;
    this.coolDown = 0;
    this.timesNope = 0;
    this.enemies = this.getEnemies();
    
    this.myAttack = 
        function(enemy){
            var eDist = this.distanceTo(enemy);
            if((eDist <= this.range) && 
            (this.coolDown === 0 )){
                this.attack(enemy);
                this.say("yes! " + this.coolDown);
                this.coolDown = this.maxCoolDown;
                }
                else{
                    this.say(
                    this.timesNope +
                    " nope! " + Math.round(
                        this.coolDown)
                    );
                    this.moveXY(
                        this.pos.x, this.pos.y
                        );
                    this.timesNope++;
                }
        };
}

if(this.coolDown > 0){
    this.coolDown = Math.round(this.coolDown - 1);
    }

var enemyExists;
enemyExists  = this.enemies.length > 0;

var eDist;
var enemy;
var enemyInRange;

if(enemyExists){
    enemy = this.getNearestEnemy();
    eDist = this.distanceTo(enemy);
    ePos = enemy.pos;
    enemyInRange = eDist <= this.range;
    if(enemyInRange){
        if(this.coolDown === 0 && eDist >= 10){
            this.myAttack(enemy);
        }
        else{
            this.moveXY(4, 50);
        }
    } else{
        this.moveXY(ePos.x, ePos.y );
    }
}

I just added a starting storyline to the level. I had issues with the camera placement, it didn’t want to point at what I told it to, so it is just stationary. What do you all think?

Hey, I quite liked the intro. But now it seems this.range is undefined. Also the guide talks about the town square, but you have changed the area to grass. Lastly, what do feel about the difference between move and moveXY? I personally prefer move, as I think it makes for prettier code. But I also think it may be harder to use, as you may have to pass it an object like {x: X, y: Y}.

Congrats for making it to the /play page!

And it turns out it is possible to influence the starting position of the archer by pressing shift+space a lot of times very quickly at the start. But I’d say that is only a minor issue. I see that range is undefined because you changed the name to attackRange in one place, but not in the other. I have made a few changes, maybe I will suggest a patch.

Working on a patch right now. Not sure where I missed changing to attackRange.

edit: OK, found where the attackRange hadn’t been changed.

1 Like

I agree, I like the name this.move better, but the arguments of this.moveXY better. Would be nice to simply have this.move and it can take a thang, a pos object, or 2 numbers.

Ah, nice patch, you made all the changes I was hoping for. I’m especially glad that we can now use both moveXY and move :). Note that move also works with vectors, which I think is sweet :).

Maybe I should finally solve the level now then :P. I’m being a bit perfectionistic about it, I don’t want to make a hacky solution, but rather a general one. But that is hard.

Try it, it’s fun! See if anyone can beat my solution–16 lines of CoffeeScript, which slays them in 3:00.4:

2 Likes

Challenge accepted!

python code, 12 lines (with no errors for getting distance to undefined)

Though I just dropped that time to 1:41.6 by changing a constant slightly. But the ogres appear randomly at the start, so anything within a few seconds of each other could be simply because of the random placement.

2 Likes

Well, it sure took some tweaking, but I beat your 1:41.6 in the end. My best: 1:39.7

2 Likes

Nice, I was thinking that some following a circular path might do better. Still pretty close considering the random placement, but it seems reasonable that it would out-perform my rectangle.

Hey Guys, I can’t play this level it detects an infinite loop or something when trying to load the level!

That is probably because it is such an old level. Perhaps there will be a way to bring it back somehow, but I do not know either.

Yup, still broken. (20 characters)