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

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?
How to calibrate kinect skeleton data to video feed?
XNA game studio4.0 using c#
How to add collision detection in a 2D car game in XNA?

Categories

HOME
multithreading
keras
image-processing
mockito
drivers
gis
rubygems
ip
webpack-2
ravendb
kibana-4
spring-kafka
etl
opentracing
pc
undefined
clickonce
cultureinfo
format-specifiers
rundeck
cas
facet
bootstrap-material-design
maquette
nameservers
javascriptcore
key-value-observing
lxd
hybridauth
form-data
normal-distribution
http-digest
vxworks
simplexml
espeak
ssjs
trim
email-templates
pdf-reactor
firebase-admin
android-mediaprojection
nxlog
node-sass
apache-fop
dropbox-php
csound
slickedit
android-cursor
knpmenubundle
or-tools
medium.com
file-writing
qpid
clang-static-analyzer
prettytensor
hill-climbing
whois
cannon.js
jmeter-maven-plugin
kcachegrind
angular-leaflet-directive
map-projections
cakephp-3.1
npapi
formatjs
facebook-graph-api-v2.4
xcode-6.2
navigationservice
reactfx
mechanize-ruby
srs
uv-mapping
gridfs
dir
apc
google-cloud-save
comaddin
anonymous-methods
path-separator
rdoc
labwindows
doh
external-accessory
genshi
yetanotherforum
yui-datatable
fixed-width
kdbg
microsoft-virtualization
adrotator

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App