Blackbox game

Vragen en suggesties over het programmeren van spelletjes, sprites en dergelijke in Liberty BASIC

Moderator: anthonio

Blackbox game

Berichtdoor Gordon » zo dec 24, 2006 10:10 pm

Hallo,

Ik ga een game maken.
Blackbox.

De basic versie is uit 1978 van ene Jeff Kenton.

Gordon.
Avatar gebruiker
Gordon
Site Admin
 
Berichten: 684
Geregistreerd: zo mei 22, 2005 12:50 am

Berichtdoor Gordon » wo jan 03, 2007 12:12 am

Ik heb een playable versie.
Maar een grote inertie heeft me getroffen.

Ik moet weer tekenen.
Diamanten, sterren enz...

Gordon

Afbeelding
Laatst bijgewerkt door Gordon op za jun 02, 2007 11:37 am, in totaal 1 keer bewerkt.
Avatar gebruiker
Gordon
Site Admin
 
Berichten: 684
Geregistreerd: zo mei 22, 2005 12:50 am

Berichtdoor Gordon » za jan 06, 2007 12:54 pm

Hier is een test versie
Code: Selecteer alles
'G. Rahman Blackbox
'Dec 30, 2006

    'NOMAINWIN
    WindowWidth = 660 : WindowHeight = 630
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    w1=1*50:w2=2*50:w3=3*50:w4=4*50
    w5=5*50:w6=6*50:w7=7*50:w8=8*50

    w0=1
    bmpbutton #m.32, "blboxE1.bmp",b1,UL,w0,w1
    bmpbutton #m.31, "blboxE1.bmp",b1,UL,w0,w2
    bmpbutton #m.30, "blboxE1.bmp",b1,UL,w0,w3
    bmpbutton #m.29, "blboxE1.bmp",b1,UL,w0,w4
    bmpbutton #m.28, "blboxE1.bmp",b1,UL,w0,w5
    bmpbutton #m.27, "blboxE1.bmp",b1,UL,w0,w6
    bmpbutton #m.26, "blboxE1.bmp",b1,UL,w0,w7
    bmpbutton #m.25, "blboxE1.bmp",b1,UL,w0,w8

    w0=450
    bmpbutton #m.24, "blboxN1.bmp",b1,UL,w1,w0
    bmpbutton #m.23, "blboxN1.bmp",b1,UL,w2,w0
    bmpbutton #m.22, "blboxN1.bmp",b1,UL,w3,w0
    bmpbutton #m.21, "blboxN1.bmp",b1,UL,w4,w0
    bmpbutton #m.20, "blboxN1.bmp",b1,UL,w5,w0
    bmpbutton #m.19, "blboxN1.bmp",b1,UL,w6,w0
    bmpbutton #m.18, "blboxN1.bmp",b1,UL,w7,w0
    bmpbutton #m.17, "blboxN1.bmp",b1,UL,w8,w0

    w0=450
    bmpbutton #m.16, "blboxW1.bmp",b1,UL,w0,w8
    bmpbutton #m.15, "blboxW1.bmp",b1,UL,w0,w7
    bmpbutton #m.14, "blboxW1.bmp",b1,UL,w0,w6
    bmpbutton #m.13, "blboxW1.bmp",b1,UL,w0,w5
    bmpbutton #m.12, "blboxW1.bmp",b1,UL,w0,w4
    bmpbutton #m.11, "blboxW1.bmp",b1,UL,w0,w3
    bmpbutton #m.10, "blboxW1.bmp",b1,UL,w0,w2
    bmpbutton #m.09, "blboxW1.bmp",b1,UL,w0,w1

    w0=1
    bmpbutton #m.08, "blboxS1.bmp",b1,UL,w8,w0
    bmpbutton #m.07, "blboxS1.bmp",b1,UL,w7,w0
    bmpbutton #m.06, "blboxS1.bmp",b1,UL,w6,w0
    bmpbutton #m.05, "blboxS1.bmp",b1,UL,w5,w0
    bmpbutton #m.04, "blboxS1.bmp",b1,UL,w4,w0
    bmpbutton #m.03, "blboxS1.bmp",b1,UL,w3,w0
    bmpbutton #m.02, "blboxS1.bmp",b1,UL,w2,w0
    bmpbutton #m.01, "blboxS1.bmp",b1,UL,w1,w0

    button #m.33, "Solve", [solve], UL 550,450
    button #m.33, "Info", [hlps], UL 550,50

    loadbmp "btile","blbtile.bmp"

    DIM N1$(32), B(10,10) ,N2$(16), G(8,8) ,N3$(16)
    global ANTW

    open "Blackbox G.Rahman 2007" for graphics_nsb as #m
    #m "trapclose [Quit]"
    #m "down; fill black; flush"

    SC=0:IM=1:W=0

    FOR I=1 TO 8
        FOR J=1 TO 8
            B(I,J)=0
            G(I,J)=0    '------ for guessing purposses
        NEXT J
    NEXT I

B(2,5)=1:B(4,5)=1:B(7,5)=1 'TESTING


    for tilesx = 1 to 8
        for tilesy = 1 to 8
            #m "drawbmp btile ";tilesx*50;" ";tilesy*50;"; flush"
        next tilesy
    next tilesx

'initial setup of the board display

        FOR I=1 TO 32:N1$(I)=RIGHT$(STR$(I),2):NEXT I
        #m "backcolor blue"
        #m "color yellow"

        FOR I=01 TO 08
        #m "place ";I*50+20;" ";60
        #m "\"+N1$(I)
        NEXT I

        FOR I=09 TO 16
        #m "place ";435;" ";(I-8)*50+28
        #m "\"+N1$(I)
        NEXT I

        FOR I=17 TO 24
        #m "place ";450-(I-16)*50+17;" ";448
        #m "\"+N1$(I)
        NEXT I

        FOR I=25 TO 32
        #m "place ";50;" ";450-(I-24)*50+28
        #m "\"+N1$(I)
        NEXT I


' place the atoms (4) at random
'    H = 4

'    FOR I=1 TO H
'[r] HV=INT(RND(8)*8)+1
'    VV=INT(RND(8)*8)+1

'        IF B(HV,VV)=1 THEN
'            GOTO [r]
'        ELSE
'            B(HV,VV)=1
'        END IF
'    NEXT I


'----------------------- for testing purpose with nomainwin
FOR I=1 TO 32:N1$(I)=RIGHT$(STR$(I),2):NEXT I
FOR I=1 TO 7 :N2$(I)=CHR$(64+I)+CHR$(64+I):NEXT I
FOR I=8 TO 16:N2$(I)=CHR$(65+I)+CHR$(65+I):NEXT I
FOR I=1 TO 8: N3$(I)=STR$(I):NEXT I
FOR I=9 TO 16 :N3$(I)=CHR$(56+I)+" ":NEXT I

FOR I=1 TO 8
    FOR J=1 TO 8
    PRINT USING("##",B(I,J));
    NEXT J
    PRINT
NEXT I
'---------------------------


[loop]
    scan
    if ANTW>0 then R=ANTW :goto [ray]
    goto [loop]
wait

[ray]

    ANTW=0
    X1 = R

    PRINT:PRINT:PRINT "LAUNCHED RAY ";R 'for testing with nomainwin



[LAUNCH]
    IF X1<9 THEN E=1:HV=1:VV=X1
    IF X1<17 AND X1>8 THEN E=2:HV=X1-8:VV=8
    IF X1<25 AND X1>16 THEN E=3:HV=8:VV=25-X1
    IF X1<33 AND X1>24 THEN E=4:HV=33-X1 :VV=1
    IF B(HV,VV)=1 THEN GOTO [Hit]

    IF E=1 OR E=3 THEN
        IF VV<>1 THEN
            IF B(HV,VV-1)=1 THEN
            GOTO [Reflect]
            END IF
        END IF
    END IF
    IF E=1 OR E=3 THEN
        IF VV<>8 THEN
            IF B(HV,VV+1)=1 THEN
            GOTO [Reflect]
            END IF
        END IF
    END IF


    IF E=2 OR E=4 THEN
        IF HV<>1 THEN
            IF B(HV-1,VV)=1 THEN
            GOTO [Reflect]
            END IF
        END IF
    END IF

    IF E=2 OR E=4 THEN
        IF HV<>8 THEN
            IF B(HV+1,VV)=1 THEN
            GOTO [Reflect]
            END IF
        END IF
    END IF

[Pass0]
    IF E=1 AND HV=8 THEN
        GOTO [Pass1]
        ELSE
            IF B(HV+1,VV)=1 THEN
            GOTO [Hit]
            END IF
     END IF

    IF E=2 AND VV=1 THEN
        GOTO [Pass1]
        ELSE
            IF B(HV,VV-1)=1 THEN
            GOTO [Hit]
            END IF
    END IF

    IF E=3 AND HV=1 THEN
        GOTO [Pass1]
        ELSE
            IF B(HV-1,VV)=1 THEN
            GOTO [Hit]
            END IF
    END IF

    IF E=4 AND VV=8 THEN
        GOTO [Pass1]
        ELSE
            IF B(HV,VV+1)=1 THEN
            GOTO [Hit]
            END IF
    END IF


    IF E=1 AND VV<>1 AND B(HV+1,VV-1)=1 THEN E=4 :GOTO [Pass0]
    IF E=1 AND VV<>8 AND B(HV+1,VV+1)=1 THEN E=2 :GOTO [Pass0]
    IF E=2 AND HV<>1 AND B(HV-1,VV-1)=1 THEN E=1 :GOTO [Pass0]
    IF E=2 AND HV<>8 AND B(HV+1,VV-1)=1 THEN E=3 :GOTO [Pass0]
    IF E=3 AND VV<>1 AND B(HV-1,VV-1)=1 THEN E=4 :GOTO [Pass0]
    IF E=3 AND VV<>8 AND B(HV-1,VV+1)=1 THEN E=2 :GOTO [Pass0]
    IF E=4 AND HV<>1 AND B(HV-1,VV+1)=1 THEN E=1 :GOTO [Pass0]
    IF E=4 AND HV<>8 AND B(HV+1,VV+1)=1 THEN E=3 :GOTO [Pass0]

    IF E=1 THEN HV=HV+1
    IF E=2 THEN VV=VV-1
    IF E=3 THEN HV=HV-1
    IF E=4 THEN VV=VV+1
    GOTO [Pass0]

[Pass1]
    IF E=1 THEN X2=25-VV
    IF E=2 THEN X2=33-HV
    IF E=3 THEN X2=VV
    IF E=4 THEN X2=8+HV

[Pass2]
    IF X2=X1 THEN
    GOTO [Reflect]
    ELSE
    R1$ = N1$(X1)
    R2$ = N1$(X2)
    SC=SC+2
    GOTO [DISLPAY]
    END IF

[Reflect]
        R1$ = N1$(X1):N1$(X1)="R ":SC=SC+1
        NOTICE "Note" + chr$(13)+ "REFLECTED at ";R1$
        GOTO [loop]

[Hit]
        R1$ = N1$(X1):N1$(X1)="H ":SC=SC+1
        NOTICE "Note" + chr$(13)+ "HIT at ";R1$
        GOTO [loop]

[DISLPAY]

        FOR I=01 TO 08
                if I = X2 or I=X1 then
                #m "color red"
                #m "place ";I*50+20;" ";60
                #m "\"+N1$(I)
                exit for
                end if
        NEXT I

        FOR I=09 TO 16
                if I = X2 or I=X1 then
                #m "color red"
                #m "place ";435;" ";(I-8)*50+28
                #m "\"+N1$(I)
                exit for
                end if
        NEXT I

        FOR I=17 TO 24
                if I = X2 or I=X1 then
                #m "color red"
                #m "place ";450-(I-16)*50+17;" ";448
                #m "\"+N1$(I)
                exit for
                end if
        NEXT I

        FOR I=25 TO 32
                if I = X2 or I=X1 then
                #m "color red"
                #m "place ";50;" ";450-(I-24)*50+28
                #m "\"+N1$(I)
                exit for
                end if
        NEXT I

'------------- for testing purpose with nomainwin
    PRINT "X1 X2  ";N1$(X1),N1$(X2)
    FOR I=01 TO 08:PRINT"  "+N1$(I);:NEXT I:PRINT
    FOR I=09 TO 16:PRINT" "+N1$(I);:NEXT I:PRINT
    FOR I=17 TO 24:PRINT" "+N1$(I);:NEXT I:PRINT
    FOR I=25 TO 32:PRINT" "+N1$(I);:NEXT I:PRINT
    NOTICE chr$(13)+ "In at ";R1$+chr$(13) +"Out at ";R2$
    GOTO [loop]
