Skip to content

Commit

Permalink
Initial logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfyxon committed Dec 15, 2023
1 parent 177e9a7 commit da1c78f
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions scripts/tanksAndCannons.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
window.addEventListener("load",function(){
const canvas = document.getElementById("canv");

const imgTank1Base = document.getElementById("img-tank1-base");
const imgTank1Cannon = document.getElementById("img-tank1-cannon");

var tanks = [];
var cannons = [];

function addTank(){
const base = Sprite(imgTank1Base);
const cannon = Sprite(imgTank1Cannon);

const scale = 0.6;
const rmHeight = 20;

base.rescale(scale);
cannon.rescale(scale);

base.area.endVec.y -= rmHeight;
cannon.area.endVec.y -= rmHeight;

tanks.push({
base: base,
cannon: cannon
})
}
addTank()
setInterval(function(){
clearCanvas(canvas);

for(var i=0;i<tanks.length;i++){
const tank = tanks[i];
tank.base.render(canvas);
tank.cannon.render(canvas);
}

},optiItv());
})

0 comments on commit da1c78f

Please sign in to comment.