|
Post by anurup on Aug 3, 2016 18:14:09 GMT 1
basica, Thanks for taking the time to reply. Found your reply as I deleted my earlier two posts - because I managed to stumble upon the solution looking up the canvas.bac code. Talk about a monkey hacking away long enough at a keyboard... Greatly appreciate your reply still... Best Regards Anurup
|
|
|
Post by basica on Aug 3, 2016 18:23:07 GMT 1
anurup,
Pleased you found a way for "detecting key strokes"
Regards, basica
|
|
|
Post by Pjot on Sept 10, 2017 14:41:31 GMT 1
All, For some other program I was playing around with the canvas, and I discovered that neither the STB plugin nor the SVG plugin could load a plain XPM image Therefore, I created a new XPM canvas plugin which can do so, demonstration program is here. BR Peter EDIT: fixed memory leak in the XPM plugin. Also updated the canvas to make the XPM plugin work. Please update to make the XPM images work properly.
|
|
|
Post by Pjot on Sept 21, 2018 15:03:50 GMT 1
All, A long time ago I made a Belote game in some other language using an XPM file, containing all cards. Now with the above XPM plugin we can load them to an OpenGL canvas. Program and screenshot below. Notice how few lines of code are needed for this result BR Peter '------------------------------------------------------------------------------------------------ PRAGMA INCLUDE cards.xpm
INCLUDE canvas INCLUDE canvas-plugin-xpm
CONST CARDWIDTH = 71 CONST CARDHEIGHT = 96
ENUM Clubs, Diamonds, Hearts, Spades ENDENUM
DECLARE Card$[57+96]
' Set color properties for each card Card$[0] = " 71 96 56 1" FOR nr = 1 TO 56 Card$[nr] = allCards[nr] NEXT
'------------------------------------------------------------------------------------------------
SUB Draw_Card(which, color, xpos, ypos)
LOCAL x
' Copy card definitiion FOR x = 0 TO CARDHEIGHT-1 Card$[57+x] = MID$(allCards[57+(which-1)*CARDHEIGHT+x], color*CARDWIDTH+1, CARDWIDTH) NEXT
' Draw card XPM_IMAGE(Card$, xpos, ypos)
END SUB
'------------------------------------------------------------------------------------------------
WINDOW("Demo XPM", 640, 480)
' Green background (RGBA) INK(0, 100, 0, 255) CLS
FOR card = 1 TO 13 Draw_Card(card, Clubs, 50+card*35, 80) Draw_Card(card, Diamonds, 50+card*35, 180) Draw_Card(card, Hearts, 50+card*35, 280) Draw_Card(card, Spades, 50+card*35, 380) NEXT
XPM_IMAGE_FREE
WAITKEY
Attachments:
cards.xpm (405.95 KB)
|
|
|
Post by vovchik on Sept 21, 2018 16:31:11 GMT 1
Dear Peter, Thanks. It all works nicely for me. I will see whether I have a small SVG set of cards that is equally pretty but that might be smaller in terms of bytes. I think I had a set somewhere and may have posted it. With kind regards, vovchik UPDATED: I found the source (the svgs are part of an fltk bacon demo - all in the source code - and not large.) Attachments:fgs-drag-img.tar.gz (59.66 KB)
|
|
|
Post by Pjot on Sept 22, 2018 8:01:04 GMT 1
Thanks vovchik,
Compiles and works fine! And looks very good, as usual. The drag-and-drop is really nice.
BR, Peter
|
|
|
Post by Pjot on Aug 3, 2019 10:29:44 GMT 1
All, So now the mouse interaction is working smoothly, I have ported the HUG Clines game to the updated canvas context. Code is here and a screenshot below. Should work with vanilla BaCon 3.9.1 BR Peter Attachments:
|
|
|
Post by vovchik on Aug 3, 2019 11:49:09 GMT 1
Dear Peter,
Thanks. It works fine on my Mint 19.2 with the latest BaCon beta.
With kind regards, vovchik
|
|