Shooting towards a specific point on screen

Started by Fuseki, November 14, 2011, 12:39:20 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Fuseki

Here's probably a simple question, but I can't wrap my head around it today for some reason.

I'm trying to set up a firing system that uses crosshairs, and want to shots to hit the point where the crosshairs WERE when the player pressed fire, and I don't want the shots to follow the crosshairs while it moves. Does this make sense? I'm trying to get a bullet to move from it's point of origin to another specific point. I know this requires using the angle commands (I think), but I can't figure it out. Basically, let's say I'm starting at 0,480 and want to move the object to 10,250.


I've gotten as far as:


-player fires
-store current crosshair coordinates


I just need to figure out:

- move bullet towards the point where the crosshairs were when player pressed fire

Any help offered is appreciated.
Fuseki Games
Classic- style games for the Dreamcast
http://www.fusekigames.com
----------------
Dreamcast Fenix Resource Page
http://atari.vg-network.com

Fuseki

#1
Figured it out:



angle=near_angle(angle,fget_angle(x,y,plx,ply),180000);
repeat
   advance(10);



...where plx and ply are where the crosshairs were when the fire button was pressed. The angle is to shoot straight up; I'd have to use two different processes for left and right shooting, and change the angle to 90000 and 45000 (I think). I'll eventually use the process ID for the near_angle function (once the crosshair code is put into its own process) but this'll do for now. Just need boundary checking and I'm good!


DISCLAIMER: this is for FENIX 0.84, not BENNU.
Fuseki Games
Classic- style games for the Dreamcast
http://www.fusekigames.com
----------------
Dreamcast Fenix Resource Page
http://atari.vg-network.com