Results 1 to 3 of 3

Thread: DXInput and DXSpriteEngine having some trouble.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    DXInput and DXSpriteEngine having some trouble.

    Well im using DXTimer with an interval of around 30 to fresh the screen and check the keyboard state to see if i need to move my sprite or not. I tryed two timer's but then nothing would draw

    My hero animation is 16 images 4 across and 4 down making up 128 by 128. So their 32x32 each and are all setup. For my hero sprite i have:

    AnimeCount as 4.
    AnimLooped as False //to begin with.
    AnimSpeed as either 30/50 or 15 //tryed quite a few things.
    AnimStart as 0 //facing downward.

    err well now to the actuall problem...... When my map loads up and the hero on it i press say right key his animation plays while it is held.... veryyyyy slowlyyyy no matter what AnimSpeed or Update Interval is i cant get animation cycling quick enough.

    And holding right key only works once and after that hitting that key and others (up,left,down) he does move as he should but his animation does not play. When DXInput is updated and a certain key is pressed i call my DoMove procedure with an argument specifying what key it was and this is what i do in it:
    Code:
    Procedure TFrmMain.HMove(Const Direction: ShortString);
    Begin
        Chesso.AnimLooped := True;
     If (Direction = 'Right') Then Begin
        Chesso.AnimStart := HRight;
        Chesso.X := Chesso.X  + 1;
     End
     Else If (Direction = 'Left') Then Begin
        Chesso.AnimStart := HLeft;
        Chesso.X := Chesso.X - 1;
     End
     Else If (Direction = 'Down') Then Begin
        Chesso.AnimStart := HDown;
        Chesso.Y := Chesso.Y + 1;
     End
     Else If (Direction = 'Up') Then Begin
        Chesso.AnimStart := HUp;
        Chesso.Y := Chesso.Y - 1;
     End;
    End;
    Chesso is the sprite, HRight and HLeft etc are constants for the directions which i use when changing sprites AnimStart value.

  2. #2
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    DXInput and DXSpriteEngine having some trouble.

    My guess is that the procedure is being called more than once - probably every time the frame updates. In the procedure you keep resetting the AnimationStart to the first frame of the animation so even if the animation frame tries to change it gets schanged back to the first one right away.
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  3. #3

    DXInput and DXSpriteEngine having some trouble.

    Well i tryed checking if it was already at that point but i guess that may not work either. Does anyone know a better way?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •