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

Messages - naylorbrandon

#1
Advanced Technical Forum / Re: projectiles 2
Wed 09/06/2010 20:24:14
That did it! Thanks for all the help guys!
#2
Advanced Technical Forum / Re: projectiles 2
Wed 09/06/2010 16:30:13
I've tried everything you guys have posted, but the result does not change. I know the bullet is being placed at a valid location because the function works if I substitute "move" for "walkstraight." But I can't use "move" because it changes the course of the bullet if I click outside a walkable area. Also, the "walk" function produces the same results as a the "walkstraight" function, but "move" works almost the way I want it. I guess what I really need is something along the lines of a "movestraight" function, if it exists.
#3
Advanced Technical Forum / Re: projectiles 2
Wed 09/06/2010 05:25:13
the bullet does not appear at all.
#4
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;
}
#6
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;
}
#7
Advanced Technical Forum / Re: projectiles
Wed 09/06/2010 01:24:21
I got it working by making the bullets a character. I'm going to see what I can do about duplicate characters, or possibly make multiple copies of the bullet char.
thanks for the help!
#8
Advanced Technical Forum / Re: projectiles
Tue 08/06/2010 23:11:25
How should I summon the bullet image? If i use draw, can I move the drawing, and erase just the bullet after it's run its course? Or should I summon it as a character?
#9
Advanced Technical Forum / Re: projectiles
Tue 08/06/2010 20:58:37
when I click, i want the image of the bullet to travel from the character and move in the direction of the cursor, but to continue past the cursor such that if points A, B, and C make a line, A being the character, B being the mouse, the projectile would travel past B and go on through C.

One way I've thought about doing this is using the draw line tool instead of an image, but when I try to erase the line it removes my background.
#10
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
#11
It's working now!
Thank you!
#12
Ok, thanks! But, how do I do that?
#13
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