Code archives/3D Graphics - Misc/Handle 3D Sprites as 2D Sprites
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
You can position a Sprite in the same way as an Image - but now you have alpha-transparency etc. Note that this example works with diffrent Screenresolutions and diffrent CameraZooms. | |||||
WIDTH = 800 HEIGHT = 600 halfWIDTH = WIDTH/2 halfHEIGHT = HEIGHT/2 Graphics3D WIDTH,HEIGHT,16,2 SetBuffer BackBuffer() camera = CreateCamera() camzoom#=1.0 ; this is default. Other values work as well. CameraZoom camera,camzoom# CameraRange camera,1,(halfWIDTH * camzoom#)+1000 sprite=CreateSprite() ; if you want the sprite to be 32*32 Pixels: ScaleSprite sprite,32/2,32/2 EntityColor sprite,255,0,0 While KeyDown(1)=0 PositionEntity sprite,MouseX()-halfWIDTH,halfHEIGHT-MouseY(),halfWIDTH * camzoom# UpdateWorld RenderWorld Flip Wend EndGraphics End |
Comments
None.
Code Archives Forum