Exemplo n.º 1
0
        /// <summary>loops thru the keys and checks logic if pressed, if so do its action</summary>
        /// <returns>returns if ANY action has occured from a keypress</returns>
        public bool handle()
        {
            bool action = false;

            keyNode cur = top;

            while (cur != null)
            {
                bool pressed;

                if (!cur.keyDown)
                {
                    pressed = GAME.Engine.GetKey(cur.key);
                }
                else
                {
                    pressed = GAME.Engine.GetKeyDown(cur.key);
                }


                if (pressed && cur.timer.complete())
                {
                    cur.timer.start();
                    cur.action();
                    action = true;
                }

                cur.timer.update();

                cur = cur.next;
            }

            return(action);
        }
Exemplo n.º 2
0
        public void add(int key, Action action, Timer timer, bool keydown = false)
        {
            keyNode newNode = new keyNode(key, action, timer, keydown);

            newNode.next = top;
            top          = newNode;
        }