Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Beginner needs help
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01088449
Message ID:
01088783
Views:
19
The Bouncy Ball
* Bouncy.PRG
* Cheap - very cheap!
PUBLIC oform
minballwidth=12
maxballwidth=40

oform=CREATEOBJECT('theform')
WITH oform
.ADDOBJECT('cmdBallColor','theButton')
.cmdBallColor.CAPTION=[Fore]
.cmdBallColor.left=62
.ADDOBJECT('cmdFormColor','theButton')
.cmdFormColor.CAPTION=[Back]
.cmdFormColor.left=124
.addproperty("vector",1)
.addproperty("squeezevector",-1)
.addproperty("bounce",.f.)
ENDWITH 
READ events
RELEASE ALL

DEFINE CLASS theBigBall as Shape
curvature=99
height=40
width=40
backstyle=0
backcolor=RGB(0,100,255)
left=0
top=50
visible=.t.
borderwidth=8
bordercolor=RGB(255,0,0)
ENDDEFINE 

DEFINE CLASS theform as Form
Caption=[Horizontal Bouncer]
autocenter=.t.
width=186
height=300
PROCEDURE init
this.visible=.t.
this.resize
this.t1.interval=2
ENDPROC 
PROCEDURE queryunload
CLEAR EVENTS
ENDPROC 
PROCEDURE resize
STORE .2*this.height TO this.bigball.width,this.bigball.height,;
      maxballwidth
minballwidth=maxballwidth/3
this.BigBall.top=(this.height-this.bigball.height)/2
ENDPROC 
ADD OBJECT BigBall as theBigBall
ADD OBJECT t1 as theTimer
ADD OBJECT s1 as theSpinner
ENDDEFINE 

PROCEDURE moveball(oform) &&,nStart,nDirection)
WITH oform
.BigBall.left=.BigBall.left+.vector
.bounce=.vector>0 AND .BigBall.left>.width-.BigBall.width OR ;
        .vector<0 AND .BigBall.left<1
ENDWITH 
ENDPROC 

PROCEDURE squeezeball(oform)
WITH oform
.BigBall.width=.BigBall.width+.squeezeVector
IF .squeezevector>0 AND .BigBall.width>maxballwidth-1 && Done with bounce
   .bounce=.f.
   .squeezevector=-1
   .vector=.vector*-1
ELSE
IF .squeezevector<0 AND .BigBall.width<minballwidth
   .squeezevector=1
ENDIF
IF .vector>0
   .BigBall.left=.BigBall.left-.squeezevector
ENDIF 
ENDIF
ENDWITH 
ENDPROC 

DEFINE CLASS theTimer as Timer
interval=0
PROCEDURE timer
IF thisform.bounce
   squeezeball(oform)
ELSE 
   moveball(thisform)
ENDIF    
ENDPROC 
ENDDEFINE 

DEFINE CLASS theButton as CommandButton 
visible=.t.
top=0
left=0
height=20
width=60
fontsize=8
PROCEDURE click
IF this.Caption=[Fore]
   thisform.BigBall.bordercolor=GETCOLOR(thisform.BigBall.bordercolor)
ELSE
   thisform.backcolor=GETCOLOR(thisform.backcolor)
ENDIF 
ENDPROC
ENDDEFINE 

DEFINE CLASS theSpinner as Spinner
visible=.t.
width=60
height=20
fontsize=8
left=0
top=0
spinnerlowvalue=0
spinnerhighvalue=12
value=2
PROCEDURE interactivechange
thisform.t1.interval=this.Value
ENDPROC
ENDDEFINE 
*END Bouncy.PRG
Imagination is more important than knowledge
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform