Game Development Community

Turning particles images into a weapon

by Paul Jackson · in Torque Game Builder · 08/19/2006 (9:39 pm) · 7 replies

I am trying to use a particle image from "particle image map 1" , the blue one inparticular. I am having a hard time trying to make it into a sort of missle that shoots out like the demo but vertically( the shooter is a vertical shooter). I have tried to adapt the code examples to make it work but have been unsuccesful. Any help would be greatly apprecatied.

#1
08/20/2006 (2:15 am)
Post the code you've got so far. ;)
#2
08/20/2006 (4:27 am)
It sounds more like a particle problem rather than a code problem. Have you tried playing with the particles to make them vertical rather than horizontal?
#3
08/20/2006 (9:26 am)
Function playerShip::createMissile(%this)
{
%this playerMissile=new t2dStaticSprite()
{
scenegraph = %this.scenegraph:
class = playerMissile;
missileSpeed= %this.missileSpeed;
player = %this;
};
%this.playerMissile.fire();
}


This is for the playerMissle file:

function playerMissile::fire(%this)
{
%this.setWorldLimit(kill,"-47.115,-34.578,47.115,34.578");
%this.setLinearVelocityY(%this.missileSpeed);
%this.setPosition(%this.player.getPosition());
%this.setImageMap(playerMissileImageMap):
%this setSize(10,5);
%this.setCollisionActive(true,true);
%this.setCollisionPhysics(false,false);
%this.setCollisionCallback(true);
}

function playerMissile::onCollsion(%srcObj,%dstObj,%srcRef,%dstRef,%time,%normal,%contactCount,%contacts)
{
if(%dstObj.class $= "enemyShip")
{
%srcObj.explode();
%dstObj.explose();
}
}

function playerMissile::explode(%this)
{
%this.safeDelete();
}

I am trying to use the blue one out of the Particles1.png set of static images.
#4
08/20/2006 (6:03 pm)
Phillip, I don't think he's actually using the particle engine, per se, just using the image as a sprite.

Paul, it just occurred to me that I'm not quite sure what the problem you're having is. Are you saying the projectiles are still moving horizontally? Are they not appearing? Not moving, perhaps?

I can't seem to figure out where you're defining "missileSpeed".

Just noticed something:
Function playerShip::createMissile(%this)
{
[b]%this playerMissile=new t2dStaticSprite()[/b]
{

Shouldn't that be
%this.playerMissile=new t2dStaticSprite()
(note the "." between "%this" and "playerMissile")
#5
08/20/2006 (7:07 pm)
The projecticle is not even coming out, as a matter a fact when i push the space bar it just crashes torque all together. I defined missile speed with the editor in the dynamic fields tab. I am trying to use the code from the shooter turtorial and just rework it for a vertical game. I am still kinda new at programming(I have only been learning it for 2 semesters at school and are base language is java so i am having some diffuclty just making it from scratch). I would show you a screen shot if i knew how to do it.
#6
11/17/2006 (8:31 pm)
9 times out of 10 when it "should" be working and it isn't.. you mistyped something in your code.. I think the missed period Teck pointed out is causing your crash (if not your problem in general).

You also missed one here where you define your missiles size.. (%this setSize(10,5);)... ouch.
#7
11/18/2006 (12:40 am)
@paul,

there's also a "." missing here:
%this setSize(10,5);
every time you run your game from the editor, hit the tilde "~" key to open the console...
just to make sure that you don't have any script errors.

if you do, nothing will work properly.