FightCode: code your own robot using JavaScriptFightCode: танковые войны на JavaScript

FightCode – this is an online game for programmers, such as Robocode. JavaScript is used to programme your tanks. You can see the battles just in the browser. The Code Editor has got «jail» inside browser, which allows to see the result of code changes in the real time. The authors of FightCode has effectively worked with graphics. The game is also easy for coding and has good documentation.

[tube]http://www.youtube.com/watch?v=9-nZykgmr3E&feature=youtu.be[/tube]
FightCode – это онлайн-игра для программистов, сделанная по образу и подобию классической Robocode. Для программирования танков используется JavaScript, а сражения происходят прямо в вашем браузере. Редактор кода на сайте имеет встроенную «песочницу», которая позволяет в реальном времени видеть эффект от изменений кода. В отличие от других подобных игр, создатели FightCode хорошо поработали над графикой в игре. При этом игра достаточно проста и хорошо документирована.

[tube]http://www.youtube.com/watch?v=9-nZykgmr3E&feature=youtu.be[/tube]

The example of my tank:

//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {

};

Robot.prototype.onIdle = function(ev) {
    var r = ev.robot;
    r.clone();
    r.rotateCannon(360);
    r.ahead(150);     
    r.turn(30);
    r.ahead(150);
};

//the enemy in sight
Robot.prototype.onScannedRobot = function(ev) {
    var r = ev.robot;     
		if (ev.scannedRobot.parentId == r.id || ev.scannedRobot.id == r.parentId) {
			return; //do not shoot at the friendly tanks
		}  
  	r.rotateCannon(2);    
  	r.fire(); 
  	r.turn(8);            
  	r.rotateCannon(-20); 
  	r.ahead(15);
};

// switch on the hiding
Robot.prototype.onHitByBullet = function(ev) {
    var r = ev.robot;
    r.disappear();
}

// hit the wall
Robot.prototype.onWallCollision = function(ev) {
    var r = ev.robot;
    r.back(50);
};

//hit the tank
Robot.prototype.onRobotCollision = function(ev) {
    var r = ev.robot;
    r.back(30);
};


Пример моего танка:

//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {

};

Robot.prototype.onIdle = function(ev) {
    var r = ev.robot;
    r.clone();
    r.rotateCannon(360);
    r.ahead(150);     
    r.turn(30);
    r.ahead(150);
};

//в поле зрения появился враг
Robot.prototype.onScannedRobot = function(ev) {
    var r = ev.robot;     
		if (ev.scannedRobot.parentId == r.id || ev.scannedRobot.id == r.parentId) {
			return; //не стреляем по своим
		}  
  	r.rotateCannon(2);     // пара градусов вправо
  	r.fire(); 
  	r.turn(8);             // 10 минус 2 градуса вправо
  	r.rotateCannon(-20); 
  	r.ahead(15);
};

// как только нас засекли - включаем маскировку
Robot.prototype.onHitByBullet = function(ev) {
    var r = ev.robot;
    r.disappear();
}

// как только врезались в стену
Robot.prototype.onWallCollision = function(ev) {
    var r = ev.robot;
    r.back(50);
};

//как только врезались в другой танк
Robot.prototype.onRobotCollision = function(ev) {
    var r = ev.robot;
    r.back(30);
};

