move bitmap

move bitmap

Postby Marcelo Via Giglio » Fri Nov 23, 2012 1: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: Select all  Expand view


#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
Marcelo Via Giglio
 
Posts: 1064
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: move bitmap

Postby Antonio Linares » Fri Nov 23, 2012 9:35 am

Marcelo,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: move bitmap

Postby Marcelo Via Giglio » 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
Marcelo Via Giglio
 
Posts: 1064
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: move bitmap

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: move bitmap

Postby Enrico Maria Giordano » Fri Nov 23, 2012 3:59 pm

Compiling your sample I get:

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


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: move bitmap

Postby Marcelo Via Giglio » Fri Nov 23, 2012 8:01 pm

Hello Enrico,

sorry I have my compile parameters very open, try with

Code: Select all  Expand view
#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
 
Marcelo Via Giglio
 
Posts: 1064
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 92 guests