'-------------------------------------

[info]
'------demo here?
wait

[solve] notice "NOW TELL ME, WHERE DO YOU THINK THE ATOMS ARE?"
wait




sub b1 but1$
ANTW=val(right$(but1$,2))
end sub


[hlps]

    WindowWidth = 400
    WindowHeight = 340
    UpperLeftX=210
    UpperLeftY=40

    c$=chr$(13)
    hlp1$ = c$+c$+_
    "Three, four or five balls are hidden"+c$+_
    "randomly, in a eight by eight"+c$+_
    "field. The object of the game is"+c$+_
    "to find them. You can locate them by "+c$+_
    "sending rays into the blackbox field "+c$+_
    "from the sides. A ball will absorb a"+c$+_
    "ray that strikes it directly, or"+c$+_
    "deflect a ray that comes within one "+c$+_
    "square nearby."+c$+c$+_
    "A ray will either be hit, a"+c$+_
    "reflection or be deflected to leave"+c$+_
    "the matrix at another point."

    graphicbox #hm.1, 0, 0, 400,340

    open "<:<:<:<:<:< BLACKBOX >:>:>:>:>:>:>:>" for dialog_modal as #hm
    #hm   "trapclose [qn]"
    #hm.1 "down; fill yellow; flush"
    #hm.1 "font courier_new 12 bold italic"


    #hm.1 "color black"
    #hm.1 "backcolor yellow"
    #hm.1 "|";hlp1$

    wait

[qn] 'close the help display
    close #hm
    wait

[Quit]
    close #m
    end



Gordon

Maak eerst enkele BMP's van 50X50.
Avatar gebruiker
Gordon
Site Admin
 
Berichten: 684
Geregistreerd: zo mei 22, 2005 12:50 am

Berichtdoor Gordon » za jan 06, 2007 3:34 pm

Code: Selecteer alles
'Gordon 2007 5/1
'maak een tile (bouwsteen)

nomainwin

button #2.1, "demo", [demo], UL, 180, 180
open "" for graphics as #2
#2 "trapclose [quit]"

#2 "down; fill cyan"
#2 "backcolor blue"
#2 "place 2 2;down"
#2 "boxfilled 48 48"

#2 "getbmp testtile 0 0 50 50"
wait

[demo]
#2 "down; fill black"
#2 "drawbmp testtile 30 30"


'------------- hier kun je bijvoorbeeld
'--------------xxxxxxxx.bmp veranderen
'--------------in blbtile.bmp

'bmpsave "testtile", "xxxxxxxx.bmp"


wait


[quit]
close #2
end


Voorbeeld
Avatar gebruiker
Gordon
Site Admin
 
Berichten: 684
Geregistreerd: zo mei 22, 2005 12:50 am

Berichtdoor Gordon » za jan 06, 2007 4:07 pm

Code: Selecteer alles
'Gordon 2007 5/1
'maak een pijltje uit gegeven plaatjes

nomainwin

bmpbutton #2.1, "C:\Program Files\Liberty BASIC v4.03\bmp\SCRLDOWN.BMP", [demo], UL, 17, 17
open "" for graphics as #2
#2 "trapclose [quit]"

#2 "down; fill red"
#2 "backcolor green"
#2 "place 2 2;down"
#2 "boxfilled 48 48"

#2 "getbmp testpijl 0 0 50 50"
wait

[demo]
#2 "down; fill darkred"
#2 "drawbmp testpijl 80 80"


'------------- hier kun je bijvoorbeeld
'--------------xxxxxxxx.bmp veranderen
'--------------in blboxS1.bmp

'bmpsave "testpijl", "xxxxxxxx.bmp"


wait


[quit]
close #2
end



Eerst moet je misschien uitzoeken waar je de map C:\Program Files\Liberty BASIC v4.03\bmp\SCRLDOWN.BMP gelaten hebt.

Enfin daar ben je programmeur voor.

Of gewoon even een teken programma runnen.

Gordon.
Avatar gebruiker
Gordon
Site Admin
 
Berichten: 684
Geregistreerd: zo mei 22, 2005 12:50 am


Keer terug naar Games

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers. en 1 gast

cron