They're easy to find.
Gone.....
Edit: Removed redundant declaration and fixed tail texture with font repositioned correctly.
Added init check...my way.

Code: Select all
;Helicopter - template Base project
;----------------------------------
;F12 - Start Engine
;F11 - Turn off engine
;+ - increase rotorspeed
;- - Decrease rotorspeed
;z = bank left
;x = bank right
;Arrow up - Increase height
;Arrow left - backward
;Arrow right - Forward
;----------------------------------
;No turning implemented
;No tiling implemented
;----------------------------------
If InitEngine3D() = 0
MessageRequester("Your system is fubar!", "Unable to load 3D engine")
End
EndIf
If InitSprite() = 0
MessageRequester("Can't open a screen? WTF??", "Remind me to never buy a system like yours")
End
EndIf
If InitKeyboard() = 0
MessageRequester("COME ON!!!!", "No keyboard? Really??")
End
EndIf
If InitSound() = 0
MessageRequester("Hah!", "Silent movie.")
End
EndIf
UseOGGSoundDecoder()
Structure _object
ma.i
ms.i
tx.i[6]
id.i
speed.f
EndStructure
Structure _chop
body._object
MainRotor._object[3]
rotorGear._object
tailRotor._object[2]
TailGear._object
tail._object[2]
legs._object[6]
mainrotorNode.i
tailrotorNode.i
bodyNode.i
mainobject._object
EndStructure
Structure _spr
Id.i
Rpm.i
EndStructure
Declare.i CreateHeli()
Declare.i CreateScene()
Global ch._chop, sn.i, ground._object, rpm._spr, RotorSpeed.f = 0.0, Ignite.i = 0, Quit.i = #False
Global TailFont.i
OpenWindow(0, 0, 0, 1024, 768, "'Chopper'", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, 1024, 768)
Add3DArchive("\", #PB_3DArchive_FileSystem)
Add3DArchive(".", #PB_3DArchive_FileSystem)
TailFont = LoadFont(#PB_Any, "Arial", 36)
WorldShadows(#PB_Shadow_Modulative)
CreateCamera(0, 0, 0, 100, 100)
CameraRange(0, 0, 1400)
MoveCamera(0, 0, 0.1, 7)
CameraBackColor(0, $E28B29)
CreateCamera(1, 0, 0, 20, 20)
CameraBackColor(1, $E28B29)
CreateLight(0, $FFFFFFFF, 0, 100, 0)
ret = CreateHeli()
ret = CreateScene()
rpm\Rpm = -1
Repeat
Repeat
ev = WindowEvent()
If ev = #PB_Event_CloseWindow : Quit = #True : EndIf
Until ev = 0
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Add) And RotorSpeed < 50
RotorSpeed + 0.1
ElseIf KeyboardPushed(#PB_Key_Subtract) And RotorSpeed > 20
RotorSpeed - 0.1
ElseIf KeyboardReleased(#PB_Key_F12) And Ignite = 0
Ignite = 1
If sn > 0
PlaySound(sn, #PB_Sound_Loop)
EndIf
ElseIf KeyboardReleased(#PB_Key_F11) And Ignite = 1
Ignite = 0
EndIf
If Ignite = 1 And RotorSpeed < 40
RotorSpeed + 0.1
ElseIf Ignite = 0 And RotorSpeed > 0
RotorSpeed - 0.1
If RotorSpeed <= 0
RotorSpeed = 0
If sn > 0
StopSound(sn)
EndIf
EndIf
EndIf
If RotorSpeed <> rpm\Rpm
If rpm\Id > 0
FreeSprite(rpm\Id)
EndIf
rpm\Rpm = RotorSpeed
rpm\Id = CreateSprite(#PB_Any, 150, 40,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(rpm\Id))
DrawingMode(#PB_2DDrawing_Outlined)
Box(1, 1, 149, 59, $FFFF15)
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(2, 3, "RPM: " + StrF(rpm\Rpm*100,2), $FFFF15)
StopDrawing()
TransparentSpriteColor(rpm\Id, 0)
EndIf
If RotorSpeed > 40
If KeyboardPushed(#PB_Key_Up)
ApplyEntityImpulse(ch\mainobject\id, 0, 0.009, 0, 0, 0, 0)
EndIf
If KeyboardPushed(#PB_Key_Left)
ApplyEntityImpulse(ch\mainobject\id, -0.001, 0, 0, 0, 0, 0)
EndIf
If KeyboardPushed(#PB_Key_Right)
ApplyEntityImpulse(ch\mainobject\id, 0.001, 0, 0, 0, 0, 0)
EndIf
If KeyboardPushed(#PB_Key_Z)
ApplyEntityImpulse(ch\mainobject\id, 0, 0, 0.001, 0, 0, 0)
EndIf
If KeyboardPushed(#PB_Key_X)
ApplyEntityImpulse(ch\mainobject\id, 0, 0, -0.001, 0, 0, 0)
EndIf
EndIf
RotateNode(ch\mainrotorNode, 0, RotorSpeed, 0, #PB_Relative)
RotateNode(ch\tailrotorNode, 0, 0, RotorSpeed, #PB_Relative)
CameraFollow(1, EntityID(ch\mainobject\id), 5, 10, 10, 10, 10)
CameraLookAt(0, EntityX(ch\mainobject\id), EntityY(ch\mainobject\id), EntityZ(ch\mainobject\id))
RenderWorld()
DisplayTransparentSprite(rpm\Id, 1, ScreenHeight()-SpriteHeight(rpm\Id))
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or quit = #True
Procedure.i CreateHeli()
With ch\body
\ms = CreateSphere(#PB_Any, 0.5, 20, 20)
TransformMesh(\ms, 0, 0, 0, 2.5, 1.2, 1, 0, 0, 0)
\tx[0] = CreateTexture(#PB_Any, 2048, 2048)
StartDrawing(TextureOutput(\tx[0]))
Box(0, 0, 2048, 2048, $DEDADA)
Box(0, 256, 1024, 512, $DEDADA)
DrawingMode(#PB_2DDrawing_Default)
Box(1032, 786, 20, 10, $92918D)
Box(1028, 256, 128, 512, $DEDADA)
Box(1917, 256, 128, 512, $DEDADA)
DrawingMode(#PB_2DDrawing_Outlined)
Box(1917, 768, 128, 512, $92918D)
Box(1918, 769, 126, 510, $92918D)
Box(1027, 768, 128, 512, $92918D)
Box(1028, 767, 128, 512, $92918D)
DrawingMode(#PB_2DDrawing_Default)
Box(2010, 786, 20, 10, $92918D)
StopDrawing()
\tx[1] = CreateTexture(#PB_Any, 2048, 2048)
StartDrawing(TextureOutput(\tx[1]))
DrawingMode(#PB_2DDrawing_AlphaBlend)
Box(0, 0, 2048, 2048, 0)
Box(0, 256, 1024, 512, $F0DE910B)
Box(1028, 256, 128, 512, $F0DE910B)
Box(1917, 256, 128, 512, $F0DE910B)
StopDrawing()
\ma = CreateMaterial(#PB_Any,TextureID(\tx[0]))
AddMaterialLayer(\ma, TextureID(\tx[1]), #PB_Material_AlphaBlend)
MaterialCullingMode(\ma, #PB_Material_NoCulling)
MaterialFilteringMode(\ma, #PB_Material_Anisotropic, 8)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0.85, 0)
EndWith
With ch\legs[0]
\ms = CreateCylinder(#PB_Any, 0.04, 2, 5, 1,0)
\tx[0] = CreateTexture(#PB_Any, 64, 64)
StartDrawing(TextureOutput(\tx[0]))
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor($3B3832) : BackColor($86807D)
LinearGradient(0, 0, 64, 64)
Box(0, 0, 64, 64)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx[0]))
MaterialCullingMode(\ma, #PB_Material_NoCulling)
ScaleMaterial(\ma, 0.5, 0.5)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0.001, 0.38)
RotateEntity(\id, 0, 0, 90)
EndWith
With ch\legs[1]
\ms = CreateCylinder(#PB_Any, 0.04, 0.5, 5, 1,0)
\tx[1] = CreateTexture(#PB_Any, 64, 64)
StartDrawing(TextureOutput(\tx[1]))
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor($3B3832) : BackColor($86807D)
LinearGradient(0, 0, 64, 64)
Box(0, 0, 64, 64)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx[1]))
MaterialCullingMode(\ma, #PB_Material_NoCulling)
ScaleMaterial(\ma, 0.5, 0.5)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0.5, 0.2, 0.27)
RotateEntity(\id, -30, 0, 0)
EndWith
With ch\legs[2]
\ms = CreateCylinder(#PB_Any, 0.04, 0.5, 5, 1,0)
\tx[2] = CreateTexture(#PB_Any, 64, 64)
StartDrawing(TextureOutput(\tx[2]))
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor($3B3832) : BackColor($86807D)
LinearGradient(0, 0, 64, 64)
Box(0, 0, 64, 64)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx[2]))
MaterialCullingMode(\ma, #PB_Material_NoCulling)
ScaleMaterial(\ma, 0.5, 0.5)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), -0.5, 0.2, 0.27)
RotateEntity(\id, -30, 0, 0)
EndWith
With ch\legs[3]
\ms = CreateCylinder(#PB_Any, 0.04, 2, 5, 1,0)
\tx[3] = CreateTexture(#PB_Any, 64, 64)
StartDrawing(TextureOutput(\tx[3]))
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor($3B3832) : BackColor($86807D)
LinearGradient(0, 0, 64, 64)
Box(0, 0, 64, 64)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx[3]))
MaterialCullingMode(\ma, #PB_Material_NoCulling)
ScaleMaterial(\ma, 0.5, 0.5)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0.001, -0.38)
RotateEntity(\id, 0, 0, 90)
EndWith
With ch\legs[4]
\ms = CreateCylinder(#PB_Any, 0.04, 0.5, 5, 1,0)
\tx[4] = CreateTexture(#PB_Any, 64, 64)
StartDrawing(TextureOutput(\tx[4]))
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor($3B3832) : BackColor($86807D)
LinearGradient(0, 0, 64, 64)
Box(0, 0, 64, 64)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx[4]))
MaterialCullingMode(\ma, #PB_Material_NoCulling)
ScaleMaterial(\ma, 0.5, 0.5)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0.5, 0.2, -0.27)
RotateEntity(\id, 30, 0, 0)
EndWith
With ch\legs[5]
\ms = CreateCylinder(#PB_Any, 0.04, 0.5, 5, 1,0)
\tx[5] = CreateTexture(#PB_Any, 64, 64)
StartDrawing(TextureOutput(\tx[5]))
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor($3B3832) : BackColor($86807D)
LinearGradient(0, 0, 64, 64)
Box(0, 0, 64, 64)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx[5]))
MaterialCullingMode(\ma, #PB_Material_NoCulling)
ScaleMaterial(\ma, 0.5, 0.5)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), -0.5, 0.2, -0.27)
RotateEntity(\id, 30, 0, 0)
EndWith
With ch\tail[0]
\ms = CreateCylinder(#PB_Any, 0.1, 1)
TransformMesh(\ms, 0, 0, 0, 1.0, 1.5, 0.6, 0, 0, 0)
\tx[0] = CreateTexture(#PB_Any, 1024, 1024)
StartDrawing(TextureOutput(\tx[0]))
If TailFont > 0
DrawingFont(FontID(TailFont))
EndIf
DrawingMode(#PB_2DDrawing_AlphaBlend)
Box(0, 0, 1024, 1024, $FFDEDADA)
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(420, 148, "GalCorp FBE-16F9", $FFFF4C5E)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx[0]))
MaterialCullingMode(\ma, #PB_Material_NoCulling)
MaterialFilteringMode(\ma, #PB_Material_Anisotropic, 8)
RotateMaterial(\ma, 90, 0, 0)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), -1.9, 0.8, 0)
RotateEntity(\id, 0, 0, 90)
EndWith
With ch\tail[1]
\ms = CreateCylinder(#PB_Any, 0.1, 1)
TransformMesh(\ms, 0, 0, 0, 0.8, 0.5, 0.6, 0, 0, 0)
\tx[1] = CreateTexture(#PB_Any, 2048, 2048)
StartDrawing(TextureOutput(\tx[1]))
DrawingMode(#PB_2DDrawing_AlphaBlend)
Box(0, 0, 2048, 2048, $FFDEDADA)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx[1]))
MaterialCullingMode(\ma, #PB_Material_NoCulling)
MaterialFilteringMode(\ma, #PB_Material_Anisotropic, 8)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), -2.79, 0.95, 0)
RotateEntity(\id, 0, 0, 45)
EndWith
With ch\rotorGear
\ms = CreateCylinder(#PB_Any, 0.04, 0.1)
\tx[0] = CreateTexture(#PB_Any, 128, 128)
StartDrawing(TextureOutput(\tx[0]))
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor($3B3832) : BackColor($86807D)
LinearGradient(10, 10, 54, 54)
Box(0, 0, 64, 64)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx[0]))
MaterialCullingMode(\ma, #PB_Material_NoCulling)
MaterialFilteringMode(\ma, #PB_Material_Anisotropic, 8)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 1.5, 0)
EndWith
With ch\TailGear
\ms = CreateCylinder(#PB_Any, 0.02, 0.05)
\tx[0] = CreateTexture(#PB_Any, 128, 128)
StartDrawing(TextureOutput(\tx[0]))
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor($3B3832) : BackColor($86807D)
LinearGradient(10, 10, 54, 54)
Box(0, 0, 64, 64)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx[0]))
MaterialCullingMode(\ma, #PB_Material_NoCulling)
MaterialFilteringMode(\ma, #PB_Material_Anisotropic, 8)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0, 0)
RotateEntity(\id, 90, 0, 0)
EndWith
With ch\MainRotor[0]
\ms = CreateCylinder(#PB_Any, 0.2, 10)
TransformMesh(\ms, 0, 0, 0, 0.1, 0.01, 10, 0, 0, 0)
\tx[0] = CreateTexture(#PB_Any, 128, 128)
StartDrawing(TextureOutput(\tx[0]))
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor($3B3832) : BackColor($86807D)
LinearGradient(10, 10, 54, 54)
Box(0, 0, 64, 64)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx[0]))
MaterialCullingMode(\ma, #PB_Material_NoCulling)
MaterialFilteringMode(\ma, #PB_Material_Anisotropic, 8)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0, 0)
RotateEntity(\id, 0, 0, 90)
EndWith
With ch\MainRotor[1]
\ms = CreateCylinder(#PB_Any, 0.2, 10)
TransformMesh(\ms, 0, 0, 0, 0.1, 0.01, 10, 0, 0, 0)
\tx[1] = CreateTexture(#PB_Any, 128, 128)
StartDrawing(TextureOutput(\tx[1]))
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor($3B3832) : BackColor($86807D)
LinearGradient(10, 10, 54, 54)
Box(0, 0, 64, 64)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx[1]))
MaterialCullingMode(\ma, #PB_Material_NoCulling)
MaterialFilteringMode(\ma, #PB_Material_Anisotropic, 8)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0, 0)
RotateEntity(\id, 90, 0, 90)
EndWith
With ch\tailRotor[0]
\ms = CreateCylinder(#PB_Any, 0.1, 5)
TransformMesh(\ms, 0, 0, 0, 0.07, 0.01, 3, 0, 0, 0)
\tx[0] = CreateTexture(#PB_Any, 128, 128)
StartDrawing(TextureOutput(\tx[0]))
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor($3B3832) : BackColor($86807D)
LinearGradient(10, 10, 54, 54)
Box(0, 0, 64, 64)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx[0]))
MaterialCullingMode(\ma, #PB_Material_NoCulling)
MaterialFilteringMode(\ma, #PB_Material_Anisotropic, 8)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0, 0)
RotateEntity(\id, 0, 90, 0)
EndWith
With ch\tailRotor[1]
\ms = CreateCylinder(#PB_Any, 0.1, 5)
TransformMesh(\ms, 0, 0, 0, 0.07, 0.01, 3, 0, 0, 0)
\tx[1] = CreateTexture(#PB_Any, 128, 128)
StartDrawing(TextureOutput(\tx[1]))
DrawingMode(#PB_2DDrawing_Gradient)
FrontColor($3B3832) : BackColor($86807D)
LinearGradient(10, 10, 54, 54)
Box(0, 0, 64, 64)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx[1]))
MaterialCullingMode(\ma, #PB_Material_NoCulling)
MaterialFilteringMode(\ma, #PB_Material_Anisotropic, 8)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, 0, 0)
RotateEntity(\id, 90, 90, 0)
EndWith
;Attachments
ch\bodyNode = CreateNode(#PB_Any, 0, 0, 0)
ch\mainrotorNode = CreateNode(#PB_Any, 0, 1.6, 0)
ch\tailrotorNode = CreateNode(#PB_Any, -2.951, 1.1, -0.082)
With ch
AttachNodeObject(\bodyNode, EntityID(\body\id))
AttachNodeObject(\bodyNode, EntityID(\legs[0]\id))
AttachNodeObject(\bodyNode, EntityID(\legs[1]\id))
AttachNodeObject(\bodyNode, EntityID(\legs[2]\id))
AttachNodeObject(\bodyNode, EntityID(\legs[3]\id))
AttachNodeObject(\bodyNode, EntityID(\legs[4]\id))
AttachNodeObject(\bodyNode, EntityID(\legs[5]\id))
AttachNodeObject(\bodyNode, EntityID(\rotorGear\id))
AttachNodeObject(\bodyNode, EntityID(\tail[0]\id))
AttachNodeObject(\bodyNode, EntityID(\tail[1]\id))
AttachNodeObject(\mainrotorNode, EntityID(\MainRotor[0]\id))
AttachNodeObject(\mainrotorNode, EntityID(\MainRotor[1]\id))
AttachNodeObject(\tailrotorNode, EntityID(\TailRotor[0]\id))
AttachNodeObject(\tailrotorNode, EntityID(\TailRotor[1]\id))
AttachNodeObject(\tailrotorNode, EntityID(\TailGear\id))
\mainobject\ms = CreateCube(#PB_Any, 0.01)
TransformMesh(\mainobject\id, 0, 0, 0, 3, 0.2, 3, 0, 0, 0)
UpdateMeshBoundingBox(\mainobject\ms)
\mainobject\id = CreateEntity(#PB_Any, MeshID(\mainobject\ms), #PB_Material_None, 0, 0, 0)
HideEntity(\mainobject\id, #True)
AttachEntityObject(\mainobject\id, "", NodeID(\bodyNode))
AttachEntityObject(\mainobject\id, "", NodeID(\mainrotorNode))
AttachEntityObject(\mainobject\id, "", NodeID(\tailrotorNode))
CreateEntityBody(\mainobject\id, #PB_Entity_BoxBody, 0.019)
EndWith
sn = LoadSound(#PB_Any, "chop_01.wav")
ProcedureReturn #True
EndProcedure
Procedure.i CreateScene()
Protected col.i, x.i, y.i, z.i
With ground
\ms = CreateCube(#PB_Any, 1)
TransformMesh(\ms, 0, 0, 0, 400, 0.5, 400, 0, 0, 0)
UpdateMeshBoundingBox(\ms)
\tx = CreateTexture(#PB_Any, 2048, 2048)
StartDrawing(TextureOutput(\tx))
DrawingMode(#PB_2DDrawing_AlphaBlend)
Box(0, 0, 2048, 2048, $FF9FA0A3)
DrawingMode(#PB_2DDrawing_AlphaBlend)
For x = 1 To 2047 Step 256
For y = 1 To 2047 Step 256
Box(x, y+64, 256, 32, $FF6F7170)
Box(x+64, y, 32, 256, $FFEFEEEC)
Next y
Next x
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx))
MaterialFilteringMode(\ma, #PB_Material_Anisotropic, 8)
ScaleMaterial(\ma, 0.1, 0.1)
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), 0, -0.6, 0)
CreateEntityBody(\id, #PB_Entity_BoxBody, 0)
EndWith
ProcedureReturn #True
EndProcedure