Hexagons and stuff

Creating Games? Developing something for fun?

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2751
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Hexagons and stuff

Post by richmond62 » Thu Jun 28, 2018 8:34 am

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 15 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2751
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Hexagons and stuff

Post by richmond62 » Thu Jun 28, 2018 8:58 am

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 1127 times
-
and (y/x) = 1,73684 :D

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2751
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Hexagons and stuff

Post by richmond62 » Thu Jun 28, 2018 10:58 am

hex-apothem.png
hex-apothem.png (4.88 KiB) Viewed 1118 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2751
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Hexagons and stuff

Post by richmond62 » Wed Jul 04, 2018 4:35 pm

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 13 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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2751
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Hexagons and stuff

Post by richmond62 » Wed Jul 04, 2018 5:53 pm

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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2751
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Hexagons and stuff

Post by richmond62 » Wed Jul 04, 2018 6:01 pm

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 973 times
-
Beebs.jpg
-
that's my BBC Master Compact having a break on the right hand side.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2751
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Hexagons and stuff

Post by richmond62 » Wed Jul 04, 2018 7:07 pm

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.

Klaus
Posts: 10427
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Hexagons and stuff

Post by Klaus » Wed Jul 04, 2018 7:36 pm

Creating a "Regular Polygon Graphic" and setting its "polySides" to 6 does not work for you?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2751
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Hexagons and stuff

Post by richmond62 » Wed Jul 04, 2018 7:48 pm

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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2751
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Hexagons and stuff

Post by richmond62 » Wed Jul 04, 2018 7:56 pm

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 14 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 13 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.
Last edited by richmond62 on Wed Jul 04, 2018 8:10 pm, edited 2 times in total.

Klaus
Posts: 10427
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Hexagons and stuff

Post by Klaus » Wed Jul 04, 2018 7:56 pm

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2751
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Hexagons and stuff

Post by richmond62 » Wed Jul 04, 2018 8:04 pm

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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2751
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Hexagons and stuff

Post by richmond62 » Sat Jul 21, 2018 6:58 pm

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 10 times
--
Of course I could just download and use this: https://thorbjorn.itch.io/tiled

but that spoils the fun.

bwmilby
Posts: 212
Joined: Wed Jun 07, 2017 5:37 am
Location: New Orleans, LA
Contact:

Re: Hexagons and stuff

Post by bwmilby » Sat Jul 21, 2018 11:21 pm

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.
Brian Milby

Script Tracker https://github.com/bwmilby/lc-misc/tree/master/ScriptTracker

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2751
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Hexagons and stuff

Post by richmond62 » Sun Jul 22, 2018 2:41 pm

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.

Post Reply

Return to “Creating Games”