Basketball Camp

Offensive Basketball Player Defensive Basketball Player basketball basket

LiveCode Files for this Project

Getting Started

We will build this stack together from scratch. Here are a few quick notes:

First Script for button "Move Offensive Player":

(Click here for a text file with these scripts.)

 on mouseUp  
   set the moveSpeed to 200  
   put random(320) into varOffensivex  
   put random(480) into varOffensivey  
   put round(varOffensivex/2) into varDefensivex  
   put round(varOffensivey/2) into varDefensivey  
   move button "offensive" to varOffensivex, varOffensivey without waiting  
   wait 10 ticks  
   set the moveSpeed to 100  
   move button "defensive" to varDefensivex, varDefensivey   
 end mouseUp  

 


Final Script for button "Move Offensive Player":

 on mouseUp  
   set the moveSpeed to 200  
   //basketball court is 10 pixels from each side, so subtract 20 from screen dimensions for next two lines  
   put (the random of 300)+10 into varOffensivex  
   put (the random of 460)+10 into varOffensivey  
   put item 1 of the location of button "basket" into varBasketx  
   put item 2 of the location of button "basket" into varBaskety  
   put round (varBasketx + ((varOffensivex-varBasketx)/2) ) into varDefensivex  
   put round (varBaskety + ((varOffensivey-varBaskety)/2) ) into varDefensivey  
   move button "offensive" to varOffensivex, varOffensivey without waiting  
   wait 10 ticks  
   set the moveSpeed to 100  
   move button "defensive" to varDefensivex, varDefensivey   
 end mouseUp  

Adding a skin to a button (one approach)

on opencard

set the icon of button "offensive" to {IDNumberOfImage}

end opencard