|
Post by tsh73 on Sept 10, 2022 20:52:10 GMT
Along this this LB thread libertybasiccom.proboards.com/thread/2101/another-animationnomainwin
'WindowWidth = 350 'WindowHeight = 390 WindowWidth = 500 WindowHeight = 540 'WindowWidth = 1000 'WindowHeight = 1000 open "Resize me! XOR animation" for graphics_nsb as #gr #gr "home; down; posxy cx cy" #gr "trapclose [quit]"
'#gr "circle 30" '#gr "go 20" #gr "color white" #gr "backcolor black" #gr "rule XOR"
pi=acs(-1) aa=0 'radians r=min(cx, cy)*0.35 R=int(2*min(cx, cy))/1.6 while 1 x=cx+r*cos(aa) y=cy+r*sin(aa) #gr "place ";x;" ";y for a = 0 to 350 step 15 'degrees #gr "piefilled ";R;" ";R;" ";a+d;" ";7 scan next
x=cx+r*cos(aa+pi) y=cy+r*sin(aa+pi) #gr "place ";x;" ";y for a = 0 to 350 step 15 #gr "piefilled ";R;" ";R;" ";a+d;" ";7 scan next
timer 50, [nxt] wait [nxt] timer 0 #gr "cls" d=(d+1) mod 15 aa=aa+1/57/5 #gr "home; down; posxy cx cy" r=min(cx, cy)*0.35 R=int(2*min(cx, cy))/1.6 wend
wait
[quit] timer 0 close #gr end
|
|
|
Post by plus on Sept 10, 2022 23:26:02 GMT
Can you xor sprites so not so slow and flashy?
|
|
|
Post by tsh73 on Sept 11, 2022 6:14:54 GMT
I'm afraid not
|
|
|
Post by plus on Sept 11, 2022 19:35:30 GMT
S'OK worked it out in another Basic, really cool graphic @john T! Attachments:
|
|
|
Post by Rod on Sept 12, 2022 10:55:59 GMT
It would seem possible with sprites as they are transparent and can be overlaid. I just need to draw the sprites programmatically to prove the point.
This code creates sixteen sprites bmp0.bmp to bmp15.bmp
nomainwin WindowWidth = 800 WindowHeight = 600 open "animation" for graphics_nsb as #gr #gr "trapclose [quit]" #gr "down ; color white" #gr "backcolor black"
cx=100 cy=100 pi=acs(-1) aa=0 'radians r=min(cx, cy)*0.35 R=int(2*min(cx, cy))/1
for d=0 to 15 x=cx+r*cos(aa) y=cy+r*sin(aa) #gr "backcolor black ;color white" #gr "place ";x;" ";y for a = 0 to 350 step 15 'degrees #gr "piefilled ";R;" ";R;" ";a+d;" ";7 next #gr "backcolor black ; place 0 200 ; boxfilled 250 400" #gr "backcolor blue ; color black" #gr "place ";x;" ";y+200 for a = 0 to 350 step 15 'degrees #gr "piefilled ";R;" ";R;" ";a+d;" ";7 next #gr "getbmp bmp 0 0 250 400" bmpsave "bmp","bmp";str$(d);".bmp" #gr "cls" next
[quit] close #gr end
This code creates a simple rotation.
nomainwin 'get the sprite images and background for n= 0 to 15 loadbmp "fan";n, "bmp";n;".bmp" next
'open a window and graphicbox WindowHeight = 300 WindowWidth = 400 graphicbox #w.g, 0, 0, 400, 300 open "sprite test" for window_nf as #w print #w, "trapclose [quit]"
'add a background and 4 sprites and animation cycling print #w.g, "down ; fill white; getbmp background 0 0 400 300 ; background background" for n= 0 to 15 #w.g "addsprite fan fan0 fan1 fan2 fan3 fan4 fan5 fan6 fan7 fan8 fan9 fan10 fan11 fan12 fan13 fan14 fan15" #w.g "addsprite fan1 fan0 fan1 fan2 fan3 fan4 fan5 fan6 fan7 fan8 fan9 fan10 fan11 fan12 fan13 fan14 fan15" #w.g "cyclesprite fan 1" #w.g "cyclesprite fan1 1" #w.g "spritexy fan 100 50" #w.g "spritexy fan1 50 50" next
timer 16, [advanceAnimation] wait
[advanceAnimation] 'draw another cycle of animation #w.g "drawsprites" wait
[quit] close #w end
|
|
|
Post by tsh73 on Sept 12, 2022 13:02:38 GMT
They can be overlaid but you will not get XOR effect. (only OR)
|
|
|
Post by Rod on Sept 12, 2022 14:08:55 GMT
I see the difference now.
|
|