Skip to main content
Inlined some external references and added some tags.
Source Link
aaaaaaaaaaaa
  • 8.9k
  • 1
  • 23
  • 35

What is the most practical way to implement camera/viewport to a 2D-game?

I've read, that I should store the object world position instead of position relative to the screen?

Current situation:

I have implemented a simple 2D-game where I load objects and levels from XML-files. Currently the level XML-file looks like this.this:

<map>
   <tile obj="ground" x="0" y="555" />
   <tile obj="ground" x="16" y="555" />
   <tile obj="ground" x="32" y="555" />
   ...
</map>

All objects have a 2d-vector "position" storing their current location on the screen.

What I want it to be:

I made a picture to explain what I'm trying to achieve.Viewport/gameworld illustration

In the picture:

  • Camera is either 800x600 or 640x480
  • Blocks and sprites are 16x16 pixels.
  • World size may vary
  • The coordinates probably should be normalized relative to the world, not to the screen?
  • Viewport position relative to player's x, y and moves when the player reaches camera dead zone (similar to this video).

I'm asking pseudo examples / articles, but if you need to know what I'm using for the development: SDL & C/C++.

What is the most practical way to implement camera/viewport to a 2D-game?

I've read, that I should store the object world position instead of position relative to the screen?

Current situation:

I have implemented a simple 2D-game where I load objects and levels from XML-files. Currently the level XML-file looks like this. All objects have a 2d-vector "position" storing their current location on the screen.

What I want it to be:

I made a picture to explain what I'm trying to achieve. In the picture:

  • Camera is either 800x600 or 640x480
  • Blocks and sprites are 16x16 pixels.
  • World size may vary
  • The coordinates probably should be normalized relative to the world, not to the screen?
  • Viewport position relative to player's x, y and moves when the player reaches camera dead zone (similar to this).

I'm asking pseudo examples / articles, but if you need to know what I'm using for the development: SDL & C/C++.

What is the most practical way to implement camera/viewport to a 2D-game?

I've read, that I should store the object world position instead of position relative to the screen?

Current situation:

I have implemented a simple 2D-game where I load objects and levels from XML-files. Currently the level XML-file looks like this:

<map>
   <tile obj="ground" x="0" y="555" />
   <tile obj="ground" x="16" y="555" />
   <tile obj="ground" x="32" y="555" />
   ...
</map>

All objects have a 2d-vector "position" storing their current location on the screen.

What I want it to be:

Viewport/gameworld illustration

In the picture:

  • Camera is either 800x600 or 640x480
  • Blocks and sprites are 16x16 pixels.
  • World size may vary
  • The coordinates probably should be normalized relative to the world, not to the screen?
  • Viewport position relative to player's x, y and moves when the player reaches camera dead zone (similar to this video).

I'm asking pseudo examples / articles, but if you need to know what I'm using for the development: SDL & C/C++.

deleted 45 characters in body
Source Link
bluekirai
  • 313
  • 1
  • 2
  • 5

What is the most practical way to implement camera/viewport to a 2D-game?

I've read, that I should store the object world position instead of position relative to the screen?

Current situation:

I have implemented a simple 2D-game where I load objects and levels from XML-files. Currently the level XML-file looks like this (sorry for the messiness)this. All objects have a 2d-vector "position" storing their current location on the screen.

What I want it to be:

I made a picture to explain what I'm trying to achieve. In the picture:

  • Camera is either 800x600 or 640x480
  • Blocks and sprites are 16x16 pixels.
  • World size may vary
  • The coordinates probably should be normalized relative to the world, not to the screen?
  • Viewport position relative to player's x, y and moves when the player reaches camera dead zone (similar to this).

I'm asking pseudo examples / articles, but if you need to know what I'm using for the development: SDL & C/C++.

What is the most practical way to implement camera/viewport to a 2D-game?

I've read, that I should store the object world position instead of position relative to the screen?

Current situation:

I have implemented a simple 2D-game where I load objects and levels from XML-files. Currently the level XML-file looks like this (sorry for the messiness). All objects have a 2d-vector "position" storing their current location on the screen.

