News:

Function Finder  Find all the functions within source code files

Main Menu

Pseudo-3D

Started by Tracy, April 10, 2006, 12:44:38 AM

Previous topic - Next topic

Tracy

Hi all.

I was working on this for an effect in my game and decided it was cool enough to share. It's a 3D illusion of rotating spheres around a central point. It's not much more than eye-candy, but if you're feeling spunky you can modify the X and Y coordinates with some sin/cosine values and get some interesting stuff.

Besides, it IS a pretty good illusion. Enjoy.

P.S. You'll need to download the attached files to have it run properly.
Edit: Took Ian's advice and zipped it all. No screenie, though, as my printscreen key seems to be on the fritz. (I need to reload windows, because I can't load www.blogger.com, either and can't figure out what's up.   :( )

PlayBASIC Code: [Select]
; PROJECT : Project3
; AUTHOR : Tracy
; CREATED : 4/8/2006
; EDITED : 4/10/2006
; ---------------------------------------------------------------------
i=GetFreeImage()
LoadImage "fireballbig.png",i
PrepareFXImage i

Spritenum=60

For s=1 To spritenum
s=GetFreeSprite()
CreateSprite(s)
SpriteDrawMode s,2
SpriteImage s,i
SpriteVisible s,1
AutoCenterSpriteHandle s,True
Next


wispimage=GetFreeImage()
wisp=GetFreeSprite()
CreateSprite(wisp)
LoadImage "ball.bmp",wispimage
PrepareFXImage wispimage
SpriteDrawMode wisp,2
SpriteImage wisp,wispimage
SpriteVisible wisp,1
ScaleSpriteXY wisp,0.25,1.5
AutoCenterSpriteHandle wisp,True

basex#=GetScreenWidth()/2
basey#=GetScreenHeight()/2
sinewidth#=180
sinespeedX#=0.75
sinespeedY#=0.5
yspeed#=-0
yoffset#=100
movespeed#=2
rotator#=0
rotaterate#=8
Yslantangle#=0
Xslantangle#=0
Xsplit=-1 `place at 1 to un-split, -1 to split
Ysplit=1 `place at 1 to un-split, -1 to split.
Depth#=0.3 `value between 0 and 1 (or -1, if you're feeling trippy...)
flat=0
ydest#=0
SetFPS 60

Do
If UpKey()Then Ydest#=WrapAngle(Ydest#,-movespeed#)
If DownKey()Then Ydest#=WrapAngle(Ydest#,movespeed#)
If LeftKey()Then Xdest#=WrapAngle(Xdest#,-movespeed#)
If RightKey()Then Xdest#=WrapAngle(Xdest#,movespeed#)
Yslantangle#=CurveAngle(Ydest#,Yslantangle#,90.0)
Xslantangle#=CurveAngle(Xdest#,Xslantangle#,90.0)

Cls 0
ScaleSpriteX wisp,1+0.8*Cos(angle#)
PositionSpriteXYZ wisp,baseX#,basey#,sinewidth#
For n=1 To spritenum
angle#=sineangleX#+(360/spritenum)*n
RotateSprite n,angle#*3
ScaleSprite n,1+depth#*Z#
If flat=True Then ScaleSpriteX n,Cos(angle#*rotaterate#)
X1#=Sin(angle#)*Cos(Xslantangle#)+Sin(yslantangle#)*Cos(angle#)*Sin(xslantangle#)
Y1#=Sin(angle#)*Sin(Xslantangle#)-Sin(yslantangle#)*Cos(angle#)*Cos(xslantangle#)
Z#=Cos(angle#)*Abs(Cos(yslantangle#))
X2#=1
Y2#=1


PositionSpriteXYZ n,basex#+(X1#*x2#)*sinewidth#*Xsplit^n,basey#+(y1#*y2#)*sinewidth#*Ysplit^n,sinewidth#-Cos(angle#)*sinewidth#
Next
yoffset#=yoffset#+yspeed#
oldsineangle#=sineangleX#
sineangleX#=WrapAngle(SineangleX#,sinespeedX#)



DrawOrderedSprites

Ink RGB(255,255,255)
Print "Xslantangle#: "+Str$(xslantangle#)
Print "Yslantangle#: "+Str$(Yslantangle#)
Print "Use arrow keys to rotate, spacebar to turn coin-mode on/off"

If SpaceKey()=False Then switched=False
If SpaceKey() And switched=False
flat=flat*-1+1
switched=True
EndIf
Sync
Loop




Big C.

Tracy, what a great demo...  :)

Please, make the FireballBig.png as an attached file (= downloadable link), so someone can download them without renaming.  ;)

Big C.

Ian Price

That's not bad at all :)

But on a similar note to Big C, why not put everything into an attachment - code and everything and show a screenshot, rather than the actual code.
I came. I saw. I played some Nintendo.

medwayman

#3
Very nice demo. The spinning coins look very cool B)  

Nice work  :)

hatonastick

A very nice version of an old-school demo effect!
Matthew 5:14-16