Lurker News

Comments (270) 108 threads

Earlier comments
eagsalazar2#
Wow I really enjoyed that! When I was still trying to "win" my eyes were watering like crazy because you just can't blink once the score gets high. Am I the only one who at some point got suicidal? You're like OMG I need a break and the only way is to start chasing the red dot. When I got back below 10 and the red dot disappeared I was like holy shit there is no way out! Felt like a great twisted ending to some intense psycho thriller. Also my right (arrows) hand is now aching.

Great job!

krozgen2 replies#
Snowcrash mode :) (In console): setInterval(function() { hero.x = powerUp.x; hero.y = powerUp.y; }, 50); setInterval(function() { hero.x = reward.x; hero.y = reward.y; }, 100);
lmitchell#
I... definitely did not just watch this play itself for like five straight minutes...

I think I need to get more fresh air or something.

wrayjustin2 replies#
I did the same, but played around a bit more and made an "AI" mode:

  maxScore = 0;
  setInterval( function() {
  	if (score > maxScore) {
  		maxScore = score;
  	}
  	if (distance(hero.y, hero.x, ennemi.y, ennemi.x) < (vitesseEnnemi * 15 + 30)) {
  		hero.y += (hero.y - ennemi.y) * speedLimit / distance(hero.y, hero.x, ennemi.y, ennemi.x);
  		hero.x += (hero.x - ennemi.x) * speedLimit / distance(hero.y, hero.x, ennemi.y, ennemi.x);
  	}
  	if (spawn > PowerUpspawnRate) {
  		hero.y += (powerUp.y - hero.y) * speedLimit / distance(hero.y, hero.x, powerUp.y, powerUp.x);
  		hero.x += (powerUp.x - hero.x) * speedLimit/ distance(hero.y, hero.x, powerUp.y, powerUp.x);
  	} else {
  		hero.y += (reward.y - hero.y) * speedLimit / distance(hero.y, hero.x, reward.y, reward.x);
  		hero.x += (reward.x - hero.x) * speedLimit/ distance(hero.y, hero.x, reward.y, reward.x);
  	}
  }, 25);
It's oddly fun to watch the little green guy pull off some sick dekes.

If you want your green guy to flat-out avoid the enemy, just wrap the second set of conditions there in an else block.
edit: Formatting for readability/copy+paste

krozgen1 reply#
I love when the red square comes close and the green one jukes in a tight spiral around it, just thinking "Whoa nope nope NOPE ah it's okay"
wrayjustin1 reply#
LOL yeah, it's like watching a sport. By about a score of 300 the enemy is just too fast for our hero. =/

Continue this thread — 1 reply

toabi#
Lower the timeout from 25 to 5 and it's like Neo fighting agent smith :D
undershirt#
A great reflection on both the quality of the teacher and the promise of the student. And I really liked all the subtleties captured in such simple code. Refreshing!
Zelphyr1 reply#
That's impressive. Can you provide more info such as how old he is, did he have any kind of programming experience prior, and how did you go about teaching him?
lovasoa#
Of course I can. My brother is 15, he is smart and he had programmed before, but only on his calculator (in TI-BASIC, I think). He already knew the basics of programming. He got his first real computer for Christmas. I was with him at my parents house, behind his shoulder as we created the skeleton of the game together over a weekend. After that I left, and he kept adding features on his own.

Load more comments