Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Spriet shooting example

Author
Message
Guyon
20
Years of Service
User Offline
Joined: 6th Jun 2003
Location: United States
Posted: 10th Jul 2003 04:06
Looking for an example for one sprite shooing a bullet sprite at a third sprite.


Hit=0
A bonus would be see a 1 assigned to the variable HIT if the bullet hits the target.
Drum
21
Years of Service
User Offline
Joined: 10th Apr 2003
Location:
Posted: 10th Jul 2003 05:15
Hey,
This isnt exactly what you are looking for im sorta in a rush....


To adjust this to your needs simply change the bits which have mousex and mousey to the x and y position of that third sprite.

by the way you will need to get a bullet sprite sized 1,19 but if i were you just create a box for the getimage if you know what i mean.

p.s. this may not be of any use seeing that it is for DBpro

hopethat helped
NICK
Guyon
20
Years of Service
User Offline
Joined: 6th Jun 2003
Location: United States
Posted: 10th Jul 2003 05:25
yes it for DBpro. I made the bullet, and will look into it better tonight but this code actially crashed my DBpro.
JesterDev
20
Years of Service
User Offline
Joined: 22nd Jun 2003
Location:
Posted: 10th Jul 2003 05:35 Edited at: 10th Jul 2003 06:04
Here's the code from a simple game I'm working playing around with while I learn. It does what you want, more or less. You'll need to add in your own images though. But if you want the images, let me know.



Drum
21
Years of Service
User Offline
Joined: 10th Apr 2003
Location:
Posted: 10th Jul 2003 07:29
Hmmm it made crash... well it worked fine with me.. make sure the bullet is:

<1>
_
| | ^
| | 1
| | 9
|_|

So basicly its like a match stick, standing up. Thats the only reason i think it could stuff up.

later.
nick
Guyon
20
Years of Service
User Offline
Joined: 6th Jun 2003
Location: United States
Posted: 10th Jul 2003 08:28
JesterDev
Why does your bullet travel up? What is the command that makes it do that?

I want the enemy to shoot at my hero. I think Iam on the right track using:

ReturnFloat= ATANFULL(ABS(HeroX-x), abs(HeroY-y))

But don't know to get your sprite 1 to shoot at angles.
Drum
21
Years of Service
User Offline
Joined: 10th Apr 2003
Location:
Posted: 10th Jul 2003 08:38
If sprite exist(bullet) then move sprite 3,4

this is moving the sprite at the angle it is currently at which is 0!
Guyon
20
Years of Service
User Offline
Joined: 6th Jun 2003
Location: United States
Posted: 10th Jul 2003 09:18
Ahhhhhh I thought it just rotated the sprite. I didn't realize it directed it too.

now trying to get a formula to aim the sprite at the target. i am so close
Guyon
20
Years of Service
User Offline
Joined: 6th Jun 2003
Location: United States
Posted: 10th Jul 2003 09:30
Ok Drum I had the bullet going the wrong way. It no longer crashes!

Now all I have to do is figure out how you aim!
Drum
21
Years of Service
User Offline
Joined: 10th Apr 2003
Location:
Posted: 10th Jul 2003 11:27
if you want to make go towards the sprite "3" change the angleo# code to this:

Angleo#=atanfull(sprite x(3)-sprite x(1), sprite y(1)-sprite y(3))

so the code is:


note are quite a few changes in that..
also if you don't want the inacurracy of the bullets get rid of the random bit. but then you would have to have a timer on the shot or else they just look like a line.
Guyon
20
Years of Service
User Offline
Joined: 6th Jun 2003
Location: United States
Posted: 10th Jul 2003 17:09
Thanks Guys, both of you were so helpful. I finailly got it. Thanks! I owe you! x-d
Drum
21
Years of Service
User Offline
Joined: 10th Apr 2003
Location:
Posted: 11th Jul 2003 04:15
Glad it helped

Login to post a reply

Server time is: 2024-04-19 22:34:38
Your offset time is: 2024-04-19 22:34:38