Jump to content

Photo

Samus' Power Beam


  • Please log in to reply
37 replies to this topic

#31 Colin

Colin

    Coblin the Goblin

  • Members

Posted 22 August 2008 - 12:02 AM

How might I determine the amount of frames?

#32 Joe123

Joe123

    Retired

  • Members

Posted 22 August 2008 - 02:34 AM

Urm....

You know what, just tell me how long it is in seconds.

#33 Colin

Colin

    Coblin the Goblin

  • Members

Posted 22 August 2008 - 09:22 AM

It's less than a second... I'd estimate 1/2 of a second. Actually, thinking about it, it's more like 1/4-1/3

#34 Joe123

Joe123

    Retired

  • Members

Posted 23 August 2008 - 04:36 AM

Ah, I need you to be a bit more exact than that.
Could you open it up in a wav editor and check it?
Or send it me and I'll do it?

#35 Colin

Colin

    Coblin the Goblin

  • Members

Posted 23 August 2008 - 10:03 AM

OK, I opened it up in a .wav editor. It's 0.15 seconds.

#36 Joe123

Joe123

    Retired

  • Members

Posted 23 August 2008 - 10:29 AM

CODE
import "std.zh"

//Inputs
const int Beam1Tile        = 0;    //Tile for the un-charged beam to use
const int Beam1Frames    = 0;    //No. frames of animation
const int Beam1Speed    = 0;    //Speed
const int Beam2Tile        = 0;    //Tile for charged beam to use
const int Beam2Frames    = 0;    //No. frames of animation
const int Beam2Speed    = 0;    //Speed
const int BeamCset        = 8;    //Cset for the beams to use

const int BeamChargeSFX    = 35;    //Sound effect to play when beam is fully-charged
const int BeamSFX        = 2;    //Sound effect to play when beam is fired
const int ChargeSFX        = 0;    //Sound effect to play while charging
const int ChargeSFXLength    = 9;     //Length of the sound effect in frames

const int NoTurn        = 1;    //If greater than 0, Samus cannot turn to face a different direction whilst charging up the beam. If set to 0, she can turn around. This only works with Diagonal Movement on.
const int DistFromSprite= 8;    //The number of pixels away from Samus the projectile is fired from. Default 8, set it up how you will.
const int BeamSpeed        = 3;    //Speed for beams to fly at goes here
const int Beam1Damage    = 2;    //Damage for un-charged beam here
const int Beam2Damage    = 4;    //Damage for charged beam here
const int BeamChargeMax    = 40;    //Time to wait for beam to charge up here
const int BeamDelayMax    = 5;    //Delay in which Samus cannot shoot (we don't want the screen full of hundreds of beams (I don't think))

//Global utility integers
bool shootbeam;
int beamdelay;

global script slot_2{
    void run(){
    //power beam utility variables
    int beamd;
    int beamx;
    int beamy;
    lweapon beam1;
    lweapon beam2;
    int charging;
        while(true){
            //Power-beam script
            if(shootbeam){
                beamd = Link->Dir;
                beam1 = Screen->CreateLWeapon(8);
                beam1->OriginalTile = Beam1Tile;
                beam1->Tile = Beam1Tile;
                beam1->CSet = BeamCset;
                beam1->NumFrames = Beam1Frames;
                beam1->ASpeed = Beam1Speed;
                
                beam1->Damage = Beam1Damage;
                beam1->Step = BeamSpeed;
                beamx = 0; beamy = 0;
                if(beamd>1) beamx = (((beamd-2)*2)-1)*DistFromSprite;
                if(beamd<2) beamy = ((beamd*2)-1)*DistFromSprite;
                beam1->X = Link->X+beamx;
                beam1->Y = Link->Y+beamy;
                beam1->Z = Link->Z;
                beam1->Dir = beamd;
            Game->PlaySound(BeamSFX);
            Link->Action = LA_ATTACKING;
            shootbeam = false;
            beamdelay = BeamDelayMax;
            charging++;
            beamd = Link->Dir;
            Waitframe();
                while((Link->InputA || Link->InputB) && charging < BeamChargeMax){
                    if(charging%ChargeSFXLength == 0) Game->PlaySound(ChargeSFX);
                    charging++;
                    Link->InputA = false;
                    Link->InputB = false;
                    if(NoTurn > 0){
                        Waitdraw();
                    Link->Dir = beamd;
                    }
                Waitframe();
                }
                if(charging >= BeamChargeMax) Game->PlaySound(BeamChargeSFX);
                while((Link->InputA || Link->InputB) && charging >= BeamChargeMax){
                    Link->InputA = false;
                    Link->InputB = false;
                    if(NoTurn > 0){
                        Waitdraw();
                    Link->Dir = beamd;
                    }
                Waitframe();
                }
                if(charging >= BeamChargeMax){
                    beamd = Link->Dir;
                    beam2 = Screen->CreateLWeapon(8);
                    beam2->OriginalTile = Beam2Tile;
                    beam2->Tile = Beam2Tile;
                    beam2->CSet = BeamCset;
                    beam2->NumFrames = Beam2Frames;
                    beam2->ASpeed = Beam2Speed;
                    
                    beam2->Damage = Beam2Damage;
                    beam2->Step = BeamSpeed;
                    beamx = 0; beamy = 0;
                    if(beamd>1) beamx = (((beamd-2)*2)-1)*DistFromSprite;
                    if(beamd<2) beamy = ((beamd*2)-1)*DistFromSprite;
                    beam2->X = Link->X+beamx;
                    beam2->Y = Link->Y+beamy;
                    beam2->Z = Link->Z;
                    beam2->Dir = beamd;
                Game->PlaySound(BeamSFX);
                Link->Action = LA_ATTACKING;
                }
            charging = 0;
            }
            if(beamdelay > 0) beamdelay--;        
            //Power-beam ends here
            
            //Other scripts go here...
            
        Waitframe();
        }
    }
}

//Activation script for the beam
item script Power_Beam{
    void run(){
        if(beamdelay == 0) shootbeam = true;
    }
}



Give that one a go.
Two new constants - sound effect to play, and length of sound effect.
I've set up the length for you; 0.15 seconds should relate to 9 frames if my maths is correct.

#37 Colin

Colin

    Coblin the Goblin

  • Members

Posted 23 August 2008 - 12:30 PM

Alright, it's perfect. icon_thumbsup.gif

#38 Joe123

Joe123

    Retired

  • Members

Posted 24 August 2008 - 06:12 AM

Glad to be able to help ^_^


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users