Recent Posts

Pages: 1 ... 8 9 [10]
91
Code and examples / Re: CyberSlots...... Game made with Blitz3d
« Last post by B+ on July 08, 2019, 02:13:59 PM »
Hi Rick,

DirectPlay, your app wont work without it. Apparently Windows 10 thinks it's antiquated. I suppose it could be installed but I am not Gamer and I am concerned about adding stuff that might be another door for malware to come through.
92
Code and examples / Re: CyberSlots...... Game made with Blitz3d
« Last post by Rick3137 on July 08, 2019, 12:18:17 PM »
 Thanks for warning me. What was missing? Was it a Windows thing with missing Dll's ?
93
Code and examples / Re: CyberSlots...... Game made with Blitz3d
« Last post by B+ on July 07, 2019, 10:08:06 PM »
Hi Rick,

I was going to try the game but the exe said I needed stuff. Sorry, I was already concerned about running an exe, I trust you, not so much a compiled exe telling me to download stuff.  :(
94
General questions and discussions / Re: Celtic Knot Challenge
« Last post by B+ on July 07, 2019, 10:02:48 PM »
I'm afraid I found the hard way to do it.

For your amusement here is my QB64 v1.3 code:

Code: [Select]
OPTION _EXPLICIT
_TITLE "Celtic Challenge Advanced Sub" 'B+ 2019-07-06 develop as a sub
' parameters are x, y origin, radius of Knot, thicknes of rings, border color and fill color
' is there a max radius of knot?

CONST xmax = 700, ymax = 700, pi = 3.14159265
CONST xc = xmax / 2, yc = ymax / 2
SCREEN _NEWIMAGE(xmax, ymax, 32)
_SCREENMOVE 100, 20

DIM knot, thick, w$
WHILE 1
    CLS
    INPUT "Enter knot size, 20 to 150 best "; knot
    INPUT "Enter ring thickness, 1 to 20% knot best ", thick
    INPUT "Enter f to fill in with green, best not to fill when thickness < %5 knot "; w$
    IF w$ = "f" THEN celticKnot xc, yc, knot, thick, &HFFFFFF00, &HFF00BB00 ELSE celticKnot xc, yc, knot, thick, &HFFFFFF00, 0
    INPUT "press enter to cont... "; w$
    _DISPLAY

WEND

'the max thickness for the knotRadius is .25 * knotRadius, ideal max is about 20%
' use 0 for fill color to skip PAINT jobs, recommended for small or thin knots
SUB celticKnot (xc, yc, knotR, ringThick, outline AS _UNSIGNED LONG, fill AS _UNSIGNED LONG)
    DIM r, r1, hex, hd2, nHex

    'a good naming system is crucial i/o = inner/outer circle,
    'p1/m1 plus1/minus1 (actually it's plus and minus 1/2 for outer rings)
    DIM xi, yi, xim1, yim1, xip1, yip1, xom1, yom1, xop1, yop1

    'points of interest
    DIM xm1, xm2, xm3, xm4, xm5, xm6, xm7, xm9, xm10, xm12
    DIM ym1, ym2, ym3, ym4, ym5, ym6, ym7, ym9, ym10, ym12
    DIM xn1, xn2, xn3, xn4, xn5, xn6, xn8, xn9, xn10, xn11
    DIM yn1, yn2, yn3, yn4, yn5, yn6, yn8, yn9, yn10, yn11
    DIM xp1, xp2, xp3, xp4, xp5, xp6, xp7, xp8
    DIM xq1, xq2, xq3, xq4, xq5, xq6
    DIM yp1, yp2, yp3, yp4, yp5, yp6, yp7, yp8
    DIM yq1, yq2, yq3, yq4, yq5, yq6

    r = .8 * knotR '4
    r1 = r - ringThick '3 * ringThick ' 3
    hex = pi * 2 / 6
    hd2 = hex / 2

    FOR nHex = 1 TO 6

        '5 circle origin sets

        'inner ring before main ring
        xim1 = xc + knotR * COS((nHex - 1) * hex - hd2)
        yim1 = yc + knotR * SIN((nHex - 1) * hex - hd2)

        'main inner ring to draw up
        xi = xc + knotR * COS(nHex * hex - hd2)
        yi = yc + knotR * SIN(nHex * hex - hd2)

        'inner ring after main
        xip1 = xc + knotR * COS((nHex + 1) * hex - hd2)
        yip1 = yc + knotR * SIN((nHex + 1) * hex - hd2)

        'outer ring before main ring
        xom1 = xc + (2 * knotR - 1.5 * ringThick) * COS((nHex - 1) * hex)
        yom1 = yc + (2 * knotR - 1.5 * ringThick) * SIN((nHex - 1) * hex)

        'outer ring after main ring
        xop1 = xc + (2 * knotR - 1.5 * ringThick) * COS(nHex * hex)
        yop1 = yc + (2 * knotR - 1.5 * ringThick) * SIN(nHex * hex)

        'working main ring from 0 to 2*pi  one segment at a time

        'first point of interest on main is out circle /\ out circle of op1
        intersect2Circles xi, yi, r, xop1, yop1, r, xm1, ym1, xm4, ym4
        intersect2Circles xi, yi, r, xop1, yop1, r1, xm2, ym2, xm3, ym3

        intersect2Circles xi, yi, r, xop1, yop1, r1, xm2, ym2, xm3, yn3
        intersect2Circles xi, yi, r1, xop1, yop1, r1, xn2, yn2, xn3, yn3

        minorArc xi, yi, r, rAngle(xi, yi, xm1, ym1), rAngle(xi, yi, xm3, ym3), outline
        minorArc xi, yi, r1, rAngle(xi, yi, xn2, yn2), rAngle(xi, yi, xn3, yn3), outline

        'inside main outside po1
        intersect2Circles xi, yi, r1, xop1, yop1, r, xn1, yn1, xn4, yn4

        'outside main with outside im1
        intersect2Circles xi, yi, r, xim1, yim1, r, xm5, ym5, xm10, ym10

        'inside main outside im1
        intersect2Circles xi, yi, r1, xim1, yim1, r, xn5, yn5, xn10, yn10

        minorArc xi, yi, r, rAngle(xi, yi, xm4, ym4), rAngle(xi, yi, xm5, ym5), outline
        minorArc xi, yi, r1, rAngle(xi, yi, xn4, yn4), rAngle(xi, yi, xn5, yn5), outline


        'outside main to inside im1
        intersect2Circles xi, yi, r, xim1, yim1, r1, xm6, ym6, xm9, ym9

        'inside main to inside im1
        intersect2Circles xi, yi, r1, xim1, yim1, r1, xn6, yn6, xn9, yn9

        minorArc xi, yi, r, rAngle(xi, yi, xm6, ym6), rAngle(xi, yi, xm9, ym9), outline
        minorArc xi, yi, r1, rAngle(xi, yi, xn6, yn6), rAngle(xi, yi, xn9, yn9), outline

        'outer main to outer om1
        intersect2Circles xi, yi, r, xom1, yom1, r, xm7, ym7, xm12, ym12

        'inner main to inner om1
        intersect2Circles xi, yi, r1, xom1, yom1, r1, xn8, yn8, xn11, yn11

        minorArc xi, yi, r, rAngle(xi, yi, xm10, ym10), rAngle(xi, yi, xm12, ym12), outline
        minorArc xi, yi, r1, rAngle(xi, yi, xn10, yn10), rAngle(xi, yi, xn11, yn11), outline


        'now for the two that fold inward

        'outer op1 to outer  ip1
        intersect2Circles xop1, yop1, r, xip1, yip1, r, xp1, yp1, xp4, yp4
        'outer op1 to inner p1
        intersect2Circles xop1, yop1, r, xip1, yip1, r1, xp2, yp2, xp3, yp3
        'inner op1 to inner p1
        intersect2Circles xop1, yop1, r1, xip1, yip1, r1, xq2, yq2, xq3, yq3

        minorArc xop1, yop1, r, rAngle(xop1, yop1, xp1, yp1), rAngle(xop1, yop1, xp3, yp3), outline
        minorArc xop1, yop1, r1, rAngle(xop1, yop1, xq2, yq2), rAngle(xop1, yop1, xq3, yq3), outline

        'inner op1 outer inner p1
        intersect2Circles xop1, yop1, r1, xip1, yip1, r, xq1, yq1, xq4, yq4

        minorArc xop1, yop1, r, rAngle(xop1, yop1, xp4, yp4), rAngle(xop1, yop1, xm1, ym1), outline


        'last test?
        minorArc xop1, yop1, r1, rAngle(xop1, yop1, xq4, yq4), rAngle(xop1, yop1, xn1, yn1), outline


        'outer om1 to outer outer main
        intersect2Circles xom1, yom1, r, xi, yi, r, xp5, yp5, xp8, yp8
        'inner om1 to inner main
        intersect2Circles xom1, yom1, r1, xi, yi, r1, xq5, yq5, xq6, yq6
        'outer om1to inner main
        intersect2Circles xom1, yom1, r, xi, yi, r1, xp6, yp6, xp7, yp7

        minorArc xom1, yom1, r, rAngle(xom1, yom1, xp5, yp5), rAngle(xom1, yom1, xp7, yp7), outline
        minorArc xom1, yom1, r1, rAngle(xom1, yom1, xq5, yq5), rAngle(xom1, yom1, xq6, yq6), outline

    NEXT

    IF fill THEN
        DIM px, py, midR
        midR = (r + r1) / 2 + .5
        FOR nHex = 1 TO 6
            'circles with origins in main circle
            'main inner ring to draw up
            xi = xc + knotR * COS(nHex * hex - hd2)
            yi = yc + knotR * SIN(nHex * hex - hd2)

            '4 paint points
            px = xi + midR * COS(nHex * hex + .1 * pi)
            py = yi + midR * SIN(nHex * hex + .1 * pi)
            'CIRCLE (px, py), 1, fill
            PAINT (px, py), fill, outline

            px = xi + midR * COS(nHex * hex + .7 * pi)
            py = yi + midR * SIN(nHex * hex + .7 * pi)
            'CIRCLE (px, py), 1, fill
            PAINT (px, py), fill, outline

            px = xi + midR * COS(nHex * hex + 1.3 * pi)
            py = yi + midR * SIN(nHex * hex + 1.3 * pi)
            'CIRCLE (px, py), 1, fill
            PAINT (px, py), fill, outline

            px = xi + midR * COS(nHex * hex + 1.7 * pi)
            py = yi + midR * SIN(nHex * hex + 1.7 * pi)
            'CIRCLE (px, py), 1, fill
            PAINT (px, py), fill, outline

        NEXT
    END IF
END SUB

'given a circles origin and point on the circumference return the arc measure of that point
FUNCTION rAngle (coX, coY, circumX, circumY)
    rAngle = _ATAN2(circumY - coY, circumX - coX)
    IF rAngle < 0 THEN rAngle = rAngle + _PI(2)
END FUNCTION

'given two arc angles I want the one that draws the smaller arc drawn
SUB minorArc (x, y, r, ra1, ra2, c AS _UNSIGNED LONG)
    DIM raStart, raStop

    'which has smaller arc measure
    IF ra1 < ra2 THEN
        IF ra2 - ra1 < _PI THEN raStart = ra1: raStop = ra2 ELSE raStart = ra2: raStop = ra1
    ELSE
        IF ra1 - ra2 < _PI THEN raStart = ra2: raStop = ra1 ELSE raStart = ra1: raStop = ra2
    END IF
    arc x, y, r, raStart, raStop, c
END SUB

SUB intersect2Circles (x1, y1, r1, x2, y2, r2, ix1, iy1, ix2, iy2)
    'x1, y1 origin of circle 1 with radius r1
    'x2, y2 origin of circle 2 with radius r2
    'ix1, iy1 is the first point of intersect
    'ix2, iy2 is the 2nd point of intersect
    'if ix1 = ix2 = iy1 = iy2 = 0 then no points returned

    DIM d, a, h, Px, Py, offset, rang1, rang2
    d = distance(x1, y1, x2, y2) 'distance between two origins
    IF r1 + r2 < d THEN
        'PRINT "The circles are too far apart to intersect.": END
        'some signal ???    if ix1 = ix2 = iy1 = iy2 = 0 then no points returned
        ix1 = 0: ix2 = 0: iy1 = 0: iy2 = 0
        EXIT SUB
    END IF
    IF (d < r1 AND r2 + d < r1) OR (d < r2 AND r1 + d < r2) THEN ' no intersect
        ix1 = 0: ix2 = 0: iy1 = 0: iy2 = 0
        EXIT SUB
    END IF
    'results
    a = (r1 ^ 2 - r2 ^ 2 + d ^ 2) / (2 * d)
    Px = x1 + a * (x2 - x1) / d
    Py = y1 + a * (y2 - y1) / d
    h = (r1 ^ 2 - a ^ 2) ^ .5
    ix1 = INT(Px - h * (y2 - y1) / d)
    iy1 = INT(Py + h * (x2 - x1) / d)
    ix2 = INT(Px + h * (y2 - y1) / d)
    iy2 = INT(Py - h * (x2 - x1) / d)

    ''getting the order of points matched to varaible labels
    offset = rAngle(xc, yc, x1, y1)
    rang1 = rAngle(x1, y1, ix1, iy1) - offset
    IF rang1 < 0 THEN rang1 = rang1 + 2 * pi
    rang2 = rAngle(x1, y1, ix2, iy2) - offset
    IF rang2 < 0 THEN rang2 = rang2 + 2 * pi
    IF rang2 < rang1 THEN SWAP ix1, ix2: SWAP iy1, iy2

