|
Post by honkytonk on Dec 22, 2022 15:45:00 GMT
Hello, In this soft--->: libertybasic.fr/upload/pouic.zipSprites are created spontaneously (left click), which prevents a winning ending, since we cannot know how many sprites have been created. In short: can we count the sprites that are in play in real time? Thank you for.
|
|
|
Post by Rod on Dec 22, 2022 16:27:19 GMT
I don't see sprites being created in the code in the download. You create 30 sprites at the start and then remove them one at a time if they are in the spritecollide list. You are counting missed shots and dead sprites. So we know how many sprites are in play?
Even if you were reintroducing sprites you can still count their reintroduction.
|
|
|
Post by honkytonk on Dec 23, 2022 11:19:49 GMT
Sprites are created by themselves (spontaneously), I could not determine if they are created with a simple click or with a click on sprite. At the latest news, 17 more have been created (30 + 17-->47 in the end). I'm on XP, haven't tested on Win10 yet.
|
|
|
Post by Rod on Dec 23, 2022 12:48:42 GMT
Ok, what is happening is that occasionally spritecollide finds more than one sprite under the cursor. So you need to work the list and kill all sprites found else they are left hanging about and none are deleted. Click on a single sprite and it will be deleted, click on the middle of two and they will both be deleted.
nomainwin s=30: x=1: y=2: dx=3: dy=4 dim s(s,4) 'x,y,dx,dy for n= 1 to s s(n,x)=n*25 s(n,y)=n*15 s(n,dx)=0 s(n,dy)=0 next WindowWidth = 800 WindowHeight = 600 UpperLeftX = int((DisplayWidth-WindowWidth)/2) UpperLeftY = int((DisplayHeight-WindowHeight)/2) graphicbox #1.gb 0,0, 800, 600 open "Sprite Demo" for graphics_nsb as #1 #1 "trapclose [quit]" #1.gb, "when leftButtonDown [MoveCmd]" #1.gb "fill black;getbmp bac 0 0 800 600;background bac" #1.gb "font courrier 16 bold": live=30: dead=0 loadbmp "enfa","bmps\enfa.bmp": loadbmp "curs","bmps\curso.bmp" #1.gb "addsprite curs curs" for n= 1 to 30 #1.gb "addsprite s";n;" enfa" #1.gb "spritexy s";n;" ";s(n,x);" ";s(n,y) next timer 17,[draw] '33 [draw] #1.gb "drawsprites" #1.gb "color white;backcolor black" #1.gb "place 50 20": #1.gb "\ Live: ";str$(live) #1.gb "place 200 20": #1.gb "\ Deaded: ";str$(dead) for n=1 to 30 s(n,dx)=s(n,dx) s(n,dy)=s(n,dy) s(n,x)=s(n,x)+s(n,dx) s(n,y)=s(n,y)+s(n,dy) 'bounce off walls if s(n,x)>=790 then s(n,dx)=s(n,dx)*-1 if s(n,y)>=590 then s(n,dy)=s(n,dy)*-1 if s(n,x)<0 then s(n,dx)=s(n,dx)*-1 if s(n,y)<0 then s(n,dy)=s(n,dy)*-1 #1.gb "spritexy s";n;" ";s(n,x);" ";s(n,y) next '#1.gb "spritexy s";6;" ";s(6,x);" ";s(6,y) '#1.gb "spritexy s";7;" ";s(7,x);" ";s(7,y) if live<=0 then timer 0: #1.gb "fill black" #1.gb "font courrier 20 bold" #1.gb "color white;backcolor black" #1.gb "place 200 300": #1.gb "\ Game Over" end if wait [MoveCmd] #1.gb, "spritexy curs ";MouseX;" ";MouseY #1.gb, "spritecollides curs list$" notice list$ if list$="" then live=live-1: wait w=1 s$=word$(list$,w," ") while s$<>"" #1.gb, "spritevisible ";s$;" ";"off": dead=dead+1 w=w+1 s$=word$(list$,w," ") wend wait [quit] unloadbmp "enfa": unloadbmp "curs" timer 0 close #1 end
|
|
|
Post by honkytonk on Dec 23, 2022 18:06:02 GMT
ok i will try that
|
|