The core code for this is located at
http://www.awosa.net/code for now.
This code is for the Blitz3D engine.
This code we altered in class today to include the ability to create walls on the fly:
---------------------------------------------------------------------------------
Graphics3D 800,600, 16,1
Global health = 100000
light = CreateLight()
Const player=1
Const scene=2
Collisions player,scene, 2,2
man = CreateCylinder()
EntityColor man, 99,99,99
EntityType man, player
Global manpivot = CreateSphere(8,man)
MoveEntity manpivot,0,0,10
ScaleEntity manpivot,0.1,0.1,0.1
Global wall = CreateCube()
ScaleEntity wall, 5,1,1
HideEntity wall
enemy1= CreateCone()
EntityColor enemy1, 255,200,50
EntityType enemy1,player
enemy2 = CreateCone()
EntityColor enemy2, Rand(255),Rand(255),Rand(255)
EntityType enemy2, player
SeedRnd (enemy2)
Global camera= CreateCamera(man)
MoveEntity camera, 0,10,-20
plane = CreatePlane()
EntityColor plane, 0,255,0
MoveEntity plane,0,-10,0
For i = 1 To 100
box = CreateCube()
ScaleEntity box, 5,2,5
PositionEntity box, Rand(1000), 0, Rand(1000)
EntityColor box, Rand(255),Rand(255), Rand(255)
EntityType box, scene
Next
While Not KeyHit(1)
PointEntity camera,man
If KeyDown(200) Then MoveEntity man, 0,0,2
If KeyDown(208) Then MoveEntity man, 0,0,-2
If KeyDown(203) Then TurnEntity man,0,1,0
If KeyDown(205) Then TurnEntity man, 0,-1,0
;If KeyDown(15) Then MoveEntity man, 0,1,0
PointEntity enemy1, man
PointEntity enemy2, man
MoveEntity enemy1, 0,0,0.3
MoveEntity enemy2, 0,0,0.5
If EntityDistance (enemy1, man) < 5 Then health = health -1
If EntityDistance (enemy2, man) < 5 Then health = health -3
If health = 0 Then End
;; CREATING WALLS ON THE FLY
If KeyHit (2) Then
newwall = CopyEntity (wall)
xx# = EntityX(manpivot,True)
yy# = EntityY(manpivot)
zz# = EntityZ(manpivot,True)
PositionEntity newwall, xx,yy,zz,True
EntityType newwall, scene
RotateEntity newwall, 0,EntityYaw(man),0
End If
UpdateWorld
RenderWorld
Text 20,20, health
Flip
Wend
Thursday, February 7, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment