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! / Can someone help me with enemy bullet???

Author
Message
TLOZ
20
Years of Service
User Offline
Joined: 7th May 2005
Location: Enfield, NC
Posted: 22nd May 2005 01:06
I'm trying to make a scrolling shooter with DBC and I can't get my enemy's bullets to shoot at the player's ship. Can someone please show me how to get them to shoot at the player's position? I just need someone to get me started in the right direction.
pizzaman
21
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 22nd May 2005 10:53
Heres some code I just created quickly to help you



Basically whats going on is that the angle between the player and enemy is found. Then the angle is wrapped into the proper quadrant.

By multiplying the BulletSpeed (measured in pixels per second) with cos(Angle) you get the horizontal component or the BulletSpeed, and by multiplying the BulletSpeed with sin(angle) you get the verticle component.

These components are then added to the Bullets coordinates to move the bullet, however the components are first multiplyed by the frame time - this is for timer based movement which means the bullet will move the same distance no matter the frame rate.

TLOZ
20
Years of Service
User Offline
Joined: 7th May 2005
Location: Enfield, NC
Posted: 22nd May 2005 13:02
thanks pizzaman!

thats exactly what I needed.

Login to post a reply

Server time is: 2025-05-17 10:23:11
Your offset time is: 2025-05-17 10:23:11