Re: Cards.dll

new topic     » topic index » view thread      » older message » newer message

Here's a little something using cards.dll.

include win32lib.ew

without warning

atom cdtInit, cdtDraw, cdtDrawEx, cdtTerm  --functions in cards.dll

atom cwidth, cheight  --size of cards
cwidth = allocate(4)
cheight = allocate(4)

atom Win
Win = createEx (Window, "Cards", 0, 0, 0, 1024, 768, WS_OVERLAPPEDWINDOW,
WS_EX_APPWINDOW)

function InitCardsDll()
atom hCardDll

    hCardDll = open_dll("cards.dll")
    if hCardDll = NULL then
        printf(1,"Couldn't find cards.dll",{})
    end if

    if hCardDll = 0  then
        return FALSE
    end if

    cdtInit = define_c_proc(hCardDll,"cdtInit",{C_POINTER,C_POINTER})
cdtDraw =
    define_c_proc(hCardDll,"cdtDraw",{C_INT,C_INT,C_INT,C_INT,C_INT,C_INT})

    return TRUE
end function


function MAKE_CARD_VALUE(integer face, integer suit)
	return face + suit*4
end function

VOID = InitCardsDll()

procedure WinCreate(integer self, integer event, sequence parms)
    c_proc(cdtInit,{cwidth, cheight})
    setTimer(Win,1,30)
end procedure
setHandler(Win, w32HActivate, routine_id("WinCreate"))

procedure Timer(integer self, integer event, sequence parms)
sequence rect
atom hDC
integer x,y, card
    rect = getClientRect(Win)
    hDC = getDC(Win)
	
    x = rand(rect[3] - peek4u(cwidth))
    y = rand(rect[4] - peek4u(cheight))
	
    card = MAKE_CARD_VALUE(rand(4)-1, rand(13)-1)
	
    c_proc(cdtDraw,{hDC, x, y, card, 0, 0})
end procedure
setHandler(Win,w32HTimer, routine_id("Timer"))


WinMain(Win,Normal)


new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu