Help with scrolling

BlitzPlus Forums/BlitzPlus Programming/Help with scrolling

Belgarion(Posted 2003) [#1]
Simple, yet I just can't seem to figure this out :\

Fruit machine reels. I simply want to be able to scroll them, and decide which positions I want to spin in.

I have tried many different ways of scrolling, with varying degrees of success. But I can't seem to do what I need to. Ideally I would be able to do something like this (in pseudo-code):

Procedure REEL1(chosen symbol to spin in,Step up/down,Speed)
Spin reel a few times, land on chosen symbol
End proc

Easy lol. Main problem I am having, however, is having all reels spinning independently, so if Reel1 is stopped, other reels carry on, or if Reel2 is stopped, Reel1 and any other reels stop too.

Main question to all of this: Is is easier to store reel positions in an array, and use this to display the correct symbols? And if so, could someone maybe help with the code as I'm somewhat stumped :(


Tricky(Posted 2003) [#2]
Scrolling itself has never been my true problem, at least not in Blitz, but how to scroll depends on many things...

But I see that scrolling itself is not the problem...

Putting this in an array could help...

Dim Reel(3)
Dim Rolling(3)
Dim Hold(3)


This is a way of using arrays... (I don't think types is a good idea here, I wouldn't prefer it in this case, but it IS an option)

If I'd use the example above I use "Reel" for the value of the Reel, Rolling to indicate if a reel is rolling or not... If it is you see the reel rolling and the value is true, and false if the reel has stopped, and hold for if the use pressed the "Hold" button, which some expanded version of fruit machines support, but you could leave that one out...

A sample code with THIS array structure could be
For R = 1 to 3
    If Rolling(R) Then RollReel(3)
    Next


The reel will only roll if the respective Rolling variable has been set to true...

Does this cover you problem?


Oldefoxx(Posted 2003) [#3]
An array is a good way to emmulate the sequence of fruit on the wheels of a slot machine. In this manner, you can easily control the order of fruit as well as the number of times each fruit appears.

However, spinning the wheels is often done in other software by presenting the wheel(s) as a blur of motion. That is, each slot is actually three to five blobs of color that look like the blur of consecutive spots rotating at high speed. You just alternate between several sets of blobs to give the appearance that the wheel is rotating at a high enough speed to cause the images to blur. It can look very realistic, but actually has nothing to do with the fruit arrays. And the fruit arrays do not have to be images themselves, but possibly words, such as "Cherry", or an index into an image array to help you find the right image when you need it. Since you are presenting possibly four or five blurred images alternately, you only need to paint each to a different wheel in the background, and flip to the background at regular intervals to maintain the image. That means the flip has to be done at regular intervals, which you can control with a timer. When a wheel stops, also on fairly regular intervals, you have painted over its image with a selected sequence of fruit on the background. Thereafter you just paint the same image on the background before each flip. Each "wheel" display can be controlled with the same procedure, just a different reference to the location of the wheel being displayed on the machine. You will soon find that it takes very little effort to go from three wheels to five or more.

The fruit arrays are not identical for each wheel. Some wheels have more of one fruit than another, so that overall, some combinations occur regularly, and others only on rare occasions. This determines the odds and the payout.

Note that slot machines that have "blanks" between fruit represent only half the chance of getting a winning combination on a per-wheel basis. If there are three wheels, that would be one-half of one-half of one-half, meaning only 1/8th chance of finding a paying combination that a machine with no blanks would have. For seven wheels, it would be 1/128ths of the same chance. This is why casinos can affort to offer "progressive" pots because they can tease you with a chance at big money while almost everyone just loses their shirts.


cbmeeks(Posted 2003) [#4]
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


Tricky(Posted 2003) [#5]
Why 3 diffrent types?


cbmeeks(Posted 2003) [#6]
lol...I dunno...I was at work at typed that in about 5 minutes....yes, you could do it in one type....jeesh

lol

cb


Oldefoxx(Posted 2003) [#7]
You could use a decelleration factor and overshoot (go to a slightly negative value, then return to zero) to create a realistic bounce and rebound effect as each reel stops.

Try to do just one reel at first. If you get it to work, it should be a fairly trivial effort to expand it to handle more than one reel at a time, either by duplicating the code or increasing the number of subscripts involved in your arrays. Using Types is fine, and it may increase your understanding of how to deploy them, but the big problem is learning to handle the replacement of images within the appropriate area of the screen in a timely and realistic fashion. Using Flip between the background and foreground is not always the best solution, simply because you can be needlessly updating a lot of static data, resulting in slower performance, and also because rapid flips can result in unacceptable screen flicker.


Belgarion(Posted 2003) [#8]
Thanks for the help guys :) I'm a little 'old school' so I'll stick to arrays (still can't get used to types).

Got it sorta working now, by using the long strip of symbols behind a viewpoint. Although it is a little tricky to do it this way - I have to try and simulate lights behind each reel. I won't be using the fake reels as I will be implementing feature games that require the reels to scroll slowly.

I'll try using the array to acyually display each symbol seperately, instead of he long strip - that might be easier for what I need to do later on.

:)


Ross C(Posted 2003) [#9]
ever thought of doin it in 3d, would be alot simplier. sorry but i always look for the simple way of doin things..


cbmeeks(Posted 2003) [#10]
How would 3D be simpler?

cb


Ross C(Posted 2003) [#11]
well create a tube mesh and texture it with the different symbols and then simply say

TurnEntity reel,1,0,0


i think it would be anyway, but my idea of simple is sometimes a bit long winded :)


John Pickford(Posted 2003) [#12]
#


Belgarion(Posted 2003) [#13]
mmm I have done it in 3D, and I have it spinning quite nicely. But, because my experience in 3D is almost zero, I have no clue as to how to go about coding the actual displays in 3D. Which is a shame cos the reels look pretty spiffing :^9

Been a while since I did any real coding, guess I'm very rusty :-\