Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8377183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:36:13+00:00 2026-06-09T15:36:13+00:00

I’m getting started to XNA and I want to build a basic 2D tile-based

  • 0

I’m getting started to XNA and I want to build a basic 2D tile-based engine.

So far i’ve allready made some car steering maths and handling but NO COLLISION yet.

Now I’ve decidet to make the car destructible, so when i hit a wall, the area of the car will be bumped.

picture

The center part of the car remains the same, but when an other car hits the players car from the left side, I want to replace the “normal” image of the left side with the “bumped” image from the left side.

My problem is, that i dont even now how to GROUP all the parts of the car ( there will also be Front and back lights added ) so when I drive all the parts are following.

So far i have a simple Car and CarParts class like this:

public Car() {
    Vector2D Position;
    float Rotation;
    Vector2D Direction;
    Texture2D BaseTexture;
    List<CarParts> Parts;
}

public CarParts() {
    Vector2D RelativePosition;
    Texture2D Testure;
}

where:

List[0] = FrontPart;
List[1] = FrontLeftPart;
List[2] = FrontRightPart;
List[3] = LeftPart;
List[4] = RightPart;
List[5] = RearLeftPart;
List[6] = RearRightPart;
List[7] = ReartPart;

How can i make those CHILDS move with the Main Car ?

° EDIT: or is there another way to make that happen ?

Thanks for all your help !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:36:14+00:00Added an answer on June 9, 2026 at 3:36 pm

    If you are using SpriteBatch, then the way to handle this is with careful setting of the origin parameter to the Draw method (MSDN). In this answer where I say “sprite” I mean a single call to Draw – so your car will be made up of multiple sprites.

    The origin parameter sets the origin from where position, scaling and rotation of your sprite takes place. You can set the origin to a position outside of the boundary of a sprite.

    The origin position is interpreted as relative to the top-left corner of the source rectangle of your sprite. (If you do not specify a source rectangle, a source rectangle that covers the entire texture is assumed). The origin is specified in units that match pixels in the source texture.

    So – you should maintain a list of the 9 textures (or 9 source rectangles, if you are using sprite sheets) that make up the different parts of your car. And, also, for each part, store an origin position.

    The origin positon that you set for each sprite will be (centre of car) - (top left of sprite).

    Car part example

    So for the centre sprite in the car, it will be approximately in the centre of the rectangle. For the top left corner of the car, it will be positive on both axes but beyond the boundaries of the sprite. For the bottom right corner, the origin will be negative on both axes therefore outside the sprite boundary. And so on for the other parts.

    Then, simply draw all 9 sprites that make up your car, each one having a different source-rectangle/texture and origin. But each one having the same position, scale, and rotation.

    No need to mess around with matrices or anything 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.