Bomb man game development process (4) bomber show and move

Source: Internet
Author: User

Objective

In the above, I have described how to test, how to refactor tests, and through experiments to master the technology of map display. This article will use the technology shown in the map to show the bomber, and let our bomber move.

Note: In order to improve the quality of the blog and focus on recording development and iterative thinking practices, this article and subsequent posts will no longer record the test process.

The purpose of this article

To realize the bomber's display and movement.

Review the updated domain model above

Thinking about the domain model

The Showmap class is responsible for displaying the map, including the game logic. The game category is responsible for the logic of the game, so showmap and game have duplication of responsibilities. Moreover, the logic of the display map is not very complicated, and it can be directly placed in the game without the need for a special class to take charge of this part of the logic.

Now come back and look at the display map implementation of the Showmap class:

Drawmap:function () {
    var i = 0,
        j = 0,
        map = Bomberconfig.map,
        bitmap = null,
        mapData = Mapdataopera Te.getmapdata (),
        x = 0,
        y = 0,
        img = null;
  
    This._createlayer ();
  
    for (i = 0; i < map. ROW; i++) {
        //Note!
        //y is longitudinal height,x for transverse width
        y = i * map. HEIGHT;
  
        for (j = 0; J < map. COL; J + +) {
            x = J * Map. WIDTH;
            img = this._getmapimg (i, J, MapData);
            Bitmap = Bitmapfactory.createbitmap ({img:img, width:map. WIDTH, Height:map. HEIGHT, x:x, y:y});
            This.layer.appendChild (bitmap);
        }
    This.layer.draw ();
}

Showmap will display the specific implementation of the map delegated to layer, responsible for the operation of layer, this responsibility can also be moved to game. And given that the Showmap class is used as an experiment (see development strategy above), now the "show map" function has been implemented, SHOWMAP is not necessary.

So, I remove the Showmap class and move it into game.

The domain model after reconstruction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.