Author Topic: Enemies Shooting Back  (Read 8792 times)

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Enemies Shooting Back
« on: 2006-10-22, 02:46:42 AM »
I need enemies to shoot back at you. So far I've got a special function that makes an aimer sprite on the player. And a function that makes a bullet go towards the aimer on the player therefore aiming at the player. This works great except the bullet doesn't go straight on it's way to the aimer. It zig-zags before it gets to it which is pretty stupid.

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Enemies Shooting Back
« Reply #1 on: 2006-10-23, 12:14:24 AM »
Can anyone help with this problem? ???

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Enemies Shooting Back
« Reply #2 on: 2006-10-23, 05:06:32 AM »
Why do you need an aimer?  Why not just head straight for the player sprite?

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Enemies Shooting Back
« Reply #3 on: 2006-10-25, 12:56:38 AM »
Why do you need an aimer?  Why not just head straight for the player sprite?
I tried that, if the bullet ever misses you it turns around and comes back which I don't like.  :-[ It misses you fairly often since your moving. The aimer sprite is stationary, created where the player is, so it goes at the player. It never misses the aimer because it doesn't move. When the bullet hits the aimer or you the aimer deletes. But the problem is that the bullet swerves from side to side on it's way to the aimer.  :(

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Enemies Shooting Back
« Reply #4 on: 2006-10-25, 06:12:57 AM »
It seems like what you really want is to set the sprite on its course and then just let it fly in a straight line.  Unfortunately there isn't a way to set it on a course that heads toward the player sprite, only some preset path (vector).  But it could be done relatively easy with a piece of script.  Would you be open to trying some script if it were provided?

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Enemies Shooting Back
« Reply #5 on: 2006-10-26, 12:01:51 AM »
Yeh script is fine. But I do have an existing script generated by the scripting wizard used to make the player able to shoot.
« Last Edit: 2006-10-26, 12:10:07 AM by Jam0864 »

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Enemies Shooting Back
« Reply #6 on: 2006-10-26, 06:01:01 PM »
This sample project doesn't use script, and doesn't have any problems zig-zagging as far as I can tell:
http://gamedevprj.sf.net/files/ShootAtPlayer.zip

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Enemies Shooting Back
« Reply #7 on: 2006-10-27, 12:00:06 AM »
That sample project works great! He/she thought of the same idea as me. (Aimer created on top of player bullet goes towards aimer) and I can't see any key differences between this project and mine.

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Enemies Shooting Back
« Reply #8 on: 2006-10-27, 12:04:27 AM »
I just noticed their bullet is a 360 degree sprite and mines an 8 directional sprite. Would that matter?

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Enemies Shooting Back
« Reply #9 on: 2006-10-27, 05:45:24 AM »
I should have said, I made that project yesterday after reading your problem in order to try to provide a better solution for you, but then it turned out that things seemed to work alright without script.
It's very possible that using a 36-state sprite works better than using an 8-state sprite because an 8-state sprite has to accelerate in one of 8 directions while a 36-state sprite can accelerate in 36 directions, being much more precise.  So you might want to try switching to see if that works better for you.  Keep in mind that just because a sprite has 36 states doesn't mean in needs to have 36 different graphics.  If your bullet sprite is large and complex, you could continue using 8 images and just split them into 36 states so that each image maps to 4 or 5 states.  Or you could take it up to 12 images and have each image map to exactly 3 states.

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Enemies Shooting Back
« Reply #10 on: 2006-10-27, 09:06:59 PM »
Ah, I see. I figured 8 directional sprites could go in more than 8 directions because my player sprite on Platformania could go more than 8 directions. Thanks, it works great!  ;D :D :) ;)

cbass

  • Expert
  • Regular
  • *****
  • Posts: 97
  • script this
    • View Profile
    • Squest RPG
Re: Enemies Shooting Back
« Reply #11 on: 2006-10-30, 07:52:56 AM »
8 state sprites can go in more than 8 directions.  Its just a matter of finding the vectors to start them off in, which usually requires script or paths.

(cool, when did this forum get spellcheck :) )

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Enemies Shooting Back
« Reply #12 on: 2006-10-30, 05:49:27 PM »
Note the fine distinction between "accelerate in 8 directions" and "move in 8 directions".  While an 8-state sprite can move in a countless number of direction, it can only accelerate in 8 directions when following another sprite because, just like a player sprite controlled by input, an 8-state sprite following another sprite is internally simulating arrow key presses to follow the sprite.

Scarecrow(sXs)

  • Visitor
  • *
  • Posts: 9
    • View Profile
Re: Enemies Shooting Back
« Reply #13 on: 2007-04-24, 05:27:17 PM »
Actually 8 directions is better for an enemy bullet. Once the bullet is created(IF 360) it will have to turn towards the player sprite before it can start moving towards it. with 8 directions the sprite can instantly flip around and start moving. You were talking about the bullet having bad accuracy? just change the Inertia to zero. This will create 100% accuracy(which is not always wanted though) 360 bullets are alot slower when it comes to turning. :P

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Enemies Shooting Back
« Reply #14 on: 2007-04-24, 05:39:26 PM »
Note to self: don't waste time making rotating sprites that stop and turn for SGDK2 ;).