Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.0.1/TweenMax.min.js"></script>
<body>
  <div><h1>score : 0</h1></div>
  <svg width="1180" height='400'>
    <g>
       <image x="-80" y="100" xlink:href="http://www.changunn.com/blog/wp-content/uploads/2018/08/challenger-tank-firing-2-roy-pedersen1.png"/>
      <circle class="element" cx="55" cy="280" r="20px" />
      <circle class="element" cx="25" cy="280" r="20px" />
     <rect class="element" x="15" y="220" width="60" height="45"/>
      <rect class="element" x="65" y="250" width="100" height="5"/>
     </g>


  </svg>
  <p>click the thank</p>
</body>
</html>
              
            
!

CSS

              
                p {
  font-size:30px;
  fill: blue;
}

.element {
  fill:darkolivegreen
}
div {
  padding-left:50%
}

svg {
  background-color:lightgray};


              
            
!

JS

              
                tl = new TimelineMax();
var i = 0;


//the tank group <g> of circles and rects is moving on

tl.to("g",53,{x:850,ease:Linear.easeOut},"bang")




//the flame is invisible at the begining
tl.set("image",{autoAlpha:0,scale:0.5,transformOrigin:'0% 0%'},'bang');

//on click event. the tank is a group of circles and rects with class: element
$(".element").on("click",fire);

//on click function
function fire(){
  i=i+1;//score
 $("h1").text("score : "+i);//score
  tl=new TimelineMax();
  
  //label for back movment of tank
 tl.add("fr")
 
 //label from back move and fire of tank
.fromTo(".element",0.4,{x:-25},{x:5},"fr")
  .fromTo("image",0.4,{autoAlpha:1},{autoAlpha:0},"fr")
 ;
}
              
            
!
999px

Console