1 / 7

Moving the Snake

MoveSnake () Method. Moving the Snake. How do we move the snake?. In the program, the snake head and tail are the only parts that move. Tail. Head. How do we move the snake?. The snake head and tail are each tracked in the SnakeSpriteData structure. public struct SnakeSpriteData {

Télécharger la présentation

Moving the Snake

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MoveSnake() Method Moving the Snake

  2. How do we move the snake? • In the program, the snake head and tail are the only parts that move. Tail Head

  3. How do we move the snake? • The snake head and tail are each tracked in the SnakeSpriteDatastructure. publicstructSnakeSpriteData { publicintsnakeLength; publicintsnakeHeadXCoordinate; publicintsnakeHeadYCoordinate; publicSegmentDirectionsnakeHeadDirection; publicintsnakeTailXCoordinate; publicintsnakeTailYCoordinate; publicSegmentDirectionsnakeTailDirection; publicintamountOfBends; publicsnakeBendData[] snakeBendArray; }

  4. How do we move the snake? • Snake movement is determined based upon the direction the head and tail are moving • publicSegmentDirectionsnakeHeadDirection • publicSegmentDirectionsnakeTailDirection Tail Head (10,5) x y (21,7) x y

  5. How do we move the snake? • The direction of the snake head and tail indicate which coordinate components (x or y coordinate) need to be changed X Tail Head (10,5) x y (21,7) x y Y

  6. How do we move the snake? • The direction of the snake head and tail indicate which coordinate components (x or y coordinate) need to be changed X Tail Head (10,5) x y (21,7) x y Y

  7. How do we move the snake? • The components that should be changed follow based on the direction • Up • Y component needs to decremented (subtracted from) • Down • Y component needs to incremented (added to) • Right • X component needs to incremented • Left • X component needs to decremented

More Related