Board Logo
« Looking for examples to include with Just BASIC v2 »

Welcome Guest. Please Login or Register.
Jan 18th, 2018, 3:45pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ


« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 sticky  Author  Topic: Looking for examples to include with Just BASIC v2  (Read 853 times)
CarlGundel
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 155
xx Looking for examples to include with Just BASIC v2
« Thread started on: Jul 18th, 2017, 09:06am »

Hey all,

Getting ready to release the first beta of Just BASIC v2.0. I'm interested in any example programs that can be freely distributed with Just BASIC for this release. They can be games, graphics demos, utilities, small applications, etc.

The author can include credit in remarks at the top of the source code of course, but I do need permission to redistribute with Just BASIC (and for Liberty BASIC also would be great). smiley

Please contact me at carlg@justbasic.com if you like to contribute an example to Just BASIC v2.0.

Thanks,

-Carl
User IP Logged

tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3636
xx Re: Looking for examples to include with Just BASI
« Reply #1 on: Jul 18th, 2017, 09:22am »

Please explain *what* JB 2.0 will be.

Any new commands?
Any deprecated commands no more supported?
Any differences from JB 1.01?

How one could supply demo program for JB 2.0 without actually testing on JB 2.0?
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
CarlGundel
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 155
xx Re: Looking for examples to include with Just BASI
« Reply #2 on: Jul 18th, 2017, 09:55am »

on Jul 18th, 2017, 09:22am, tsh73 wrote:
Please explain *what* JB 2.0 will be.

Any new commands?
Any deprecated commands no more supported?
Any differences from JB 1.01?

How one could supply demo program for JB 2.0 without actually testing on JB 2.0?

Thanks. You make a good point, but the examples do not need to demo new features necessarily. My thought wasn't to make people run off and write new code, but if they already had something written which would make a nice example program.

-Carl

Here is the new stuff in a nutshell. No deprecated features.

Raised memory limit from 70MB to 256MB
Variable highlighting and click-navigation in code editor
OPEN "COMn:" - Remove restrictions on baud rates
Better support for Windows 10
Help files are converted to HTML
StartupDir$ variable
Always Open Main Window on Debug (new preference)
Compiler reporting (new preference)
Always Open Main Window On Debug (new preference)
Filter Bad Characters (new preference)
Breakpoints for debugging
Debugger Improvements
ON ERROR GOTO and RESUME
Groupboxes Accept New Commands
New Sprite Commands
spritetofront, spritetoback
SHOW and HIDE commands have been added to GUI controls

New functions and commands:
COLORDIALOG
DECHEX$( )
FONTDIALOG
GETTRIM #h, n
HEXDEC( "value" )
INPUTTO$(#h, c$)
MAPHANDLE
MAX( )
MIN( )
POPUPMENU
PRINTERDIALOG
RESUME
SORT
TITLEBAR
TRACE n
User IP Logged

Facundo
Board Moderator


member is offline

Avatar




PM

Gender: Male
Posts: 1303
xx Re: Looking for examples to include with Just BASI
« Reply #3 on: Jul 18th, 2017, 10:50am »

Those are a lot of new features Carl. Are you sure these are for JB ? What about Resize Handler, does it stay? It wasn't mentioned at the help file but works with v1.01.

I think one of the new free form j could be included. Not sure which one, both are great.

Wow SHOW and HIDE, and spriteToBack and SpriteToFront !
User IP Logged

cundo aka MSlayer
tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3636
xx Re: Looking for examples to include with Just BASI
« Reply #4 on: Jul 18th, 2017, 2:21pm »

Wow wow. Lot of new features. Is anything left to LB?

About example programs:
one way (probably right one) is to select / write demo programs from scratch, that is, removing all existing JB samples, may be adding back some of them.
Like, in my folder, there rolodex1 and rolodex3, draw1 and draw_r and DRAWX bas files.

That would require some planning. Here's my attempt, take it or not:
(though some of them really look more like tutorials)
Some programs showing off topics:
- some David Ahl (-style) code with line numbers to show JB could be used to run such code (with minimal changes)
- console mode "input - calculate - print" program
- program that lists / shows example for all math functions
(AND may be adds some useful ones as user-defined)
- program that lists / shows example for all string functions
- all kinds of conditions (IF THEN, IF THEN ELSE, conditional GOTO, nested IFs, logical operators in conditions, several variants of SELECT CASE)
- all kinds of loops. Nested loops. EXIT FOR/WHILE/DO (does JB 2.0 will error on exiting nested loop with GOTO as current JB/LB?)
- sub, function and GOSUB/RETURN
- error handling, and scoping it into a sub/function
- command line handling (parameters passed into program)
- working with sequential text files (write then read)
* BTW all that were console mode programs ! *
- program showing off all graphic commands (in a single "for graphics" window)
- working sprite example (as for now SPRTTST programs not really working)

Ok and then some GUI and games wink

I offer two my programs as samples - they could be easily used/adapted:
* rainbowFunction, showing off full color range and offering handy function to make that range
* plotting a function, last link from Graphics 101 – plotting a function

Also I wonder if Running external editor WITH current file from JB will be of interest. If it will work in JB 2.0, then it'll be example of TKN program and parameter passing. (but I have no idea if it'll continue work in JB 2.0)
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Re: Looking for examples to include with Just BASI
« Reply #5 on: Jul 18th, 2017, 2:36pm »

3D rotation, panning, zoom via slider control.

Code:
    nomainwin

    global x,y,z,Dist,Perspective,MidX,MidY,degtorad,MaxPoints,barpos,scaledvalue
    x=1
    y=2
    z=3
    Dist = 180          'distance
    Perspective = 30    'perspective
    MidX = 250
    MidY = 250          'center of screen
    degtorad=asn(1) / 90   'degrees x degtorad=radians

    WindowWidth = 800
    WindowHeight = 600
    graphicbox #w.g, 10,10,500,500
    graphicbox #w.g1, 520, 20, 182, 19
    statictext #w.st11, "0", 520, 5, 40, 15
    statictext #w.st12, "180", 600, 5, 40, 15
    statictext #w.st13, "359    X Axis", 680, 5, 140, 15
    checkbox   #w.c1, "Rot", set, reset,715,20,50,20

    graphicbox #w.g2, 520, 60, 182, 19
    statictext #w.st21, "0", 520, 45, 40, 15
    statictext #w.st22, "180", 600, 45, 40, 15
    statictext #w.st23, "359    Y Axis", 680, 45, 140, 15
    checkbox   #w.c2, "Rot", set, reset,715,60,50,20


    graphicbox #w.g3, 520, 100, 182, 19
    statictext #w.st31, "0", 520, 85, 40, 15
    statictext #w.st32, "180", 600, 85, 40, 15
    statictext #w.st33, "359    Z Axis", 680, 85, 140, 15
    checkbox   #w.c3, "Rot", set, reset,715,100,50,20


    graphicbox #w.g4, 520, 140, 182, 19
    statictext #w.st41, "-90", 520, 125, 40, 15
    statictext #w.st42, "0", 600, 125, 40, 15
    statictext #w.st43, "90     X Translate", 680, 125, 140, 15

    graphicbox #w.g5, 520, 180, 182, 19
    statictext #w.st51, "-90", 520, 165, 40, 15
    statictext #w.st52, "0", 600, 165, 40, 15
    statictext #w.st53, "90     Y Translate", 680, 165, 140, 15

    graphicbox #w.g6, 520, 220, 182, 19
    statictext #w.st61, "-90", 520, 205, 40, 15
    statictext #w.st62, "0", 600, 205, 40, 15
    statictext #w.st63, "90     Z Translate", 680, 205, 140, 15

    graphicbox #w.g7, 520, 260, 182, 19
    statictext #w.st71, "-180", 520, 245, 40, 15
    statictext #w.st72, "0", 600, 245, 30, 15
    statictext #w.st73, "180   Distance", 680, 245, 140, 15

    graphicbox #w.g8, 520, 300, 182, 19
    statictext #w.st81, "-90", 520, 285, 40, 15
    statictext #w.st82, "0", 600, 285, 30, 15
    statictext #w.st83, "90     Perspective", 680, 285, 140, 15



    open "3D Rotation" for window as #w
    #w "trapclose quit"
    #w.g "down ; fill white"

    sliders=8
    dim slide(sliders,2) 'slide bar position and scaledvalued value, barpos,scaledvalue
    barpos=1
    scaledvalue=2
    'set the starting positions that are not zero
    slide(4,barpos)=90
    slide(5,barpos)=90
    slide(6,barpos)=90
    slide(7,barpos)=Dist
    slide(8,barpos)=Perspective+90


    'using handle variable set all slider fonts postions and events
    for n= 1 to sliders
        s$="#w.g"+str$(n)
        st1$="#w.st"+str$(n)+"1"
        st2$="#w.st"+str$(n)+"2"
        st3$="#w.st"+str$(n)+"3"

        #st1$ "!font arial 10"
        #st2$ "!font arial 10"
        #st3$ "!font arial 10"

        #s$ "down ; backcolor black"
        call display s$

        #s$ "when leftButtonMove mouse"
        #s$ "when leftButtonUp mouse"
        #s$ "when characterInput key"

    next

    'load point and line data
    restore [PointData] 'Set pointer to read from label PointData.
    read MaxPoints 'Reads MaxPoints from appended data.
    dim color$(MaxPoints)
    dim pointData(MaxPoints,3) 'x,y,z planet coordinates
    dim pData(MaxPoints,3) 'pixels drawn to screen
    dim oData(MaxPoints,3) 'old pixel data to erase
    dim order(MaxPoints)    'kind of z-order, to draw

    for i = 1 to MaxPoints
        read xp,yp,zp
        pointData(i,x)=xp
        pointData(i,y)=yp
        pointData(i,z)=zp
        read c$
        color$(i)=c$

    next


    call draw
    wait





