maxrow() and maxcol()

User avatar
Silvio.Falconi
Posts: 7136
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

maxrow() and maxcol()

Post by Silvio.Falconi »

How I can converte from clipper these functions ?'
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Antonio Linares
Site Admin
Posts: 42521
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 76 times
Contact:

Re: maxrow() and maxcol()

Post by Antonio Linares »

You can get the screen resolution but the amount of rows and cols depends on what font you use
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio.Falconi
Posts: 7136
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: maxrow() and maxcol()

Post by Silvio.Falconi »

I use a dialog

#include "fivewin.ch"
#include "constant.ch"

FUNCTION BlackJack()
Local nBottom := 42
Local nRight := 99
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight := nBottom * DLG_CHARPIX_H

DEFINE DIALOG oDlg21 ;
TITLE "test" ;
SIZE nWidth, nHeigh

ACTIVATE DIALOG oDlg21 CENTERED
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
Posts: 7136
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: maxrow() and maxcol()

Post by Silvio.Falconi »

resolved!!!
Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
Posts: 7136
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: maxrow() and maxcol()

Post by Silvio.Falconi »

I wish simulate a n animation from top/sx to center bu tI dont't now how make it
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Antonio Linares
Site Admin
Posts: 42521
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 76 times
Contact:

Re: maxrow() and maxcol()

Post by Antonio Linares »

Very nice! :-)

Using a timer and changing the coordinates of the image control ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio.Falconi
Posts: 7136
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: maxrow() and maxcol()

Post by Silvio.Falconi »

no I'm made this


Code: Select all | Expand

function Muovi( nWidth,nHeight )
   Local oSprite

   cardmap:= "Back"





    @ 0, 0 BITMAP oSprite;
             RESOURCE cardmap;
           PIXEL NOBORDER

       oSprite:ltransparent:=.t.


       sleep(20)
       nxPos := 650
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 600
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 580
       nYPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 540
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 520
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 500
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 480
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 440
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 420
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 400
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 380
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 340
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 320
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 300
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 280
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 240
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

      return nil
 



But I not have a right animation
I wish have an animation ogf a card from the deck (at left ) to center
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
Posts: 7136
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: maxrow() and maxcol()

Post by Silvio.Falconi »

a test to try


Code: Select all | Expand


#include "fivewin.ch"
#include "constant.ch"
#define   TXT_GAME                "EasyBlackJack"
#define   TXT_RELEASE             "1.00"
FUNCTION BlackJack()
            LOCAL i
            Local nBottom   := 42
            Local nRight    := 99
            Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
            Local nHeight := nBottom * DLG_CHARPIX_H

oImagen = TImage():Define("PANNOBLACK",  )
DEFINE DIALOG oDlg21         ;
   TITLE TXT_GAME +" "+ TXT_RELEASE     ;
   SIZE nWidth, nHeight

oDlg21:bPainted := {|hDC| PalBmpDraw( hDC, 0, 0, oImagen:hBitmap,, oDlg21:nWidth, oDlg21:nHeight,, .T.)  }

ACTIVATE DIALOG oDlg21 CENTERED ;
         ON INIT (BuildMenu(nWidth,nHeight))
  RETURN NIL


 Function  BuildMenu(nWidth,nHeight)
  MENU oMenu 2015
    MENUITEM "&Info"
    MENU
   MENUITEM "Cards" action Presentazione(nWidth,nHeight)
    ENDMENU
    ENDMENU
  oDlg21:SetMenu(oMenu)
RETURN NIL

Function Presentazione(nWidth,nHeight)
   
      Muovi(nWidth,nHeight)

     
   return nil
function Muovi( nWidth,nHeight )
   Local oSprite

   cardmap:= "Back"





    @ 0, 0 BITMAP oSprite;
             RESOURCE cardmap;
           PIXEL NOBORDER

       oSprite:ltransparent:=.t.


       sleep(20)
       nxPos := 650
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 600
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 580
       nYPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 540
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 520
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 500
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 480
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 440
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 420
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 400
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 380
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 340
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 320
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 300
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 280
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

       sleep(20)
       nxPos := 240
       nyPos := 80
       oSprite:Move( nYPos, nXPos, , , .T. )

      return nil




