All pastes #85605 Raw Edit

Mine

public text v1 · immutable
·published 2006-07-12 02:03 UTC
rendered paste body
Graphics3D 640,480,32,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,5,0
RotateEntity camera,45,-45,0

light=CreateLight()
RotateEntity light,90,0,0

; CREATE TEXTURES
whitetexture=CreateTexture( 256,256 )
SetBuffer TextureBuffer( whitetexture )
ClsColor 255,255,255
Cls
SetBuffer BackBuffer()
redtexture=CreateTexture( 256,256 )
SetBuffer TextureBuffer( redtexture )
ClsColor 255,0,0
Cls
SetBuffer BackBuffer()
; END CREATE TEXTURES
ter=16
; Create terrain
terrain=CreateTerrain(ter)
EntityPickMode terrain,2

; Load the tank
mediumtank=LoadMesh( "media/mediumtank.x" )
RotateMesh mediumtank, 0, 180,0
ScaleEntity mediumtank,0.025,0.025,0.025
PositionEntity mediumtank,1,0,1
EntityTexture mediumtank,whitetexture

medtank2 = LoadMesh("media/mediumtank.x")
RotateMesh medtank2, 0, 180,0
ScaleEntity medtank2, 0.025, 0.025, 0.025
PositionEntity medtank2, 3, 0, 1
EntityTexture medtank2, redtexture

; Texture terrain
grass_tex=LoadTexture( "media/grass_patchy.jpg" )
EntityTexture terrain,grass_tex
;TerrainDetail terrain,2000,False
ter=8
ScaleTexture grass_tex,ter/2,ter/2
; terr. mod script
;For x=-ter/4 To ter/4
;For y=-ter/4 To ter/4
; x1=x+ter/2
; y1=y+ter/2
; e#=Sqr(x*x+y*y)
; h#=1.0-(e/Sqr( (ter/4)*(ter/4) + (ter/4)*(ter/4) ) )
; h1#=-Cos(h*90.0)/2.0+0.5
; If h1<0.0 Then h1=0.0 
; If h1>1.0 Then h1=1.0 

;ModifyTerrain terrain,x1,y1,h1
;Next
;Next
; end terr. mod script
; the variable that the selected unit will go in
selectedunit=False
angle=0
triangle_point_x=0
triangle_point_z=0
object_to_point=0
point_to_target=0
object_to_target=0
Global idling=True
Global idling2 = True
Global TARGET = CreatePivot() ;CreateSphere() ;CreatePivot()
Global TARGET2 = CreatePivot()

Function moveunit(unit, whichidle, whichtarget)
	If ( Not whichidle ) 
	;only move and turn if greater than 25 units from target
	If EntityDistance( unit , whichtarget ) > .5 ;25
		;get yaw angle to target
		DY# = DeltaYaw( unit , whichtarget )
		;turn tank slowly towards target
		TurnEntity unit, 0 , DY * .1 , 0
		;move tank forward if within 10 degrees of target
		
		MoveEntity unit, 0, 0, .05
		
	EndIf
EndIf
End Function

While Not KeyDown( 1 )

; Up
If KeyDown( 200 ) Or KeyDown( 17 )=True Then MoveEntity camera,0,0.05,0.05
; Down
If KeyDown( 208 ) Or KeyDown( 31 )=True Then MoveEntity camera,0,-0.05,-0.05
; Left
If KeyDown( 203 ) Or KeyDown( 30 )=True Then MoveEntity camera,-0.05,0,0
; Right
If KeyDown( 205 ) Or KeyDown( 32 )=True Then MoveEntity camera,0.05,0,0
;rotate left
If KeyDown( 46 )=True Then TurnEntity camera,0,1,1
;rotate right
If KeyDown( 47 )=True Then TurnEntity camera,0,-1,-1
; WireFrame
If KeyHit( 44 )=True Then
	WireFrame 1
Else If KeyHit( 45 )=True Then
	WireFrame 0
End If

If MouseHit(1)
	CameraPick(camera,MouseX(),MouseY())
	idling=False
	PositionEntity TARGET, PickedX(), PickedY(), PickedZ()
EndIf	

If MouseHit(2)
	CameraPick(camera, MouseX(), MouseY())
	idling2=False
	PositionEntity target2, PickedX(), PickedY(), PickedZ()
EndIf
	
moveunit(mediumtank, idling, TARGET)
moveunit(medtank2, idling2, target2)

UpdateWorld
RenderWorld

Framecounter_counter=Framecounter_counter+1
If Framecounter_time=0 Then Framecounter_time=MilliSecs()
If Framecounter_time+1001 <MilliSecs() Then
	Framecounter_framerate=Framecounter_counter
	Framecounter_counter=0
	Framecounter_time=MilliSecs()
End If
;Onscreen debug schizz
Text 0,0,"Xylia Project pre-alpha"
Text 0,20,"Click anywhere on the terrain to move the tank"
Text 0,40,"Use the arrow keys or WASD to move the camera"
Text 0,60,"Press Z for wireframe mode and X for textured"
Text 0,80,"Press C/V to rotate camera Left/Right"
Text 0,100,"Copyright © 2006 Liam Pinkerton"
Text 0,420,"FPS: "+Framecounter_framerate
Text 0,440,"PickedX: "+PickedX#()
Text 0,460,"PickedZ: "+PickedZ#()
Flip
Wend
End