sub draw

    'if the checkbox is set rotate the x,y or z axis
    #w.c1 "value? result$"
    if result$="set" then
        slide(x,barpos)=slide(x,barpos)+1'x
        if slide(x,barpos)=181 then slide(x,barpos)=0
        call display "#w.g1"
    end if

    #w.c2 "value? result$"
    if result$="set" then
        slide(y,barpos)=slide(y,barpos)+1'y
        if slide(y,barpos)=181 then slide(y,barpos)=0
        call display "#w.g2"
    end if

    #w.c3 "value? result$"
    if result$="set" then
        slide(z,barpos)=slide(z,barpos)+1'z
        if slide(z,barpos)=181 then slide(z,barpos)=0
        call display "#w.g3"
    end if

    #w.g "discard"
    'rotate and translate the points acccording to the slider values
    'then draw over the old lines and draw the new lines
    'core code from WIRE3DUO.BAS by Matt Bross, 1997
    '*********************************ROTATION******************************
    'set R1 R2 or R3 in any combination to rotate x,y,z plane 360o
    R1 = slide(x,scaledvalue) 'rotate around the x axis 0 to 359
    R2 = slide(y,scaledvalue) 'rotate around the y axis 0 to 359
    R3 = slide(z,scaledvalue) 'rotate around the z axis 0 to 359

    '********************************TRANSLATION****************************
    'set mmX mmY and mmZ to translate (slide) points on x,y,z plane
    mmX=slide(4,scaledvalue) 'translate x -90 to +90
    mmY=slide(5,scaledvalue) 'translate y -90 to +90
    mmZ=slide(6,scaledvalue) 'translate z -90 to +90
    Dist=slide(7,scaledvalue)
    Perspective=slide(8,scaledvalue)

    '******************************ROTATE POINTS****************************
    S1 = sin(R1*degtorad): S2 = sin(R2*degtorad): S3 = sin(R3*degtorad)
    C1 = cos(R1*degtorad): C2 = cos(R2*degtorad): C3 = cos(R3*degtorad)
    for i = 1 to MaxPoints
        'Rotate points around the y axis.
        tempX = (pointData(i,x) * C2 - pointData(i,z) * S2)
        tempZ = (pointData(i,x) * S2 + pointData(i,z) * C2)
        'Rotate points around the x axis.
        pData(i,z) = (tempZ * C1 - pointData(i,y) * S1)
        tempY = (tempZ * S1 + pointData(i,y) * C1)
        'Rotate points around the z axis.
        pData(i,x) = (tempX * C3 + tempY * S3)
        pData(i,y) = (tempY * C3 - tempX * S3)
        '*****************************CONVERT 3D TO 2D**************************
        tempZ = pData(i,z) + mmZ - Perspective
        if tempZ < 0 then  'calculate points visible to the viewer
            pData(i,x) = (pData(i,x) + mmX) * Dist / tempZ + MidX
            pData(i,y) = (pData(i,y) + mmY) * Dist / tempZ + MidY
            pData(i,z) = 50-abs(tempZ)
        end if
    next
    '******************************DRAW PLANETS****************************
    'sort by size - pData(i,z)
    'calculate z-order
    for i = 1 to MaxPoints
        order(i)=i
    next

    for i = MaxPoints-1 to 1 step -1
        for j = 1 to i
            if pData( order(j),z) > pData( order(j+1),z) then
                 tmp = order(j)
                  order(j) =  order(j+1)
                  order(j+1) = tmp
            end if
        next
    next

    for j = 1 to MaxPoints

         i = order(j)   'use z-order
        'erase old line
        #w.g "backcolor white ; color white"
        #w.g "place ";oData(i,x);" ";oData(i,y);" ; circlefilled ";oData(i,z)

        'remember new points for erasing later
        oData(i,x) = pData(i,x): oData(i,y) = pData(i,y) : oData(i,z)=pData(i,z)

        #w.g "backcolor ";color$(i);" ; color red ";color$(i)

        #w.g "place ";pData(i,x);" ";pData(i,y);" ; circlefilled ";pData(i,z)
    next
    call delay
end sub


sub delay
    'timer must be encased with a sub to function properly
    timer 17,[done]
    wait
    [done]
    timer 0
    call draw
end sub

sub quit handle$
    'close the program
    timer 0
    close #w
    end
end sub

sub key handle$,c$

    'react to left and right cursor on the currently selected slider
    key=asc(right$(c$,1))
    s=val(right$(handle$,1))
    if key=_VK_LEFT then slide(s,barpos)=slide(s,barpos)-(slide(s,barpos)>0)
    if key=_VK_RIGHT then slide(s,barpos)=slide(s,barpos)+(slide(s,barpos)<180)
    call display handle$
end sub


sub mouse handle$,xpos,ypos
    'react to mouse movement and left button up on the selected slider
    s=val(right$(handle$,1))
    if xpos>=0 and xpos<=180 then slide(s,barpos)=xpos
    call display handle$
end sub

sub display handle$
    'update the slider display and save the new scaled values
    s=val(right$(handle$,1))
    if s<4 then
        slide(s,scaledvalue)=slide(s,barpos)*2
    else
        if s=7 then
        slide(s,scaledvalue)=slide(s,barpos)*2-180
        else
        slide(s,scaledvalue)=slide(s,barpos)-90
        end if
    end if
    st$="#w.st"+str$(s)+"2"
    #st$ slide(s,barpos)
    #handle$ "discard"
    #handle$ "fill darkgray"
    #handle$ "line 0 8 180 8"
    #handle$, "place ";slide(s,barpos)-4;" 0 ; boxfilled  ";slide(s,barpos)+4;" 17"
end sub






[PointData]
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%planet points%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'number of points
DATA 8
'Location of points (x, y, z)
DATA -10,10,-10,"red",-10,-10,-10,"green",-10,10,10,"blue",-10,-10,10,"cyan"
DATA  10,10,10,"black",10,-10,10,"brown",10,10,-10,"darkred",10,-10,-10,"pink"





 
User IP Logged

Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Re: Looking for examples to include with Just BASI
« Reply #6 on: Jul 18th, 2017, 2:39pm »

Simple Barcode printing.

Code:
    'code128 barcode drawing
    'http://www.barcodeisland.com/code128.phtml
    quietZone$    = "00000000000"
    startBsymbol$ = "11010010000"
    codeCsymbol$  = "10111011110"
    stopsymbol$   = "11000111010"
    termination$  = "11"
    codeCvalue    = 99
    dim barcodeimage$(127)'barcode images
    dim barcodevalues(127)'barcode value

    'load character set B symbols
    i=0
    while i<127
        read i,v,b$
        barcodeimage$(i)=b$
        barcodevalues(i)=v
    wend

    'open a small window
    graphicbox #bc.gb1, 20, 20, 300, 30
    graphicbox #bc.gb2, 20, 100, 300, 30
    textbox #bc.tb1, 20, 60, 300, 25
    textbox #bc.tb2, 20, 150, 300, 25
    WindowWidth = 400
    WindowHeight = 300
    open "Code128 Bar Code" for window as #bc
    print #bc, "trapclose [quit]"

    'build a simple, uncompressed barcode
    'calculate checksum and build barcode image
    'the checksum starts as the initial startsymbol value
    'to that we add the value of every subsequent symbol times
    'its position in the message. Then mod 103 the total

    message$="Just BASIC"

    'select character set B ,B has upper and lower case alpha and numeric characters
    startBvalue=104
    'start checksum calculation
    checksum=startBvalue
    barcode$=""
    for n = 1 to len(message$)
        checksum = checksum + n * barcodevalues(asc(mid$(message$,n,1)))
        barcode$ = barcode$ + barcodeimage$(asc(mid$(message$,n,1)))
    next

    'calculate modulus checkdigit value
    checksum = checksum mod 103

    'create total barcode image
    barcode$=quietZone$+startBsymbol$+barcode$+barcodeimage$(checksum)+stopsymbol$+termination$

    'draw barcode
    #bc.gb1 "down ; fill white "
    x=0
    for n = 1 to len(barcode$)
        if mid$(barcode$,n,1)="1" then
            #bc.gb1 "line ";x;" 0 ";x;" 40"
        end if
        x=x+1
    next
    #bc.gb1 "flush"
    #bc.tb1 message$


    'build a compressed image that packs numeric data
    'this solution is unique to the following message and packs the
    'last six numeric digits

    message$="HI345678"

    'select character set B
    startBvalue=104
    'the example on the web site uses set A which is 103 so my checksum will vary
    'from the example given on the web site but the code is still valid, you can
    'build your barcode from any character set.
    checksum=startBvalue
    barcode$=""
    for n = 1 to 2
        checksum = checksum + n * barcodevalues(asc(mid$(message$,n,1)))
        barcode$ = barcode$ + barcodeimage$(asc(mid$(message$,n,1)))
    next

    'add the code 128 C symbol to change to packed numbers
    barcode$=barcode$+codeCsymbol$
    checksum=checksum+codeCvalue*3

    'now add the numbers in pairs
    cdx=4
    for n = 3 to 7 step 2
        checksum = checksum + cdx * barcodevalues(val(mid$(message$,n,2))+32)
        barcode$ = barcode$ + barcodeimage$(val(mid$(message$,n,2))+32)
        cdx=cdx+1
    next

    'calculate modulus checkdigit value
    checksum = checksum mod 103

    'create total barcode image
    barcode$=quietZone$+startBsymbol$+barcode$+barcodeimage$(checksum)+stopsymbol$+termination$

    'draw barcode
    #bc.gb2 "down ; fill white "
    x=0
    for n = 1 to len(barcode$)
        if mid$(barcode$,n,1)="1" then
            #bc.gb2 "line ";x;" 0 ";x;" 40"
        end if
        x=x+1
    next
    #bc.gb2 "flush"
    #bc.tb2 message$
    wait

    [quit]
    close #bc
    end







'barcode value and image table
'this is table B that has upper and lower case alpha and numeric
'table C is simply numeric pairs 00 01 etc so we dont need the data for that.
'Table A has upper case alpha and numeric but not lower case alpha.
'You will need to get Table A from the web site if you wish to use
'the special characters available in table A
data 32,00,11011001100'space
data 33,01,11001101100'!
data 34,02,11001100110'"
data 35,03,10010011000'#
data 36,04,10010001100'$
data 37,05,10001001100'%
data 38,06,10011001000'&
data 39,07,10011000100''
data 40,08,10001100100'(
data 41,09,11001001000')
data 42,10,11001000100'*
data 43,11,11000100100'+
data 44,12,10110011100',
data 45,13,10011011100'-
data 46,14,10011001110'.
data 47,15,10111001100'/
data 48,16,10011101100'0
data 49,17,10011100110'1
data 50,18,11001110010'2
data 51,19,11001011100'3
data 52,20,11001001110'4
data 53,21,11011100100'5
data 54,22,11001110100'6
data 55,23,11101101110'7
data 56,24,11101001100'8
data 57,25,11100101100'9
data 58,26,11100100110':
data 59,27,11101100100';
data 60,28,11100110100'<
data 61,29,11100110010'=
data 62,30,11011011000'>
data 63,31,11011000110'?
data 64,32,11000110110'@
data 65,33,10100011000'A
data 66,34,10001011000'B
data 67,35,10001000110'C
data 68,36,10110001000'D
data 69,37,10001101000'E
data 70,38,10001100010'F
data 71,39,11010001000'G
data 72,40,11000101000'H
data 73,41,11000100010'I
data 74,42,10110111000'J
data 75,43,10110001110'K
data 76,44,10001101110'L
data 77,45,10111011000'M
data 78,46,10111000110'N
data 79,47,10001110110'O
data 80,48,11101110110'P
data 81,49,11010001110'Q
data 82,50,11000101110'R
data 83,51,11011101000'S
data 84,52,11011100010'T
data 85,53,11011101110'U
data 86,54,11101011000'V
data 87,55,11101000110'W
data 88,56,11100010110'X
data 89,57,11101101000'Y
data 90,58,11101100010'Z
data 91,59,11100011010'[
data 92,60,11101111010'\
data 93,61,11001000010']
data 94,62,11110001010'^
data 95,63,10100110000'_
data 96,64,10100001100'`
data 97,65,10010110000'a
data 98,66,10010000110'b
data 99,67,10000101100'c
data 100,68,10000100110'd
data 101,69,10110010000'e
data 102,70,10110000100'f
data 103,71,10011010000'g
data 104,72,10011000010'h
data 105,73,10000110100'i
data 106,74,10000110010'j
data 107,75,11000010010'k
data 108,76,11001010000'l
data 109,77,11110111010'm
data 110,78,11000010100'n
data 111,79,10001111010'o
data 112,80,10100111100'p
data 113,81,10010111100'q
data 114,82,10010011110'r
data 115,83,10111100100's
data 116,84,10011110100't
data 117,85,10011110010'u
data 118,86,11110100100'v
data 119,87,11110010100'w
data 120,88,11110010010'x
data 121,89,11011011110'y
data 122,90,11011110110'z
data 123,91,11110110110'{
data 124,92,10101111000'|
data 125,93,10100011110'}
data 126,94,10001011110'~
data 127,95,10111101000'DEL



 

« Last Edit: Jul 19th, 2017, 04:18am by Rod » User IP Logged

Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Re: Looking for examples to include with Just BASI
« Reply #7 on: Jul 18th, 2017, 2:40pm »

Invaders again! use the mouse to move the gun right click to fire.

Code:
    nomainwin
    WindowWidth  = 800
    WindowHeight = 600
    UpperLeftX   = (DisplayWidth-WindowWidth)/2
    UpperLeftY   = (DisplayHeight-WindowHeight)/2
    graphicbox #w.g, 0,0,800,600
    open "Invaders" for graphics_nf_nsb as #w
    #w "trapclose [quit]"

    [initialise]
    x=1
    y=2
    dim bullet(6,2) 'bullet x,y
    dim alien(6,2)  'alien x,y
    adir=-10        'alien direction
    aspeed=1.01     'alien acceleration
    base=540        'base line of gun


    'the alien sprite
    #w.g "down ; font ariel bold 20"
    #w.g "color black ; backcolor black ; place 0 40 ; boxfilled 60 80"
    #w.g "color white ; place 2 70 ;\<**>"
    #w.g "color white ; backcolor white ; place 0 0 ; boxfilled 60 40"
    #w.g "backcolor white ; color black ; place 2 30 ;\<**>"
    #w.g "getbmp alien 0 0 60 80"

    'the bullet sprite
    #w.g "color black ; backcolor black ; place 0 40 ; boxfilled 60 80"
    #w.g "color white ; place 2 70 ;\!"
    #w.g "color white ; backcolor white ; place 0 0 ; boxfilled 20 40"
    #w.g "backcolor white ; color black ; place 2 30 ;\!"
    #w.g "getbmp bullet 0 0 20 80"

    'box background
    for i = 0 to 150
        j = 256 - i
        #w.g "down ; backcolor ";j/3;" ";j/3;" ";j/3
        #w.g "color ";j/3;" ";j/3;" ";j/3
        #w.g "place ";i;" ";i
        #w.g "boxfilled ";800 - i;" ";600 - i
    next

    'stars
    for n= 1 to 100
        c=int(rnd(0)*255)
        #w.g "color ";c;" ";c;" ";c;" ; set ";150+rnd(0)*500;" ";150+rnd(0)*300
    next
    #w.g "getbmp bak 0 0 800 600"
    #w.g "background bak";

    'set out the sprites
    for n = 1 to 6
        bullet(n,x)=400
        bullet(n,y)=base
        alien(n,x)=200+70*n
        alien(n,y)=0
        #w.g "addsprite alien";str$(n);" alien"
        #w.g "addsprite bullet";str$(n);" bullet"
    next

    'start the keyboard checking event
    #w.g "when mouseMove [track]"
    #w.g "when leftButtonUp [fire]"
    #w.g "setfocus"


    ' now start the timer to repeatedly call the drawing loop
    timer 56, [drawingloop]

    'now sit and wait
    wait

    [drawingloop]
    for n = 1 to 6

        'move the bullets
        if bullet(n,y) = 540 then
            bullet(n,x) = gunX
        else
            bullet(n,y) = bullet(n,y) -10
            for c= 1 to 6
                'check for collision
                #w.g, "spritecollides alien";str$(c);" list$"
                if left$(list$,6)="bullet" then
                    playwave "media\bump.wav",async
                    a=val(mid$(list$,7,1))
                    bullet(a,x)=gunX
                    bullet(a,y)=base
                    alien(c,y)=600
                    list$=""
                end if
            next
            if bullet(n,y) < -40 then bullet(n,y) = base : bullet(n,x)=gunX
        end if

        'move the aliens
        alien(n,x) = alien(n,x) + adir
        if alien(n,x) < 0 or alien(n,x) > 760 then bounce=1


        'place the sprites and draw
        #w.g "spritexy bullet";str$(n);" ";bullet(n,x);" ";bullet(n,y)
        #w.g "spritexy alien";str$(n);" ";alien(n,x);" ";alien(n,y)
        #w.g "drawsprites"

    next

    'if we hit a wall bounce
    if bounce then
        bounce=0
        adir = adir * -1
        adir=adir*aspeed
        for m = 1 to 6
            alien(m,y)=alien(m,y)+20
        next
    end if
    wait

    [fire]
    'find the first free bullet and launch it
    for b = 1 to 6
        if bullet(b,y)=base then
            bullet(b,y)=base-1
            exit for
        end if
    next
    wait

    [track]
    'keep the launch pad lined up with the mouse
    gunX=MouseX-20
    wait

    [quit]
    timer 0
    unloadbmp "bak"
    unloadbmp "alien"
    unloadbmp "bullet"
    close #w



 
