Bouncing Smiley Script

Friday, October 6, 2006 by sViz | Discussion: DesktopX

Okay, so a while back I got an idea for this widget and it involves A LOT of special effects. Seemed like a daunting task to undertake but inspired by SirSmiley’s cool effects undertook it I did. In case I never actually complete this widget (considering how slow the process is) I just wanted to share the scripts for the effects as I complete them. Needless to say, credit goes to RomanDA for his very helpful tutorials.

The first one I’ve completed is the bouncing smiley (my desktop has been a zoo with smilies going every which way). It works best with any round image. I’ve broken down each action into sub procedures—it’s just easier for me to comprehend and manage that way.


Dim maxW
Dim minW

Sub Object_OnScriptEnter
'--Set maximum & minimum width
maxW= 100
minW= 40
'---Set object's position, width & height
object.left =500
object.top= 500
object.Width = 50
object.Height =50
Call jump
End Sub

Sub jump
object.SetTimer 1, 15
object.KillTimer 6
End Sub

Sub slowup
object.SetTimer 2, 15
object.KillTimer 1
End Sub

Sub slowdown
object.SetTimer 3, 15
object.KillTimer 2
End Sub

Sub fall
object.SetTimer 4, 15
object.KillTimer 3
End Sub

Sub squash
object.settimer 5, 15
object.KillTimer 4
End Sub

Sub stretch
object.settimer 6, 15
object.KillTimer 5
End Sub



'----JUMP-----
Sub object_ontimer1
object.Top = object.top -10
If object.top <= 350 Then Call slowup
End Sub

'----SLOW UP----
Sub object_ontimer2
object.top= object.top - 5
If object.top <= 300 Then Call slowdown
End Sub

'----SLOWDOWN----
Sub object_ontimer3
object.Top = object.top+5
If object.top => 315 Then Call fall
End Sub

'----FALL----
Sub object_ontimer4
object.Top= object.top + 10
If object.top => 500 Then Call squash
End Sub

'----SQUASH----
Sub object_ontimer5
If object.width < maxW Then
object.height = object.height-2
object.width= object.Width +5
object.top= object.top + 2
object.Left= object.Left -2
End If
If object.width => maxW Then Call stretch
End Sub

'----STRETCH----
Sub object_ontimer6
If object.width > minW Then
object.height = object.height+2
object.width= object.Width -5
object.top= object.top - 2
object.Left= object.Left +2
End If
If object.width <= minW Then Call jump
End Sub





Thanks for reading. More later. Please share any tips or comments.
ZubaZ
Reply #1 Friday, October 6, 2006 1:14 PM
Too fun!! Thanks!
SirSmiley
Reply #2 Friday, October 6, 2006 3:05 PM
Hillarious. Should try them with one of Mouserunner's Smiley's.

Edit: Of course my lazy @ss prefers to drag & drop. So, add this to the bottom of the script for easy changing.

'Drop random files for more fun.
Sub Object_OnDropFiles(files)
Object.picture = files
End Sub
sViz
Reply #3 Saturday, October 7, 2006 12:10 PM
Thanks for the tip SirS I'll be sure to include it in the next script. Also, thanks for the link to that site.   
sViz
Reply #4 Saturday, October 7, 2006 5:16 PM
A few additional sub procedures in this script has the smiley bouncing from one end of the screen to the other and then starting over again. It is set to bounce from left to right. To change directions just uncomment Call bounceLeft and comment out Call bounceRight.



Dim maxW
Dim minW

Sub Object_OnScriptEnter
'--Set maximum & minimum width
maxW= 100
minW= 40
'---Set object's position, width & height
object.left =system.VScreenLeft
object.top= 500
object.Width = 50
object.Height =50
Call jump
Call bounceRight
'Call bounceLeft
End Sub


Sub jump
object.SetTimer 1, 15
object.KillTimer 6
End Sub

Sub slowup
object.SetTimer 2, 15
object.KillTimer 1
End Sub

Sub slowdown
object.SetTimer 3, 15
object.KillTimer 2
End Sub

Sub fall
object.SetTimer 4, 15
object.KillTimer 3
End Sub

Sub squash
object.settimer 5, 15
object.KillTimer 4
object.KillTimer 7
object.KillTimer 8
End Sub

Sub stretch
object.settimer 6, 15
object.KillTimer 5
End Sub

Sub bounceLeft
object.SetTimer 7, 15
object.KillTimer 8
End Sub

Sub bounceRight
object.settimer 8, 15
object.KillTimer 7
End Sub

'----JUMP-----
Sub object_ontimer1
object.Top = object.top -10
Call bounceRight
'Call bounceLeft
If object.top <= 350 Then Call slowup
End Sub

'----SLOW UP----
Sub object_ontimer2
object.top= object.top - 5
If object.top <= 300 Then Call slowdown
End Sub

'----SLOWDOWN----
Sub object_ontimer3
object.Top = object.top+5
If object.top => 315 Then Call fall
End Sub

'----FALL----
Sub object_ontimer4
object.Top= object.top + 10
If object.top => 500 Then Call squash
End Sub

'----SQUASH----
Sub object_ontimer5
If object.width < maxW Then
object.height = object.height-2
object.width= object.Width +5
object.top= object.top + 2
object.left= object.left- 2
End If
If object.width => maxW Then Call stretch
End Sub

'----STRETCH----
Sub object_ontimer6
If object.width > minW Then
object.height = object.height+2
object.width= object.Width -5
object.top= object.top – 2
object.left= object.left+ 2
End If
If object.width <= minW Then Call jump
End Sub

'----BOUNCE LEFT----
Sub object_ontimer7
If object.left > system.VScreenLeft Then object.left = object.Left -5
If object.left < system.VScreenLeft Then object.left = system.screenwidth
End Sub

'----BOUNCE RIGHT----
Sub object_ontimer8
If object.left <= system.ScreenWidth Then object.left = object.Left +5
If object.right => system.ScreenWidth Then object.left = 0
End Sub


'---Drop random files to change picture
Sub Object_OnDropFiles(files)
Object.picture = files
End Sub
SirSmiley
Reply #5 Saturday, October 7, 2006 8:39 PM

This ones even harder to catch & drop a picture on. Lot's of fun.

It's got me thinking again about the dx's ability for some simple games like pong, air hockey, snake, etc.
RomanDA
Reply #6 Tuesday, October 10, 2006 12:21 PM
Rock on!!
This looks kewl..

if one of the top selling gadgets is a magic 8-ball, this could have a future!!

Gald the Tut's help

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01