Example #1
0
        public void Update()
        {
            float delta = (SDL.SDL_GetTicks() - lastFrameTime) / 1000.0f;

            lastFrameTime = SDL.SDL_GetTicks();

            if (spriteId != -1)
            {
                pos += dx * delta;
                if (pos >= 640 - 16 && dx > 0)
                {
                    pos = 640 - 16;
                    dx  = -dx;
                    Cats.SetAnimation(spriteId, "walk left");
                }
                else if (pos <= 0 && dx < 0)
                {
                    pos = 0;
                    dx  = -dx;
                    Cats.SetAnimation(spriteId, "walk right");
                }
                Cats.SetSpritePosition(spriteId, (int)pos, 200);
            }
            Cats.SetScroll(-(int)pos, 0);
            Redraw(delta);
        }
Example #2
0
 void CreateSpriteInstance()
 {
     if (spriteId == -1)
     {
         spriteId = Cats.CreateSpriteInstance("sprite");
         Cats.SetAnimation(spriteId, "walk right");
         pos = 0;
         dx  = 100f;
     }
 }