the test.rc

1 24 "WindowsXP.Manifest"

BACK BITMAP ".\CARD\BACK.BMP"
PANNOBLACK BITMAP ".\PANNO\BLACK.BMP"


the back.bmp
Image

the BLACK.jpg

Image


I wish this animation see the line red
Image


it is possible ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: maxrow() and maxcol()

Post by ukoenig »

Silvio,

the card-painting of Your sample doesn't look very nice ( not transparent and bad movement )
As well I repainted the card with Pixelformer like You can see

have a look at my solution :

http://www.pflegeplus.com/DOWNLOADS/Cardmove1.zip

Moving a image-group and changing the direction You can have a look at :

viewtopic.php?f=3&t=31972

Image

best regards
Uwe :D
Last edited by ukoenig on Sat Feb 20, 2016 5:02 pm, edited 2 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
Silvio.Falconi
Posts: 7136
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: maxrow() and maxcol()

Post by Silvio.Falconi »

Thanks Uwe,
Now the animation run ok
but now I have another problem

Image

two cards for the Dealer

the first card ( back) is moved ok
the second card (ace) is moved ok

but the ace is down and I not see good the card
how I can make to have it up


then I tried to move a card for the player
it is moving but came from a bad point
look at mail pls
it must go out from deck and go to position I insert


Image

the red line is the animation now
the green line is the animation i wish
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: maxrow() and maxcol()

Post by ukoenig »

Silvio,

left down or down left is my other sample.
I think You need a DIAGONAL-calculation
from the upper-right corner ?

Image

best regards
Uwe :?:
Last edited by ukoenig on Sat Feb 20, 2016 5:17 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: maxrow() and maxcol()

Post by ukoenig »

Silvio,

added new calculations to display VERTICAL movements
I still have to bring the last painted image on TOP
After all I think the basics are done for You to carry on with the rest.

have a look at Your email
( I changed from RESOURCE to FILENAME for my tests ! )

The changes for VERTICAL movements

Code: Select all | Expand


FUNCTION CardMove(cCardName, nTDI, nTPI, nLl, nCard, lDealer)
// FUNCTION CardMove(
//CardName,
//Top dealer,
//Top player,
//left start position,
//nCard,
//dealer or player)

* Local oSprite[nCard]
local cardmap
Local G := 46, H := 41, I := 1, J := 1

IF ccardname = 0
    cardmap := c_path1 + "Back.bmp"
ELSE
      cardmap := c_path1 + "card" +alltrim(str(ccardname)) + ".bmp"
Endif

@ 0,0 IMAGE oSprite[nCard] FILENAME CardMap NOBORDER

oSprite[nCard]:lTransparent := .T.
oSprite[nCard]:Hide()

IF lDealer = .T. // DEALER  movement HORIZONTAL top / right to top / left
    FOR I := 1 TO 1
        FOR J := 1 to G
            nLl-= 10
            oSprite[nCard]:Show()
            oSprite[nCard]:Move ( nTDI,nLl,,,.t.)
            oSprite[nCard]:Refresh()
            SYSWAIT1(0.01)
        NEXT
        nLl := 660
        G -= 8
    NEXT
ELSE // PLAYER  movement VERTICAL from top / right to bottom / left
    nLl := 660
    FOR I := 1 TO 1
        FOR J := 1 to H
            nLl-= 10
            oSprite[nCard]:Show()
            oSprite[nCard]:Move ( nTDI+= 8,nLl,,,.t.)
            oSprite[nCard]:Refresh()
            SYSWAIT1(0.01)
        NEXT
        nLl := 660
        G -= 8
    NEXT
ENDIF

