Programming Video Games - Understanding Motion

Started by kevin, February 02, 2010, 08:29:57 AM

Previous topic - Next topic

kevin

  Programming Video Games - Understanding Motion (Part 1 of 2)

   This series of example will hopefully shed some light upon how we create the illusion of the motion in computer program.  



Example #1

   This example displays three whole frames of a moving circle.

 
PlayBASIC Code: [Select]
   ; In this we're going to see how we create the illusion
; of motion in our programs
;
; To do this, we need to make our program draw the moving object
; in one place, show this to the user, then clear the screen then
; move the object to it's next position and repeat the process.
;


; ==========================
; FRAME #1
; ==========================

; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)

; draw the object in it's first position
Circle 100,200,50,true

; show the screen to the user
Sync

; Wait a 1/2 of a second (500 milliseconds)
Wait 500


; ==========================
; FRAME #2
; ==========================

; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)

; draw the object (10 pixels across from where it was drawn in frame #1)
; So to the user it'll appear to have moved to the RIGHT.
Circle 110,200,50,true

; show the screen to the user
Sync


; Wait a 1/2 of a second (500 milliseconds)
Wait 500



; ==========================
; FRAME #3
; ==========================

; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)

; draw the object (10 pixels across from where it was drawn in frame #2)
; So to the user it'll appear to have moved to the RIGHT.
Circle 120,200,50,true

; show the screen to the user
Sync



; Display the message done when the demo is complete
Print "Done"

; wait for the user to press a key
WaitKey









 Example #2 (Moving Object Across the Screen)

   This example extend the previous example, so rather than moving three small steps, this one appears to make the circle move all the way across the screen.


PlayBASIC Code: [Select]
   ;  This example extends the first example.  This time, the following
; code make a circle appear to move all the way across the screen..



; Frame #1
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 0,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #2
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 10,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #3
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 20,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #4
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 30,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #5
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 40,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #6
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 50,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #7
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 60,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #8
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 70,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #9
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 80,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #10
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 90,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #11
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 100,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #12
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 110,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #13
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 120,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #14
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 130,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #15
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 140,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #16
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 150,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #17
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 160,200,50,true
; show the screen to the user
Sync
; Wait a 1/10 of a second (100 milliseconds)
Wait 100; Frame #18
; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)
; draw the object in it's first position
Circle 170,200,50,true
; show the screen to the user
Sync
Login required to view complete source code



   While this works, it's really not very practical from a programming stand point.   I mean, that's  an awful lot of code to so such a simple thing.  Imagine the amount of code required to move a screen full of objects..    So clearly there must be a better way.    


 

Example #3

   This example replaces all the manual code with a FOR/NEXT looping structure.    This greatly simplifies the code and gives us much more flexibility..  

 
PlayBASIC Code: [Select]
   ; In the previous examples our program created motion by manually drawing
; the circle at fixed positions on the screen, then showing the screen
; to the user. While that works, it's really not very practical.

; This time aroudn we're going to use a VARIABLE and FOR/NEXT loop.
; Our For /Next loop is going to count from 0 to 800 (By one's).
; We'll use this counter our circles X position.

; So each loop,

; * we clear the screen (removing whatever was last on it)
; * draw our moving object (in this case our circle)
; * Sync to show the newly drawn screen to the user
; * Wait 10 milliseconds. This gives the viewer enough time to see
; the newly drawn screen.
;
; if we do this each loop and our loop counts from 0 to 800, then the viewer
; will see the circle move slowly across the screen.


; Set up our For/Next loop. This Loop will use the XPOS variable as it's counter
; when the loop starts XPOS variable will be initialized to 0. Each time PB runs
; through the For/NEXT loop, the XPOS variable will be increased by ONE.
; It'll keep doing this, until XPOS reaches the higher limit of 800.
For Xpos =0 to 800

; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)

; draw the at it's CURRENT position. Notice we're using the XPOS
; variable this time.
Circle Xpos,200,50,true

; show the screen to the user
Sync

; Wait a 1/100 of a second (10 milliseconds)
Wait 10

