NewWorld3D Example Code
Here is an example of using the NewWorld3D control from Visual Basic:
Private Declare Function PlayMIDI Lib "miniMIDI.DLL" Alias "PLAYMIDI" (fileName As String) As Integer Private Declare Function StopMIDI Lib "miniMIDI.DLL" Alias "STOPMIDI" () As Integer Dim MusicOn As Integer
Private Sub cmd_ChangeMap_Click() myNW.nwSelectMap "C:\Program Files\NewWorld3D\", "flipWorld.txt" End Sub Private Sub cmdStart_Click() myNW.nw3DInit "C:\Program Files\NewWorld3D\", "maze.txt" End Sub Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Dim tempx As Integer, tempy As Integer If KeyCode = 87 Then ' w key myNW.nwMoveForward ElseIf KeyCode = 65 Then ' a key myNW.nwTurnLeft ElseIf KeyCode = 83 Then ' s key myNW.nwMoveBackward ElseIf KeyCode = 68 Then ' d key myNW.nwTurnRight ElseIf KeyCode = 32 Then myNW.nwOpenCloseDoor End If tempx = myNW.nwGetPosX: tempy = myNW.nwGetPosY tempx = tempx / 64: tempy = tempy / 64 If (tempx < 990 And tempx > 920) And (tempy < 2000 And tempy > 1950) Then txt_Status = "Meet the buddha" ElseIf tempx > 12 And tempx < 18 And tempy > 29 And tempy < 32 Then txt_Status = "Listen to my music!" PlayMIDI "Beet5.MID" MusicOn = True Else txt_Status = "X:" & tempx & " Y:" & tempy If MusicOn Then MusicOn = False StopMIDI End If End If KeyCode = 0 End Sub Private Sub Form_Terminate() If MusicOn Then MusicOn = False StopMIDI End If End Sub