RETURN NIL
 


best regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
Silvio.Falconi
Posts: 7136
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: maxrow() and maxcol()

Post by Silvio.Falconi »

Uwe,
your test sample run ok and it was I wish

When I put this function on my source it make error and I not understood why


the error

Code: Select all | Expand

Application
===========
   Path and name: G:\13_02_2016\BlackJack\BlackJack.Exe (32 bits)
   Size: 7,474,688 bytes
   Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603)
   FiveWin  Version: FWHX 16.01
   Windows version: 6.1, Build 7600

   Time from start: 0 hours 0 mins 24 secs
   Error occurred at: 02/20/16, 00:43:25
   Error description: Error BASE/1004  Class: 'NIL' has no exported method: NWIDTH
   Args:
     [   1] = U  

Stack Calls
===========
   Called from:  => NWIDTH( 0 )
   Called from: .\source\classes\BITMAP.PRG => TBITMAP:NEW( 178 )
   Called from: .\source\classes\IMAGE.PRG => TIMAGE:NEW( 53 )
   Called from: Source\PBlack.prg => CARDMOVE( 959 )
   Called from: Source\PBlack.prg => PLAY21( 290 )
   Called from: Source\PBlack.prg => (b)BUILDMENU( 118 )
   Called from: .\source\classes\MENU.PRG => TMENU:COMMAND( 1062 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:COMMAND( 380 )
   Called from:  => TWINDOW:HANDLEEVENT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 905 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 293 )
   Called from: Source\PBlack.prg => BLACKJACK( 101 )
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Antonio Linares
Site Admin
Posts: 42521
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 76 times
Contact:

Re: maxrow() and maxcol()

Post by Antonio Linares »

Silvio,

Are you using ... OF oWnd when you create your bitmap ?

from bitmap.prg line 178:

nHeight := Min( ::nHeight(), oWnd:nHeight() )

it seems as oWnd is nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio.Falconi
Posts: 7136
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: maxrow() and maxcol()

Post by Silvio.Falconi »

Antonio,
It is strange we use oDgl21 ( dialog) and it is static

I have the CardMove function ( made from Uwe and Modify by me)
see the call to this function

Code: Select all | Expand


static oDlg21
static c_path1
static oSprite[52]
static nCard
static adeck
static ncardval  := 1
static ccardname := 2
static ccardBmp  := 3
static ndecksize := 52
static ndelay := 2
static anewdeck


Function Play21()
 local nmaxchips := 1000
  local nchips
  local nbet := 0
  local ncardsleft := 0
  local ndealerdealt := 0
  local nplayerdealt := 0
  local ndeckpos := 1
  local caction := " "
  local aplayershand
  local adealershand
  local ldoubledown := .f.
  local lplayerbust := .f., ldealerbust := .f.
  local nplayerhandval
  local ndealerhandval
  local cplayagain := "Y"
  local ndealrow := 95
  local nplayrow := 450
  local ndealcol := 660
  local nplaycol := 660
  nchips := nmaxchips
  nCard:= 1


do  while .t.


    aplayershand := {}
    adealershand := {}


if ncardsleft < 10    // if there are <  10 cards on deck  it make a shuffle
   
      msginfo("Please wait while I shuffle the deck...","BlackJack")
      newdeck()    // create an array with 4 field for the cards
      shuffle()      // shuffle the card  array  with random function

      ncardsleft := ndecksize
      ndeckpos := 1
     
    endif


// show the chips
Msginfo( "You have "+alltrim(str(nchips))+" chips.","BlackJack")
nbet := 1
MsgGet( TXT_GAME, TXT_HOW_BAT_CHIPS, @nBet, , , )
msginfo("your Bet is :"+STR(nBet))


    ndealerdealt := 10
    nplayerdealt := 10


