FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour move bitmap
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
move bitmap
Posted: Fri Nov 23, 2012 01:46 AM
Hello,

I want to move a bitmap across a dialog, but it is really slow, how can I speed up the moving, maybe will be to code some thing in C
some help?

regards

Marcelo

Code (fw): Select all Collapse
#include "fivewin.ch"

FUNCTION main()
   LOCAL oDlg, oBmp, i := 0, oTimer

   DEFINE DIALOG oDlg FROM 10,10 TO 600,1000 PIXEL TRANSPARENT

   @ 10,10 BITMAP oSprite FILE "face.bmp" OF oDlg PIXEL SIZE 20,20 TRANSPARENT NOBORDER

   @ 100,10 button "MOVER" of odlg action oTimer:activate() PIXEL

   DEFINE TIMER oTimer;
       INTERVAL 0;
         ACTION move( oSprite, @i, oTimer )

   ACTIVATE DIALOG oDlg ON INIT oTimer:hWndOwner := oDlg:hWnd

   RETURN NIL

FUNCTION move( oSprite, i, oTimer )
   i += 5
   oSprite:move( 10 + i, 10 + i )

   IF i > 400
      oTimer:deactivate()
   ENDIF

   RETURN NIL
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: move bitmap
Posted: Fri Nov 23, 2012 09:35 AM

Marcelo,

I think that INTERVAL 0 is not allowed. Please try with 1, or higher

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: move bitmap
Posted: Fri Nov 23, 2012 11:12 AM

Dear Antonio,

first thank for your response, with interval 0 or 1 or 2 there are not difference.

For linear moving, I can increase the steep displacement and get a better speed sensation, but for non uniform moving it is not smooth

For start this work

Thanks very much

Regards

Marcelo

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: move bitmap
Posted: Fri Nov 23, 2012 11:18 AM

Marcelo,

I have not tested it myself but maybe a call to SysRefresh() will improve it

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: move bitmap
Posted: Fri Nov 23, 2012 03:59 PM
Compiling your sample I get:

Code (fw): Select all Collapse
test.prg(10) Warning W0001  Ambiguous reference: 'TRANSPARENT'


EMG
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: move bitmap
Posted: Fri Nov 23, 2012 08:01 PM
Hello Enrico,

sorry I have my compile parameters very open, try with

Code (fw): Select all Collapse
#include "fivewin.ch"

FUNCTION main()
   LOCAL oDlg, oBmp, i := 0, oTimer, oSprite

   DEFINE DIALOG oDlg FROM 10,10 TO 600,1000 PIXEL TRANSPARENT

   @ 10,10 BITMAP oSprite FILE "face.bmp" OF oDlg PIXEL SIZE 20,20 NOBORDER

   @ 100,10 button "MOVER" of odlg action oTimer:activate() PIXEL

   DEFINE TIMER oTimer;
       INTERVAL 1;
         ACTION move( oSprite, @i, oTimer )

   ACTIVATE DIALOG oDlg ON INIT oTimer:hWndOwner := oDlg:hWnd

   RETURN NIL

FUNCTION move( oSprite, i, oTimer )
   i += 5
   oSprite:move( 10 + i, 10 + i )

   IF i > 400
      oTimer:deactivate()
   ENDIF
   Sysrefresh() 

   RETURN NIL

Continue the discussion