The Daily Click ::. Forums ::. Klik Coding Help ::. Need some help with my shooting system... (TGF)
 

Post Reply  Post Oekaki 
 

Posted By Message

RPG Player 2003



Registered
  27/06/2003
Points
  248
8th November, 2003 at 15:05:24 -

Basic Note - I'm NOT willing to buy MMF!

Here's my problem : I have a platformer-like game with a custom shooting system. You move your crosshair around, shoot and reload with the mouse. With the red crosshair dot you control there are four orange lines that follow your crosshair.

The orange lines get more distant or closer to the red dot according to the weapon you are using to indicate your accuracy (If you played Counter-Strike, you should know what I mean by this). The lines get more distant if you shoot, and closer if you stop to aim. The red dot also kicks forth and back if the weapon has some recoil (almost all have).

I did that so that if you keep shooting your powerful assault rifle at a full automatic rate, the accuracy of your shots will go out of the window, meaning that trigger-happy fingers will NOT succeed.

The shots are supposed to land instantly somewhere between the four lines. This is where the problem comes : EVERYTHING I tried just sent the bullets in random places across the window. I need help there, it's making me crazy! That's almost... 6 hours trying to fix it. Other than that, everything is well at the game (well, still need to work on the enemies AI, but that's later).

Please HELP!!!

 
"I see", said the blind men to his deaf wife.

Beware of the grass, don't step on the dog!

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
8th November, 2003 at 15:22:48 -

Ok, here's the way

Generate a number with its maximum being how wide the "Box" is - X co-ord
Same as above except how tall it is - Y co-ord
--------------
now, you need to find out how far the center of your target is from the left and top (X,Y), then Subract half of the width of the box from the X(Of the target, not the random one. Do this again with the Y (target). Then finally add in the random X,Y coords. This should make all the shots appear within the box.
Hope this helped.


Image Edited by the Author.

 
Craps, I'm an old man!

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
8th November, 2003 at 15:35:26 -

buy mmf

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
9th November, 2003 at 02:00:39 -

X position of shot = (leftline.x + RND(rightline.x - leftline.x))
Y position of shot = (topline.y + RND(bottomline.y - topline.y))

 
n/a
   

Post Reply



 



Advertisement

Worth A Click