The Daily Click ::. Forums ::. Klik Coding Help ::. Okay, I want to shoot, but I hate TGF's shooting engine, what are my options?
 

Post Reply  Post Oekaki 
 

Posted By Message

Jon Chambers



Registered
  25/08/2002
Points
  1071
9th January, 2004 at 17:45:34 -

Okay, I want to shoot, but I hate TGF's shooting engine, what are my options? I want to fire at the curser, and I want it to be destroyed as soon as it hits something before or after it reaches the curser. I want it to pass through the exact center of the curser. I would prefer an invisable bullet, but it doesn't matter. Also, I want instant hits.

Keep in mind that I can use fastloop, and drawline. The only idea I can think of envolves sine cosine, and two values with a massive number of decimal points.

 
Copy this to your hard drive. It will be worth alot when I'm famous.

Notice: Spelling mistakes above left in for people who need to correct others to make their life fulfilled.

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
9th January, 2004 at 18:30:33 -

Direction calculator might help here, or trigonometry, then you can make the bullets move using coordinates rather than the default shooting + use fastloop I'm using it for my game, but I don't have an example ready, sorry... maybe there's an article around?

 
n/a

Jon Chambers



Registered
  25/08/2002
Points
  1071
9th January, 2004 at 21:43:42 -

Direction calculator? Is that an extention? I don't want 32 directions, I want more.

 
Copy this to your hard drive. It will be worth alot when I'm famous.

Notice: Spelling mistakes above left in for people who need to correct others to make their life fulfilled.

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
10th January, 2004 at 04:33:11 -

Since you're going for an invisible bullet, just do a little trick and make the bullet always head towards the cursor spot. If you're too lazy, just give the bullet a Ball movement and make it Always look at Cursor.

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Deleted User
10th January, 2004 at 04:36:50 -

It's cheating.

 

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
10th January, 2004 at 05:40:23 -

Hardly. The bullet just goes from Point A to Point B, which is usually a straight line.

Point A = Character
Point B = Cursor

Just make sure that the cursor's position is the same by the time the bullet reaches it .

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
10th January, 2004 at 07:14:11 -

Lol, you are trying to do the same as me. 360 degree mouse shooting, instant hitting.

This might help: http://www.create-games.com/article.asp?id=1221

 
n/a

Shen

Possibly Insane

Registered
  14/05/2002
Points
  3497
10th January, 2004 at 07:32:56 -

Why not just do, user clicks on enemy: Subtract 1 from enemy health? It's a lot easier.

 
gone fishin'

Jon Chambers



Registered
  25/08/2002
Points
  1071
10th January, 2004 at 15:25:51 -

Okay, muz, you're not cheating, but your idea is too slow. Tell me how I can speed it up without it going through the occational pixel thin wall and I'll do it. Shen, I don't want this charactor to shoot through walls.

 
Copy this to your hard drive. It will be worth alot when I'm famous.

Notice: Spelling mistakes above left in for people who need to correct others to make their life fulfilled.

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
10th January, 2004 at 15:31:09 -

fast loops it is.
Loop
set posx of bullet to posx + 1
check for collision
next loop

 
Craps, I'm an old man!

Daniel[Crazy_Productions]

Possibly Insane

Registered
  29/12/2002
Points
  2505
10th January, 2004 at 18:00:29 -

jon just use x=x+cos(angle*pi/180)*5 y=y+sin(angle*pi/180)*5 and put it in a fastloop

 
Beware of life ...so far noone have survived it.......

Jon Chambers



Registered
  25/08/2002
Points
  1071
10th January, 2004 at 19:47:43 -

*5? Wouldn't that imply that *5 is needed, which would imply that the distance travelled is rounded of to the nearest pixel out of 5, which would imply that long range firing would miss the target completely, and still the bullet would be able to travell through a wall 4 pixels thick. Thanx for you help and all, but I need it to fire at a speciffic target, not a speciffic angle. Is there a way of making an object travel constantly towards another object in fastloop? As if I were to say, "look at target, set speed to 10" in fastloop?

What would be ideal, is if I were to create an invisable line from the gun to the target (I already know how to do that) then send and object along the line until it hits something. Then destroy/damage whatever it hit.

 
Copy this to your hard drive. It will be worth alot when I'm famous.

Notice: Spelling mistakes above left in for people who need to correct others to make their life fulfilled.

Jon Chambers



Registered
  25/08/2002
Points
  1071
11th January, 2004 at 04:46:00 -

Okay, I'm gonna try something, but it's gonna take me ages to get right. I'm gonna run it past you guys, incase you spot any bugs, or ways of making it easier. First of all, the computer checks to see if the character is facing closest to up, down, left or right. Now, lets say for example, it's closest to right. The bullet starts off at the gun. Then it goes to the right one pixel, and set the counter to one, and positions virtically to the following formulae
(Y"target"-Y"man")*counter/(X"target"-X"man")-Y"man"
Then add one to the counter, move one to the right, and start again. All in fast loop. There will be a similar formulae for up, left and down. Do you reakon that'd work? I'll do it tomorrow maybe.

 
Copy this to your hard drive. It will be worth alot when I'm famous.

Notice: Spelling mistakes above left in for people who need to correct others to make their life fulfilled.

ChrisB

Crazy?

Registered
  16/08/2002
Points
  5457
11th January, 2004 at 11:13:43 -

Here's an example I made ages ago:
http://sfgames.clicksplat.com/cgi-bin/download.cgi?examples/tgf&InstantHitBullet.zip

You need the Advanced Math object and Fast Loop object.

 
n/a

Cazra

Crazy?

Registered
  24/07/2002
Points
  4472

Game of the Week WinnerVIP Member
11th January, 2004 at 11:48:31 -

Shen- I think he wants the bullet to hit enemies in between the player and the cursor too. By clicking on an enemy, this won't happen.

The best way to do this is to use 360 directions and fastloop, like everyone else is saying.

Once you understand how angles work with Sine and Cosine, trig will be a piece of cake!

 
n/a
   

Post Reply



 



Advertisement

Worth A Click