home *** CD-ROM | disk | FTP | other *** search
/ DarkBASIC - The Ultimate 3D Game Creator / PCactive 8 CD1 - DarkBasic.iso / SOFTWARE / DEMOS / Technology demos / gun / gun.dba < prev    next >
Encoding:
Text File  |  2001-01-25  |  3.3 KB  |  89 lines

  1. remstart
  2.             *-----------------------------------------------*
  3.             |                                               |
  4.             |     Gun Technology Demo                       |
  5.             |     Version 1.01 - 25th January 2001          |
  6.             |                                               |
  7.             |     Author:  Rob Moran (theGecko)             |
  8.             |     Web:     http://www.gecko.f2s.com        |
  9.             |     E-Mail:  gecko@f2s.com                    |
  10.             |     AIM:     Rob M0RAN                        |
  11.             |     ICQ#:    105558276                        |
  12.             |                                               |
  13.             |     This demonstration shows a reflection     |
  14.             |     technique known as 'Chrome Wrap'          |
  15.             |                                               |
  16.             |     100's - images/sprites                    |
  17.             |     200's - objects                           |
  18.             |                                               |
  19.             *-----------------------------------------------*
  20. remend
  21.  
  22. `------------------------------------------------------SETUP------------------------------------------------------
  23.  
  24. set display mode 800,600,16
  25. autocam off
  26. hide mouse
  27. sync on
  28. backdrop on
  29. color backdrop rgb(0,0,0)
  30.  
  31. `-----------images
  32.  
  33. load image "map1.bmp",101
  34. load image "map2.bmp",102
  35. load image "map3.bmp",103
  36. load image "map4.bmp",104
  37. load image "text1.bmp", 106
  38. load image "text2.bmp", 107
  39.  
  40. `convert image to sprite to make it see-through
  41. sprite 1,0,0,106
  42. sprite 2,200,560,107
  43.  
  44. `-----------models
  45.  
  46. load object "gun.3ds",201
  47. position object 201,0,0,220
  48. texture object 201,101
  49. ghost object on 201
  50.  
  51. `----------------------------------------------------MAIN LOOP----------------------------------------------------
  52.  
  53. do
  54.    `get any mouse movements
  55.    anglex#=wrapvalue(anglex#-mousemovey())
  56.    angley#=wrapvalue(angley#-mousemovex())
  57.  
  58.    `rotate object
  59.    rotate object 201, anglex#, angley#, 0.0
  60.  
  61.    `this is the funky bit - move the texture offset of the reflection map in the opposite
  62.    `direction as the mouse moves, thus keeping the texture facing the camera
  63.    `the current angle must be tested to counteract the texture scrolling the wrong way
  64.    if anglex# > 90 & anglex# < 270
  65.       scroll object texture 201, (mousemovex()*0.00275), 0.0-(mousemovey()*0.0055)
  66.    else
  67.       scroll object texture 201, (mousemovex()*0.00275), (mousemovey()*0.0055)
  68.    endif
  69.         `                                         ^-----------------------^-------- these numbers work for
  70.         `                                                                           any model/texture
  71.    `move camera in or out when mouse buttons pressed
  72.    if mouseclick()=1 then move camera 5
  73.    if mouseclick()=2 then move camera -5
  74.  
  75.    `change 'ghost' property of object on + and - keys
  76.    if keystate(74) then ghost object off 201
  77.    if keystate(78) then ghost object on 201
  78.  
  79.    `change reflection map on keys '1' to '4'
  80.    if keystate(2) then texture object 201,101
  81.    if keystate(3) then texture object 201,102
  82.    if keystate(4) then texture object 201,103
  83.    if keystate(5) then texture object 201,104
  84.  
  85.    sync
  86. loop
  87.  
  88. `------------------------------------------------------END--------------------------------------------------------
  89.