Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - naylorbrandon

#1
Advanced Technical Forum / projectiles 2
Wed 09/06/2010 04:44:15
I can now launch a bullet, if I change the walk straight function to a move with move-anywhere on. But I only want the bullet to travel on walkable areas, and go in the direction of the mouse, and not some altered course set by the program to. the walk straight function works for my other characters. Why won't it work for criflebullet?
(note, the program is not returning any errors)


function shot_vector(int, int, int, int)
{
  criflebullet.ChangeRoom(1, 0, 0); //places in the test room
  criflebullet.x = cglitch.x;
  criflebullet.y = cglitch.y-50; //places bullet behind player character
  int vectorx;
  int vectory;
  vectorx = (mouse.x+16) - cglitch.x;
  vectory = (mouse.y+32) - cglitch.y; //determine driection to move bullet


  criflebullet.WalkStraight(((cglitch.x) + (vectorx)), ((cglitch.y) + (vectory)));

  return;
}
#2
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;
}
#3
Advanced Technical Forum / projectiles
Tue 08/06/2010 09:22:32
How would I go about writing a script for firing a gun? Would I do a drawimage of a bullet and move it? Or is there a better way
#4
I want my character to move continuously while the arrow key is pressed, but currently, I press a key, he moves an interval, and I have to press the key again before he will move again. Here is my current code:

  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);
SMF spam blocked by CleanTalk