Ejemplo n.º 1
0
        /*
        =============================
        =
        = ControlJoystick (joy# = 1 / 2)
        =
        =============================
        */
        private ControlStruct ControlJoystick(short joynum)
        {
            short joyx = 0; /* resistance in joystick */
            short joyy = 0;

            ReadJoystick(joynum, out joyx, out joyy);

            if((joyx > 500) | (joyy > 500))
            {
                joyx = (short) (JoyXlow[joynum] + 1); /* no joystick connected, do nothing */
                joyy = (short) (JoyYlow[joynum] + 1);
            }

            short xmove = 0;
            if(joyx > JoyXhigh[joynum])
                xmove = 1;
            else if(joyx < JoyXlow[joynum])
                xmove = -1;

            short ymove = 0;
            if(joyy > JoyYhigh[joynum])
                ymove = 1;
            else if(joyy < JoyYlow[joynum])
                ymove = -1;

            ControlStruct action = new ControlStruct();
            switch(ymove * 3 + xmove)
            {
                case -4: action.dir = dirtype.northwest; break;
                case -3: action.dir = dirtype.north; break;
                case -2: action.dir = dirtype.northeast; break;
                case -1: action.dir = dirtype.west; break;
                case 0: action.dir = dirtype.nodir; break;
                case 1: action.dir = dirtype.east; break;
                case 2: action.dir = dirtype.southwest; break;
                case 3: action.dir = dirtype.south; break;
                case 4: action.dir = dirtype.southeast; break;
            }

            short buttons = _sys.ReadJoystickButtons(joynum); /* Get all four button status */

            if(joynum == 1)
            {
                action.button1 = ((buttons & 0x10) == 0);
                action.button2 = ((buttons & 0x20) == 0);
            }
            else
            {
                action.button1 = ((buttons & 0x40) == 0);
                action.button2 = ((buttons & 0x80) == 0);
            }

            if(buttonflip)
            {
                bool buttonState = action.button1;
                action.button1 = action.button2;
                action.button2 = buttonState;
            }

            return action;
        }
Ejemplo n.º 2
0
        //=========================================================================
        /*
        ===========================
        =
        = ControlKBD
        =
        ===========================
        */
        private ControlStruct ControlKBD()
        {
            short xmove = 0;
            short ymove = 0;

            if(keydown[key[(short) dirtype.north]])
                ymove = -1;

            if(keydown[key[(short) dirtype.east]])
                xmove = 1;

            if(keydown[key[(short) dirtype.south]])
                ymove = 1;

            if(keydown[key[(short) dirtype.west]])
                xmove = -1;

            if(keydown[key[(short) dirtype.northeast]])
            {
                ymove = -1;
                xmove = 1;
            }

            if(keydown[key[(short) dirtype.northwest]])
            {
                ymove = -1;
                xmove = -1;
            }

            if(keydown[key[(short) dirtype.southeast]])
            {
                ymove = 1;
                xmove = 1;
            }

            if(keydown[key[(short) dirtype.southwest]])
            {
                ymove = 1;
                xmove = -1;
            }

            ControlStruct action = new ControlStruct();

            switch(ymove * 3 + xmove)
            {
                case -4: action.dir = dirtype.northwest; break;
                case -3: action.dir = dirtype.north; break;
                case -2: action.dir = dirtype.northeast; break;
                case -1: action.dir = dirtype.west; break;
                case 0: action.dir = dirtype.nodir; break;
                case 1: action.dir = dirtype.east; break;
                case 2: action.dir = dirtype.southwest; break;
                case 3: action.dir = dirtype.south; break;
                case 4: action.dir = dirtype.southeast; break;
            }

            action.button1 = keydown[keyB1];
            action.button2 = keydown[keyB2];

            return action;
        }
Ejemplo n.º 3
0
        //==========================================================================
        /*
        ===================
        =
        = PlayLoop
        =
        ===================
        */
        private void PlayLoop()
        {
            do
            {
                c = ControlPlayer(1);

                screenofs = 0; // draw in split screen (radar, time, etc)

                for(short objIndex = 0; objIndex <= lastobjIndex; objIndex++)
                {
                    obj = objlist[objIndex];

                    if(obj._class != 0)
                    {
                        obj.CopyTo(obon);
                        obon.think();
                        obon.CopyTo(obj);
                    }
                }

                DropTime();

                if(keydown[0x57]) // DEBUG!
                {
                    // as: Support for extra sound effects
                    DamagePlayer(TAKEDAMAGESND);
                    ClearKeys();
                }

                if(bordertime != 0 && (bordertime -= tics) <= 0)
                {
                    bordertime = 0;
                    ColorBorder(0);
                }

                FinishView(); // base drawn by player think

                CheckKeys();

            } while(leveldone == 0);
        }