User IP Logged

Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Re: Looking for examples to include with Just BASI
« Reply #8 on: Jul 18th, 2017, 2:41pm »

If VB Script is allowed then Just BASIC speaks.

Code:
open "speak.vbs" for output as #1
#1 "Set MyVoice = CreateObject("; chr$(34); "Sapi.SpVoice"; chr$(34); ")"
#1 "Set fso = CreateObject("; chr$(34); "Scripting.FileSystemObject"; chr$(34); ")"
#1 "Set f = fso.OpenTextFile(WScript.Arguments.Item(0),1,true)"
#1 "Do While f.AtEndOfStream <> True"
#1 "MyVoice.Speak f.ReadLine"
#1 "Loop"
#1 "f.close"
close #1

open "morning.txt" for output as #2
#2 "Good morning Just BASIC user how are you today"
close #2

open "evening.txt" for output as #2
#2 "Good evening Just BASIC user hope you had a good day today"
close #2

a$ = "morning.txt"
b$ = "cscript.exe speak.vbs "; a$
run b$, hide


a$ = "evening.txt"
b$ = "cscript.exe speak.vbs "; a$
run b$, hide


 
User IP Logged

Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Re: Looking for examples to include with Just BASI
« Reply #9 on: Jul 18th, 2017, 2:51pm »

Mesmerizing lissajous figures for the science class.

All of the above in the public domain and no credits necessary


Code:
 nomainwin
    dim hz1$(12)
    dim hz2$(12)
    dim vo1$(24)
    dim vo2$(24)
    dim ph1$(360)
    dim ph2$(360)

    WindowWidth = 600
    WindowHeight = 700
    graphicbox  #1.gb 45,20,500,500
    statictext  #1.hz, "Hertz" ,125, 560,80,20
    combobox    #1.hz1, hz1$(),[hertz1],125,580,80,20
    combobox    #1.hz2, hz2$(),[hertz2],125,620,80,20
    statictext  #1.ph, "Phase" ,225, 560,80,20
    combobox    #1.ph1, ph1$(),[phs1],225,580,80,20
    combobox    #1.ph2, ph2$(),[phs2],225,620,80,20
    statictext  #1.vo, "Volume" ,325, 560,80,20
    combobox    #1.vo1, vo1$(),[vol1],325,580,80,20
    combobox    #1.vo2, vo2$(),[vol2],325,620,80,20
    open "Lissajous" for window as #1
    #1, "trapclose [quit]"


    for n= 1 to 10
        hz1$(n)=str$(n)
        hz2$(n)=str$(n)
    next

    for n= 1 to 12
        vo1$(n)=str$(n*20)
        vo2$(n)=str$(n*20)
    next

    for n= 0 to 359 step 45
       ph1$(n)=str$(n)
       ph2$(n)=str$(n)
    next


    'set the initial combobox data
    #1.hz1 "reload"
    #1.hz1 "select 1"
    hertz1=1
    #1.hz2 "reload"
    #1.hz2 "select 1"
    hertz2=1
    #1.vo1 "reload"
    #1.vo1 "select 100"
    vol1=100
    #1.vo2 "reload"
    #1.vo2 "select 100"
    vol2=100
    #1.ph1 "reload"
    #1.ph1 "select 0"
    phase1=0
    #1.ph2 "reload"
    #1.ph2 "select 0"
    phase2=0

    #1.gb "down ; fill 0 50 0"
    #1.gb "color 50 50 50"
    for x= 20 to 580 step 20
        #1.gb "line ";x;" 0 ";x;" 600"
    next
    for y= 20 to 580 step 20
        #1.gb "line 0 ";y;" 600 ";y
    next
    #1.gb "flush one"
    #1.gb "color 0 100 0"

    midX=250
    midY=250
    rad=57.29577951

