Recent Posts

Pages: [1] 2 3 ... 10
1
QB64 Discussion / Re: Practicing Coding Game
« Last post by bplus on Today at 04:05:59 PM »
I must say, most people would grab images and manipulate them. But I admire the brave soul who chooses to draw by code! :)

Here is quad drawing tools. Basically you need a triangle fill routine and then draw 2 triangles that share an edge.

I constructed parallelograms, random quad and rhombus from central point. I am afraid the level for that is a little high too.
Fortunately you don't need allot of math to get 4 points for the quad but you do have to watch that the shared edge is line x2, y2 to x4, y4 for quad sub.

Code: [Select]
_TITLE "A draw quad tool, white = parallelogram, red = random quad, blue = rhombus" 'B+ started 2019-03-21

RANDOMIZE TIMER
CONST white = &HFFFFFFFF
CONST red = &HFFFF0000
CONST blue = &HFF0000FF

'a quad is 4 points about a center, squares, rectangles, rhombus, parallelogram, trapizoids are special cases
SCREEN _NEWIMAGE(800, 600, 32)
_SCREENMOVE 300, 40

WHILE _KEYDOWN(27) = 0
    CLS
    'try paralleogram  white
    'pick a random point not too close to edge of screen (50 away) to be center of parallelogram
    x0 = (_WIDTH - 100) * RND + 50: y0 = (_HEIGHT - 100) * RND + 50
    'pick a random radius from center, all are equal for parellel
    r = RND * 40 + 10
    'pick an angle between 0 and 180 degrees =_PI radians
    a = RND * _PI
    'a par o gram has 2 angles that sum to 180 = _PI
    p1 = RND * PI(11 / 6) + _PI(1 / 6): p2 = _PI - p1
    a1 = a + p1
    a2 = a1 + p2
    a3 = a2 + p1
    x1 = x0 + r * COS(a): y1 = y0 + r * SIN(a)
    x2 = x0 + r * COS(a1): y2 = y0 + r * SIN(a1)
    x3 = x0 + r * COS(a2): y3 = y0 + r * SIN(a2)
    x4 = x0 + r * COS(a3): y4 = y0 + r * SIN(a3)
    fquad x1, y1, x2, y2, x3, y3, x4, y4, white

    'random quad
    ' or lets say all the angles are 90 more than last but use random radius from center point
    x0 = (_WIDTH - 100) * RND + 50: y0 = (_HEIGHT - 100) * RND + 50
    a = _PI(.25) * RND 'start point angle from center
    r = 10 + 40 * RND
    x1 = x0 + r * COS(a): y1 = y0 + r * SIN(a)
    r = 10 + 40 * RND
    x2 = x0 + r * COS(a + _PI(.5)): y2 = y0 + r * SIN(a + _PI(.5)) 'plus 90 degree = pi/2 = .5*pi
    r = 10 + 40 * RND
    x3 = x0 + r * COS(a + _PI): y3 = y0 + r * SIN(a + _PI) 'plus 180 degrees = pi
    r = 10 + 40 * RND
    x4 = x0 + r * COS(a + _PI(1.5)): y4 = y0 + r * SIN(a + _PI(1.5)) 'plus 270 degrees = 3/2*pi
    fquad x1, y1, x2, y2, x3, y3, x4, y4, red
    'PSET (x0, y0), white
    'LINE (x0, y0)-(x1, y1), white
    'LINE (x0, y0)-(x2, y2), blue
    'LINE (x0, y0)-(x3, y3), white
    'LINE (x0, y0)-(x4, y4), blue

    'rhombus like ellipse 2 radii
    r1 = RND * 35 + 15: r2 = RND * 35 + 15
    x0 = (_WIDTH - 100) * RND + 50: y0 = (_HEIGHT - 100) * RND + 50
    a = _PI(.25) * RND 'start point angle from center
    x1 = x0 + r1 * COS(a): y1 = y0 + r1 * SIN(a)
    x2 = x0 + r2 * COS(a + _PI(.5)): y2 = y0 + r2 * SIN(a + _PI(.5)) 'plus 90 degree = pi/2 = .5*pi
    x3 = x0 + r1 * COS(a + _PI): y3 = y0 + r1 * SIN(a + _PI) 'plus 180 degrees = pi
    x4 = x0 + r2 * COS(a + _PI(1.5)): y4 = y0 + r2 * SIN(a + _PI(1.5)) 'plus 270 degrees = 3/2*pi
    fquad x1, y1, x2, y2, x3, y3, x4, y4, blue
    _DISPLAY
    _LIMIT 1
