relopcasa.blogg.se

Battle city tank game
Battle city tank game













If he shot the enemy will be destroyed (or, inadvertently, your) tank, the game will be lost.

battle city tank game

In the lower center of the screen is always your headquarters (in the form of the emblem of an eagle), protected by a thin brick wall. The game is developed within a single screen (that is, without scrolling), filled with various elements of the landscape.

battle city tank game

If (upIsClear(playerCoords, playerCoords)) else if (event.key = 'D' || event.The concept of the game is quite simple: one (or two - in the mode for two players), your tank should kill hordes of attacking enemy tanks, while preventing the destruction of their own staff. ToRelativeCoord(playerCoords), width * 2, height * 2) ,Ĭonst canvas = document.getElementById('map') Ĭonst toRelativeCoord = (fromCoord) => fromCoord * width Ĭtx.fillRect(toRelativeCoord(playerCoords), I think my intersection logic is kind of rudimentary, is there a way to improve this as well?Īnd I also struggled a little bit with the map drawing, as it's drawn vertically so I had to change the i and j variables so that the map wouldn't be rotated 90 degrees, I'm also interested in other options to do this and not having to paint the map and player every time I move the player in one direction. My code currently creates the map using 26 x 26 little squares (I chosen that amount because there are 13 "cols" in the image above, but each brick col is destroyed partially by a certain amount per shot (if IRC that was about 2-4 shots in the original game), in my case that's 2 bullets, so 13x2 = 26), my player uses 2 x 2 which is not ideal, because it requires to check 2 blocks for every direction, if I wanted to use a bigger grid, the size of the player grid might increase as well, making the code unmaintainable, how could I improve this code in order to have my player a single entity instead of a 4-block entity? Nothing fancy just some squares with a color, I tried to replicate the first map: I've already managed to make the map and the player to move. A friend of mine gave me the task to create a Battle City replica.















Battle city tank game