ID:1554940
 
(See the best response by Kaiochao.)
Problem description:

Could someone walk me through on how to create a pixel projectile system. I'm to nub to do it on my own.
Pixel movement or no?
In response to Kaiochao
It's for a pixel movement game.
What do you want your projectiles to do, specifically?
In response to Kaiochao
I want them to go to the location where I click on the map, at an angle?

I would like them non-dense, that way they can fly over water and hit the enemy across the view. But have certain things it won't be able to cross over, like targets. you hit all 5 targets and then the switch door opens. Or a tall-wall, what blocks all projectiles from crossing it.

Basically the game I'm making, will be an Archer using a bow and arrow, and the arrows will be used for interactions.
In response to Flysbad
Best response
Flysbad wrote:
I want them to go to the location where I click on the map, at an angle?
My mouse library includes a /mouse datum, which provides mouse properties such as angle from the center of the screen (usually where the player is) to the mouse.
client
// when a mouse button is pressed
MouseDown()
..()
// tell the mob to shoot at the current angle to the mouse
mob.Shoot(mouse.angle)

mob
// shoot at a certain angle
proc/Shoot(Angle)
// create a new arrow, giving src and the shooting angle as arguments
new /obj/projectile/arrow (src, Angle)

// if you have a projectile defined like:
obj/projectile
// how many pixels the projectile covers (in any direction)
var speed

// the angle of the projectile (passed to constructor)
var tmp/angle

// rectangular velocity components (to be calculated)
var tmp/vx
var tmp/vy

New(mob/Shooter, Angle)
angle = Angle

// Center the projectile on the shooter
SetCenter(Shooter.Cx(), Shooter.Cy(), Shooter.z)

// This assumes your arrow icon points north and a positive angle rotates clockwise.
vx = sin(angle) * speed
vy = cos(angle) * speed

// Rotate the projectile
transform = turn(matrix(), angle)

// Call this every frame in some global infinite loop.
proc/Tick()
Translate(vx, vy)

// It'd be simpler to use Project(speed, angle),
// but Project() performs the trig calculation (done in New()) every time,
// so it's faster to only do that calculation once.

I would like them non-dense, that way they can fly over water and hit the enemy across the view. But have certain things it won't be able to cross over, like targets. you hit all 5 targets and then the switch door opens. Or a tall-wall, what blocks all projectiles from crossing it.
I suppose you could do something like this:
atom
var tall = FALSE // get hit by arrows?

Cross(atom/movable/O)
// If we're tall, don't let arrows through.
if(tall && istype(O, /obj/projectile/arrow))
return FALSE

return ..()

mob
tall = TRUE

obj/tall_wall
tall = TRUE

With this, the arrow should Bump() into objects that don't allow it to pass through, even though the arrow isn't dense.

Basically the game I'm making, will be an Archer using a bow and arrow, and the arrows will be used for interactions.
This sounds like a fun game, and I look forward to it. Have you considered using a sidescroller perspective? That way, tall wall detection is pretty much automatic.
In response to Kaiochao
Thanks for the help, let me see what I can do with this little system :P

Kaiochao wrote:
My mouse library includes a /mouse datum, which provides mouse properties such as angle from the center of the screen (usually where the player is) to the mouse.
Yeah I've became a fan of your libraries recently, trying to figure out how to use them to their full extent.

Kaiochao wrote:
This sounds like a fun game
Yeah.. hopefully I'll be able to create it.

Kaiochao wrote:
and I look forward to it. Have you considered using a sidescroller perspective? That way, tall wall detection is pretty much automatic.

I'm clueless when it comes to sidescrollers, I struggle even with pixel movement, but tile-movement is just so ugly, it's hard to want to use it.

Hum.. am i missing something here? (another thing you're working on?) Not that the bits you've mentioned so far aren't interesting, but what about densetsu? (i'm right in thinking the project has been going strong until recently -and that perhaps something might have only just set it back a bit, giving you time for things like this... right?)