TGC Codebase Backup



3D Sprites by Richard Davey

12th Sep 2003 13:08
Summary

Basically this was a speed test to see how many sprites could be plotted on-screen and the results are fantastic. My system managed over 520 sprites (16x16 pixels) at 75 frames per



Description

==========================================================
A Screaming Product Of The DARKFORGE (www.darkforge.co.uk)
==========================================================

Title

3D Sprites

Version

1.0

Date

April 12th 2000

Files

3d_sprites.dba 1477 Bytes
bubble_64x64.bmp 3368 Bytes
bubble_32x32.bmp 1816 Bytes
bubble_16x16.bmp 1322 Bytes
3dsprites_1.gif 30731 Bytes
3dsprites_2.gif 20951 Bytes
3dsprites_3.gif 12961 Bytes

Programmer

Richard Davey
rich@fatal-design.com

DB Version

DarkBasic v1.04 (Registered)

License

Public Domain

Comments

This uses the new sprite command in 1.04 but you can
replace it with the bob command if you're running an
earlier version and it'll still work just the same.

Basically this was a speed test to see how many sprites
could be plotted on-screen and the results are fantastic.
My system managed over 520 sprites (16x16 pixels) at 75
frames per second. It also did 175 64x64 sprites at 75 fps
- enjoy this power coding! :-)

==========================================================
(c) www.darkforge.co.uk 2000
==========================================================



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
`              3D Sprites
` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
` By Rich Davey (rich@fatal-design.com)
` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
` Music listened  to while  coding this
` The Mind of Goa (various artists)
` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
` Note:
`
`	My own personal testing gave the following results on a Pentium3-450
`	with 128Megs of RAM and a GeForce 256 Pro graphics card
`
`	175 64x64 sprites at 75 fps
`	350 32x32 sprites at 75 fps
`	525 16x16 sprites at 75 fps
`
`	Change the stars value below for maximum effect!
`	Gain extra speed by turning the print command off.

sync rate 0
sync on
hide mouse

randomize 1000

load image "bubble_64x64.bmp",1
`load image "bubble_32x32.bmp",1
`load image "bubble_16x16.bmp",1

stars=150

dim x#(stars) 
dim y#(stars)

for i = 1 to stars
	x#(i)=rnd(640.0)-320.0
	y#(i)=rnd(480.0)-240.0
	sprite i,x#,y#,1
	set sprite i,0,1
next i

sx#=1.03985 : sy#=1.03985
slidex#=320.0 : slidey#=240.0

ink rgb(255,255,255),0

do

	cls 0

	for j=1 to stars
		sprite j,x#(j)+slidex#,y#(j)+slidey#,1
		x#(j)=x#(j)*sx#
		y#(j)=y#(j)*sy#
		if x#(j) > 640.0 then x#(j)=x#(j)-640.0
		if y#(j) > 480.0 then y#(j)=y#(j)-480.0
		if x#(j) < -640.0 then x#(j)=x#(j)+640.0
		if y#(j) < -480.0 then y#(j)=y#(j)+480.0
	next j

	set cursor 0,0 : print "FPS ", screen fps()
	set cursor 0,12 : print "SPRITES ", stars

	sync 

loop