I'm attempting to create a laser beam that can shoot enemies on the screen, much like in classic games such as Space Invaders or Galaga. However, I am encountering difficulties getting the laser to move when I click the button. Below is the code I have so far:
<html>
<body>
<div id="container"></div>
<button type='button'>click me</button>
<div id="laser" style="display: none; background-color:red; width:100px; height:50px"></div>
<script>
$(document).ready(function()
{
$('button').click(function()
{
$('#container').append($('#laser'));
$('#laser').show()
$('#laser').animate({left:'500px'},5000);
});
)};
</script>