Going Shopping!

clip art of man with neutral expression clip of a man with a neutral expression and arms folded cartoon of a man with a happy expression cartoon of a man with an alarmed expression


Video Tutorial

Click here for a YouTube video of Lloyd building this project.

(Note: For a "crystal clear" video, you may have to manually change the quality settings in YouTube to "720p HD" - just look for the gear symbol in the bottom right-hand corner of the YouTube window.)

LiveCode File for this Project

Original Script for the button "man":

Important Note: The icon numbers shown below will almost certainly not match the numbers needed in your program. So, be sure to check for the correct numbers (as explained in the video) and update accordingly.

 on mouseDown  
   grab me  
   set the icon of me to 1008  
   put empty into field "message"  
 end mouseDown  
 on mouseUp  
   set the icon of me to 1009  
   //Check for collisions  
   if intersect(me, button "bank", "opaque pixels") then  
    put "Thanks for taking me to the bank. Here's $5 for your trouble." into field "message"  
   end if  
   if intersect(me, button "grocery", "opaque pixels") then  
    put "Thanks for taking me to the grocery store. Here's a tomato for your trouble." into field "message"  
   end if  
 end mouseUp  

Advanced Script for the button "man":

 global varMoney, varGroceryCost, varIceCreamCost, varBankWithdrawal  
 on mouseDown  
   grab me  
   set the icon of me to 1043  
   put empty into field "message"  
 end mouseDown  
 on mouseUp  
   set the icon of me to 1042  
   //Check for collisions  
   if intersect(me, button "bank", "opaque pixels") then  
    set the icon of me to 1044  
    add 100 to varMoney  
    put "You withdrew $"&varBankWithdrawal&" from your account." into field "message"  
    put "$"&varMoney into field "money"  
   end if  
   if intersect(me, button "ice cream", "opaque pixels") then  
    if varMoney < varIceCreamCost then   
      put "Sorry, but you only have $"&varMoney&" to spend, and you need $"&varIceCreamCost&"." into field "message"  
      set the icon of me to 1041  
    end if  
    if varMoney >= varIceCreamCost then  
      set the icon of me to 1044  
      put "Enjoy an ice cream! You spent $"&varIceCreamCost&"." into field "message"  
      subtract varIceCreamCost from varMoney  
      put "$"&varMoney into field "money"  
    end if     
   end if  
   if intersect(me, button "grocery", "opaque pixels") then  
    if varMoney < varGroceryCost then   
      put "Sorry, but you only have $"&varMoney&" to spend, and you need $100." into field "message"  
      set the icon of me to 1041  
    end if  
    if varMoney >= varGroceryCost then  
      set the icon of me to 1044  
      put "Time to go shopping! You spent $"&varGroceryCost&"." into field "message"  
      subtract varGroceryCost from varMoney  
      put "$"&varMoney into field "money"  
    end if  
   end if  
 end mouseUp