Does anyone know how to program grenades. I want to make a grenade for a platformer I'm making. I haveno idea where to start. Note: the grenade doesn't need to have fast I need a code that allows to throw a grenade at almost any angle and has splash damage.

Building off of The Cow's ideas, here's what I was able to come with:

A,B=Coordinates of grenade

I,J=Initial Coordinates of grenade

G=Gravitational Acceleration Constant (on Earth its about 9.8 m/s²)

V=Initial Velocity

θ=Angle of Throw

T=Time

```
:ClrDraw
:0→Xmin
:1→ΔX
:-62→Ymin
:0→Ymax //This sets up a graphing window where each point is also one pixel
throws grenade by pressing key or something
:I→A
:J→B
:0→T
:Repeat pxl-Test(A,B
:Pxl-On(A,B
:Pxl-Off(A,B
:I+VTcos(θ→A
:J-GT²+VTsin(θ→B
:T+.01→T
:End
some explosion animation
```

The splash damage code could be done a number of ways, depending on how your game keeps track of entities. You could do a test that involves increasing the radius of a circle from the grenade and detecting whether or not it hit something. Or, if entities are stored in a list or matrix, you could do the distance formula from each enemy to the grenade. Either way, here is the basic formula for calculating damage:

A,B=Coordinates of Grenade Explosion

C,D=Coordinates of Entity

E=Amount of Damage taken at a distance of 1

```
:(A-C)²+(B-D)²
:E/Ans→(var) //This can be whatever variable is used to keep track of damage for entities
```

This was the best I could do. Hope it helps! :)

Thanks for the help but I when I put the code in I get a domain error. I think it's because B ends up being a decimal.

Note: The trigonometry page didn't help. When I typed the program into my calculator it didn't even work.

I would assume you want code to be able to lob projectiles (in general) with different angles and power. In the case of a platformer, I think the angle and power should be fixed though.

You can have the grenades be physics based. The coordinates of a projectile at any given time are:

X coord: x = vx * t + xi = vi * cos(θ) * t +xi

Y coord: y = -g * t^2 + vy * t + yi = -g * t^2 + vi * sin(θ) * t + yi

x and y are x and y coordinates of projectile at time t, g is gravitation acceleration (constant), vi is initial velocity (constant), xi and yi are initial coordinates, theta is angle. Remember that a higher y is a higher vertical height.

For the splash damage, it can be treated like point sound waves, which increase quadratically with distance. As in, an object would take one fourth the damage it would have taken if it were twice as close. You can calculate the distance with the pythagorean theorem.

I would write sample TI-BASIC code, but I'm getting too lazy. If you need more specific info, I would be glad to help.

Fire Emblem for TI 83/4+ Progress: Demo: 75% Total: 40% Postponed indefinitely