timer 100, [drawit]
wait

    [drawit]
    start=0
    #1.gb "discard ; redraw one"
    for n= 0 to 359
        x=midX-(vol1*sin(phase1/rad))
        y=midY-(vol2*cos(phase2/rad))
        if start=1 then
            #1.gb "line ";oldX;" ";oldY;" ";x;" ";y
        else
            start=1
            #1.gb "set ";x;" ";y
        end if
        oldX=x
        oldY=y
        phase1=phase1+hertz1
        if phase1>359 then phase1=phase1-359
        phase2=phase2+hertz2
        if phase2>359 then phase2=phase2-360

    next
    wait


    [hertz1]
    #1.hz1 "contents? text$"
    hertz1=val(text$)
    goto [drawit]

    [hertz2]
    #1.hz2 "contents? text$"
    hertz2=val(text$)
    goto [drawit]

    [vol1]
    #1.vo1 "contents? text$"
    vol1=val(text$)
    goto [drawit]

    [vol2]
    #1.vo2 "contents? text$"
    vol2=val(text$)
    goto [drawit]

    [phs1]
    #1.ph1 "contents? text$"
    phase1=val(text$)
    goto [drawit]

    [phs2]
    #1.ph2 "contents? text$"
    phase2=val(text$)
    goto [drawit]


    [quit]
    timer 0
    close #1
    end


  
User IP Logged

Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Re: Looking for examples to include with Just BASI
« Reply #10 on: Jul 18th, 2017, 3:04pm »

Adventures always fire the imagination.

Code:
    'mini adventure by rod
    'an adaptation of code provided by Alyce
    True=1
    False=0
    [WindowSetup]
    NOMAINWIN
    WindowWidth = 511 : WindowHeight = 358
    UpperLeftX = INT((DisplayWidth-WindowWidth)/2)
    UpperLeftY = INT((DisplayHeight-WindowHeight)/2)

    [ControlSetup]
    statictext #main.s1, "Type here. Hit 'ENTER.'", 10, 260, 169, 25
    statictext #main.s2, "Tunnel Lore.", 10, 10, 169, 25
    'button with extension *default* is activated in dialog window
    'when user hits *ENTER*
    'very clever tip to remember
    button     #main.default, "Okay",[processinput],UL, 380, 290, 105, 25
    button     #main.quit, "Quit",[quit],UL, 380, 255, 105, 25
    textbox     #main.type, 10, 290, 355, 24
    texteditor #main.display, 10, 40, 490, 210

    Open "My Great Adventure" for Dialog as #main
    #main "trapclose [quit]"
    #main "font ms_sans_serif 10"


    gosub [data]           'build the array of information to use in the adventure

    [awaitinput]
    #main.type ""          'clear typing box
    #main.type "!setfocus" 'set focus so typing goes into textbox
    wait                   'now sit and wait for some user input, an "event"


    [quit]
    close #main : END

    [processinput]
    #main.type "!contents? txt$"    'get text typed by user

    select case upper$(left$(txt$,1)) 'make it uppercase and use the first letter only
        case "N"
        if moven$<>"" then
            move$="You walk North"
            loc$=moven$
            move=True
        else
            move$="You cannot go North"
            move=False
        end if
        case "S"
        if moves$<>"" then
             move$="You walk South"
             loc$=moves$
             move=True
        else
            move$="You can't go South"
            move=False
        end if
        case "E"
        if movee$<>"" then
            move$="You walk East"
            loc$=movee$
            move=True
        else
            move$="You are not able to go East"
            move=False
        end if
        case "W"
        if movew$<>"" then
            move$="You walk West"
            loc$=movew$
            move=True
        else
            move$="You can't go West"
            move=False
        end if
        case "T"
            if o$<>"" then
                #main.display "You pick up the "+o$
            else
                #main.display "There is nothing to pick up."
            end if
            goto [awaitinput]
            ' you will need to add code to remove the item from the location$() and add it to your inventory$
        case "L"
            #main.display, "I didn't bring my glasses so can't see anything."
            goto [awaitinput]
        case else
            #main.display "I don't yet understand that word."
            #main.display "I do understand North South East West Look Take"
            goto [awaitinput]
    end select

    [displaylocation]
    #main.display "!cls" ' clear the screen
    #main.display move$
    desc$=""
    n$=""
    moven$=""
    s$=""
    moves$=""
    e$=""
    movee$=""
    w$=""
    movew$=""
    o$=""
    for n=1 to 100
    if left$(location$(n),7)=loc$+"DESC" then desc$=right$(location$(n),len(location$(n))-7)
    if left$(location$(n),4)=loc$+"N" then n$=right$(location$(n),len(location$(n))-7) : moven$=mid$(location$(n),5,3)
    if left$(location$(n),4)=loc$+"S" then s$=right$(location$(n),len(location$(n))-7) : moves$=mid$(location$(n),5,3)
    if left$(location$(n),4)=loc$+"E" then e$=right$(location$(n),len(location$(n))-7) : movee$=mid$(location$(n),5,3)
    if left$(location$(n),4)=loc$+"W" then w$=right$(location$(n),len(location$(n))-7) : movew$=mid$(location$(n),5,3)
    if left$(location$(n),4)=loc$+"O" then o$=right$(location$(n),len(location$(n))-7)
    next n
    #main.display desc$
    if n$<>"" then #main.display "To the north  ";n$
    if s$<>"" then #main.display "To the south ";s$
    if e$<>"" then #main.display "To the east ";e$
    if w$<>"" then #main.display "To the west ";w$
    if o$<>"" then #main.display "At your feet there is a ";o$
    #main.display "What do you want to do?"
    goto [awaitinput]

    [data]
    dim location$(100)
    restore
    read d$
    n=1
    while d$<>"EndofData"
        location$(n)=d$
        n=n+1
        read d$
    wend
    loc$="001"
    goto [displaylocation]

    'whats going on here looks complicated but its not really, we number every location
    'in the adventure starting with 001,  You then add locations to 001, if we add another
    'location North of 001 we write a data line that says 001N002 002 is the location you
    'get to if you go North.   Each location has a main DESC and for each directional move
    'from that location we write a line explaining what we see 001N002Description.
    'You can also put an object at the location with 001OBJsword.   This is just one way of
    'doing it, study other examples and choose one you feel comfortable with.




    data, "001DESCYou are standing beside a hill in the pale evening sun."
    data, "001N002you spy the entrance to a cave."
    data, "001OBJEtar torch and a stone flint."
    data, "002DESCYou are in the entrance of a low cave."
    data, "002N005the light fades quickly in a low dank tunnel."
    data, "002S001is the tunnel entrance."
    data, "002E003you see the entrance to a guard hut."
    data, "002W004there is what looks like a storage room."
    data, "002OBJEsword"
    data, "003DESCThe hut is deserted but lights blink on a control panel."
    data, "003W002is the tunnel."
    data, "004DESCThe door has been forced and the storage room is empty."
    data, "004E005is the tunnel."
    data, "005DESCThe tunnel is blocked by fallen rubble."
    data, "005S002is the entrance to the tunnel."
    data, "EndofData"

 