// delear Cards
CardMove(0, ndealrow, nplayrow, ndealcol+ndealerdealt*4, nCard, .T.)             // animation card delear   Back ( hide)
    aadd(adealershand,{adeck[ndeckpos,ncardval],adeck[ndeckpos,ccardname],adeck[ndeckpos,ccardBmp]})  // save to array this card
    ndeckpos ++              // deck position
    ndealerdealt+=20
    nCard++                    // oSprite array

CardMove(adeck[ndeckpos,ccardBmp], ndealrow, nplayrow, ndealcol+ndealerdealt*4, nCard, .T.)   // animation card delear
 aadd(adealershand,{adeck[ndeckpos,ncardval],adeck[ndeckpos,ccardname],adeck[ndeckpos,ccardBmp]})    // save to array this card
  ndeckpos ++          // deck position
  ndealerdealt +=20
  nCard++              // oSprite array



// Player cards
CardMove(adeck[ndeckpos,ccardBmp],ndealrow, nplayrow, nplaycol+nplayerdealt*4, nCard, .F.)   // animation  first card player  
    aadd(aplayershand,{adeck[ndeckpos,ncardval],adeck[ndeckpos,ccardname],adeck[ndeckpos,ccardBmp]})   // save to array this card
    ndeckpos ++
    nplayerdealt+=20
     nCard++

CardMove(adeck[ndeckpos,ccardBmp],ndealrow, nplayrow, nplaycol+nplayerdealt*4, nCard, .F.)   // animation  Second card player  
    aadd(aplayershand,{adeck[ndeckpos,ncardval],adeck[ndeckpos,ccardname],adeck[ndeckpos,ccardBmp]})   // save to array this card
    ndeckpos ++
    nplayerdealt+=20
     nCard++


   ldoubledown := .t.
    lplayerbust := .f.
    ldealerbust := .f.
    lonecard := .f.

  do while .t.  // the players hand

.....

 do while .t   // delear Hand
// cicle for the delear hand
....

enddo



 do case
  // case of total point cards
....
 endcase


 msginfo( "Dealers hand "+ alltrim(str(ndealerhandval))+CRLF+;
                "Players hand " + alltrim(str(nplayerhandval)),TXT_GAME )


 ncardsleft := ndecksize - ndeckpos



    IF msgYesNo("Play again? ")
       clrscr()
    else
       clrscr()
        exit
     endif

   enddo




   return nil







//-------------------------------------------------------------------------------------------------------------------//
FUNCTION CardMove(cCardName, nTDI, nTPI, nLl, nCard, lDealer)
local cardmap
Local G := 46, H := 41, I := 1, J := 1

IF ccardname = 0
   cardmap := c_path1 + "Back.bmp"
ELSE
      cardmap := c_path1 + "card" +alltrim(str(ccardname)) + ".bmp"
Endif

@ 0,0 IMAGE oSprite[nCard] FILENAME CardMap NOBORDER of oDlg21

oSprite[nCard]:lTransparent := .T.
oSprite[nCard]:Hide()

IF lDealer = .T.
   FOR I := 1 TO 1
      FOR J := 1 to G
         nLl-= 10
         oSprite[nCard]:Show()
         oSprite[nCard]:Move ( nTDI,nLl,,,.t.)
         oSprite[nCard]:Refresh()
         SYSWAIT1(0.01)
      NEXT
      nLl := 660
      G -= 8
   NEXT
ELSE
   nLl := 660
   FOR I := 1 TO 1
      FOR J := 1 to H
         nLl-= 10
         oSprite[nCard]:Show()
         oSprite[nCard]:Move ( nTDI+= 8,nLl,,,.t.)
         oSprite[nCard]:Refresh()
         SYSWAIT1(0.01)
      NEXT
      nLl := 660
      G -= 8
   NEXT
ENDIF

RETURN NIL


FUNCTION SYSWAIT1( nLong )
local nSeconds

DEFAULT nLong := .1
nSeconds := Seconds() + nLong

WHILE Seconds() < nSeconds
   SysRefresh()
END

RETURN NIL
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Post Reply