Game Development Reference
In-Depth Information
protected override void
LoadContent()
{
spriteBatch =
new
SpriteBatch(
this
.GraphicsDevice);
wheel = Content.Load<Texture2D>("wheel");
car = Content.Load<Texture2D>("car");
truck = Content.Load<Texture2D>("truck");
connection = Content.Load<Texture2D>("connection");
trailer = Content.Load<Texture2D>("trailer");
}
protected override void
Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Grey);
spriteBatch.Begin();
for
(
int
t = 0; t < road.Length; t++)
road[t].Draw(
this
,t
∗
120, 60);
spriteBatch.End();
}
}
class
MotorizedVehicle
{
public void
Draw(Game g,
int
x,
int
y)
{
}
}
class
Car : MotorizedVehicle
{
public void
Draw(Game g,
int
x,
int
y)
{
−
30), Color.Blue);
g.spriteBatch.Draw(g.wheel,
new
Vector2(x + 5, y
g.spriteBatch.Draw(g.car,
new
Vector2(x, y
−
10), Color.Red);
g.spriteBatch.Draw(g.wheel,
new
Vector2(x + 25, y
−
10), Color.Red);
}
}
class
Truck : MotorizedVehicle
{
public void
Draw(Game g,
int
x,
int
y)
{
−
45), Color.Green);
g.spriteBatch.Draw(g.wheel,
new
Vector2(x + 5, y
g.spriteBatch.Draw(g.truck,
new
Vector2(x, y
−
10), Color.Red);
g.spriteBatch.Draw(g.wheel,
new
Vector2(x + 20, y
−
10), Color.Red);
−
10), Color.Red);
g.spriteBatch.Draw(g.wheel,
new
Vector2(x + 55, y
}
}