Lieutenant, Engineering Corps
I'm currently trying to implement new projectile types: Guided Projectiles & Beams. I feeling a little bit lost here. Can you please point me to the right classes/methods, which are responsible for launching projectile from the weapon, after all required information (such as speed, trail size, image & etc) were already received and processed?
Commander, Engineering Corps
With my utter lack of understanding of anything apart from trial and error.
// Speed of projectile, assuming 1 = 1 tile per second/tick?
.shot(new Img("spritesheet", 64, 304, 1, 1, false))
// Co-Ords, size, ?
.exhaust(new WeaponAppearance.ShotExhaustEmitter(Type.GRENADE_SPARK, 0.01, 1, Math.PI, 1, 0.5, 1))
// Types are defined in .partical.java, donno how that works. First values were for frequency and length (I think), Math Values = lower makes it more tame, higher more energetic
Donno if that helps at all..
Sure, basically most of what you need will be in Shot.java. Weapons create new Shots by adding them to the combat.
Zarkonnen, and d.blit in draw(Draw d) in Shot.java is responsible for showing/rendering where exactly is projectile itself in current "tick" - right?
Yep, and the
sX + ((tX - sX) * time / travelTime) - img.srcWidth / 2,
sY + ((tY - sY) * time / travelTime) - img.srcHeight / 2,
Math.atan2((tY - sY), (tX - sX))
lines after it calculate the x-position, y-position and rotation on the basis of where the shot started from, is going, and how long it's travelled.
So if you want to make guided missiles you probably want to change how shots' positions are stored, giving them a current x/y coordinate you can then modify, etc.
Thanks! Also, can you please point me to the method that is responsible for rotating the gun/barrel towards the target?
EDIT: I think weaponAngle = Direction.radiansFromTo(sX, sY, target.b.x, target.b.y) from public boolean fire(Combat c) at Module.java is responsible for it. Please correct me, if I'm wrong.