What I want it to be:

I made a picture to explain what I'm trying to achieve. In the picture:

  • Camera is either 800x600 or 640x480
  • Blocks and sprites are 16x16 pixels.
  • World size may vary
  • The coordinates probably should be normalized relative to the world, not to the screen?
  • Viewport position relative to player's x, y and moves when the player reaches camera dead zone (similar to this).

I'm asking pseudo examples / articles, but if you need to know what I'm using for the development: SDL & C/C++.

What is the most practical way to implement camera/viewport to a 2D-game?

I've read, that I should store the object world position instead of position relative to the screen?

Current situation:

I have implemented a simple 2D-game where I load objects and levels from XML-files. Currently the level XML-file looks like this. All objects have a 2d-vector "position" storing their current location on the screen.

What I want it to be:

I made a picture to explain what I'm trying to achieve. In the picture:

  • Camera is either 800x600 or 640x480
  • Blocks and sprites are 16x16 pixels.
  • World size may vary
  • The coordinates probably should be normalized relative to the world, not to the screen?
  • Viewport position relative to player's x, y and moves when the player reaches camera dead zone (similar to this).

I'm asking pseudo examples / articles, but if you need to know what I'm using for the development: SDL & C/C++.

Tweeted twitter.com/#!/StackGameDev/status/283648839116795904
added 76 characters in body
Source Link
House
  • 73.5k
  • 17
  • 188
  • 276

What is the most practical way to implement camera/viewport to a 2D-game?

I've read, that I should store the object world position instead of position relative to the screen?

Current situation:

I have implemented a simple 2D-game where I load objects and levels from XML-files. Currently the level XML-file looks like this (sorry for the messiness). All objects have a 2d-vector "position" storing their current location on the screen.

What I want it to be:

I made a picture to explain what I'm trying to achieve. In the picture:

  • Camera is either 800x600 or 640x480
  • Blocks and sprites are 16x16 pixels.
  • World size may vary
  • The coordinates probably should be normalized relative to the world, not to the screen?
  • Viewport position relative to player's x, y and moves when the player reaches camera dead zone (similar to this).

I'm asking pseudo examples / articles, but if you need to know what I'm using for the development: SDL & C/C++.

What is the most practical way to implement camera/viewport to a 2D-game?

I've read, that I should store the object world position instead of position relative to the screen?

Current situation:

I have implemented a simple 2D-game where I load objects and levels from XML-files. Currently the level XML-file looks like this (sorry for the messiness). All objects have a 2d-vector "position" storing their current location on the screen.

What I want it to be:

I made a picture to explain what I'm trying to achieve. In the picture:

  • Camera is either 800x600 or 640x480
  • Blocks and sprites are 16x16 pixels.
  • World size may vary
  • The coordinates probably should be normalized relative to the world, not to the screen?
  • Viewport position relative to player's x, y and moves when the player reaches camera dead zone.

I'm asking pseudo examples / articles, but if you need to know what I'm using for the development: SDL & C/C++.

What is the most practical way to implement camera/viewport to a 2D-game?

I've read, that I should store the object world position instead of position relative to the screen?

Current situation:

I have implemented a simple 2D-game where I load objects and levels from XML-files. Currently the level XML-file looks like this (sorry for the messiness). All objects have a 2d-vector "position" storing their current location on the screen.

What I want it to be:

I made a picture to explain what I'm trying to achieve. In the picture:

  • Camera is either 800x600 or 640x480
  • Blocks and sprites are 16x16 pixels.
  • World size may vary
  • The coordinates probably should be normalized relative to the world, not to the screen?
  • Viewport position relative to player's x, y and moves when the player reaches camera dead zone (similar to this).

I'm asking pseudo examples / articles, but if you need to know what I'm using for the development: SDL & C/C++.

deleted 149 characters in body
Source Link
House
  • 73.5k
  • 17
  • 188
  • 276
Loading
Source Link
bluekirai
  • 313
  • 1
  • 2
  • 5
Loading