WEND
' if you connect 2 points that are not adjacent but opposite each other you divide a quad to 2 triangle
' So if we have code to draw a filled triangle we have to just draw 2 filled triangles.

'need 4 non linear points (not all on 1 line) list them clockwise so x2, y2 is opposite of x4, y4
SUB fquad (x1, y1, x2, y2, x3, y3, x4, y4, K AS _UNSIGNED LONG)
    ftri x1, y1, x2, y2, x4, y4, K
    ftri x3, y3, x2, y2, x4, y4, K
END SUB

'Very Handy code to draw a filled triangle
SUB ftri (x1, y1, x2, y2, x3, y3, K AS _UNSIGNED LONG)
    a& = _NEWIMAGE(1, 1, 32)
    _DEST a&
    PSET (0, 0), K
    _DEST 0
    _MAPTRIANGLE _SEAMLESS(0, 0)-(0, 0)-(0, 0), a& TO(x1, y1)-(x2, y2)-(x3, y3)
    _FREEIMAGE a& '<<< this is important!
END SUB

2
QB64 Discussion / Re: Practicing Coding Game
« Last post by eddy498 on Today at 12:18:00 PM »
Hmm that code confuses me. I'm still not at that level.
Want something more along the lines of
SUB makerocks
And the do a bunch of lines to make an outline of a rock. But my problem is how do I go about making angles and the faces different colors. For example u know how rocks have shades on different sides. And they are different shapes. I know about line BF which will fill the box in but how do I go about making a parrellelogram where the box is at an angle and it's filled with a different shade??
This is what has me confused since I don't want to just use boxes as rocks.
3
Programs / Re: The Recursive Descent Parser
« Last post by Aurel on Today at 10:55:50 AM »
Hi..
I just forund in my old programs one created by author of qb64
i called that program GALEON BASIC.
This program is posted on old forum ..long time ago.
There is a interesting way used for evaluating expression with GOTO command..
so can i publish it here ?
4
Programs / Re: adventure game engine
« Last post by pforpond on Today at 08:32:05 AM »
Hi
last time I have missed two little feedbacks
1.  here
Quote
$EXEICON:'data\icon.ico'
I must add .\  to let to find icon in the right path
Thank you for spotting this!

Quote
2. just after press F5 the window of the application is so small
but pressing the combokey of windows Alt+Enter I get fullscreen and now it is ok
The window is super small because of the small resolution images I'm currently using. The window should be resizable to your preferred size. I will be adding an option in the main menu to toggle windowed/fullscreen modes in a future update. :)
5
Programs / Re: mpfr
« Last post by jack on Today at 07:41:53 AM »
a more complex example
lanczos gamma approximation
Code: [Select]

$CONSOLE:ONLY
_DEST _CONSOLE

DIM SHARED prec AS LONG
DIM SHARED error_code AS LONG
main

REM $include: 'mpfr-include.bi'
SUB main
    DIM c AS LONG, n AS LONG, i AS LONG

    prec = 1024 ' bits precision, about 300 decimal digits
    n = 6
    DIM x(n) AS mpfr_struct, g AS mpfr_struct
    FOR i = 0 TO n
        CALL mpfr_init2(x(i), prec)
    NEXT
    CALL mpfr_init2(g, prec)
    c = mpfr_set_si(g, 5, MPFR_RNDN)
    CALL make_lanczos(x(), g, error_code)
    FOR i = 0 TO n
        PRINT "C("; i; ") = ";
        CALL print_mpfr_f(x(i), 27, 20)
    NEXT
    FOR i = 0 TO n
        CALL mpfr_clear(x(i))
    NEXT
    CALL mpfr_clear(g)
END SUB

SUB make_lanczos (x() AS mpfr_struct, g AS mpfr_struct, error_code AS LONG)

    DIM i AS LONG, j AS LONG, n AS LONG, c AS LONG
    n = UBOUND(x)
    DIM a(n, n) AS mpfr_struct
    DIM b(n) AS mpfr_struct
    DIM sqr2pi AS mpfr_struct, pi2 AS mpfr_struct, fac AS mpfr_struct
    DIM one AS mpfr_struct, tmp AS mpfr_struct, tmp2 AS mpfr_struct
    FOR i = 0 TO n
        FOR j = 0 TO n
            CALL mpfr_init2(a(i, j), prec)
        NEXT
        CALL mpfr_init2(b(i), prec)
    NEXT
    CALL mpfr_init2(sqr2pi, prec)
    CALL mpfr_init2(pi2, prec)
    CALL mpfr_init2(fac, prec)
    CALL mpfr_init2(one, prec)
    CALL mpfr_init2(tmp, prec)
    CALL mpfr_init2(tmp2, prec)
    c = mpfr_set_si(one, 1, MPFR_RNDN)
    c = mpfr_const_pi(pi2, MPFR_RNDN)
    c = mpfr_mul_si(pi2, pi2, 2, MPFR_RNDN)
    c = mpfr_sqrt(sqr2pi, pi2, MPFR_RNDN)

    'setup the matrix, for n=6 the matrix looks like this

    ' [[ 1, 1,   1/2, 1/3, 1/4,  1/5,  1/6 ]
    ' [  1, 1/2, 1/3, 1/4, 1/5,  1/6,  1/7 ]
    ' [  1, 1/3, 1/4, 1/5, 1/6,  1/7,  1/8 ]
    ' [  1, 1/4, 1/5, 1/6, 1/7,  1/8,  1/9 ]
    ' [  1. 1/5, 1/6, 1/7, 1/8,  1/9,  1/10 ]
    ' [  1, 1/6, 1/7, 1/8, 1/9,  1/10, 1/11 ]
    ' [  1, 1/7, 1/8, 1/9, 1/10, 1/11, 1/12 ]]

    FOR i = 0 TO n
        c = mpfr_set_si(a(i, 0), 1, MPFR_RNDN)
        FOR j = 1 TO n
            c = mpfr_div_si(a(i, j), one, i + j, MPFR_RNDN)
        NEXT
    NEXT

    'setup the constant terms, for n=6 and g=5 they are
    'b( 0) = 41.62443691643906820752
    'b( 1) = 16.01231640525168135809
    'b( 2) =  9.36473553710404851170
    'b( 3) =  6.57049625931606149987
    'b( 4) =  5.09521672929646781312
    'b( 5) =  4.20380175313001102196
    'b( 6) =  3.61487381446333490266

    c = mpfr_set_si(fac, 1, MPFR_RNDN)

    FOR i = 0 TO n
        IF i > 1 THEN
            c = mpfr_mul_si(fac, fac, i, MPFR_RNDN)
        END IF
        'b(i)=exp(i+half+g)/(i+half+g)^(i+half)*fac/sqr2pi
        c = mpfr_add_d(tmp, g, 0.5, MPFR_RNDN)
        c = mpfr_add_si(tmp, tmp, i, MPFR_RNDN)
        c = mpfr_exp(b(i), tmp, MPFR_RNDN)
        c = mpfr_set_d(tmp2, i + 0.5, MPFR_RNDN)
        c = mpfr_pow(tmp, tmp, tmp2, MPFR_RNDN)
        c = mpfr_div(b(i), b(i), tmp, MPFR_RNDN)
        c = mpfr_mul(b(i), b(i), fac, MPFR_RNDN)
        c = mpfr_div(b(i), b(i), sqr2pi, MPFR_RNDN)
        'CALL print_mpfr_f(b(i), 27, 20)
    NEXT

    'now solve the system of linear equations, for n=6 and g=5 they are
    ' [[ 1, 1,   1/2, 1/3, 1/4,  1/5,  1/6 ]    = 41.62443691643906820752
    ' [  1, 1/2, 1/3, 1/4, 1/5,  1/6,  1/7 ]    = 16.01231640525168135809
    ' [  1, 1/3, 1/4, 1/5, 1/6,  1/7,  1/8 ]    =  9.36473553710404851170
    ' [  1, 1/4, 1/5, 1/6, 1/7,  1/8,  1/9 ]    =  6.57049625931606149987
    ' [  1. 1/5, 1/6, 1/7, 1/8,  1/9,  1/10 ]   =  5.09521672929646781312
    ' [  1, 1/6, 1/7, 1/8, 1/9,  1/10, 1/11 ]   =  4.20380175313001102196
    ' [  1, 1/7, 1/8, 1/9, 1/10, 1/11, 1/12 ]]  =  3.61487381446333490266

    'and the solution for the above example is
    'C(0) =   1.00000000019001482399
    'C(1) =  76.18009172947146348309
    'C(2) = -86.50532032941676765250
    'C(3) =  24.01409824083091049018
    'C(4) =  -1.23173957245015538752
    'C(5) =   0.00120865097386617851
    'C(6) =  -0.00000539523938495313

    'which is the Lanczos gamma function approximation
    'as published in Numerical recipes

    CALL gauss_jordan(a(), b(), x(), n, error_code)

    FOR i = 0 TO n
        FOR j = 0 TO n
            CALL mpfr_clear(a(i, j))
        NEXT
        CALL mpfr_clear(b(i))
    NEXT
    CALL mpfr_clear(sqr2pi)
    CALL mpfr_clear(pi2)
    CALL mpfr_clear(fac)
    CALL mpfr_clear(one)
    CALL mpfr_clear(tmp)
    CALL mpfr_clear(tmp2)
END SUB



SUB gauss_jordan (a() AS mpfr_struct, y() AS mpfr_struct, coef() AS mpfr_struct, ncol AS LONG, error_code AS LONG)

    ' matrix solution by Gaussian Elimination

    DIM b(ncol, ncol) AS mpfr_struct, w(ncol) AS mpfr_struct ' work array, ncol long

    DIM i AS LONG, j AS LONG, i1 AS LONG, k AS LONG, l AS LONG, n AS LONG, c AS LONG
    DIM hold AS mpfr_struct, sm AS mpfr_struct, tmp AS mpfr_struct
    DIM t AS mpfr_struct, ab AS mpfr_struct, big AS mpfr_struct
    CONST TRUE = -1
    CONST FALSE = NOT TRUE

    error_code = FALSE
    n = ncol

    FOR i = 0 TO ncol
        FOR j = 0 TO ncol
            CALL mpfr_init2(b(i, j), prec)
        NEXT
        CALL mpfr_init2(w(i), prec)
    NEXT
    CALL mpfr_init2(hold, prec)
    CALL mpfr_init2(sm, prec)
    CALL mpfr_init2(t, prec)
    CALL mpfr_init2(ab, prec)
    CALL mpfr_init2(big, prec)
    CALL mpfr_init2(tmp, prec)

    FOR i = 0 TO n
        ' copy to work arrays
        FOR j = 0 TO n
            'b(i,j)=a(i,j)
            c = mpfr_set(b(i, j), a(i, j), MPFR_RNDN)
        NEXT j
        'w(i)=y(i)
        c = mpfr_set(w(i), y(i), MPFR_RNDN)
        'coef(i)=zero
        c = mpfr_set_si(coef(i), 0, MPFR_RNDN)
    NEXT
    FOR i = 0 TO n - 1
        c = mpfr_abs(big, b(i, i), MPFR_RNDN)

        l = i
        i1 = i + 1
        FOR j = i1 TO n
            ' search for largest element
            c = mpfr_abs(ab, b(j, i), MPFR_RNDN)
            IF mpfr_cmp(ab, big) > 0 THEN
                c = mpfr_set(big, ab, MPFR_RNDN)
                l = j
            END IF
        NEXT
        IF mpfr_cmp_si(big, 0) = 0 THEN
            error_code = TRUE
        ELSE
            IF l <> i THEN
                ' interchange rows to put largest element on diagonal
                FOR j = 0 TO n
                    c = mpfr_set(hold, b(l, j), MPFR_RNDN)
                    c = mpfr_set(b(l, j), b(i, j), MPFR_RNDN)
                    c = mpfr_set(b(i, j), hold, MPFR_RNDN)
                NEXT
                c = mpfr_set(hold, w(l), MPFR_RNDN)
                c = mpfr_set(w(l), w(i), MPFR_RNDN)
                c = mpfr_set(w(i), hold, MPFR_RNDN)
            END IF
            FOR j = i1 TO n
                c = mpfr_div(t, b(j, i), b(i, i), MPFR_RNDN)
                FOR k = i1 TO n
                    c = mpfr_mul(tmp, t, b(i, k), MPFR_RNDN)
                    c = mpfr_sub(b(j, k), b(j, k), tmp, MPFR_RNDN)
                NEXT
                c = mpfr_mul(tmp, t, w(i), MPFR_RNDN)
                c = mpfr_sub(w(j), w(j), tmp, MPFR_RNDN)
            NEXT ' j-loop
        END IF ' if big - else
    NEXT ' i-loop
    IF mpfr_cmp_si(b(n, n), 0) = 0 THEN
        error_code = TRUE
    ELSE
        c = mpfr_div(coef(n), w(n), b(n, n), MPFR_RNDN)
        i = n - 1
        ' back substitution
        DO
            c = mpfr_set_si(sm, 0, MPFR_RNDN)
            FOR j = i TO n
                c = mpfr_mul(tmp, b(i, j), coef(j), MPFR_RNDN)
                c = mpfr_add(sm, sm, tmp, MPFR_RNDN)
            NEXT
            c = mpfr_sub(tmp, w(i), sm, MPFR_RNDN)
            c = mpfr_div(coef(i), tmp, b(i, i), MPFR_RNDN)
            i = i - 1
        LOOP UNTIL i < 0
    END IF
    IF error_code THEN PRINT "ERROR: Matrix is singular"
   
    FOR i = 0 TO ncol
        FOR j = 0 TO ncol
            CALL mpfr_clear(b(i, j))
        NEXT
        CALL mpfr_clear(w(i))
    NEXT
    CALL mpfr_clear(hold)
    CALL mpfr_clear(sm)
    CALL mpfr_clear(t)
    CALL mpfr_clear(ab)
    CALL mpfr_clear(big)
    CALL mpfr_clear(tmp)
END SUB
the output
Code: [Select]
C( 0 ) =      1.00000000019001482399
C( 1 ) =     76.18009172947146348309
C( 2 ) =    -86.50532032941676765250
C( 3 ) =     24.01409824083091049018
C( 4 ) =     -1.23173957245015538752
C( 5 ) =      0.00120865097386617851
C( 6 ) =     -0.00000539523938495313
6
QB64 Discussion / Re: Practicing Coding Game
« Last post by bplus on Yesterday at 11:57:22 PM »
Here are some trees
Code: [Select]
_TITLE "Fall Foliage 2017-10-21 by bplus"
'fall foliage.bas SmallBASIC 0.12.9 (B+=MGA) 2017-10-21
'test landscape and portrait views for Android
'xmx = min(xmax, 400) : ymx = min(700, ymax) 'portrait
'OK it's just plain better in landscape view

'now for full viewing enjoyment
'xmx = xmax : ymx = ymax

CONST xmx = 1200
CONST ymx = 700
COMMON SHARED rad
DEFSNG A-Z

rad = _PI(1 / 180)
SCREEN _NEWIMAGE(xmx, ymx, 32)
_SCREENMOVE 100, 20 'adjust as needed _MIDDLE needs a delay .5 or more for me


n = 3
WHILE 1
    IF n < 15 THEN n = n + 3
    horizon = rand%(.8 * ymx, .9 * ymx)
    FOR i = 0 TO horizon
        midInk 0, 0, 128, 10, 120, 128, i / horizon
        lien 0, i, xmx, i
    NEXT
    FOR i = horizon TO ymx
        midInk 70, 108, 30, 60, 10, 5, (i - horizon) / (ymx - horizon)
        lien 0, i, xmx, i
    NEXT
    FOR i = 1 TO xmx * ymx * .00018
        leaf rand%(0, xmx), rand%(horizon * 1.002, ymx)
    NEXT
    IF n < .01 * xmx THEN trees = n ELSE trees = rand%(.002 * xmx, .03 * xmx)
    FOR i = 1 TO trees
        y = horizon + .04 * ymx + i / trees * (ymx - horizon - .1 * ymx)
        r = .01 * y: h = rand%(y * .15, y * .18)
        branch rand%(10, xmx - 10), y, r, 90, h, 0
    NEXT
    fRect xmx, 0, xmax, ymax, 0
    fRect 0, ymx, xmx, ymax, 0
    _DISPLAY
    SLEEP 2
WEND

SUB branch (xx, yy, startrr, angDD, lengthh, levv)
    x = xx: y = yy
    lev = levv
    length = lengthh
    angD = angDD
    startr = startrr
    x2 = x + COS(rad * (angD)) * length
    y2 = y - SIN(rad * (angD)) * length
    dx = (x2 - x) / length
    dy = (y2 - y) / length
    bc& = _RGB(30 + 6 * lev, 15 + 3 * lev, 5 + 2 * lev)
    FOR i = 0 TO length
        COLOR bc&
        fCirc x + dx * i, y + dy * i, startr
    NEXT
    IF lev > 1 THEN leaf x2, y2
    IF .8 * startr < .1 OR lev > 7 OR length < 3 THEN EXIT SUB
    lev = lev + 1
    branch x2, y2, .8 * startr, angD + 22 + rand%(-10, 19), rand%(.75 * length, .9 * length), lev
    branch x2, y2, .8 * startr, angD - 22 - rand%(-10, 19), rand%(.75 * length, .9 * length), lev
END SUB

'Steve McNeil's  copied from his forum   note: Radius is too common a name
SUB fCirc (CX AS LONG, CY AS LONG, R AS LONG)
    DIM subRadius AS LONG, RadiusError AS LONG
    DIM X AS LONG, Y AS LONG

    subRadius = ABS(R)
    RadiusError = -subRadius
    X = subRadius
    Y = 0

    IF subRadius = 0 THEN PSET (CX, CY): EXIT SUB

    ' Draw the middle span here so we don't draw it twice in the main loop,
    ' which would be a problem with blending turned on.
    LINE (CX - X, CY)-(CX + X, CY), , BF

    WHILE X > Y
        RadiusError = RadiusError + Y * 2 + 1
        IF RadiusError >= 0 THEN
            IF X <> Y + 1 THEN
                LINE (CX - Y, CY - X)-(CX + Y, CY - X), , BF
                LINE (CX - Y, CY + X)-(CX + Y, CY + X), , BF
            END IF
            X = X - 1
            RadiusError = RadiusError - X * 2
        END IF
        Y = Y + 1
        LINE (CX - X, CY - Y)-(CX + X, CY - Y), , BF
        LINE (CX - X, CY + Y)-(CX + X, CY + Y), , BF
    WEND
