home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 March / Chip_1998-03_cd.bin / zkuste / SVET_GEO / GEORAY / GEORAY.ZIP / SOURCE.ZIP / RAYCAST / RAYCAST.GOC
Text File  |  1996-03-02  |  6KB  |  233 lines

  1. /***********************************************************************
  2.  *
  3.  * PROJECT:       Raycast
  4.  * FILE:          raycast.goc
  5.  *
  6.  * AUTHOR:        Marcus Gröber
  7.  *
  8.  ***********************************************************************/
  9.  
  10. /*
  11.  ***************************************************************************
  12.  *        Include files
  13.  ***************************************************************************
  14.  */
  15.  
  16. @include <stdapp.goh>
  17. #include <math.h>
  18. #include <stdio.h>
  19.  
  20. @include "raycast.goh"
  21. #include "globals.h"
  22.  
  23.  
  24. /*
  25.  ***************************************************************************
  26.  *        Class & Message Definitions
  27.  ***************************************************************************
  28.  */
  29.  
  30. @class  RaycastProcessClass, GenProcessClass;
  31.   @message void MSG_RAY_PROCESS_GO();
  32.   @message void MSG_RAY_PROCESS_LEFT();
  33.   @message void MSG_RAY_PROCESS_RIGHT();
  34.   @message void MSG_RAY_PROCESS_LOOK();
  35.   @message (GEN_BOOLEAN_GROUP_APPLY_MSG) MSG_RAY_PROCESS_ONOFF_CHANGED;
  36. @endc   /* end of class definition */
  37.  
  38. @classdecl      RaycastProcessClass, neverSaved;
  39.  
  40. /*
  41.  ***************************************************************************
  42.  *        UI Objects
  43.  ***************************************************************************
  44.  */
  45.  
  46. #define OPTION_DRAW_MAP 0x0001
  47.  
  48. /*
  49.  *        Application Object
  50.  */
  51.  
  52. @start    AppResource;
  53.  
  54. @object GenApplicationClass RaycastApp = {
  55.  
  56.     GI_visMoniker = list { @RaycastTextMoniker, @Moniker0, @Moniker1 }
  57.  
  58.     GI_comp = @RaycastPrimary;
  59.  
  60.     gcnList(MANUFACTURER_ID_GEOWORKS,GAGCNLT_WINDOWS) = @RaycastPrimary;
  61. }
  62.  
  63. @visMoniker RaycastTextMoniker = "Raycasting Demo";
  64.  
  65. @include "art\appicon.goh"
  66.  
  67. @end    AppResource;
  68.  
  69. /*
  70.  *              Interface Objects
  71.  */
  72.  
  73. @start  Interface;              /* this resource is for misc UI objects */
  74.  
  75. @object GenPrimaryClass RaycastPrimary  = {
  76.     GI_comp = @RaycastLook,
  77.               @LeftTrigger,@GoTrigger,@RightTrigger,@OptionsMenu
  78. @ifdef DO_ERROR_CHECKING
  79.     ,@RedrawTime
  80. @endif
  81.     ;
  82.     HINT_SIZE_WINDOW_AS_DESIRED;
  83.     HINT_DISPLAY_NOT_RESIZABLE;
  84. }
  85.  
  86. @object RaycastClass RaycastLook = {
  87.     RCI_plx = 192;
  88.     RCI_ply = 192;
  89.     RCI_plw = 0;
  90.     RCI_drawMap = FALSE;
  91. }
  92.  
  93. @object GenInteractionClass OptionsMenu = {
  94.     GI_visMoniker = "?";
  95.     GI_comp = @OnOffOptions,@LookTrigger;
  96.     GII_visibility = GIV_POPUP;
  97.     HINT_SEEK_SLOT = 4;
  98. }
  99.  
  100. @object GenBooleanGroupClass OnOffOptions = {
  101.     GI_comp = @OptionDrawMap;
  102.     GBGI_destination = process;
  103.     GBGI_applyMsg = MSG_RAY_PROCESS_ONOFF_CHANGED;
  104.     GBGI_selectedBooleans = 0;
  105. }
  106.  
  107. @object GenBooleanClass OptionDrawMap = {
  108.     GI_visMoniker = 'M',"Draw Map";
  109.     GBI_identifier = OPTION_DRAW_MAP;
  110. }
  111.  
  112. @object GenTriggerClass LeftTrigger = {
  113.     GI_visMoniker = "Left";
  114.     GTI_actionMsg = MSG_RAY_PROCESS_LEFT;
  115.     GTI_destination = process;
  116.     HINT_SEEK_MENU_BAR;
  117.     HINT_SEEK_SLOT = 0;
  118. }
  119. @object GenTriggerClass GoTrigger = {
  120.     GI_visMoniker = "Go";
  121.     GTI_actionMsg = MSG_RAY_PROCESS_GO;
  122.     GTI_destination = process;
  123.     HINT_SEEK_MENU_BAR;
  124.     HINT_SEEK_SLOT = 1;
  125. }
  126. @object GenTriggerClass RightTrigger = {
  127.     GI_visMoniker = "Right";
  128.     GTI_actionMsg = MSG_RAY_PROCESS_RIGHT;
  129.     GTI_destination = process;
  130.     HINT_SEEK_MENU_BAR;
  131.     HINT_SEEK_SLOT = 2;
  132. }
  133. @object GenTriggerClass LookTrigger = {
  134.     GI_visMoniker = "Look";
  135.     GTI_actionMsg = MSG_RAY_PROCESS_LOOK;
  136.     GTI_destination = process;
  137. }
  138.  
  139. @ifdef DO_ERROR_CHECKING
  140. @object GenGlyphClass RedrawTime = {
  141.     GI_visMoniker = "";
  142. }
  143. @endif
  144.  
  145. @end Interface;
  146.  
  147. /*
  148.  ***************************************************************************
  149.  *                     Code for RaycastProcessClass
  150.  ***************************************************************************
  151.  */
  152. @method RaycastProcessClass, MSG_GEN_PROCESS_OPEN_APPLICATION
  153. {
  154.     @callsuper();
  155.     @send RaycastLook::MSG_RAYCAST_INIT_TABLES();
  156.                                         /* set up tables for Raycast object */
  157.     @call RaycastApp::MSG_GEN_APPLICATION_INSTALL_TOKEN();
  158.                                         /* install token if not already there */
  159. }
  160.  
  161. @method RaycastProcessClass, MSG_RAY_PROCESS_GO
  162. {
  163.     sword plx,ply,plw;
  164.  
  165.     @call RaycastLook::MSG_RAYCAST_GET_PLAYER(&plx,&ply,&plw);
  166.  
  167.     plx += IntegerOf(GrMulWWFixed(x_winkel_tab[plw],MakeWWFixed(50)));
  168.     ply += IntegerOf(GrMulWWFixed(y_winkel_tab[plw],MakeWWFixed(50)));
  169.  
  170.     if( maze[plx>>TEX_SHIFT][ply>>TEX_SHIFT]==' ' )
  171.       @send RaycastLook::MSG_RAYCAST_SET_PLAYER(plx,ply,plw);
  172. }
  173.  
  174. @method RaycastProcessClass, MSG_RAY_PROCESS_LEFT
  175. {
  176.     sword plx,ply,plw;
  177.  
  178.     @call RaycastLook::MSG_RAYCAST_GET_PLAYER(&plx,&ply,&plw);
  179.  
  180.     plw+=(ANZ_WINKEL/32);
  181.     if(plw>=ANZ_WINKEL)
  182.       plw-=ANZ_WINKEL;
  183.  
  184.     @send RaycastLook::MSG_RAYCAST_SET_PLAYER(plx,ply,plw);
  185. }
  186.  
  187. @method RaycastProcessClass, MSG_RAY_PROCESS_RIGHT
  188. {
  189.     sword plx,ply,plw;
  190.  
  191.     @call RaycastLook::MSG_RAYCAST_GET_PLAYER(&plx,&ply,&plw);
  192.  
  193.     plw-=(ANZ_WINKEL/32);
  194.     if(plw<0)
  195.       plw+=ANZ_WINKEL;
  196.  
  197.     @send RaycastLook::MSG_RAYCAST_SET_PLAYER(plx,ply,plw);
  198. }
  199.  
  200. @method RaycastProcessClass, MSG_RAY_PROCESS_ONOFF_CHANGED
  201. {
  202.     @send RaycastLook::MSG_RAYCAST_SET_MAP_MODE(
  203.       (selectedBooleans & OPTION_DRAW_MAP)?TRUE:FALSE);
  204. }
  205.  
  206. @method RaycastProcessClass, MSG_RAY_PROCESS_LOOK
  207. {
  208. @ifdef DO_ERROR_CHECKING
  209.     dword time1,time2;
  210.     char buf[80];
  211. @endif
  212.     sword plx,ply,plw;
  213.     int i;
  214.  
  215.     @call RaycastLook::MSG_RAYCAST_GET_PLAYER(&plx,&ply,&plw);
  216.  
  217. @ifdef DO_ERROR_CHECKING
  218.     time1=TimerGetCount();
  219. @endif
  220.     for(i=0; i<32; i++)
  221.     {
  222.       plw+=(ANZ_WINKEL/32);
  223.       if(plw>=ANZ_WINKEL)
  224.         plw-=ANZ_WINKEL;
  225.       @call RaycastLook::MSG_RAYCAST_SET_PLAYER(plx,ply,plw);
  226.     }
  227. @ifdef DO_ERROR_CHECKING
  228.     time2=TimerGetCount();
  229.     sprintf(buf,"Time to redraw: %5ld ms",(time2-time1)*17/32);
  230.     @call RedrawTime::MSG_GEN_REPLACE_VIS_MONIKER_TEXT(buf,VUM_NOW);
  231. @endif
  232. }
  233.