Download
movesnake method n.
Skip this Video
Loading SlideShow in 5 Seconds..
Moving the Snake PowerPoint Presentation
Download Presentation
Moving the Snake

Moving the Snake

178 Views Download Presentation
Download Presentation

Moving the Snake

- - - - - - - - - - - - - - - - - - - - - - - - - - - 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