HMG Slot-Machine / Threads

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2108
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

HMG Slot-Machine / Threads

Post by AUGE_OHR »

hi,

i need 3 x Thread to "shift" Colum with "different Speed"
Hb_Slot1.jpg
Hb_Slot1.jpg (101.46 KiB) Viewed 1512 times
in RED Box i have a "fix" Array where Row 1-3 are shown at Start
Result is in GREEN Box which match Image

i DON´T want "new Number" ... i want to "shift" (roll) Image and show "rolling" ... :P

1st Colum "4" go away,
"9" to 1st Line and "3" to 2nd Line.
3rd Line now become "1" (see RED Box)

same with Column 2 and 3 ... but with "different Speed" ;)

---

1st Column start first and normal end first ... but there is a "Stop Button"
"Stop Button" is disable when start but after "some time" it will enable
User can press Button to "stop rolling" ... but with delay :lol:

---

as i say i "think" i need 3 x Thread ... or other Idea to show "rolling" :idea:
attached Code with Resource
SLOT01.ZIP
(119.19 KiB) Downloaded 112 times
have fun
Jimmy
User avatar
mustafa
Posts: 1175
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: HMG Slot-Machine / Threads

Post by mustafa »

Hola Jimmy
If this sample can help you?

Regards
Mustafa
Attachments
screenshot.jpg
screenshot.jpg (61.9 KiB) Viewed 1476 times
Maquinita_2020.zip
(2.67 MiB) Downloaded 125 times
User avatar
mustafa
Posts: 1175
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: HMG Slot-Machine / Threads

Post by mustafa »

Hi jimmy
Haber si puede servir esta modificación ?
Whether this modification can do? :idea:

Code: Select all

*+--------------------------------------------------------------------
*+
*+    Static Procedure ShowPic()
*+
*+    Called from ( slot.prg )   1 - static procedure showplay()
*+
*+--------------------------------------------------------------------
*+
STATIC PROCEDURE ShowPic( Obj, nNo )

LOCAL Contador := 0 , CC

Do While Contador<10
     nNo  := Random(20)

   DO CASE
      CASE nNo = 1
         SetProperty( "SLOTMC", Obj, "Picture", "ID_Bell" )
      CASE nNo = 2
         SetProperty( "SLOTMC", Obj, "Picture", "ID_Cherry" )
      CASE nNo = 3
         SetProperty( "SLOTMC", Obj, "Picture", "ID_Club" )
      CASE nNo = 4
         SetProperty( "SLOTMC", Obj, "Picture", "ID_Diamond" )
      CASE nNo = 5
         SetProperty( "SLOTMC", Obj, "Picture", "ID_Heart" )
      CASE nNo = 6
         SetProperty( "SLOTMC", Obj, "Picture", "ID_Lemon" )
      CASE nNo = 7
         SetProperty( "SLOTMC", Obj, "Picture", "ID_Melon" )
      CASE nNo = 8
         SetProperty( "SLOTMC", Obj, "Picture", "ID_Orange" )
      CASE nNo = 9
         SetProperty( "SLOTMC", Obj, "Picture", "ID_Plum" )
      CASE nNo = 10
         SetProperty( "SLOTMC", Obj, "Picture", "ID_Seven" )
      CASE nNo = 11
         SetProperty( "SLOTMC", Obj, "Picture", "ID_Spade" )
   ENDCASE

    Contador += 1
    For CC=1 to 500000
    Next CC

Enddo

RETURN

Virtual Greetings :mrgreen: :x
Mustafa
User avatar
AUGE_OHR
Posts: 2108
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: HMG Slot-Machine / Threads

Post by AUGE_OHR »

hi,

thx for Sample, GREAT Work.

but it is not the GAME i want,
it is the Technique to "shift" Array to show "rolling" Animation and Thread which access same Data.

i want to use a Thread for each Column to Start and Stop.
all Thread are working with same Array or DBF (or SQL Table) but i´m not sure how to do it with harbour / HMG

a.) did i need MUTEX when work with Thread and Array :?:
b.) DBF have to be Lock/UnLock but how to "Sync" Thread <-> DBF :idea:
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2108
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: HMG Slot-Machine / Threads

Post by AUGE_OHR »

hi,

i got it working with 3 x Thread ... but (PROCEDURE) Code need "double Code"

Code: Select all

STATIC PROCEDURE RollRoll1()
STATIC PROCEDURE RollRoll2()
STATIC PROCEDURE RollRoll3()
STATIC PROCEDURE PlayIcon1( nStart, cIn )
STATIC PROCEDURE PlayIcon2( nStart, cIn )
STATIC PROCEDURE PlayIcon3( nStart, cIn )
so i have to re-write it as CLASS ... nor sure if it will still work with Thread :?:
SLOT02.ZIP
(2.85 KiB) Downloaded 109 times
need resource from 1st Demo

---

when press Start it take a Second before begin, why :o
some times 2nd GRID get Scrollbar ... i guess more than 1 Thread access it then ... how to sync it :idea:
have fun
Jimmy
Post Reply