User IP Logged

CarlGundel
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 155
xx Re: Looking for examples to include with Just BASI
« Reply #11 on: Jul 18th, 2017, 4:06pm »

on Jul 18th, 2017, 2:21pm, tsh73 wrote:
Wow wow. Lot of new features. Is anything left to LB?

Well, quite a lot actually. Only LB can still use APIs and third party libraries, and there are still a bunch of other things reserved for LB.

For example these are NOT in Just BASIC v2.0:

after$(sourceString$, search$) This searches in sourceString$ for the string value of search$.
afterlast$(sourceString$, search$) This searches in sourceString$ for the last incidence of the string value of search$.
"!backcolor color$" text window set the background color
endswith(sourceString$, search$) This answers true if sourceString$ ends with the characters in search$.
EVAL(code$) evaluate an expression to a numeric value
EVAL$(code$) evaluate an expression to a string
"!find str$" text window searches forward for a string
"!findback str$" text window searches backward for a string
"!forecolor color$" text window set the foreground color
httpget$(url$) This makes an httpget call to the WININET API
inputcsv #1, a$, b$, c$, d$ read comma delimited string values from a file with sensitivity to quoted values.
remchar$(sourceString$, removeThese$) Answer a string that is the sourceString$ with all the characters in removeThese$ filtered out.
replstr$() function to replace the occurances of one string with another.
"!resetfind" text window reset for find and findback
STYLEBITS add or remove style bits from a control
upto$(sourceString$, search$) This searches in sourceString$ for the string value of search$.
CALLBACK address of a callback function
CALLDLL call an API or DLL function
HBMP( "name" ) return the Windows handle for a bitmap
HWND( #handle) return the Windows handle for a window
STRUCT builds a structure used in calling of APIs and DLL functions
WINSTRING(ptr) returns string from ptr
INP(port) get a byte value from an I/O port
OUT port, byte send a byte to a port

-Carl
« Last Edit: Jul 18th, 2017, 4:10pm by CarlGundel » User IP Logged

CarlGundel
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 155
xx Re: Looking for examples to include with Just BASI
« Reply #12 on: Jul 18th, 2017, 8:47pm »

Rod,

Thanks for those. There is some nice stuff there.

One thing about the bar code example. If I change the message$ to something else it blows up with an error. For example I use "Just BASIC" and that doesn't work.

Maybe you'd like to take a stab at fixing it?

Also, do you mind if I make some changes to these examples?

-Carl
User IP Logged

Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Re: Looking for examples to include with Just BASI
« Reply #13 on: Jul 19th, 2017, 01:22am »

Feel free to change whatever you wish. No credits necessary. I will tackle the barcode example today.

I have amended the original post about barcode 128. It was a checksum error. It is quite a complex format, I coded it because someone asked for a solution, it could be more generic.

Andy has a barcode example that might be a better fit I will search. Found
« Last Edit: Jul 19th, 2017, 04:26am by Rod » User IP Logged

Facundo
Board Moderator


member is offline

Avatar




PM

Gender: Male
Posts: 1303
xx Re: Looking for examples to include with Just BASI
« Reply #14 on: Jul 21st, 2017, 1:21pm »

I would like to submit something but I don't know what would be useful or good enough. I will look trough my threads maybe there is something cool here.
User IP Logged

cundo aka MSlayer
Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls