|
Post by B+ on Jun 11, 2021 18:59:33 GMT
I am baffled as to why one line quits drawing when I click mouse and get the other line started???
nomainwin W=800:H=600 WindowWidth=W+8 WindowHeight=H+32 open "MC" for graphics_nsb_nf as #g #g "size 2" #g "down;trapclose [q];when leftButtonUp [u];setfocus" #g "color black" a=rnd(0)*W:b=0:c=rnd(0)*6-3:d=rnd(0)*3 + 3 u=0:v=0:x=400:y=H timer 60,[t]
[t] x=x+u:y=y+v:a=a+c:b=b+d #g "set ";x;" ";y #g "set ";a;" ";b wait
[u] dx=MouseX-400:dy=MouseY-H:d=(dx^2+dy^2)^.5 u=5*dx/d:v=5*dy/d:goto [t]
[q] close #g:end
|
|
|
Post by tsh73 on Jun 11, 2021 20:09:17 GMT
nomainwin W=800:H=600 WindowWidth=W+8 WindowHeight=H+32 open "MC" for graphics_nsb_nf as #g #g "size 2" #g "down;trapclose [q];when leftButtonUp [u];setfocus" #g "color black" a=rnd(0)*W:b=0:c=rnd(0)*6-3:d=rnd(0)*3 + 3 u=0:v=0:x=400:y=H timer 60,[t]
[t] x=x+u:y=y+v:a=a+c:b=b+d #g "set ";x;" ";y #g "set ";a;" ";b wait
[u] 'dx=MouseX-400:dy=MouseY-H:d=(dx^2+dy^2)^.5 'u=5*dx/d:v=5*dy/d:goto [t] 'd used by b=b+d, use next letter 'e' dx=MouseX-400:dy=MouseY-H:e=(dx^2+dy^2)^.5 u=5*dx/e:v=5*dy/e:goto [t]
[q] close #g:end
|
|
|
Post by B+ on Jun 11, 2021 20:41:06 GMT
Ah saved from my bone headed mistake! Thanks
|
|
|
Post by B+ on Jun 11, 2021 21:16:37 GMT
Windows Properties Details tells me this is 792 bytes:
nomainwin W=800:H=600 WindowWidth=W+8 WindowHeight=H+32 open "MC" for graphics_nsb_nf as #g #g "size 2" #g "down;trapclose [q];when leftButtonDown [d];setfocus" #g "color black" [a] timer 0 #g "fill white" a=rnd(0)*W:b=0:c=rnd(0)*6-3:d=rnd(0)*3 + 3 u=0:v=0:x=400:y=H timer 60,[t] [t] x=x+u:y=y+v:a=a+c:b=b+d if x<0 or y<0 or a<0 or b<0 or x>W or y>H or a>W or b>H then if b>H then m=m+1 goto [a] end if if ((x-a)^2+(y-b)^2)^.5<30 then for r=1 to 20 step 4 #g "place ";(x+a)/2;" ";(y+b)/2;"; circle ";r t=time$("ms"):while time$("ms")<t+ 40:wend next h=h+1 goto [a] else #g "set ";x;" ";y:#g "set ";a;" ";b end if wait [d] dx=MouseX-400:dy=MouseY-H:z=(dx^2+dy^2)^.5 u=5*dx/z:v=5*dy/z:goto [t] [q] notice "hits: "+str$(h)+", misses "+str$(m) close #g:end
|
|
|
Post by B+ on Jun 11, 2021 23:27:32 GMT
Whittled done some bytes (757):
nomainwin W=800:H=600:WindowWidth=W+8:WindowHeight=H+32 open "MC" for graphics_nsb_nf as #g #g "size 2;down;trapclose [q];when leftButtonDown [d];setfocus" [a] #g "fill white" a=rnd(0)*W:b=0:c=rnd(0)*6-3:d=rnd(0)*3 + 3:u=0:v=0:x=400:y=H timer 60,[t] [t] x=x+u:y=y+v:a=a+c:b=b+d if x<0 or y<0 or a<0 or b<0 or x>W or a>W or b>H then if b>H or x<0 or y<0 or x>W then m=m+1 goto [a] end if if ((x-a)^2+(y-b)^2)^.5<20 then for r=1 to 20 step 4 #g "place ";(x+a)/2;" ";(y+b)/2;"; circle ";r t=time$("ms"):while time$("ms")<t+40:wend next h=h+1:goto [a] else #g "set ";x;" ";y:#g "set ";a;" ";b end if wait [d] e=MouseX-400:f=MouseY-H:z=(e^2+f^2)^.5:u=5*e/z:v=5*f/z:goto [t] [q] s$="hits: ";h;", misses: ";m notice s$ close #g:end
|
|
|
Post by B+ on Jun 12, 2021 15:16:25 GMT
BTW, with these missiles you can click a 2nd time to change it's direction, sometimes it helps.
|
|
|
Post by B+ on Jun 12, 2021 17:36:23 GMT
For my next trick, heat seeking missiles so we don't have to depend on human shooters for survival. Anyone up for that challenge, tsh73?
|
|
|
Post by tsh73 on Jun 12, 2021 19:32:17 GMT
|
|
|
Post by B+ on Jun 13, 2021 4:21:56 GMT
Thanks to AI our land is safe: Attachments:
|
|
|
Post by B+ on Jun 13, 2021 15:37:07 GMT
Here is my War and Peace graphics modification: Attachments:
|
|
|
Post by tsh73 on Jun 16, 2021 14:04:32 GMT
Several enemy rockets version (under 1000 bytes). If program errors with (Subscript out of range: 26, r())- consider yourself won If it dies with label not found - alas you let enemy rocket fall.
nomainwin:open "" for graphics as #g:#g "down;home;posxy X Y;when mouseMove 0; when leftButtonUp 1":b$="size 1;color black":w$="size 2;color white":c$=";circlefilled ":dim r(25,6):z=2*Y:w=0:timer 30,4:wait 4 if A<5 and rnd(0)<.05 then I=I+1:A=A+1:r(I,0)=1:R=2*X*rnd(0):r(I,1)=R:r(I,3)=R:Q=2*X*rnd(0):d=d(r,0,Q,z):r(I,5)=(Q-R)/d:r(I,6)=z/d #g b$:for i=1 to I:if r(i,0)=0 then 8 r(i,3)=r(i,3)+r(i,5):r(i,4)=r(i,4)+r(i,6):gosub 6:if r(i,4)>z then 9 8 next if w=0 then wait if w=1 then M=M+D:N=N+E:if d(M,N,T,S)<11 then w=2:#g w$ #g "line ";X;" ";z;" ";M;" ";N else #g b$;";place ";T;" ";S;c$;r:for i = 1 to I:if r(i,0)=0 then 7 if d(r(i,3),r(i,4),T,S)<r then #g w$:gosub 6:r(i,0)=0:A=A-1:#g b$ 7 next r=r+2:if r>20 then #g w$;c$;r;";";b$:r=0:w=0 end if:wait 6 #g "line ";r(i,1);" 0 ";r(i,3);" ";r(i,4):return 0 x=MouseX:y=MouseY:wait 1 w=1:T=x:S=y:M=X:N=z:d=d(T,X,S,z)/10:D=(T-X)/d:E=(S-z)/d:#g "place ";x-4;" ";y+6;";\X":wait function d(x,y,a,b) d=sqr((x-a)^2+(y-b)^2) end function
|
|
|
Post by B+ on Jun 16, 2021 16:42:03 GMT
LOL not only do you lose the game you lose JB and have to start it up again and re-paste the app if you didn't save it first.
|
|
|
Post by tsh73 on Jun 16, 2021 17:55:32 GMT
Carl suggested some things to throw away so now then you lose program just ends
open "" for graphics as #g:#g "down;home;posxy X Y;when mouseMove 0; when leftButtonUp 1":b$="size 1;color black":w$="size 2;color white":c$=";circlefilled ":dim r(25,6):z=2*Y:w=0:timer 30,4 4 if A<5 and rnd(0)<.05 then I=I+1:A=A+1:r(I,0)=1:R=2*X*rnd(0):r(I,1)=R:r(I,3)=R:Q=2*X*rnd(0):d=d(r,0,Q,z):r(I,5)=(Q-R)/d:r(I,6)=z/d #g b$:for i=1 to I:if r(i,0)=0 then 8 r(i,3)=r(i,3)+r(i,5):r(i,4)=r(i,4)+r(i,6):gosub 6:if r(i,4)>z then 9 8 next if w=0 then wait if w=1 then M=M+D:N=N+E:if d(M,N,T,S)<11 then w=2:#g w$ #g "line ";X;" ";z;" ";M;" ";N else #g b$;";place ";T;" ";S;c$;r:for i = 1 to I:if r(i,0)=0 then 7 if d(r(i,3),r(i,4),T,S)<r then #g w$:gosub 6:r(i,0)=0:A=A-1:#g b$ 7 next r=r+2:if r>20 then #g w$;c$;r;";";b$:r=0:w=0 end if:wait 6 #g "line ";r(i,1);" 0 ";r(i,3);" ";r(i,4):return 0 x=MouseX:y=MouseY:wait 1 w=1:T=x:S=y:M=X:N=z:d=d(T,X,S,z)/10:D=(T-X)/d:E=(S-z)/d:#g "place ";x-4;" ";y+6;";\X":wait 9 close #g:end function d(x,y,a,b) d=sqr((x-a)^2+(y-b)^2) end function
|
|
|
Post by B+ on Jun 16, 2021 20:10:28 GMT
Yes! nice work!
|
|