2.5d shooter (like rtype delta)

Blitz3D Forums/Blitz3D Beginners Area/2.5d shooter (like rtype delta)

I made some code for you to study :)

Specially the command PositionTexture()

;Starfield example for pete carter

Graphics3D( 800, 600 )
SetBuffer( BackBuffer() )
SeedRnd( MilliSecs() )

Local Cam% = CreateCamera()

;4 different starfield textures (you may want to loadimage instead).
Local StarfieldTexture1% = CreateStarfield( 200 )
Local StarfieldTexture2% = CreateStarfield( 150 )
Local StarfieldTexture3% = CreateStarfield( 100 )
Local StarfieldTexture4% = CreateStarfield( 50 )

;4 layers of stars.
Local Layer1% = CreateSprite( Cam% )
				PositionEntity( Layer1%, 0, 0, 1.5 ) ;In front of camera.
				EntityBlend( Layer1%, 3 ) ;additive blending.
				EntityTexture( Layer1%, StarfieldTexture1% )

Local Layer2% = CreateSprite( Cam% )
				PositionEntity( Layer2%, 0, 0, 1.5 )
				EntityBlend( Layer2%, 3 )
				EntityTexture( Layer2%, StarfieldTexture2% )

Local Layer3% = CreateSprite( Cam% )
				PositionEntity( Layer3%, 0, 0, 1.5 )
				EntityBlend( Layer3%, 3 )
				EntityTexture( Layer3%, StarfieldTexture3% )

Local Layer4% = CreateSprite( Cam% )
				PositionEntity( Layer4%, 0, 0, 1.5 )
				EntityBlend( Layer4%, 3 )
				EntityTexture( Layer4%, StarfieldTexture4% )


;Textures offset variabe.
Local Offset# = 0

Repeat

		;Decrement the offset.
		Offset# = Offset# - .001
		;Scroll the starfield textures..
		PositionTexture( StarfieldTexture1%, Offset#, 0 )
		PositionTexture( StarfieldTexture2%, Offset# *.7, 0 )
		PositionTexture( StarfieldTexture3%, Offset# *.4, 0 )
		PositionTexture( StarfieldTexture4%, Offset# *.1, 0 )

UpdateWorld(): RenderWorld(): Flip()
Until KeyHit( 1 )



;Function to make a star texture.
Function CreateStarfield%( Brightness% )
			Local Image% = CreateImage( 256, 256 )
			Local Texture% = CreateTexture( 256, 256, 256 )
			Local i%

			SetBuffer( ImageBuffer( Image% ) )

			For i% = 0 To 250
				Bright% = Rand( Brightness% -50, Brightness% +50 )
				Color( Bright%, Bright%, Bright% )
				Plot( Rand( 256 ), Rand( 256 ) )
			Next

			CopyRect( 0, 0, 512, 512, 0, 0, ImageBuffer( Image% ), TextureBuffer( Texture% ) )

			SetBuffer BackBuffer()
			Return Texture%
End Function