HTML5 Game - Drawing the player ship with thrust

Description

Drawing the player ship with thrust

Demo

ResultView the demo in separate window

<!doctype html>
<html lang="en">
<body>
<div style="position: absolute; top: 50px; left: 50px;">
<canvas id="canvas" width="200" height="200">
 Your browser does not support the HTML 5 Canvas. 
</canvas>/*from  www  . j  a  va  2  s  . com*/
<script type="text/javascript">
    let theCanvas = document.getElementById('canvas');
    let context = theCanvas.getContext('2d');
   

    //drawShip
    context.strokeStyle = 'red';
    context.beginPath();
    context.moveTo(10,0); 
    context.lineTo(19,19);
    context.lineTo(10,9);
    context.moveTo(9,9); 
    context.lineTo(0,19);
    context.lineTo(9,0);
    
    //draw thrust
    context.moveTo(8,13); 
    context.lineTo(11,13);
    context.moveTo(9,14);
    context.lineTo(9,18);
    context.moveTo(10,14);
    context.lineTo(10,18);
    
    context.stroke();
    context.closePath();
</script> 

</div>
</body>
</html>

Related Topic