52 комментария к “FightCode: code your own robot using JavaScriptFightCode: танковые войны на JavaScript

  1. Hello there, just became aware of your blog through Google, and found that
    it is truly informative. I am gonna watch out for brussels.

    I’ll be grateful if you continue this in future. A lot of people will be benefited
    from your writing. Cheers!

  2. Howdy! This article couldn’t be written much better!
    Reading through this post reminds me of my previous roommate!

    He constantly kept talking about this. I’ll send this article to him.
    Fairly certain he’s going to have a very
    good read. Thanks for sharing!

  3. My spouse and I stumbled over here coming from a different web
    address and thought I may as well check things out.
    I like what I see so now i am following you. Look forward to exploring
    your web page yet again.

  4. After going over a few of the blog articles on your
    web site, I honestly appreciate your technique of blogging.

    I book-marked it to my bookmark website list and will be checking back in the near
    future. Take a look at my web site as well and let me know your opinion.

  5. Hey are using WordPress for your site platform?
    I’m new to the blog world but I’m trying to get started
    and create my own. Do you require any coding expertise to make
    your own blog? Any help would be greatly appreciated!

  6. Oh my goodness! Impressive article dude! Thanks, However I am encountering problems with your RSS.
    I don’t know the reason why I cannot join it. Is there anybody getting identical RSS issues?
    Anybody who knows the answer will you kindly respond?
    Thanks!!

  7. Hey there! I know this is somewhat off-topic but I needed to ask.
    Does running a well-established blog such as yours require a lot
    of work? I’m completely new to operating a blog however I do
    write in my diary everyday. I’d like to start a blog so I can share my personal experience and thoughts online.

    Please let me know if you have any ideas or tips for new
    aspiring bloggers. Thankyou!

  8. Hey there! I know this is kind of off topic but I was wondering which blog platform are you
    using for this site? I’m getting sick and tired of WordPress
    because I’ve had issues with hackers and I’m looking at alternatives for another platform.
    I would be fantastic if you could point me in the direction of a good platform.

  9. I truly love your site.. Excellent colors & theme.
    Did you create this website yourself? Please reply back as I’m wanting to create my own blog and want to learn where
    you got this from or just what the theme is named. Thank you!

  10. Oh my goodness! Amazing article dude! Thank you so much, However I am
    going through problems with your RSS. I don’t know why I can’t join it.

    Is there anybody having identical RSS issues? Anybody who knows the answer will you
    kindly respond? Thanks!!

  11. I would like to thank you for the efforts you have put in penning this site.

    I am hoping to check out the same high-grade blog posts by you in the future as well.
    In truth, your creative writing abilities has encouraged me to get my own blog now 😉

  12. Hmm is anyone else experiencing problems with the pictures
    on this blog loading? I’m trying to determine if its a problem on my end or if it’s the blog.
    Any suggestions would be greatly appreciated.

  13. I seriously love your blog.. Pleasant colors & theme. Did you make this web site
    yourself? Please reply back as I’m trying to create my own personal website and would love to
    learn where you got this from or just what the theme is
    named. Thanks!

  14. Hi, Neat post. There’s an issue with your website
    in internet explorer, would check this? IE still is the market leader and a large component to people will omit your excellent writing because of this problem.

  15. I’m truly enjoying the design and layout of your site.

    It’s a very easy on the eyes which makes it
    much more enjoyable for me to come here and visit more often. Did you hire out a designer to create your theme?
    Excellent work!

  16. Great goods from you, man. I have take note your stuff prior to and you are simply extremely fantastic.

    I actually like what you have received here, certainly like what you are saying and the best way in which you are saying
    it. You’re making it enjoyable and you continue to take care of to stay it wise.
    I can’t wait to read much more from you. That
    is really a wonderful site.

  17. Very nice post. I just stumbled upon your blog and wished to
    say that I’ve truly enjoyed surfing around your blog posts.

    After all I’ll be subscribing to your rss feed and I hope you write again very soon!

  18. Greetings! Quick question that’s totally off topic. Do you know how to make your site mobile
    friendly? My web site looks weird when viewing from my iphone.
    I’m trying to find a template or plugin that might
    be able to fix this issue. If you have any recommendations, please share.

    Thank you!

  19. Do you have a spam issue on this site; I also am a blogger,
    and I was wanting to know your situation; many of us have
    created some nice methods and we are looking to swap methods with others, please shoot me an e-mail if interested.

  20. Your style is very unique compared to other folks I’ve read stuff from.
    I appreciate you for posting when you’ve got the opportunity,
    Guess I will just book mark this web site.

  21. Hi there would you mind stating which blog platform you’re using?
    I’m looking to start my own blog in the near future but
    I’m having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different
    then most blogs and I’m looking for something unique.
    P.S Sorry for being off-topic but I had to ask!

  22. Its such as you learn my thoughts! You appear to understand so much about this, such as you wrote the e-book in it
    or something. I believe that you simply could do with a few
    p.c. to power the message home a little bit, however other than that, that is fantastic blog.
    A fantastic read. I will certainly be back.

Оставить ответ

Ваш адрес email не будет опубликован. Обязательные поля помечены *