; End of For/Next loop. If our loop counter XPOS is bellow the upper
; limit, PB will jump back to the top of the FOR loop and run the code
; inside the FOR/NEXT loop. It'll do this until XPOS becomes greater
; then the upper limit of 800 in this case
Next


; Display the message done when the demo is complete
Print "Done"

; Show the screen to the user
Sync


; wait for the user to press a key
WaitKey








 Example #4

   Moving to a  DO/loop structure to make the code more flexible.

PlayBASIC Code: [Select]
   ;   In the FOR/NEXT example we're successfully created a program that
; allows us to easily display a moving object. But there's a problem!
; Namely, how do we move many different objects ? Given that if we have
; many objects we're probably all going to be moving at different speeds
; and in different directions. So we'll have to look for another way.
;
; To solve this, we'll change our program to wrap the drawing process
; into a DO / LOOP structure. This structure will keep running our
; drawing code, while not being attached directly to the moving object.
;
; In the FOR/NEXT example, we used the For Loop change the XPOS variable
; for us, this time we're going have to handle this outselves. So each
; time PB executes the code within our DO/LOOP we need to add some code
; that will take the objects current XPOS value our moving objects X
; coordinate) and ADD ONE to it.
;
; We can do this in two ways. We can we can do it manually (Xpos=Xpos+1)
;, or use the INC operator (Inc XPOS).


; So this time, each loop we're,

; * we clear the screen (removing whatever was last on it)
; * draw our moving object (in this case our circle)
; * Add one our moving objects X coordinate (Xpos=Xpos+1)
; * Sync to show the newly drawn screen to the user
; * Wait 10 milliseconds. This gives the viewer enough time to see
; the newly drawn screen.
;
; if we do this each loop and our loop counts from 0 to 800, then the viewer
; will see the circle move slowly across the screen.


Do

; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)

; draw the at it's CURRENT position. Notice we're using the XPOS
; variable this time.
Circle Xpos,200,50,true

; Add one the XPOS Variable
Xpos =Xpos+1

; show the screen to the user
Sync

; Wait a 1/100 of a second (10 milliseconds)
Wait 10


loop


; NOTE: PRESS ESC or CLICK the windows [X] gadget to END PROGRAM








kevin

  Programming Video Games - Understanding Motion (Part 2 of 2)

   These series of example continue on the from previous post.   I suggest reading those prior to this (if you haven't already).


  Goto Part#1



 Example #5 (Multiple Objects)

   This example extends the  example #4 to handle moving multiple objects at once.  

PlayBASIC Code: [Select]
   ;  The previous example virtually emulates what the FOR/NEXT version
; did earlier. So this time, let's add a second moving object to the
; program.

; To do this, we'll rename our XPOS to XPOS1, we'll also add
; a variable YPOS1. These variables will hold the X/Y coordinates
; object #1.
;
; For our second object, we'll add two more variables Xpos2 and Ypos2
; these will be used to hold the second objects X/Y coordinate on screen.
;
; This time, we'll start Object #1 at the right hand side of the screen
; and move it LEFT. To do this, means that rather than adding to it's
; Xpos1 variable, we'll subtract one from it each update.
;
; For object #2, we'll start this object at the top of the screen
; and move it down. This means adding one to it's Y coordinate
; variable which is YPOS2.



; So this time, each loop we're,

; * we clear the screen (removing whatever was last on it)
; * draw our moving object (in this case our circle)

; * Subtract one from object #1 X coordinate (Xpos1=Xpos1-1)

; * Add one to object #2 Y coordinate (Ypos2=Ypos2+1)

; * Sync to show the newly drawn screen to the user
; * Wait 10 milliseconds. This gives the viewer enough time to see
; the newly drawn screen.
;
; if we do this each loop and our loop counts from 0 to 800, then the viewer
; will see the circle move slowly across the screen.


; init the Starting coordinate for Object #1
Xpos1 =800
Ypos1 = 100


; init the Starting coordinate for Object #2
Xpos2 =400
Ypos2 = 0


Do

; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)

; ==================
; Draw our objects
; ==================

; draw object #1 at it's CURRENT position.
Circle Xpos1,Ypos1,50,true


