Code archives/3D Graphics - Misc/Simple Laser Code

This code has been declared by its author to be Public Domain code.

Download source code

Simple Laser Code by Neochrome2002
Basically i had tried all the other code, but the seemed to be a bit complex for what they need to be

you create a cube (laser) the two points

A and B

these can be anything from a ship (pointA) to a precalculated range (pointB)

hope this helps
Graphics3D 640,480,16,2

SetBuffer BackBuffer()

laser = CreateCube()

PositionEntity laser,0,0,30

PointA = CreateCube()

PositionEntity PointA,-30,-30,30

PointB = CreateCube()

PositionEntity PointB,-60,60,30


lit = CreateLight()

cam = CreateCamera()

PositionEntity Cam,0,0,-50
ScaleEntity laser,1,1,1

While Not KeyDown(1)
	Cls
	
	MoveEntity  pointb,(MouseXSpeed()/5),-MouseYSpeed()/5,0
	
	t=EntityDistance(PointA,PointB)/2
	
	ScaleEntity laser,1,1,t
	PositionEntity laser,EntityX(pointa),EntityY(pointa),EntityZ(pointa)
	PointEntity laser,pointb
	MoveEntity laser,0,0,t
	
	
	
	
	
	UpdateWorld
	RenderWorld
	
	Flip
Wend
End

Comments

None.

Code Archives Forum