xna-4.0


XNA game how to make a snake tail


i am trying to figure our how to make a snake like tail for a XNA game. The snake it self is a sprite of 34x20 pixel, and my sprite of the tail is a 34x20 sprite.
But i am having problems finding a way to create a tale on.
My first idea is to make it tile based, and the remember the visited tiles, to a limit of the tail length. but this will make the tail lag, so after the snake have left the tile will there be a tail.
Do any one have an idear that i can make a tail of X length that follows the snake smooth, in an XNA game?
The snaked movement is based on pixel location, and can not stop, only change direction!
Nick Gravelyn wrote Sammy the Snake for XNA sometime ago (albeit in XNA 3), but I think that you'll find this most useful for your game.
In this example, he uses List<Point> to store the body points, which makes it very easy to add new body parts:
bodyPoints.Add(new Point(2, 0));
bodyPoints.Add(new Point(1, 0));
bodyPoints.Add(new Point(0, 0));
Then, when it comes to rendering, you can simply loop through the body points:
for (int i = 1; i < bodyPoints.Count - 1; i++)
{
DrawBody(
spriteBatch,
bodyPoints[i],
bodyPoints[i - 1],
bodyPoints[i + 1]);
}

Related Links

'Microsoft.Xna.Framework.Vector2' is a 'type' but is used like a variable?
Making a trading card game XNA
How do I fix 'No suitable method found to override' error on XNA 4.0?
When to use PresentationParameters.BackBufferWidth vs .Viewport.Width
What does the pixel shader function tex1D do with a Texture2d
How to add a lap timer in XNA?
Is there a Texture1D in XNA?
Particle System: XNA Framework HiDef profile does not support alpha blending on Vector4 textures
How to unset texture data in XNA 4.0
Detecting a Key Press in XNA 4.0?
How to add a start (splash) screen in XNA 4.0?
My program is being reported as a high-level security threat by AVG?
How to add an end screen in XNA 4.0?
Texture2D is way oversized in XNA 4.0?
How to set xna's TextureFilter to Point
Why doesnt my xna pixel shader turn this texture blue?

Categories

HOME
sendgrid
xamarin
cookies
pycharm
plone
office365api
jsp-tags
setup-deployment
spring-cloud-stream
jsrender
acquia
opengl-es-2.0
android-youtube-api
esper
basic
communication
adobe-analytics
google-cloud-ml
google-cloud-spanner
commonmark
fortumo
visual-studio-cordova
decimal
percona
solaris-10
django-cms
grails3
facebook-instant-articles
fish
kannel
buck
saas
vision
frame
javascriptcore
phonegap
pdb
calibre
serverside-rendering
occlusion
service-discovery
unspecified
uft-api
bootstrapper
broadcastreceiver
import-from-excel
apple-news
cubic-spline
termination
jlink
alphabet
darcs
media-player
iso8601
bind9
lync-client-sdk
background-service
probability-density
azure-virtual-network
pcf
impresspages
fputcsv
connect-by
make-install
associative-array
thredds
tableau-online
microbenchmark
unity3d-gui
system32
web-controls
codeigniter-url
phalanger
xcode-6.2
issuu
neolane
code-access-security
project-planning
rtmfp
balanced-payments
algebraic-data-types
gnu-smalltalk
quantlib-swig
ms-project-server-2010
dexterity
xamlparseexception
specification-pattern
trusted
jspinclude
objective-c-2.0
windows-phone-7.1.1
work-stealing
netbeans-7.1
visitor-statistic
cxxtest
iweb
phonon
msdev
grid-system
windows-live-messenger
caching-application-block

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App