END SUB

SUB fRect (x1, y1, x2, y2, c&)
    LINE (x1, y1)-(x2, y2), c&, BF
END SUB

SUB fRectStep (x1, y1, x2, y2)
    LINE (x1, y1)-STEP(x2, y2), , BF
END SUB

SUB lien (x1, y1, x2, y2)
    LINE (x1, y1)-(x2, y2)
END SUB

SUB leaf (x, y)
    sp = 15: leafs = rand%(xmx * ymx * .00001, xmx * ymx * .00002)
    FOR n = 1 TO leafs
        COLOR _RGB(rand%(50, 250), rand%(25, 255), rand%(0, 40))
        xoff = x + RND * sp - RND * sp
        yoff = y + RND * sp - RND * sp
        woff = 3 + RND * 3
        hoff = 3 + RND * 3
        fRectStep xoff, yoff, woff, hoff
    NEXT
END SUB

SUB midInk (r1%, g1%, b1%, r2%, g2%, b2%, fr##)
    COLOR _RGB(r1% + (r2% - r1%) * fr##, g1% + (g2% - g1%) * fr##, b1% + (b2% - b1%) * fr##)
END SUB

FUNCTION rand% (lo%, hi%)
    rand% = INT(RND * (hi% - lo% + 1)) + lo%
END FUNCTION

7
QB64 Discussion / Re: Practicing Coding Game
« Last post by bplus on Yesterday at 11:49:10 PM »
My code works
 
8
QB64 Discussion / Re: Practicing Coding Game
« Last post by eddy498 on Yesterday at 11:24:07 PM »
Subtract Hours * 3600 off TimeEllapsed before calculate minutes as we subtracted minutes off before finding secs remaining.

I dont get what you mean. i already for the mins and subtracted the hrs * 3600 from it. when i run the script it counts up the minutes at the same time as the seconds.

edit// nvm

i moved the mins elapes time above the mins count time and now its counting right. gonna leave it on for a bit to see if the counting goes well thanks. then gonna try to reverse it to make a countdown using this method :)

gotta try to get a bit more into the art so my backgrounds dont look so bland in the game. any ideas where i can find some references for objects such as rocks, trees, ext?
9
QB64 Discussion / Re: Practicing Coding Game
« Last post by bplus on Yesterday at 11:18:57 PM »
Subtract Hours * 3600 off TimeEllapsed before calculate minutes as we subtracted minutes off before finding secs remaining.
Code: [Select]
timeElapsed = INT(TIMER - start)
hrs = INT(timeElapsed / 3600)
te = timeElapsed - hrs * 3600
mins = INT(te / 60)
secs = te - mins * 60
PRINT " Hrs:"; hrs; " Mins:"; mins; " Secs:"; secs
10
QB64 Discussion / Re: Practicing Coding Game
« Last post by eddy498 on Yesterday at 11:09:07 PM »
okay retried and it worked. ill continue working on that later.
btw on that timer you did its great and im saving it for later.
tried to add the hrs doing same thing and it got screwed up xD

Code: [Select]
start = TIMER
WHILE _KEYDOWN(27) = 0
    CLS
    timeElapsed = INT(TIMER - start)
    hrs = INT(timeElapsed / 3600)
    mins = INT(timeElapsed / 60)
    secs = timeElapsed - mins * 60
    mins = timeElapsed - hrs * 3600
    PRINT " Hrs:"; hrs; " Mins:"; mins; " Secs:"; secs


    _LIMIT 30
WEND
where did i go wrong?
Pages: [1] 2 3 ... 10