Help with scrolling

BlitzPlus Forums/BlitzPlus Programming/Help with scrolling

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Here is how I would do it:

First, use types. Every Blitz programmer needs to be good with types.


const cherry=1
const grape=2
const lemon=3
const orange=4

Type Wheel1
   Field x,y
   Field image    ;verticle image with cherry on top
   Field land     ;what is showing (cherry, etc.)
   Field spinspeed#  ;how fast the wheel is spinning
   Field spinrate#   ;how much spinning slows down
End Type

Type Wheel2
   Field x,y
   Field image    ;verticle image with cherry on top
   Field land     ;what is showing (cherry, etc.)
   Field spinspeed#  ;how fast the wheel is spinning
   Field spinrate#   ;how much spinning slows down
End Type

Type Wheel3
   Field x,y
   Field image    ;verticle image with cherry on top
   Field land     ;what is showing (cherry, etc.)
   Field spinspeed#  ;how fast the wheel is spinning
   Field spinrate#   ;how much spinning slows down
End Type



Then, when the player pulls the "arm", you would mabe pick a random number (1-4) to land on and just let the image scroll behind a mask of the window.

For example, you would have a giant image that contained three holes. Draw the wheels first, then draw the face of the machine (with the holes).

to make the wheels appear to spin, start moving the images down the screen very fast (spinspeed#) and gradually reduce it with the spinrate# until the spinspeed# was almost 0 and the chosen fruit was in the window. When the top fruit (cherry) is approaching the window, draw another instance of the image above it...that way, it will appear to loop.


Wheel1\spinspeed# = Wheel1\spinspeed# + Wheel1\spinrate#
Wheel1\spinrate# = Wheel1\spinrate# - (rnd(0.0 - 0.5))
Wheel1\y = Wheel1\y + Wheel1\spinspeed#

Wheel2\spinspeed# = Wheel2\spinspeed# + Wheel2\spinrate#
Wheel2\spinrate# = Wheel2\spinrate# - (rnd(0.01 - 0.05))
Wheel2\y = Wheel2\y + Wheel2\spinspeed#

Wheel3\spinspeed# = Wheel3\spinspeed# + Wheel3\spinrate#
Wheel3\spinrate# = Wheel3\spinrate# - (rnd(0.001 - 0.005))
Wheel3\y = Wheel3\y + Wheel3\spinspeed#



The random numbers should keep the wheels spinning randomly...for example, you don't want all three wheels stopping at the same time...but you want the left, middle, last to finish in that order...but then again, maybe you want it to all be random

Also, make sure the spinspeed# never goes into the negative or the wheel will start spinning upwards! :-)

Hope this was helpful...

cb