Make sprites screen sized!

Share your advanced PureBasic knowledge/code with the community.
User avatar
Fou-Lu
Enthusiast
Enthusiast
Posts: 201
Joined: Tue Jul 12, 2005 8:30 am
Location: I'm pretty sure this is all a nightmare
Contact:

Make sprites screen sized!

Post by Fou-Lu »

I don't know if this is a bug or not. I don't know either if it has been mentioned before.

You probably know that the StartSpecialFX() command uses the phisic memory to make all those "alpha" and other effects faster. After it's all done, it copies the result to the video memory. What happens if we do that using a sprite buffer?

Code: Select all

Procedure ScreenSizeSprite(s.l)
usebuffer(s)
startspecialfx():displaysprite(s,0,0):stopspecialfx()
usebuffer(-1)
EndProcedure

~Fou-Lu (aka Lørd Cinneris (actually Elias Sant'Ana))

Image Image
User avatar
Fou-Lu
Enthusiast
Enthusiast
Posts: 201
Joined: Tue Jul 12, 2005 8:30 am
Location: I'm pretty sure this is all a nightmare
Contact:

Post by Fou-Lu »

Some code for you to test it: (just ctrl+c, ctrl+v)

Code: Select all

initsprite()
initkeyboard()

openscreen(320,240,16,"")

Procedure ScreenSizeSprite(s.l)
usebuffer(s)
startspecialfx():displaysprite(s,0,0):stopspecialfx()
usebuffer(-1)
EndProcedure

createsprite(0,128,128)
startdrawing(spriteoutput(0))
for y=0 to 63
c=1+random(15):mc=c
for x=0 to 63
c=c-1
if c<=-mc:c=1+random(15):mc=c
if x+c+16>63:c=(63-x)/2:mc=c:endif
red=random(2):endif
color=127-abs(127*c)/mc
plot(x+64,y+64,rgb(color*red,255-abs(x-32)*7,y*4))
plot(x+64,y,rgb(color*red,255-abs(x-32)*7,y*4))
plot(x,y+64,rgb(color*red,255-abs(x-32)*7,y*4))
plot(x,y,rgb(color*red,255-abs(x-32)*7,y*4))
next x
next y
stopdrawing()

usebuffer(0)
for g=0 to 63
grabsprite(200+g,g,0,64,48,#pb_sprite_memory)
grabsprite(100+g,g,g,64,48,#pb_sprite_memory)
next g
usebuffer(-1)

for g=0 to 63
usebuffer(100+g)
displaytranslucidesprite(263-g,0,0,64)
next g

repeat

i=i+1:if i>63:i=0:endif
ScreensizeSprite(100+i)

examinekeyboard()
flipbuffers()
until keyboardpushed(#pb_key_escape)
Sorry, it's a bit messy... :oops:
Last edited by Fou-Lu on Wed Aug 03, 2005 2:58 am, edited 1 time in total.

~Fou-Lu (aka Lørd Cinneris (actually Elias Sant'Ana))

Image Image
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Looks great. But I think you might mean <examinekeyboard()> ;)
BERESHEIT
User avatar
Fou-Lu
Enthusiast
Enthusiast
Posts: 201
Joined: Tue Jul 12, 2005 8:30 am
Location: I'm pretty sure this is all a nightmare
Contact:

Post by Fou-Lu »

Thanks netmaestro, I corrected it. It was with examinemouse() because unlike normal people, I use mousebutton(1) to finish a program rather than keyboardpushed(#pb_key_escape)... :oops:

I found that by accident. I think this might be a bug, since it makes impossible to use SpecialFX() inside a sprite buffer.

~Fou-Lu (aka Lørd Cinneris (actually Elias Sant'Ana))

Image Image
Post Reply