Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: PIT on Wed 08/11/2006 23:50:20

Title: Gun Battle?
Post by: PIT on Wed 08/11/2006 23:50:20
How would you script a bullet sprite to go from the edge of you're gun untill it hits something solid ie. a character or wall?
Title: Re: Gun Battle?
Post by: Khris on Thu 09/11/2006 04:45:35
This is one of those questions that get asked over and over again. And it's more of a beginner's question, too. Please use the forum search and check the "read before posting"-stickie in the beginner's forum which contains many links to useful sites such as the Beginner's FAQ.
Title: Re: Gun Battle?
Post by: Baron on Thu 09/11/2006 05:08:36
Well, you could use the "AreCharactersColliding" command, but I never found it very useful since it only compares baselines.  I remember when I was working on my Death Orb arcade game (never finished but workable demo  available here  (http://www.vanwijst.com/games/invasion.zip))  I made target boxes out of character[].x and character[].y variables which triggered scripts in the repeatedly execute part of my global script (although the room script would work fine to if you planned to only have the shooting in one place).  Something like:

if( (character[BULLET].x <= character[BADGUY].x+5) && (character[BULLET].x >= character[BADGUY].x -5)){
  if ((character[BULLET].y <= character[BADGUY].y +10) && (character[BULLET].y >= character[BADGUY].y)){
     
            script here (animation, change variables, blah blah blah)
}
}
   ....would make a target of 10x10 pixels at the foot of the bad guy.  When the bullet's coordinates are inside that target, the repeatedly execute script would be triggered.  It's a pretty simple way to construct a collision system.  Of course with AGS 2.7+ character[].variables have been changed to something shorter....

    ....Unless you're thinking about making a shooting cutscene, in which case it would be a much simpler matter of just reading the manual and moving characters from A to B.


EDIT: Ah yes, a little research is never a bad idea either!
Title: Re: Gun Battle?
Post by: R4L on Thu 09/11/2006 11:46:54
Sorry about this, but can an array be used as an index of collision?
Title: Re: Gun Battle?
Post by: Khris on Thu 09/11/2006 13:16:06
I can't make heads or tails of your question, what do you mean by "index of collision"?
Title: Re: Gun Battle?
Post by: R4L on Thu 09/11/2006 21:20:18
Sort of like checking every pixel of a character. I don't know why I said it like that.  :=
Title: Re: Gun Battle?
Post by: Khris on Fri 10/11/2006 04:31:27
Something like this (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=26307.0)? ;)
Title: Re: Gun Battle?
Post by: R4L on Fri 10/11/2006 18:25:10
Of course how stupid of me.  :D