Wolf3d Haven Forum

Please log in or register. Smile

Join the forum, it's quick and easy

Wolf3d Haven Forum

Please log in or register. Smile

Wolf3d Haven Forum

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Wolf3d Haven Forum

A friendly Wolfenstein 3D community, about Wolfenstein 3D, the game that gave birth to first person shooters...


2 posters

    How do you add a motorbike in SDL?

    avatar
    Guest
    Guest


    How do you add a motorbike in SDL? Empty How do you add a motorbike in SDL?

    Post by Guest Wed Mar 28, 2012 9:35 am

    Does anyone know how to add a motorbike to SDL source Code? I tried to add it and I got errors. I need someone to explain how to add a motorbike to SDL in easy step by step instructions. The original source code tutorial is hard to follow.
    stathmk
    stathmk
    Veteran
    Veteran


    Male
    Number of posts : 1778
    Age : 43
    Location : Indiana, United States
    Job : fast food worker & wolfensteingoodies.com webmaster
    Hobbie : old games & young dames
    Registration date : 2008-04-08

    How do you add a motorbike in SDL? Empty Re: Motorbike

    Post by stathmk Fri Mar 30, 2012 11:46 am

    Ask Brian if he knows Max' email address. Max is in Germany and made a motorbike for some of the episodes of Sensenman or Reaperman. However, I doubt if that's a SDL mod.

    EDIT: It took me over 20 minutes to find his email, but I sent it to you.
    Officer-Michael John
    Officer-Michael John
    Seasoned Wolfer
    Seasoned Wolfer


    Male
    Number of posts : 332
    Age : 26
    Hobbie : Video and Wolf 3D mode making
    Registration date : 2014-08-04

    How do you add a motorbike in SDL? Empty Re: How do you add a motorbike in SDL?

    Post by Officer-Michael John Thu Aug 18, 2016 4:28 am

    I know, that you know adding motorbike for SDL:

    WL_DEF.H:

    gamestate structure

    Code:
       boolean mbike;   // is the player riding on the mbike
        short motospeed;   // what's the bike's speed
        boolean left;    // are you turning left
        boolean right;   // are you turning right

    WL_AGENT.CPP:

    ControlMovement (replace this):

    Code:
    void ControlMovement (objtype *ob)
    {
        int32_t oldx,oldy;
        int     angle;
        int     angleunits;

        thrustspeed = 0;

        oldx = player->x;
        oldy = player->y;

        if(buttonstate[bt_strafeleft])
        {
            angle = ob->angle + ANGLES/4;
            if(angle >= ANGLES)
                angle -= ANGLES;
            if(buttonstate[bt_run])
                Thrust(angle, RUNMOVE * MOVESCALE * tics);
            else
                Thrust(angle, BASEMOVE * MOVESCALE * tics);
        }

        if(buttonstate[bt_straferight])
        {
            angle = ob->angle - ANGLES/4;
            if(angle < 0)
                angle += ANGLES;
            if(buttonstate[bt_run])
                Thrust(angle, RUNMOVE * MOVESCALE * tics );
            else
                Thrust(angle, BASEMOVE * MOVESCALE * tics);
        }

        //
        // side to side move
        //
        if (gamestate.mbike!=true)      // no strafe on a mbike
        {
        if (buttonstate[bt_strafe])
        {
            //
            // strafing
            //
            //
            if (controlx > 0)
            {
                angle = ob->angle - ANGLES/4;
                if (angle < 0)
                    angle += ANGLES;
                Thrust (angle,controlx*MOVESCALE);      // move to left
            }
            else if (controlx < 0)
            {
                angle = ob->angle + ANGLES/4;
                if (angle >= ANGLES)
                    angle -= ANGLES;
                Thrust (angle,-controlx*MOVESCALE);     // move to right
            }
        }
        else
        {
            //
            // not strafing
            //
            anglefrac += controlx;
            angleunits = anglefrac/ANGLESCALE;
            anglefrac -= angleunits*ANGLESCALE;
            ob->angle -= angleunits;

            if (ob->angle >= ANGLES)
                ob->angle -= ANGLES;
            if (ob->angle < 0)
                ob->angle += ANGLES;

        }

        //
        // forward/backwards move
        //
        if (controly < 0)
        {
            Thrust (ob->angle,-controly*MOVESCALE); // move forwards
        }
        else if (controly > 0)
        {
            angle = ob->angle + ANGLES/2;
            if (angle >= ANGLES)
                angle -= ANGLES;
            Thrust (angle,controly*BACKMOVESCALE);          // move backwards
        }

    }
       else
       {
          if (controlx > 0)      // this section sets left & rigth to true/false depending on the keys that player presses
          {
          gamestate.left=true;
          gamestate.right=false;
          }
          else if (controlx < 0)
          {
          gamestate.left=false;
          gamestate.right=true;
          }
          else
          {
          gamestate.left=false;
          gamestate.right=false;
          }

          anglefrac += controlx*.5;      // turning - you may adjust this line and/or add some gamestate.motospeed dependencies
          angleunits = anglefrac/ANGLESCALE;
          anglefrac -= angleunits*ANGLESCALE;
          ob->angle -= angleunits;

          if (ob->angle >= ANGLES)
             ob->angle -= ANGLES;
          if (ob->angle < 0)
             ob->angle += ANGLES;

        if (controly > 0 )               // brakes
       {
       if (gamestate.motospeed>controly)
       gamestate.motospeed-=controly*2;
       else if (gamestate.motospeed>=0-controly)
       gamestate.motospeed=0;
       else
       gamestate.motospeed+=controly*2;    
    //   SD_PlaySound (DIESND); //use some BRAKESND instead, this may cause problems, not well tested!!!
       }
        else if (controly < 0)            // accelerate
       {
        if (gamestate.motospeed<30000)
        gamestate.motospeed-=controly*.5;
        else
        gamestate.motospeed=30000;
        SD_PlaySound (HITWALLSND); //use some ENGINESND instead, this may cause problems, not well tested!!!
       }
        else   // no keys pressed - bike slowly reduces it's speed
       {
       if (gamestate.motospeed<0)
       gamestate.motospeed+=10;
       else if (gamestate.motospeed>0)
       gamestate.motospeed-=1;
       }
       Thrust (ob->angle,gamestate.motospeed);
        }

        if (gamestate.victoryflag)              // watching the BJ actor
            return;
    }


    TryMove

    Code:
      if (gamestate.mbike==true)
       {
          if (gamestate.motospeed<=200)      // very slow or backwards movement - just set the speed to 0
          gamestate.motospeed=0;
          else      // if we're riding faster... (you should add crash sound here, probably something like the sound stuff just below this "+" section. I didn't add it cause I have some problems with sound in Wolf and can't test it)
          {
             if (gamestate.motospeed>=5000) // take damage if you're driving really fast, damage depends on the speed
        {
             TakeDamage (gamestate.motospeed/500, NULL);
          SD_PlaySound (EVASND); // use some CRASHSND of your creation instead
        }
          gamestate.motospeed=-0.3*gamestate.motospeed; // bounce
          }      // so that you won't get into a wall
          ob->x=basex;
          ob->y=basey;
          return;
        }


    T_Player

    Code:
    if (gamestate.mbike!=true) {

    WL_DRAW.CPP:

    DrawPlayerWeapon

    Code:
        if (gamestate.mbike == true)
       {
       if (gamestate.left == true)
       {
        SimpleScaleShape(viewwidth/2,SPR_CHAINATK1,viewheight+1); // change SPR_* here and below to your own ones
        return;
       }
       else if (gamestate.right == true)
       {
        SimpleScaleShape(viewwidth/2,SPR_KNIFEATK2,viewheight+1);
        return;
       }
        SimpleScaleShape(viewwidth/2,SPR_PISTOLATK3,viewheight+1);
        return;
       }


    I test and work for Me. If not work then you write for Me.

    Enjoy!

    Sponsored content


    How do you add a motorbike in SDL? Empty Re: How do you add a motorbike in SDL?

    Post by Sponsored content


      Current date/time is Thu Mar 28, 2024 10:18 am