News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Unlimited Bobs / Sprites

Started by kevin, July 18, 2009, 01:26:23 AM

Previous topic - Next topic

kevin

 Unlimited Bobs / Sprites Illusion

  This is quick port (from DB to PlayBASIC) of a really Old School Visual Effect, the unlimited bobs illusion.   The routine creates the illusion of unlimited image drawing .  When in reality  it's procedurally animation.    Fun though.  



PlayBASIC Code: [Select]
` *=---------------------------------------------------------------------=*
`
` >> Unlimited Pasted Images V0.01 <<
`
` By Kevin Picone
`
` PB version: 18,July,2009
`
` DB version: 18,April,2001
`
` (c) copyright 2001-2009, By Kevin Picone, All Rights Reserved.
`
` *=---------------------------------------------------------------------=*
`
` So What does this do ?:
` =======================
`
` I'd have to say that this effect is perhaps my favourite of all time.
` I remember this done on the Vic 20! and then the C64 some years later,
` it seemed amazing then, unlimited sprites without slow down ?,
` impossible !! - But once you hit upon the trick, it's really very
` simple. And for the record NO !, it doesn't give you unlimited image
` pastes per sync :), it's just FOOLS the viewer into thinking that's what
` it's doing. :)
`
` Cya,
` Kevin Picone
`
` *=---------------------------------------------------------------------=*


` Constants


Setfps 100


screen_width=GetScreenWidth()
screen_height=GetScreenHeight()

Title$= "Unlimited Pasted Images"
Version$= "V0.01"
TextYPos=-100



`pick a size for our Image
bob_size=32


` Create an Image
for lp=0 to (bob_size/2)-1
boxc lp,lp,(bob_size-1)-lp,(bob_size-1)-lp,true,rndrgb()
next lp
getimage 1,0,0,bob_size-1,bob_size-1


` Init Frame Buffers
` ------------------

screens=6
dim buffers(screens)

for lp=1 to screens
img=100+lp
CreateIMage Img,screen_width,screen_height
buffers(lp)=img
next lp



` Init Sprites/Images Position
` ----------------------------


xpos#=screen_Width/2
Ypos#=screen_Height/2

xspeed#=1+(rnd(15)-rnd(15))
yspeed#=1+(rnd(15)-rnd(15))


` Starting Number of Images
Numb_of_images=1

do


` The main effect routine
rendertoimage buffers(1)
drawimage 1,xpos#,ypos#,true
xpos#=xpos#-(xspeed#/screens)
ypos#=ypos#-(yspeed#/screens)
if xpos#<0 or xpos#>(screen_width-bob_size) then xspeed#=xspeed#*-1
if ypos#<0 or ypos#>(screen_height-bob_size) then yspeed#=yspeed#*-1


` Randomly change the Speed values

xspeed#=xspeed#+(rnd(6)-rnd(6))
yspeed#=yspeed#+(rnd(6)-rnd(6))

` Limit The Speed values so our image doesn't move to fast

if xspeed#=>30 then xspeed#=30
if xspeed#<-30 then xspeed#=-30
if yspeed#=>30 then yspeed#=30
if yspeed#<-30 then yspeed#=-30

if buffers(1)=1 then inc Numb_of_images



copyrect buffers(1),0,0,screen_width,Screen_Height,0,0,0


` roll frames
for lp=1 to screens
buffers(lp-1)=buffers(lp)
next lp
buffers(screens)=buffers(0)




` Display Some Program By Information

rendertoscreen
if inkey$()=""
Display_UWProgramInfo(Title$,version$,textypos,0)
text 540,textypos,"Images:"+str$(numb_of_images)
if textypos<0 then inc textypos,2
endif

sync

loop





` *=----------------------------------------------------------------=*
` *=---------- Display Program TITLE & UWdesign BLURB INFO ---------=*
` *=----------------------------------------------------------------=*

Function Display_UWProgramInfo(Title$,version$,ypos,clearflag)
if clearflag=1 then cls 0
Login required to view complete source code