difficulty calling function

Started by naylorbrandon, Wed 09/06/2010 01:32:28

Previous topic - Next topic

naylorbrandon

I'm trying to call a function for bullet trajectory, but I can't call the function, and the manual isn't very specific about function syntax. As it is, it says the function shot_vector is an undefined token.

the function call is in the mouse click function, and shot_vector, the function I'm trying to call is at the bottom of the code.

here's the code, all of this is in global.asc.    Thanks

// main global script file

// called when the game starts, before the first room is loaded
function game_start()
{
KeyboardMovement.SetMode(eKeyboardMovement_Pressing);

}

// put anything you want to happen every game cycle in here
function repeatedly_execute()
{
 
}

// called when a key is pressed. keycode holds the key's ASCII code
function on_key_press(eKeyCode keycode)
{
  if (IsGamePaused()) keycode = 0; // game paused, so don't react to keypresses
 
  if (keycode == eKeyCtrlQ) QuitGame(1); // Ctrl-Q
  if (keycode == eKeyF9) RestartGame(); // F9
  if (keycode == eKeyF12) SaveScreenShot("scrnshot.pcx");  // F12
  if (keycode == eKeyCtrlS) Debug(0,0); // Ctrl-S, give all inventory
  if (keycode == eKeyCtrlV) Debug(1,0); // Ctrl-V, version
  if (keycode == eKeyCtrlA) Debug(2,0); // Ctrl-A, show walkable areas
  if (keycode == eKeyCtrlX) Debug(3,0); // Ctrl-X, teleport to room
 
  /*  //brandon's stuff, now useless
  if (IsKeyPressed(eKeyUpArrow) == 1)
  cglitch.Walk(cglitch.x, cglitch.y-10);
  if (IsKeyPressed(eKeyDownArrow) == 1)
  cglitch.Walk(cglitch.x, cglitch.y+10);
  if (IsKeyPressed(eKeyRightArrow) == 1)
  cglitch.Walk(cglitch.x+10, cglitch.y);
  if (IsKeyPressed(eKeyLeftArrow) == 1)
  cglitch.Walk(cglitch.x-10, cglitch.y);
  //end brandon
*/

  if (IsKeyPressed(eKeyQ) == 1)
  {
   /* DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
surface.DrawImage(cglitch.x,  cglitch.y-60, 11);
surface.Release();*/
   
   
  /*  DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
surface.DrawingColor = 14;
surface.DrawLine(cglitch.x, cglitch.y, mouse.x+16, mouse.y+16);
surface.Clear();
surface.Release();
*/


  }




}
#sectionend on_key_press  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
{
      combatroom = 0;
  if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
  {
  }
  else if (button == eMouseLeft)
  {
    ProcessClick(mouse.x,mouse.y, mouse.Mode);
    cglitch.FaceLocation(mouse.x+16,  mouse.y+16);
   
    if (mouse.Mode == eModeCursor10)
     {
       shot_vector (cglitch.x, cglitch.y, mouse.x, mouse.y);

      /* criflebullet.ChangeRoom(1, 0, 0);
       criflebullet.x = cglitch.x;
       criflebullet.y = cglitch.y-50;
       criflebullet.Move(mouse.x,  mouse.y);*/
     }
  }
  else if (button == eMouseRight) // right-click, so cycle cursor
  {   
    mouse.SelectNextMode();
  }
 
}
#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE





#sectionstart interface_click  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button)
{
  // OBSOLETE, NOT USED IN AGS 2.7 AND LATER VERSIONS
}
#sectionend interface_click  // DO NOT EDIT OR REMOVE THIS LINE


function cglitch_Mode8()
{

}

function dialog_request(int param) {
}


function shot_vector(int cglitch.x, int cglitch.y, int mouse.x,  int mouse.y)
{

  criflebullet.ChangeRoom(1, 0, 0);
  criflebullet.Move(cglitch.x,  cglitch.y);
  int vectorx;
  int vectory;
  vectorx = mouse.x - cglitch.x;
  vectory = mouse.y - cglitch.y;
  while((-30<criflebullet.x<830) && (-30<criflebullet.y<630))
  {
  criflebullet.Move(criflebullet.x+vectorx, criflebullet.y+vectory);
  }
  return;
}

Gilbert

Move the function shot_vector() on top of on_mouse_click(). You cannot call a function that is declared after the current one.


SMF spam blocked by CleanTalk