Page 1 of 4

Hexagons and stuff

Posted: Thu Jun 28, 2018 8:34 am
by richmond62
I was playing Hexago Continuo with my nephew last night (one of those "Richmond as Evil Uncle" evenings).
-
hexago2.jpg
-
In this game one can score by matching: colour-to-colour, number-to-number, colour-&-number-to-colour-&-number: generally a "big b*gg*r of a game".
-
Whether my headache this morning is from Hexago Continuo or the white wine is another question.

But I digress.

Having put "Twinkle Toes" to bed, I sat down in front of the computer and made this:
-
hexTest4.png
-
Which is something of a half-cock job as it only copes with rotation and
colours (using 7 custom properties).

IFF you wanted to go the whole hog, you'd have to make 36 cards,
each with different colour combinations, and different number
combinations, and 14 custom properties to keep track of them all.
-
hexTest 4.livecode.zip
Here's the stack.
(4.72 KiB) Downloaded 397 times

Re: Hexagons and stuff

Posted: Thu Jun 28, 2018 8:58 am
by richmond62
hexChess.jpg
-
AND here I am, this morning, explaining to some kids about Hexago Continuo and, accidentally on purpose 8), I put the pieces on top of a home made hexagonal chess board I made about 30 years ago.
-
So we started worrying about moving things between hexagons . . .
-
dd.png
dd.png (7.63 KiB) Viewed 17526 times
-
and (y/x) = 1,73684 :D

Re: Hexagons and stuff

Posted: Thu Jun 28, 2018 10:58 am
by richmond62
hex-apothem.png
hex-apothem.png (4.88 KiB) Viewed 17517 times

Re: Hexagons and stuff

Posted: Wed Jul 04, 2018 4:35 pm
by richmond62
Now the above is all rather charming, but . . .

The "sensible thing" would, surely, be to populate the Points list (pairs of comma delimited numbers)
with the points of a hexagonal grid?

AND, prior to that, simply to generate a hexagon with the Polygon Graphic object
(rather than the pointless, literally as well as figuratively, the Regular Polygon Graphic) by setting its points?

If one does this sort of thing:

Code: Select all

put the points of grc "RegPolygonGraphic" into fld "fPOINTS"
one gets nothing: so that is NBG!

This, however, is useful: https://rechneronline.de/pi/hexagon.php
although it does not give one a hexagon's points.
-
SALAD.png
-
HEXAGON.png
-
hex builder.livecode.zip
Here's the stack.
(1.46 KiB) Downloaded 356 times
-
This had to be built using LiveCode 7.1.4 because the LiveCode developers did NOT sort out a bug with the display of Polygon Graphics before they released their "Final" version of the LC * sequence.

Re: Hexagons and stuff

Posted: Wed Jul 04, 2018 5:53 pm
by richmond62
One of the complications with hexagons is that, while with rectangular objects you can refer to their topleft, bottomleft, topright and bottomright, you cannot refer to those and the midleft and midright of a hexagon in LiveCode.

Re: Hexagons and stuff

Posted: Wed Jul 04, 2018 6:01 pm
by richmond62
How DOES one generate a hexagon in LiveCode that measures, say, 60 pixels on each of its 6 sides?
-
IF only things were as simple as in BBC BASIC (screen shot from a BBC Model B I have in my school:
-
BBC Basic.png
BBC Basic.png (5.5 KiB) Viewed 17372 times
-
Beebs.jpg
-
that's my BBC Master Compact having a break on the right hand side.

Re: Hexagons and stuff

Posted: Wed Jul 04, 2018 7:07 pm
by richmond62
I started getting all excited about multiSpace in HyperCard,
but after a side-trip to my trusty G5 iMac I was sorely disappointed as it produced
a series of ever-decreasing nested hexagons like a set of матриошки that left me gae scunnert,
-
multiSpace.png
-
rather than a set of equal sized polygons spread across a card at equal intervals,
-
bultitude.png
-
and I jalouse full well why Kevin and Co. did not bother to include that in LiveCode.

Re: Hexagons and stuff

Posted: Wed Jul 04, 2018 7:36 pm
by Klaus
Creating a "Regular Polygon Graphic" and setting its "polySides" to 6 does not work for you?

Re: Hexagons and stuff

Posted: Wed Jul 04, 2018 7:48 pm
by richmond62
Creating a "Regular Polygon Graphic" and setting its "polySides" to 6 does not work for you?
I have had the "odd stupid moment", but not quite that bad. Creating a hexagon the way you suggest is all very fine as far as it goes, in that it creates hexagonal graphic controls. But:

1. They are not readily tileable.

2. It is not at all easy to work out the exact locations of their 6 points.

Re: Hexagons and stuff

Posted: Wed Jul 04, 2018 7:56 pm
by richmond62
I created a simple hexagonal grid using TurtleArt: http://wiki.sugarlabs.org/go/Activities/Turtle_Art
-
hexes.png
-
I know: don't laugh. 8)

and exported the resultant hex grid as an SVG file which LiveCode seemed unable to import even with this:
-
SVG Importer.livecode.zip
Richmond's SVG fudger.
(87.19 KiB) Downloaded 355 times
-
even though I opened the original SVG file in Inkscape and re-saved it.
-
hexes.svg.zip
hex grid exported from TurtleArt.
(916 Bytes) Downloaded 361 times
-
I suppose I could have processed it into a PNG image and imported that,
but that would also have been a bit useless re Mathematics.

Re: Hexagons and stuff

Posted: Wed Jul 04, 2018 7:56 pm
by Klaus
Hi RIchmond,

1. what does that mean exactly?
Will make manual adjustments neccessary, if that is what you mean.

2.
...
put the effective points of grc "the hex thingie"
...
Could be helpful here :D
This property is read-only however!


Best

Klaus

Re: Hexagons and stuff

Posted: Wed Jul 04, 2018 8:04 pm
by richmond62
put the effective points of grc "the hex thingie"
Well, Ja . . .
-
effectPts.png
-
but the problem lies in the fact that those points are read-only:
one cannot adjust them so as to effect efficient tiling.

Re: Hexagons and stuff

Posted: Sat Jul 21, 2018 6:58 pm
by richmond62
So . . .

I did have to end up with a pupil who wants to make a hexagonal tiling game in LiveCode,
didn't I?

And, in theory, at least, that's very groovy indeed,

until, that is, you also find out that he's such a pain-in-the-bum he wants to make his own hexagonal tiles . . .

Now, making square and/or rectangular tiles is easy-peasy:

1. Import your map image.

2. Lay lots of rectangular graphic objects on your map.

3. Write some code:

Code: Select all

on mouseUp
   import snapshot from rect (the rect of grc "yourSquare") of card "yourCard"
   end mouseUp
and, magically, you have a load of tiling images.

So . . . I told this chap (his name is Kamen) that I'd "work on it over the weekend" . . .
another one to add to all the other things teachers tell pupils when they don't know
how to do things.

Of course this:
on mouseUp
import snapshot from rect (the rect of grc "yourHexagon") of card "yourCard"
end mouseUp
made a right "Hot Fudge Sundae" of things, and this:
on mouseUp
import snapshot from rect (the effective points of grc "yourHexagon") of card "yourCard"
end mouseUp
just threw a blue meanie.
-
tileMaker.jpg
-
Tile Maker.livecode.zip
Here's a wonky stack.
(201.78 KiB) Downloaded 364 times
--
Of course I could just download and use this: https://thorbjorn.itch.io/tiled

but that spoils the fun.

Re: Hexagons and stuff

Posted: Sat Jul 21, 2018 11:21 pm
by bwmilby
Probably something along the lines of creating a square mask image that only shows the hex tile area and then screen shot that area. Then as you move across the image you will capture the tiles you need and can set the margins as transparent. Just need to do the math to position the captures correctly.

Re: Hexagons and stuff

Posted: Sun Jul 22, 2018 2:41 pm
by richmond62
Part of the problem is that one cannot do this:

(pseudocode)

export snapshot from stack "myStack" to file "snap.png" as PNG


as one can easily manipulate which parts of a map are visible using windowShape.