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 9233033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:27:21+00:00 2026-06-18T06:27:21+00:00

I have a simple game that I’m trying to do for learning purposes, but

  • 0

I have a simple game that I’m trying to do for learning purposes, but Matrices are a bit hard, especially in DirectX.

I currently have a tilesystem that renders tiles at the screen and a character position at the center (on startup)

When the player move to the left, the ground should move to the right so he’s always at the center of the screen. I use a Sprite to transform the Tiles and the player, but having trouble because the ground is moving and the player stands still on the ground still positioned at the center.

This is a topdown 2D game so I only need to transform Position (and perhaps rotation)

My Camera class has this method:

D3DXMatrixTransformation2D(&View, NULL, 0, &Scale, &Center, D3DXToRadian(Rotation), &Position);

I’ve also tried (for the Camera):

D3DXMatrixTranslation(&View, Position.x, Position.y, 0);

then when I render the ground sprite I set it to transform to the camera, but the Player has it’s own Matrix that I use when he’s moving.

Exactly like the one above but with his position, rotation and such…

What am I missing and what do I need?

I only have a tilesystem that fits the width/height of the screen so I should see when he’s moving but he’s standing still at the center and the ground and the player is moving.

Do I need to invert the matrix so that the ground moves in the opposite direction?

Only the player moves here and the world transforms around him.

Example

I must say that being the number #1 language in game programming there’s very little guides that explains simple things as “TopDown Camera in 2D”…

  • 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-18T06:27:22+00:00Added an answer on June 18, 2026 at 6:27 am

    With the help of people at the chat I realized what the problem was with my system, altough I tried similiar things but probably in the wrong way / order.

    For a simple 2D TopDown camera with just positioning:

    Camera2D Translation:

    D3DXMatrixTranslation(&CameraView, Position.x, Position.y, 0);
    

    For each object in the camera’s view:

    D3DXMATRIX ObjectWorld;
    D3DXMatrixTransformation2D(&ObjectWorld, NULL, 0, NULL, NULL, 0, &Position);
    
    D3DXMATRIX Translation;
    D3DXMatrixMultiply(&Translation, ObjectWorld, CameraView);
    

    and then to render the sprite:

    sprite->SetTransform(&Translation);
    sprite->Draw(Texture, NULL, NULL, NULL, Color);
    

    altough this method requires me to move the camera in the opposite direction that the player is moving, so if player is moving +100, the camera should move -100 to still be positioned at the same location relative to the player.

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

Sidebar

Related Questions

Trying to make simple minesweeper game in python, but have one problem. I have
This is a very simple game I'm trying to write but I have a
I have a simple JavaScript game that sends a score to PHP by adding
I have a very simple HTML5 game that works as expected from a regular
Say I have simple program that emulates a board game with a number of
I have just started trying to make a simple game with XNA 3.1 to
For quite awhile I have been trying to make a simple game in Java
I have a simple game that renders 2D graphics to a frame buffer (not
i am trying to make a very simple game where i have 7 positions
I have a simple game that I am building in as3/air using flash develop,

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.