How to make LASR move like PHOT

  • Merbo
    13th Dec 2010 Member 0 Permalink
    Hello, i have my own mod in the section, source and compiled are in there, but i cant figure out how to code in main.c :/ Could I please get some help? It would be appreciated.
  • Xenocide
    13th Dec 2010 Former Staff 0 Permalink
    Seeing as I'm in a good mood considering a couple failed coding attempts taking up the majority of my night...

    powder.c in create_parts

    if(t==PT_LASR)
    {
    float a = (rand()%8) * 0.78540f;
    parts[i].life = 680;
    parts[i].vx = 3.0f*cosf(a);
    parts[i].vy = 3.0f*sinf(a);
    }
  • Merbo
    13th Dec 2010 Member 0 Permalink
    Thank you SO much antb... But could you tell me what that means? I want to be able to do this on my own, without asking people all the time.
  • Pilihp64
    13th Dec 2010 Developer 0 Permalink
    it has to do with trigonometry, .7854 is in radians, and is 1/8 of a full circle, so it will end up randomly picking one of the 8 directions.
  • Xenocide
    13th Dec 2010 Former Staff 0 Permalink
    float a = (rand()%8) * 0.78540f;
    setting a to a random value, not my preferred method but this is a copy paste.

    parts[i].life = 680;
    Setting particle life to 680, it will decrease by 1 each frame until it reaches 0 when it will die.

    parts[i].vx = 3.0f*cosf(a);
    parts[i].vy = 3.0f*sinf(a);


    vx and vy are used to control movement and are set using a load of math stuff I don't understand beyond Consine and Sine based on the random number set earlier
    edit: What cracker said.
  • Finalflash50
    13th Dec 2010 Banned 0 Permalink
    This post is hidden because the user is banned
  • Merbo
    13th Dec 2010 Member 0 Permalink
    I couldn't find it, and i would still want to figure out what it meant.
  • roguegeneral--
    13th Dec 2010 Member 0 Permalink
    the c code is the hardest part of modding
  • PizzaPlatypus
    13th Dec 2010 Member 0 Permalink
    yes
  • MiXih
    13th Dec 2010 Member 0 Permalink
    roguegeneral--:
    the c code is the hardest part of modding

    wut