END SUB

SUB arc (x, y, r, raStart, raStop, c AS _UNSIGNED LONG)
    'x, y origin, r = radius, c = color

    'raStart is first angle clockwise from due East = 0 degrees
    ' arc will start drawing there and clockwise until raStop angle reached

    DIM al, a
    IF raStop < raStart THEN
        arc x, y, r, raStart, _PI(2), c
        arc x, y, r, 0, raStop, c
    ELSE
        ' modified to easier way suggested by Steve
        'Why was the line method not good? I forgot.
        al = _PI * r * r * (raStop - raStart) / _PI(2)
        FOR a = raStart TO raStop STEP 1 / al
            PSET (x + r * COS(a), y + r * SIN(a)), c
        NEXT
    END IF
END SUB

FUNCTION rrnd (n1, n2) 'return real number between
    rrnd = (n2 - n1) * RND + n1
END FUNCTION

FUNCTION distance (x1, y1, x2, y2)
    distance = ((x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ .5
END FUNCTION


What is that? over 70 variables in main sub!
95
General questions and discussions / Re: Celtic Knot Challenge
« Last post by ZXDunny on July 07, 2019, 08:47:57 AM »
Very nice, B+ :)

I'm working on my celtic knots demo right now - it's different to yours but still looks pretty nice. Unfortunately I made several updates to the editor in SpecBAS so whenever I use it I find bugs that need fixing, so progress is slow :D
96
Code and examples / CyberSlots...... Game made with Blitz3d
« Last post by Rick3137 on July 06, 2019, 09:54:13 PM »
  I purchased Blitz3d several years ago for 100 dollars. I played with it for awhile and got sidetracked.

  There are a lot of languages out there to try out, so I got side tracked.

  I recently noticed that it has been recently pushed to the open source category and it occurred to me that it might be a good choice for this website, so I decided to give it another try. ( Go to google to get a copy)

 I updated an old game I made called "Cyberslots". It is a simple math game that I use to keep my mind from going to a complete stop.
97
General questions and discussions / Re: Celtic Knot Challenge
« Last post by B+ on July 06, 2019, 02:38:17 PM »
And here is one with more open ended rings:
98
General questions and discussions / Re: Celtic Knot Challenge
« Last post by B+ on July 06, 2019, 02:37:12 PM »
Success! sort of...

I hit a wall with Circle Intersect that returns 2 points where 2 circles intersect: which point is which for assigning to a variable?

Fixed by translating the points position to a standard variable map if the circle they came had 0 rotation.

Anyway now I can draw fat and thin rings with circles more open or closed:

99
Pulsar2D / Few quick questions
« Last post by johnno56 on July 06, 2019, 02:09:58 AM »
Firstly... I was checking out AllegroBASIC and spotted a reference to Pulsar2D... I have installed both on my Linux Mint 64 bit machine.

1. Is Pulsar2D still being developed?
2. Is there any documentation for the current version?
3. Are there, or will there be, any tutorials?

Thank you

J
100
General questions and discussions / Re: Celtic Knot Challenge
« Last post by B+ on July 05, 2019, 02:07:11 PM »
To eliminate eye-balling start and end arcs, I have worked up code for the 2 points intersect of 2 circles when they do intersect.

Hopefully this will allow me to draw a variety of ring widths with math only.
Pages: 1 ... 8 9 [10]