|
Post by tsh73 on Sept 13, 2020 9:15:51 GMT
port from ABC pascal of course being compiled language it is much faster then JB.
Smaller N - faster, spidery-like Bigger N - more fluid, still menacing ("alien" feeling)
'tsh73 Sept 2020 'from demo of ABC Pascal.NET 'C:\PABCWork.NET\Samples\Graphics\GraphABC\Tentacles.pas '' in-source comment: //Program "Tentacles". Port of midletPascal :) nomainwin open "Tentacles" for graphics_nsb_nf as #gr #gr "trapclose [quit]" #gr "down" #gr "home; posxy cx cy"
#gr "color red" pi = acs(-1)
S = 14 ' N tentacles ' S = 9 N = 18 ' tentacle segments N = 10 N = 5 W = 2 'tentacle wigth
dim a(N) 'segment angles
#gr "size ";W length=min(cx,cy)*2/ 1.8 / N k = rnd(0)*2 * pi d = pi * 2 / S
k1 = 1
t0=time$("ms") while 1 SCAN #gr "cls" if t1>t0 then #gr "place 10 20":#gr "\Framerate ";k1/(t1-t0)*1000
if rnd(0)<1/50 then k = rnd(0)*2 * pi
'all angles recalc a(1) = a(1) + sin(k) / 15 for i = 2 to N a(i) = a(i) + (a(i - 1) - a(i)) * 0.1 next
for j = 0 to S - 1 x = cx y = cy for i = 2 to N '#gr "color 255 "; int(255 - 255 * i / N); " "; 255 tx = x + cos(j * d + a(i)) * length ty = y + sin(j * d + a(i)) * length #gr "line ";int(x);" ";int(y);" ";int(tx);" ";int(ty) x = tx y = ty next next
k1=k1+1 t1=time$("ms") timer 1, [tick] wait [tick] timer 0
wend wait
[quit] close #gr end
|
|
|
Post by honkytonk on Sept 13, 2020 11:32:15 GMT
timer 50 and "if rnd(0)<1/20" are best for see.
|
|
|
Post by tsh73 on Sept 14, 2020 9:03:55 GMT
resize-able version (source was resize-able)
'tsh73 Sept 2020 'from demo of ABC Pascal.NET 'C:\PABCWork.NET\Samples\Graphics\GraphABC\Tentacles.pas '' in-source comment: //Program "Tentacles". Port of midletPascal :) nomainwin open "Tentacles" for graphics_nsb as #gr #gr "trapclose [quit]" #gr "down" #gr "home; posxy cx cy"
#gr "color red" pi = acs(-1)
S = 14 ' N tentacles ' S = 9 N = 18 ' tentacle segments ' N = 10 ' N = 5 W = 2 'tentacle wigth
dim a(N) 'segment angles
#gr "size ";W length=min(cx,cy)*2/ 1.8 / N k = rnd(0)*2 * pi d = pi * 2 / S
k1 = 1
t0=time$("ms") while 1 SCAN #gr "cls" #gr "home; posxy cx cy" length=min(cx,cy)*2/ 1.8 / N if t1>t0 then #gr "place 10 20":#gr "\Framerate ";k1/(t1-t0)*1000
if rnd(0)<1/50 then k = rnd(0)*2 * pi
'all angles recalc a(1) = a(1) + sin(k) / 15 for i = 2 to N a(i) = a(i) + (a(i - 1) - a(i)) * 0.1 next
for j = 0 to S - 1 x = cx y = cy for i = 2 to N '#gr "color 255 "; int(255 - 255 * i / N); " "; 255 tx = x + cos(j * d + a(i)) * length ty = y + sin(j * d + a(i)) * length #gr "line ";int(x);" ";int(y);" ";int(tx);" ";int(ty) x = tx y = ty next next
k1=k1+1 t1=time$("ms") timer 1, [tick] wait [tick] timer 0
wend wait
[quit] close #gr end
|
|
|
Post by honkytonk on Sept 14, 2020 10:38:36 GMT
Whaooo! Very strong Could we put the parameters of modes accessible in interface..
|
|
|
Post by tsh73 on Sept 18, 2020 20:55:47 GMT
I tried. Now it could be tweaked almost on the run. About$ = _ "Tentacles"+chr$(13)+ _ "Port from ABC Pascal.NET demo"+chr$(13)+ _ "in-source comment: "+chr$(13)+ _ "//Program 'Tentacles'. Port of midletPascal"+chr$(13)+ _ "--------------------------------------------------"+chr$(13)+ _ "tsh73 Sept 2020"+chr$(13)
nomainwin
menu #gr, "File", "Start", [onFileStart], "Stop", [onFileStop], |, "e&Xit", [onFileEXit] menu #gr, "Setup", "Options", [onSetupOptions] menu #gr, "Help", "About", [onHelpAbout]
open "Tentacles" for graphics_nsb as #gr #gr "trapclose [quit]" #gr "down"
#gr "home; posxy cx cy"
#gr "color red" pi = acs(-1)
maxN=30 dim a(maxN) 'segment angles, N used
started=1
S = 14 ' N tentacles ' S = 9 N = 18 ' tentacle segments ' N = 10 ' N = 5 W = 3 'tentacle width. 3 or more for variable width dT = 20 'ms between frames cP = 0.02 'probability of direction change varW = 0 'variable width tentacles, thinning to the ends
[setup] #gr "size ";W length=min(cx,cy)*2/ 1.8 / N k = rnd(0)*2 * pi d = pi * 2 / S
t0=time$("ms") 'reset counter k1 = 1 if(started) then timer 1, [tick]
wait
[tick] if not(started) then wait timer 0
'while 1 #gr "cls" #gr "home; posxy cx cy" length=min(cx,cy)*2/ 1.8 / N if t1>t0 then #gr "place 10 20":#gr "\Framerate ";using("###.##",k1/(t1-t0)*1000)
if rnd(0)<cP then k = rnd(0)*2 * pi
'all angles recalc a(1) = a(1) + sin(k) / 15 for i = 2 to N a(i) = a(i) + (a(i - 1) - a(i)) * 0.1 next
for j = 0 to S - 1 SCAN x = cx y = cy for i = 2 to N '#gr "color 255 "; int(255 - 255 * i / N); " "; 255 tx = x + cos(j * d + a(i)) * length ty = y + sin(j * d + a(i)) * length if varW then #gr "size ";int(W*(1-i/N))+1 #gr "line ";int(x);" ";int(y);" ";int(tx);" ";int(ty) x = tx y = ty next next
k1=k1+1 t1=time$("ms")
timer dT, [tick] 'between frames wait 'wend
[quit] timer 0 Close #gr END
[onSetupOptions] 'Perform action for menu 'Setup', item 'Options' 'store old params opts$=S;" ";N;" ";W;" ";dT;" ";cP;" ";varW
WindowWidth = 304 WindowHeight = 330
statictext #opt.statictext1, "Tentacles", 25, 16, 120, 20 textbox #opt.txtS, 150, 16, 100, 25 statictext #opt.statictext3, "Segments", 25, 56, 120, 20 textbox #opt.txtN, 150, 51, 100, 25 statictext #opt.statictext5, "Width", 25, 96, 120, 20 textbox #opt.txtW, 150, 91, 100, 25 statictext #opt.statictext7, "dTimer", 25, 131, 120, 20 textbox #opt.txtDt, 150, 131, 100, 25 statictext #opt.statictext9, "ChangeProbab", 25, 176, 120, 20 textbox #opt.txtChangeP, 150, 171, 100, 25 checkbox #opt.chkVarWid, "Variable width", [checkbox11Set], [checkbox11Reset], 25, 216, 128, 20 button #opt.default, "Ok", [OkClick], UL, 150, 250, 122, 25 button #opt.btnCancel, "Cancel", [CancelClick], UL, 14, 250, 122, 25
open "Options" for dialog_nf_modal as #opt print #opt, "trapclose [quit.opt]" print #opt, "font ms_sans_serif 10"
#opt.txtS S #opt.txtN N #opt.txtW W #opt.txtDt dT #opt.txtChangeP cP #opt.chkVarWid word$("reset set",varW+1) wait
[quit.opt] Close #opt wait
[checkbox11Set] 'Perform action for the checkbox named 'chkVarWid' 'Insert your own code here wait
[checkbox11Reset] 'Perform reset for the checkbox named 'chkVarWid' 'Insert your own code here wait
[OkClick] 'Perform action for the button named 'btnOk' #opt.txtS "!contents? S" if S=0 then S=val(word$(opts$,1)) #opt.txtN "!contents? N" if N=0 then N=val(word$(opts$,2)) if N>maxN then N=maxN #opt.txtW "!contents? W" if W=0 then W=val(word$(opts$,3)) #opt.txtDt "!contents? dT" if dT=0 then dT=val(word$(opts$,4)) #opt.txtChangeP "!contents? cP" if cP=0 then cP=val(word$(opts$,5)) #opt.chkVarWid "value? result$" varW = (result$="set") Close #opt goto [setup]
[CancelClick] 'Perform action for the button named 'btnCancel' 'restore vars from ' opts$=S;" ";N;" ";w S=val(word$(opts$,1)) N=val(word$(opts$,2)) W=val(word$(opts$,3)) dT=val(word$(opts$,4)) Close #opt goto [setup]
[onFileStart] 'Perform action for menu 'File', item 'Start' started=1
t0=time$("ms") 'reset counter k1 = 1 timer 1, [tick] wait
[onFileStop] 'Perform action for menu 'File', item 'Stop' started=0 wait
[onFileEXit] 'Perform action for menu 'File', item 'e&Xit' goto [quit]
[onHelpAbout] 'Perform action for menu 'Help', item 'About' Notice About$ if(started) then timer 1, [tick] wait
|
|
|
Post by honkytonk on Sept 20, 2020 12:26:31 GMT
Could we put your virtual octopus walking movement into an equation with an equation for each tentacle connected together.
|
|