Hi Enrico !

Hi Enrico !

Postby areang » Mon Oct 30, 2006 3:07 am

:lol: How to create games with xHarbour :lol:

I used FWH and xHB.


function Games()
local oBmpBackGround, oBmpSprite1, oBmpSprite2

DEFINE WINDOW oWnd

@0,0 bitmap oBmpBackGround FILE "room.bmp" pixel of oWnd

@20,10 bitmap oBmpSprite1 FILE "ball.bmp" pixel of oWnd

oBmpSprite1:lTransparent := .t.

?????????????????????????????
// But Not Transparent //
?????????????????????????????


ACTIVATE WINDOW oWnd

return nil

Thank's

Best Regard
Areang
areang
 
Posts: 128
Joined: Mon Jul 31, 2006 3:23 pm

Re: Hi Enrico !

Postby Enrico Maria Giordano » Mon Oct 30, 2006 9:12 am

This is a working sample:

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    local oWnd, oBrush, oSprite, oTimer

    DEFINE BRUSH oBrush;
           FILE "c:\fwharbour\bitmaps\backgrnd\beach.bmp"

    DEFINE WINDOW oWnd;
           BRUSH oBrush

    @ 0, 0 BITMAP oSprite;
           FILE "c:\fwharbour\bitmaps\fdem5.bmp";
           PIXEL NOBORDER

    oSprite:lTransparent = .T.

    DEFINE TIMER oTimer OF oWnd;
           INTERVAL 10;
           ACTION MOVESPRITE( oWnd, oSprite )

    ACTIVATE WINDOW oWnd;
             ON INIT oTimer:Activate()

    RELEASE TIMER oTimer

    RETURN NIL


STATIC FUNCTION MOVESPRITE( oWnd, oSprite )

    LOCAL aWndRect := GETCLIENTRECT( oWnd:hWnd )

    LOCAL nWndWidth  := aWndRect[ 4 ] - aWndRect[ 2 ]
    LOCAL nWndHeight := aWndRect[ 3 ] - aWndRect[ 1 ]

    LOCAL nXPos, nYPos

    STATIC nXStep := 5
    STATIC nYStep := 5

    nXPos = oSprite:nLeft + nXStep
    nYPos = oSprite:nTop + nYStep

    IF nXPos < 0
        nXPos = 0
        nXStep = -nXStep
    ENDIF

    IF nYPos < 0
        nYPos = 0
        nYStep = -nYStep
    ENDIF

    IF nXPos + oSprite:nWidth >= nWndWidth
        nXPos = nWndWidth - oSprite:nWidth - 1
        nXStep = -nXStep
    ENDIF

    IF nYPos + oSprite:nHeight > nWndHeight
        nYPos = nWndHeight - oSprite:nHeight
        nYStep = -nYStep
    ENDIF

    oSprite:Move( nYPos, nXPos, , , .T. )

    RETURN NIL


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

Postby areang » Tue Oct 31, 2006 6:35 am

Thank's Enrico,

but the BMP size must fixed with window size.
when it not fixed the brush makes tiles on window surfaces.


Best Regard
Areang
areang
 
Posts: 128
Joined: Mon Jul 31, 2006 3:23 pm

Postby Rossine » Fri Nov 10, 2006 7:15 pm

Hi Areang,

Try this:

Code: Select all  Expand view

...
  IF nYPos + oSprite:nHeight > nWndHeight
        nYPos = nWndHeight - oSprite:nHeight
        nYStep = -nYStep
    ENDIF

    oSprite:refresh()  &&<<<--- Inside This

    oSprite:Move( nYPos, nXPos, , , .T. )

    RETURN NIL


Regards,

Rossine.
Rossine
 
Posts: 344
Joined: Tue Oct 11, 2005 11:33 am


Postby Silvio » Sat Nov 11, 2006 1:36 am

And if I want move the sprite with cursor key How I can make it ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby Enrico Maria Giordano » Sat Nov 11, 2006 8:01 am

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    local oWnd, oBrush, oSprite

    DEFINE BRUSH oBrush;
           FILE "c:\fwharbour\bitmaps\backgrnd\beach.bmp"

    DEFINE WINDOW oWnd;
           BRUSH oBrush

    oWnd:bKeyDown = { | nKey | MoveSprite( oWnd, oSprite, nKey ) }

    @ 0, 0 BITMAP oSprite;
           FILE "c:\fwharbour\bitmaps\fdem5.bmp";
           PIXEL NOBORDER

    oSprite:lTransparent = .T.

    ACTIVATE WINDOW oWnd

    RETURN NIL


STATIC FUNCTION MOVESPRITE( oWnd, oSprite, nKey )

    LOCAL aWndRect := GETCLIENTRECT( oWnd:hWnd )

    LOCAL nWndWidth  := aWndRect[ 4 ] - aWndRect[ 2 ]
    LOCAL nWndHeight := aWndRect[ 3 ] - aWndRect[ 1 ]

    LOCAL nXPos, nYPos

    LOCAL nXStep := 0
    LOCAL nYStep := 0

    IF nKey = VK_RIGHT; nXStep = 5; ENDIF
    IF nKey = VK_LEFT; nXStep = -5; ENDIF

    IF nKey = VK_DOWN; nYStep = 5; ENDIF
    IF nKey = VK_UP; nYStep = -5; ENDIF

    nXPos = oSprite:nLeft + nXStep
    nYPos = oSprite:nTop + nYStep

    IF nXPos < 0
        nXPos = 0
        nXStep = -nXStep
    ENDIF

    IF nYPos < 0
        nYPos = 0
        nYStep = -nYStep
    ENDIF

    IF nXPos + oSprite:nWidth >= nWndWidth
        nXPos = nWndWidth - oSprite:nWidth - 1
        nXStep = -nXStep
    ENDIF

    IF nYPos + oSprite:nHeight > nWndHeight
        nYPos = nWndHeight - oSprite:nHeight
        nYStep = -nYStep
    ENDIF

    oSprite:Refresh()

    oSprite:Move( nYPos, nXPos, , , .T. )

    RETURN NIL


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

Postby Silvio » Sat Nov 11, 2006 1:34 pm

thanks Enrico !!!
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby Silvio » Sat Nov 11, 2006 1:49 pm

And if I want press space key and fire another small sprite ?
and ihow I make if I want make collision on another sprite
think about space invaders....
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby Rossine » Sat Nov 11, 2006 6:54 pm

Hi Enrico,

It is possible, using FREEIMAGE.DLL capture the image that this in a determined window (dialog/window) and record-her in the format. JPG?

Excuse me. I am using a translator :lol:
Rossine
 
Posts: 344
Joined: Tue Oct 11, 2005 11:33 am

Postby areang » Sun Nov 12, 2006 8:07 am

Hi Enrico.

For the future the game is the good way for all clipper needed.
Just move the image object, click object, show object, hide object, rotate, scale and more. Play the sound and video file.

Think's the object are : image, sound and video

Can you make the lib for this ?

And I will buy the lib from you.

Thank's
Best Regard
Areang
areang
 
Posts: 128
Joined: Mon Jul 31, 2006 3:23 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 86 guests