; draw object #2 at it's CURRENT position.
Circle Xpos2,Ypos2,50,true


; ==================
; Move our objects
; ==================

; Subtract one from the XPOS1 Variable (the X coordinate of object #1)
Xpos1 =Xpos1-1

; Add one the YPOS2 Variable (the y coordinate of object #2)
Ypos2 =Ypos2+1

; show the screen to the user
Sync

; Wait a 1/100 of a second (10 milliseconds)
Wait 10


loop

; NOTE: PRESS ESC or CLICK the windows [X] gadget to END PROGRAM





 


 Example #6 (Multiple Objects)

   This example extends the  example #5 to handle 3 moving objects this time.  

PlayBASIC Code: [Select]
   ;  Let's another object to scene (object #3).   We'll also
; change the colour of each object, so we can tell them apart.

; Object #1 and #2 are the same as the previous example,
; but Object #3 is going to move in diagonally down and to the right
; To do this , means we need change it's X and Y coordinate each update
; So each update we'll move it right by two and down by one.


; So this time, each loop we're,

; * we clear the screen (removing whatever was last on it)

; * draw our moving object (in this case our circle)

; * Subtract one from object #1 X coordinate (Xpos1=Xpos1-1)

; * Add one to object #2 Y coordinate (Ypos2=Ypos2+1)

; * Add two to object #3 X coordinate (Xpos3=Xpos3+2)
; * Add one to object #3 Y coordinate (Ypos3=Ypos3+1)


; * Sync to show the newly drawn screen to the user

; * Wait 10 milliseconds. This gives the viewer enough time to see
; the newly drawn screen.
;
; if we do this each loop and our loop counts from 0 to 800, then the viewer
; will see the circle move slowly across the screen.


; init the Starting coordinate for Object #1
Xpos1 =800
Ypos1 = 100


; init the Starting coordinate for Object #2
Xpos2 =400
Ypos2 = 0


; init the Starting coordinate for Object #3
Xpos3 = 0
Ypos3 = 0


Do

; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)

; ==================
; Draw our objects
; ==================

; draw object #1 at it's CURRENT position (in RED).
Circlec Xpos1,Ypos1,50,true,rgb(255,0,0)
CenterText Xpos1,Ypos1,"Object #1"


; draw object #2 at it's CURRENT position (in Green).
Circlec Xpos2,Ypos2,50,true,rgb(0,255,0)
CenterText Xpos2,Ypos2,"Object #2"


; draw object #3 at it's CURRENT position (in Blue).
Circlec Xpos3,Ypos3,50,true,rgb(0,0,255)
CenterText Xpos3,Ypos3,"Object #3"


; ==================
; Move our objects
; ==================

; Subtract one from the XPOS1 Variable (the X coordinate of object #1)
Xpos1 =Xpos1-1

; Add one the YPOS2 Variable (the y coordinate of object #2)
Ypos2 =Ypos2+1

; Add two the XPOS3 Variable (the X coordinate of object #3)
Xpos3 =Xpos3+2

; Add one to the YPOS3 Variable (the Y coordinate of object #3)
Ypos3 =Ypos3+1

; show the screen to the user
Sync

; Wait a 1/100 of a second (10 milliseconds)
Wait 10


loop

; NOTE: PRESS ESC or CLICK the windows [X] gadget to END PROGRAM






 Example #7 (Multiple Objects Using Arrays)

     I the previous example we're using threes pairs of variables as the three objects X/Y coordinates.   While this is a viable solution for a small number of the objects.  What if we wanted to move 50 objects ? -  For that we'll need to use ARRAYS  


PlayBASIC Code: [Select]
   ;  In example #6,  we set up the code to handle moving three
; objects at once. Now, if all we've got is three, then
; that approach would be as good as any. But what if need
; to handle 50 objects at once ?
;
; Well, this is where ARRAYS are our friend. Rather than
; using pair of indivual variables for each object we want
; to move. What we could do, is create some arrays to hold
; each objects X/ Y coordinates in.
;
; So if we had three objects, we could dimension an array
; called XPOS, with size to hold 3 values in. The same goes
; for the Y coordinates.
;
; To dimension an Array we use the DIM command, followed by the
; array's NAME and it's size in brackets.
;
; Dim Xpos(3) ; Dim an array called Xpos with 3 slots in it
; Dim Ypos(3) ; Dim an array called Ypos with 3 slots in it

; These will take the place our unique three set of variables
; Xpos1,Ypos1 Xpos2,Ypos2, Xpos3,Ypos3

; We'll keep the motion the same as it was in the previous demo,
; the only change is that we're now storing each objects coordinates
; in arrays

; So this time, each loop we're,

; * we clear the screen (removing whatever was last on it)

; * draw our moving object (in this case our circle)

; * Subtract one from object #1 X coordinate (Xpos1=Xpos1-1)

; * Add one to object #2 Y coordinate (Ypos2=Ypos2+1)

; * Add two to object #3 X coordinate (Xpos3=Xpos3+2)
; * Add one to object #3 Y coordinate (Ypos3=Ypos3+1)


; * Sync to show the newly drawn screen to the user

; * Wait 10 milliseconds. This gives the viewer enough time to see
; the newly drawn screen.
;
; if we do this each loop and our loop counts from 0 to 800, then the viewer
; will see the circle move slowly across the screen.


; Dimension the Xpos and Ypos arrays. These arrays are big enough to hold
; coordinates for our 3 objects
Dim Xpos(3)
Dim Ypos(3)


; init the Starting coordinate for Object #1
Xpos(1) =800
Ypos(1) = 100


; init the Starting coordinate for Object #2
Xpos(2) =400
Ypos(2) = 0


; init the Starting coordinate for Object #3
Xpos(3) = 0
Ypos(3) = 0


Do

; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)

; ==================
; Draw our objects
; ==================

; draw object #1 at it's CURRENT position (in RED).
Circlec Xpos(1),Ypos(1),50,true,rgb(255,0,0)
CenterText Xpos(1),Ypos(1),"Object #1"


; draw object #2 at it's CURRENT position (in Green).
Circlec Xpos(2),Ypos(2),50,true,rgb(0,255,0)
CenterText Xpos(2),Ypos(2),"Object #2"


; draw object #3 at it's CURRENT position (in Blue).
Circlec Xpos(3),Ypos(3),50,true,rgb(0,0,255)
CenterText Xpos(3),Ypos(3),"Object #3"


; ==================
; Move our objects
; ==================

; Subtract one from the XPOS array slot 1 (the X coordinate of object #1)
Xpos(1) =Xpos(1)-1

; Add one the YPOS array slot 2 (the y coordinate of object #2)
Ypos(2) =Ypos(2)+1

; Add two to the XPOS array slot 3 (the X coordinate of object #3)
Xpos(3) =Xpos(3)+2

; Add one to the YPOS array slot 3 (the Y coordinate of object #3)
Ypos(3) =Ypos(3)+1

; show the screen to the user
Sync

; Wait a 1/100 of a second (10 milliseconds)
Wait 10


loop


; NOTE: PRESS ESC or CLICK the windows [X] gadget to END PROGRAM







 Example #8 (Multiple Objects Using Arrays)

     This version uses loops to process the groups of objects as batch.


PlayBASIC Code: [Select]
   ;  If you look at example #6 then #7, you're probably thinking
; they look almost identical. And you'd be right. All we've done
; is move from storing our object coordinates in variables to
; storing them in arrays. But we really haven't taken full
; advantage of them.
;
; The main advantage of using arrays is that we can then use
; loops to run through and process our list of objects. So we'll
; convert our code to use loops to process our objects in batches
;
; For this we'll need some more arrays. We'll need at array to
; store each objects COLOUR and another two arrays to store
; this objects movement direction. We'll call these SPEEDX &
; SPEEDY. These will be the change in pixels that this object
; moves each update.



; So this time, each loop we're,

; * we clear the screen (removing whatever was last on it)

; * loop through and draw all our moving objects

; * loop through and move all our objects.

; * Sync to show the newly drawn screen to the user

; * Wait 10 milliseconds. This gives the viewer enough time to see
; the newly drawn screen.
;
; if we do this each loop and our loop counts from 0 to 800, then the viewer
; will see the circle move slowly across the screen.


; Dimension the Xpos and Ypos arrays. These arrays are big enough to hold
; coordinates for our 3 objects
Dim Xpos(3)
Dim Ypos(3)

Dim SpeedX(3)
Dim SpeedY(3)

Dim Colour(3)

; init the Starting coordinate for Object #1
Xpos(1) =800
Ypos(1) = 100
SpeedX(1) =-1
SpeedY(1) =0
Colour(1) =rgb(255,0,0)

; init the Starting coordinate for Object #2
Xpos(2) =400
Ypos(2) = 0
SpeedX(2) =0
SpeedY(2) =1
Colour(2) =rgb(0,255,0)


; init the Starting coordinate for Object #3
Xpos(3) = 0
Ypos(3) = 0
SpeedX(3) =2
SpeedY(3) =1
Colour(3) =rgb(0,0,255)


Do

; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)

; ==================
; Draw our objects
; ==================
For Obj=1 to 3

; draw this object at it's CURRENT position and colour
Circlec Xpos(Obj),Ypos(Obj),50,true,Colour(Obj)
CenterText Xpos(Obj),Ypos(Obj),"Object #"+str$(Obj)

next


; ==================
; Move our objects
; ==================
For Obj=1 to 3

; Add this objects Speed Along the X axis to it's current positiont
Xpos(Obj) =Xpos(Obj)+SpeedX(Obj)

; Add this objects Speed Along the Y axis to it's current position
Ypos(Obj) =Ypos(Obj)+SpeedY(Obj)

next


; show the screen to the user
Sync

; Wait a 1/100 of a second (10 milliseconds)
Wait 10


loop


; NOTE: PRESS ESC or CLICK the windows [X] gadget to END PROGRAM







 Example #9 (Random Number of  Objects Using Arrays)

     This example concludes our series.  This version is set up to randomly pick the number of the objects as well as randomly assigning them a position/speed and colour.    


PlayBASIC Code: [Select]
   ;  And for the final step, this version will randomly set up
; a random number of objects and control them.


; So this time, each loop we're,

; * we clear the screen (removing whatever was last on it)

; * loop through and draw all our moving objects

; * loop through and move all our objects.

; * Sync to show the newly drawn screen to the user

; * Wait 10 milliseconds. This gives the viewer enough time to see
; the newly drawn screen.
;
; if we do this each loop and our loop counts from 0 to 800, then the viewer
; will see the circle move slowly across the screen.


; Pick the number of objects we'll be using randomly
NumberOfObjects =RndRange(5,50)

; Dimension the Xpos and Ypos arrays. These arrays are big enough to hold
; coordinates for our objects
Dim Xpos(NumberOfObjects)
Dim Ypos(NumberOfObjects)

Dim SpeedX(NumberOfObjects)
Dim SpeedY(NumberOfObjects)

Dim Colour(NumberOfObjects)

; Run through and randomly position them on screen with random colours
; and speeds


For obj=1 to NumberOfObjects
Xpos(obj) =rnd(800)
Ypos(obj) = rnd(600)
SpeedX(obj) =rndrange(-5,5)
SpeedY(obj) =rndrange(-5,5)
Colour(obj) =Rndrgb()
next


Do

; Clear the screen to black (rgb(0,0,0) ='s the colour black)
Cls rgb(0,0,0)

; ==================
; Draw & Move objects
; ==================
For Obj=1 to NumberOfObjects

; draw this object at it's CURRENT position and colour
Circlec Xpos(Obj),Ypos(Obj),50,true,Colour(Obj)
CenterText Xpos(Obj),Ypos(Obj),"Object #"+str$(Obj)


; Add this objects Speed Along the X axis to it's current positiont
Xpos(Obj) =Xpos(Obj)+SpeedX(Obj)

; Add this objects Speed Along the Y axis to it's current position
Ypos(Obj) =Ypos(Obj)+SpeedY(Obj)

next



; show the screen to the user
Sync

; Wait a 1/100 of a second (10 milliseconds)
Wait 10


loop


; NOTE: PRESS ESC or CLICK the windows [X] gadget to END PROGRAM