October 28, 2020, 05:34:23 AM

Author Topic: [bb] Simple Fog by Strider Centaur [ 1+ years ago ]  (Read 1491 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Simple Fog by Strider Centaur [ 1+ years ago ]
« on: June 29, 2017, 12:28:43 AM »
Title : Simple Fog
Author : Strider Centaur
Posted : 1+ years ago

Description : This demo a test of fog Im using for my 3D FP MMO about living under the sea is to test the fog system.  Its really super simple.

-- Updated 11/22/2004 -----
1) Used Killwoods city gen stuff to put more stuff in the scene.

2) Added improved movement control to include all degrees of rotation.  Contoles are displayed at bottom of screen.

3) Now with collision support for sea floor and objects.


Code :
Code: BlitzBasic
  1. ; The Aquatic Demo, a demo to experiment with underwater effects.
  2. ;
  3. ; Would like to grow this into a mer based game, in this demo the goals are:
  4. ;
  5. ; 1) Creat a pleasing underwater experiance in sight, sound and movement
  6. ; 2) Support multiple player access to allow it to be shared
  7. ; 3) incorperate the 3D tile system based using a 2D tile system to layout the sea floor
  8. ; 4) for comparison, try alternate terrain builds using other tool.
  9. ; 5) experement heavily with strong lighting affects and LOD in relation to intensity and fog.
  10. ; 6) create models and animation sequances that match the movement to produce a smooth integrated feel.
  11. ; 7) Get pats on the back from my Blitz Pals.  Uhh, huh, thats it yea.  LOL
  12. ;
  13. ;
  14.  
  15. ; A few things we never want to change
  16. Const WALL_TYPE = 3
  17. Const SEA_FLOOR_TYPE = 2
  18. Const PLAYER_TYPE = 1
  19. ; Keeping it simple
  20. ; Where possible I will beg barrow and umm barrow as mutch from other peoples work ( with their permisions ) as possible
  21. ; I will also use the refinement process for development, that is, first get it all working, then make it look good and
  22. ; optimize as needed.
  23.  
  24.  
  25. ; Step 1  the Player type needed for the Network thingy
  26. Type pdata
  27.         Field playerID          ; The NetID of this player
  28.         Field name$                     ; the Name of this player shown over head.
  29.         Field x#                        ; Now if Blitz supported Vectors this would be so much easier
  30.         Field y#                        ; these are movement variable not positional ones
  31.         Field z#
  32.         Field wx#                       ; world postion These on the otherhand, are postional variables
  33.         Field wy#                      
  34.         Field wz#
  35.         Field yaw#                      ; ya know this 3D world stuff is gona really take some experimenting to get these right
  36.         Field pitch#
  37.         Field roll#
  38.         Field speed#            ; yea see, its like this, things underwater do not instantly start and stop like in most FPSs.
  39.         Field accell#           ; so we need to know how fast things can speed up
  40.         Field decell#           ; and slow down
  41.         Field mesh                      ; give you one guess what goes here, if you guess the mesh Entity handle, you'd be right.
  42.         Field pivot                     ; used for movemement
  43. End Type
  44.  
  45. Type timer
  46.         Field timerID
  47.         Field tdelay
  48.         Field lasttime
  49.         Field mode                      ; 0 off, 1 + number of times to triger, -1 allways on.
  50.         Field triggered         ; 1+ = number of times triggered, should be cleared to 0 when tested. max value will never exceed 32000
  51. End Type
  52. ; So Im going to make some assumptions on screen size and modes here, I like windowed
  53. ; but if you one of those full screen types, go ahead, change it.
  54. ; Why globals, Well sure I can get this info from inside blitz, but to set the data this is how I like to do it.
  55. ; no constants this time, its nice to be able to define defaults that can be changed.  :)
  56. Global viewwidth = 800
  57. Global viewheight = 600
  58. Global viewmode = 2
  59. Global viewcolors = 32
  60.  
  61.  
  62. ;Never sure if this is needed or not, but I do it anyway
  63. Global ppivot
  64. Global pcammera
  65. Global pfog1
  66. Global pfog2
  67. Global pfog3
  68. Global pfogtex
  69. Global plight1
  70. Global plight2
  71. Global surfacedownplane
  72. Global surfaceupplane
  73. Global seafloorplane
  74. Global surfacedowntex
  75. Global surfaceuptex
  76. Global seafloortex
  77.  
  78.  
  79. ; and our dimmed arrays
  80. Dim cube%(100,100)
  81. Dim sphere%(100,100)
  82.  
  83.  
  84. ;Timers?  We don't need no stinking timers!  Well maybe just a few
  85. ;
  86.  
  87.                                        
  88. Global fratetimer   ; this will hold the frame rate timer handel
  89. Global frdelay = 1000/60        ; this is sort of 60FPS  adjust to taste
  90.  
  91. Global gamestatus       ; used to track the return status codes from functions
  92.  
  93. ; Main Loops should be very clean, no uneeded logic, no variables that are not predefined above
  94. ; easy and clean.
  95. ;============= MAIN GAME LOOP =================
  96. gamestatus = Init_Game()                ; make a non-stop timer for FPS and game controle
  97. If gamestatus = 1 Then RuntimeError ("Could not INITIALIZE GRAPHICSMODE")
  98. If gamestatus = 2 Then RuntimeError ("PDATA type does not exist, not created")
  99.  
  100. Init_World("demo")                              ; Load the game world sceen data, we make the basice in init_game, this loads
  101.                                                                 ; models for details in terrain and sturctures.
  102. fratetimer = Init_Timer( frdelay, -1 )
  103. Init_Collisions()
  104. While Not KeyHit(1)
  105.         If TimerCheck(fratetimer) Then
  106.                 InputUpdate()
  107.                 ;NetHandler()
  108.                 CollisionHandler()
  109.                 MovementUpdate()
  110.                 RenderUpdate()
  111.                 ;NetUpdate()
  112.         EndIf
  113.         ;AIUpdate()
  114. Wend
  115.  
  116. End
  117.  
  118. ;=============  END MAIN GAME LOOP ============
  119.  
  120.  
  121.  
  122. ; you will find Im function crazy, I think a game or any code should have a main section of almost purely function
  123. ; calls and the main game loop and thats it.
  124.  
  125. ; Setup all the pre demo stuff and screen modes
  126. Function Init_Game%()
  127.         AppTitle " The Merfolk Demo "
  128.         If Not GfxMode3DExists(viewwidth, viewheight, viewcolors) Then Return (1)
  129.         Graphics3D viewwidth, viewheight, viewcolors, viewmode
  130.         SetBuffer BackBuffer()
  131.        
  132.         ;creat the first pdata so we can load up the player info
  133.         p.pdata = New pdata
  134.         If p = Null Then Return (2)
  135.  
  136.         ; ok lets set up the player pivot parent and camera ( going FP here )
  137.         ppivot = CreatePivot ()
  138.         pcammera = CreateCamera(ppivot)
  139.         EntityType ppivot, PLAYER_TYPE
  140.         EntityRadius ppivot, 1.4
  141.        
  142.         ;light?  Yea the spot light its so handing to see things.
  143.         ; but Blitz is do kind to give us a default one we simply need to change the color
  144.         ; nice semi-dark blue for now
  145.         CameraFogMode pcammera,1
  146.         CameraFogColor pcammera, 0,0,100
  147.         CameraFogRange pcammera, 1,55                   ; about 100 meters
  148.        
  149.         ; Now we all know that the cammera fog is not Volumetric so we will emmulate this with a few large boxes.
  150.         ; how this works is they are centered on us, and we flip them so we can see the texture on them from the inside.
  151.         ; we then set the alpha levels from low to high as they radiate out from us.  We use 10 such bozes with a .10 alpha
  152.         ; each, the first box in placed right in front of the cammera, so everything is shaded 10% by that one, the others
  153.         ; stretch out from there till 100% opacity is reached at max range.  We can increase viewing range by simple
  154.         ; decreasing the alpha as needed.  Above water is would be reasonable to all layers to 0 opacity, or for those fogy
  155.         ; surfuce days, the first 3 or so to 0 and the rest to propper levels for the fog desired.
  156.         ;pfog1 = CreateCube(ppivot)
  157.         ;pfog2 = CreateCube(ppivot)
  158.         ;pfog3 = CreateCube(ppivot)
  159.         ;pfog4 = CreateCube(ppivot)
  160.         ;pfog5 = CreateCube(ppivot)
  161.         ;pfog6 = CreateCube(ppivot)
  162.         ;pfog7 = CreateCube(ppivot)
  163.         ;pfog8 = CreateCube(ppivot)
  164.         ;pfog9 = CreateCube(ppivot)
  165.         ;pfog10 = CreateCube(ppivot)
  166.        
  167.         pfog1 = CreateSphere(8,ppivot)
  168.         pfog2 = CreateSphere(8,ppivot)
  169.         pfog3 = CreateSphere(8,ppivot)
  170.         pfog4 = CreateSphere(8,ppivot)
  171.         pfog5 = CreateSphere(8,ppivot)
  172.         pfog6 = CreateSphere(8,ppivot)
  173.         pfog7 = CreateSphere(8,ppivot)
  174.         pfog8 = CreateSphere(8,ppivot)
  175.         pfog9 = CreateSphere(8,ppivot)
  176.         pfog10 = CreateSphere(8,ppivot)
  177.  
  178.  
  179.         FlipMesh pfog1
  180.         FlipMesh pfog2
  181.         FlipMesh pfog3
  182.         FlipMesh pfog4
  183.         FlipMesh pfog5
  184.         FlipMesh pfog6
  185.         FlipMesh pfog7
  186.         FlipMesh pfog8
  187.         FlipMesh pfog9
  188.         FlipMesh pfog10
  189.         pfogtex = LoadTexture ("texturesfog.bmp")
  190.         EntityTexture pfog1, pfogtex
  191.         EntityTexture pfog2, pfogtex
  192.         EntityTexture pfog3, pfogtex
  193.         EntityTexture pfog4, pfogtex
  194.         EntityTexture pfog5, pfogtex
  195.         EntityTexture pfog6, pfogtex
  196.         EntityTexture pfog7, pfogtex
  197.         EntityTexture pfog8, pfogtex
  198.         EntityTexture pfog9, pfogtex
  199.         EntityTexture pfog10, pfogtex
  200.  
  201.         ; since the alphas tend to add up we try to keep them change at each dispance the same
  202.         ; finally reaching opaque at the tenth box
  203.         EntityAlpha pfog1,.10
  204.         EntityAlpha pfog2,.10
  205.         EntityAlpha pfog3,.10
  206.         EntityAlpha pfog4,.10
  207.         EntityAlpha pfog5,.10
  208.         EntityAlpha pfog6,.10
  209.         EntityAlpha pfog7,.10
  210.         EntityAlpha pfog8,.10
  211.         EntityAlpha pfog9,.10
  212.         EntityAlpha pfog10,.10
  213.  
  214.         ; scale the boxes to cover the range we need
  215.         ScaleEntity pfog1,15,1,1
  216.         ScaleEntity pfog2,15,5,5
  217.         ScaleEntity pfog3,15,10,10
  218.         ScaleEntity pfog4,15,15,15
  219.         ScaleEntity pfog5,20,20,20
  220.         ScaleEntity pfog6,25,25,25
  221.         ScaleEntity pfog7,30,30,30
  222.         ScaleEntity pfog8,35,35,35
  223.         ScaleEntity pfog9,45,45,45
  224.         ScaleEntity pfog10,55,55,55
  225.        
  226.        
  227.         ; more light out there in front of us for that cool distant glow feel
  228.         ; Thats right our water will be a magical happy glowing kind of place
  229.         ; not very realistic but hey we are merfolk, we can do this kind of stuff.  :)
  230.         plight1 = CreateLight(2,ppivot)
  231.         LightColor plight1, 0,100,100
  232.         LightRange plight1, 150
  233.         PositionEntity plight1, 0,20,200
  234.        
  235.         ; and some more light, placed at point of view
  236.         plight2 = CreateLight(3,ppivot)
  237.         LightColor plight2, 0,50,50
  238.         LightRange plight2, 200.0
  239.        
  240.         ; Ok we need the Sea, well 3 planes, yea we will make a sky orb and use it when you get close to surface
  241.         ; The top plane is the furface of the water as seen from above the water, hey we want to jump out of water too.
  242.         ; this one is less transparant than the one from looking up.
  243.         surfacedownplane = CreatePlane()
  244.         PositionEntity surfacedownplane, 0,0.01, 0 ; minor adjustment over plane below it.
  245.         surfacedowntex = LoadTexture("textureswater.bmp")
  246.         EntityAlpha surfacedownplane,.75
  247.         EntityTexture surfacedownplane, surfacedowntex
  248.        
  249.         ; The next one down is the bottom a mostly transparant( hey isn't that translucent? ) plane that we can see the
  250.         ; sky throuh.  Also know that Fog is turned off when we are less than 100 meters from the surface, well in reality
  251.         ; the closer we get the further the max range of the fog raises so its still there, when we are very need the surface
  252.         ; it will extend well beyond the skysphere and thus appear non-present.  Ahh, you ask what about if you look down while
  253.         ; near the surface?  Well silly, since your location in the sphere is very near the upper side of it, the fog will
  254.         ; still be blocking the extreams of the toward the hurizon and bellow the surface, Genius I know, but as a friend
  255.         ; said, why not just use a 5 sided sky box centered on the character and placed above the water? To witch I said, "umm".
  256.         ;surfaceupplane = CreatePlane()
  257.         ;PositionEntity surfaceupplane, 0,0,0
  258.         ;surfaceuptex = LoadTexture("texturewater.bmp")  ; in future will be using 2 sepereate texture for up/down
  259.         ;EntityAlpha surfaceupplane, .30
  260.         ;FlipMesh surfaceupplane
  261.         ; of coarse we cant flip planes, what was I thinking, no big deal will simply make a surface mesh, that way I can
  262.         ; animate it with waves and stuff anyway.  So there.
  263.        
  264.         ; Finally the sea floor, yea, its a big flat sea with a sandy texture, dont like it?  Me either so will be adding
  265.         ; stuff down there real soon.
  266.         seafloorplane = CreatePlane()
  267.         PositionEntity seafloorplane, 0, -300, 0
  268.         seafloortex = LoadTexture("texturesseafloor.bmp")
  269.         EntityTexture seafloorplane, seafloortex
  270.         EntityType seafloorplane, SEA_FLOOR_TYPE
  271.        
  272.         ;initialize the skybox, using my friend idea, see also move_skybox
  273.         ;init_skybox()
  274.        
  275.         ;Set the starting info
  276.         ; sence we don't have spawn points in our wourld yet we get the good ole 0,250,0
  277.         pwx# = 0.0
  278.         pwy# = -299.0   ;we starting out at close to 300 meters down, hows that For working under preasure?  
  279.         pwz# = 0.0
  280.         pyaw# = 0.0
  281.        
  282.        
  283.         ;pmesh = LoadAnimMesh("merperson1.3ds", ppivot);  Hey when I have a model I get to uncomment this.  :)
  284.        
  285.        
  286.         ; position the player in starting location.
  287.         PositionEntity ppivot, pwx, pwy, pwz
  288.         ;PositionEntity pcammera, pwx, pwy, pwz
  289.         ;PositionEntity pfog1, pwx, pwy, pwz
  290.         ;PositionEntity pfog2, pwx, pwy, pwz
  291.         ;PositionEntity pfog3, pwx, pwy, pwz
  292.         ;PositionEntity pfog4, pwx, pwy, pwz
  293.         ;PositionEntity pfog5, pwx, pwy, pwz
  294.         ;PositionEntity pfog6, pwx, pwy, pwz
  295.         ;PositionEntity pfog7, pwx, pwy, pwz
  296.         ;PositionEntity pfog8, pwx, pwy, pwz
  297.         ;PositionEntity pfog9, pwx, pwy, pwz
  298.         ;PositionEntity pfog10, pwx, pwy, pwz
  299.  
  300.        
  301.         Return (0) ; if not true our function was completed without a problem
  302. End Function
  303.        
  304. ;setup collisions
  305. Function Init_Collisions()
  306.         Collisions PLAYER_TYPE, SEA_FLOOR_TYPE,2,3
  307.         Collisions PLAYER_TYPE, WALL_TYPE,2,3
  308. End Function
  309.  
  310. ; Handle collisions    
  311. Function CollisionHandler()
  312.        
  313. End Function
  314.  
  315. ; get input from player
  316. ; Using 3D free flight controls for all 6 degrees of rotation.
  317. Function InputUpdate()
  318.         p.pdata = First pdata
  319.         pyaw# = 0       ; lets make sure we only move if a key is down
  320.         ppitch# = 0;
  321.         p
  322. oll# = 0;
  323.         pz# = 0;
  324.         py# = 0;
  325.         px# = 0;
  326.         ; yaw ( Turn on Y Axis control)
  327.         If KeyDown( 30 ) Then
  328.                 pyaw#=+1
  329.         EndIf
  330.         If KeyDown( 32 )  Then
  331.                 pyaw#=-1
  332.         EndIf
  333.         ; move backward
  334.         If KeyDown( 31 ) Then
  335.                 pz#=-0.4
  336.         EndIf
  337.         ; move forward
  338.         If KeyDown( 17 ) Then
  339.                 pz#=+0.4
  340.         EndIf
  341.         ; strafe Left
  342.         If KeyDown( 16  ) Then
  343.                 px# = -0.4
  344.         End If
  345.         ;strafe right
  346.         If KeyDown( 18 ) Then
  347.                 px# = +0.4
  348.         End If
  349.         ;ascend ( move on Y axis )
  350.         If KeyDown( 57 ) Then
  351.                 py# = +0.4
  352.         EndIf
  353.         ;descend ( on Y axis )
  354.         If KeyDown( 45 ) Then
  355.                 py# = -0.4
  356.         EndIf
  357.         ; pitch control ( turn on X Axis control)
  358.         If KeyDown( 208 ) Then
  359.                 ppitch# =+1
  360.         EndIf
  361.         If KeyDown( 200 ) Then
  362.                 ppitch# = -1
  363.         End If
  364.         ; roll control  ( Turn on Z axis control )
  365.         If KeyDown( 203 ) Then
  366.                 p
  367. oll# = +1
  368.         End If
  369.         If KeyDown( 205 ) Then
  370.                 p
  371. oll# = -1
  372.         End If
  373.  
  374. End Function
  375.  
  376.  
  377. ; Basicly set up BlitzPlay the totally awesome network lib for Blitz.  Woot BP rocks
  378. ; Mode is either Host 0 or client 1
  379. ; port is the port to listen/connect on
  380. ; players is the max number of players
  381. ; ServerIP is the IP address of the game server(host) defaults to localhost at 128.0.0.1
  382. ; return status codes 0 if all went ok.
  383. Function Network_Init%( mode%, port, players%, ServerIP$ = "128.0.0.1" )
  384.  
  385.  
  386.         Return (0)
  387. End Function
  388.  
  389. ; update the network, basicly sends network data and recieves it from network
  390. ; while I use BlitzPlay for this, I use my own wrappers so the netcode
  391. ; stays independant of the game, incase I want to use something else later.
  392. ; returns 0 if all went as planed or errorcode otherwise.
  393. Function NetUpdate%()
  394.  
  395.         Return (0)
  396. End Function
  397.  
  398. ;The heart of the network portion of the demo/game
  399. ; This function handles all incomming messages and sorts/stores/posts the data to the right variables used
  400. ; by other functions like ChatUpdate, MovementUpdate and so forth.
  401. Function NetHandler%()
  402.  
  403.         Return (0)
  404. End Function
  405.  
  406. ; Called after input and NetHandler this function updates all movable objects in the world space
  407. ; basicly cycles through the pdata's and other similar types and adjust there postion to speed ratio
  408. ; based on the timer datas for each object. This will position all players in the game/demo
  409. Function MovementUpdate()
  410.         For p.pdata = Each pdata
  411.                 TurnEntity ppivot, ppitch#, pyaw#, p
  412. oll#
  413.                 MoveEntity ppivot, px#, py#, pz#
  414.                 pwx# = EntityX(ppivot)
  415.                 pwy# = EntityY(ppivot)
  416.                 pwz# = EntityZ(ppivot)
  417.         Next   
  418. End Function
  419.  
  420. ; This function calles all the updateworld and render functions, also handles the HUD information
  421. Function RenderUpdate()
  422.         UpdateWorld
  423.         RenderWorld
  424.         Draw2DHUD()
  425.         Flip
  426. End Function
  427.  
  428.  
  429. ;Create a new timer useing the Delay provided
  430. ; the mode is -1 non-stop, 1+ count down timer, 0 stopped( usually cause countdown has happened )
  431. ; use countdown for cases where you want effects to last for a specific time but dont need to keep
  432. ; updating the effect after that.  powerup durations for example durations for example.
  433. ; return the timer id from the timer type created      
  434. Function Init_Timer%(timeDelay%, mode ="-1")
  435.         utimer = 0
  436.         For t.timer = Each timer
  437.                 If t <> Null Then
  438.                         tiemid = t      imerID
  439.                         If timerid > utimer Then utimer = timerid   ; lets get the highest timer ID so far
  440.                 End If
  441.         Next
  442.         utimer = utimer + 1; lets make this ID one greater than the highest ID so far and thus unique
  443.         t.timer = New timer
  444.                 t       imerID = utimer
  445.                 t       delay = timeDelay
  446.                 tlasttime = MilliSecs ()
  447.                 t       riggered = 0
  448.        
  449.         Return t        imerID
  450. End Function
  451.  
  452. ;Checks the a given timer( by ID ) to see if it has triggered, clearmode 0 (default) will clear the timer if trigger and
  453. ; if so return the number of times it triggerd since last check. Setting the clearmode to none zero will
  454. ; simply return the timer triggered data and not clear it, regardless of if it triggered or not.
  455. ; the default is to clear the trigger data if triggered.
  456. Function TimerCheck%(timerID%, clearmode = 0)
  457.         For t.timer = Each timer
  458.                 If tiemrID% = t imerID Then
  459.                         If t    riggered Then
  460.                                 ttemp = t       riggered
  461.                                 If clearmode = 0 Then t riggered = 0
  462.                                 tlasttime = MilliSecs()
  463.                                 Return (ttemp)
  464.                         End If
  465.                 End If
  466.         Next
  467.         Return (-101)           ;Invalid trigerID
  468. End Function
  469.  
  470. ; loop through all timers and update there triggered stats
  471. Function TimerUpdate()
  472.         For t.timer = Each timer
  473.                 If tmode > -1 Then                                                                      ; is it non-stop or other?
  474.                         If tlasttime + t        delay > MilliSecs() Then    ; did the time expire?
  475.                                 t       riggered = t    riggered + 1                            ; yep, so increment triggered
  476.                                 tlasttime = MilliSecs()                                 ; reset timer.
  477.                                 If tmode > 1 Then                                       ; its a count down timer amd it hasnt counted down yet?
  478.                                         tmode = tmode -1                                ; yep, so count down
  479.                                         If tmode < 0 Then tmode = 0   ; prevent it from any chance of crossing over into a non-stop timer
  480.                                 End If
  481.                         End If
  482.                 Else                                                                                            ; so its a non-stop timer
  483.                         If tlasttime + t        delay > MilliSecs() Then    ; did the time expire?
  484.                                 t       riggered = t    riggered + 1                            ; yep, so increment triggered
  485.                                 tlasttime = MilliSecs()                                 ; reset timer.
  486.                         End If
  487.                 End If
  488.         Next           
  489. End Function
  490.  
  491. ; TimerResetMode lets you change the mode or count of a timer, so that for instance you can restart a stopped
  492. ; countdown timer.  It does no other testing, so if you should use TimerCheck before a reset if you are interested
  493. ; in the timer status before the reset.
  494. Function TimerResetMode( id%, modecount% )
  495.         For t.timer = Each timer
  496.                 If id = t       imerID Then
  497.                         tmode = modecount
  498.                         Return
  499.                 End If
  500.         Next
  501. End Function
  502.  
  503. ; Reset the delay setting of a timer, used for fine tuning a timer at run time, like when else silly?
  504. ; ID is the timer ID and tdelay is the delay for the timer.  It does no other timer opperation, see also TimerResetMode
  505. Function TimerResetDelay( id% , tdelay% )
  506.         For t.timer = Each timer
  507.                 If id = t       imerID Then
  508.                         t       delay = tdelay
  509.                         Return
  510.                 EndIf
  511.         Next
  512. End Function
  513.  
  514.  
  515. ; this handles the zone specific data for this area of the world, it loads all models and terrains
  516. ; repositions player to the propper zone entry point in relations to players present zone settings
  517. ; sets all lighting and rendering options and updates the network to let other players know that this
  518. ; player has left one zone and entered the one specified, including the new players starting location.
  519. ; of coarse in the Demo there is only one zone, but I figured what they heck, better to plan ahead.
  520. ; The data read comes from the zone file, named __zonename__.zon.  These files are located in the zones directory
  521. ; there format???? well to be done still.  But probably very INI in format.
  522. Function Init_World( zone$ )
  523.         zonefile$ = "zones"+ zone$ +".zon"
  524.        
  525.         ; this is just a referance set of shapes set out there in the sea
  526.         ; a bit of random city code by Killwood 04
  527.         For x = 0 To 30
  528.          For y = 0 To 49
  529.  
  530.           Read map
  531.  
  532.            If map = 1
  533.  
  534.             dice = Rand(0,1)
  535.        
  536.             Select dice
  537.  
  538.              Case 0
  539.               cube(x,y) = CreateCube()
  540.               PositionEntity cube(x,y),y * 10,-299,x * 10
  541.           EntityType cube(x,y), WALL_TYPE
  542.             Case 1
  543.              sphere(x,y) = CreateSphere()
  544.              PositionEntity sphere(x,y),y * 10,-299,x * 10
  545.                  EntityType sphere(x,y), WALL_TYPE
  546.  
  547.            End Select
  548.  
  549.         EndIf
  550.  
  551.          Next
  552.         Next
  553. End Function
  554.  
  555.  
  556. ; draws some debugging data to screen.  Will be using surfaces in 3D later, but for now this will do.
  557. ; called by RenderUpdate
  558. Function draw2DHUD()
  559.         linenum = 0            
  560.         For p.pdata = Each pdata
  561.                 linenum = linenume+1
  562.                 Text 10,2+(FontHeight()*linenum),"Player: "+p
  563. ame+" at location: x:"+pwx# +" y:"+pwy# +"z:"+pwz#
  564.         Next
  565.         Text 10, GraphicsHeight()-((FontHeight()+2)*3), "W/S Move Forward / Back, A/D Turn Left / Right, Q/E Strafe Left/Right"
  566.         Text 10, GraphicsHeight()-((FontHeight()+1)*2),"Arrow UP/DOWN Pitch Up/Down, Arrow Left/Right Roll Left/Right"
  567.         Text 10, GraphicsHeight()-((FontHeight()-1)), "Space Bar/X ascend/descend"
  568. End Function
  569.  
  570.  
  571.  
  572. .map
  573.  
  574.  
  575. Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  576. Data 0,1,0,1,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0


Comments :


killwood(Posted 1+ years ago)

 Very Good! Where could I get all the media? Thanks!-Killwood


_PJ_(Posted 1+ years ago)

 Please cpould you provide code just for the fog effect? So we dont need to worry about excess media etc?


Trader3564(Posted 1+ years ago)

 i like it as it is, its better to cut in code than to complete it because someone did not provide the media. After all most of us want to see first before work.


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal