This snake can move

Published August 23, 2019
Advertisement

Here's our snake, zipping around the field waiting for an apple to appear. ?

basic-snake-moving.jpg.77e935d570a58eeeab1128260538e454.jpg

Keeping track of the snake's body as it moves and turns was the trickier part of this, so I think I'm over the hump as far as the basic game goes.  Now I just need to add apples, and keeping track of the snake length on the screen.  Then I can get to adding some of the nicer features like music, sound effects, and game options.  I feel like I have a decent shot at getting the basic game done before the weekend is out. ?

Some of the things I wanted to take note of:

  • I feel like it's sometimes not responding to all key press events when the player presses two keys in quick succession.  I think the cause is that I'm gathering all events in one "update" call, and going with only the last one.  If the player presses two keys quickly enough, it only uses the last one to determine the input for the next frame.  I'm going to want to look into creating a queue of inputs, where each "update" call uses up the next input from the queue.
  • Right now, the grass texture is part of the same tile-set texture as all the other game elements.  I think this should be split out, so that I can render all of the grass in a single call; rather than width * height calls with the same sprite (there are 1250 total tiles on the playing field).  It's not slowing the game down anywhere near the 60fps range, but I do prefer to be more efficient than less efficient...  I'll be curious to see if this improves rendering performance at all.
  • For drawing the snake, I created the SFML "sf::Sprite" objects on-the-fly.  This doesn't appear to be a performance issue.

 

Very much looking forward to getting the basic game done so that I can start working on "phase 2"! ?

1 likes 0 comments

Comments

Rutin

What I did for my SFML pac-man game is I built in an input queue which worked really well. :) Right before hitting a turn you could hit up while moving right and once up was available it would go. It really made maze navigation super fluid.

Keep up the great work.

August 23, 2019 09:46 PM
rileyman

Well now I'm going to have to find your pac-man game ?

 

August 25, 2019 02:46 AM
Rutin
5 hours ago, rileyman said:

Well now I'm going to have to find your pac-man game ?

 

Oh it's nothing fancy just something I did as part of the GameDev challenges:

 

When you're already moving right for example, hit down on the arrow key and you'll automatically go down when it's available. It only holds 1 key stroke in the queue for this game. You'll find it makes maze navigation smoother. :) 

August 25, 2019 07:56 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement