开发者

2D World, massive world exploring tutorial? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 9 years ago.

Improve this question

I'm wondering if anyone here might be kind and link me to some tutorial that will teach you how to make a big world, by that I mean a game in XNA that is bigger than what you set your resolution too. Meaning that you have a big world you can explore, you are not just stuck to the size of your monitor. Please note I've only programmed in C# & XNA for some 6 months. But I have 5 years of game development experience.

So what I'm after is: Some basic camera? Break world/game limits of monitor size.

NOTE: I don't really know w开发者_如何学编程hat to search for to find something like this. Tips on what to search for would be appriciated.


Since pretty much every game does this, and they all do it in a different way, you're going to have trouble finding a tutorial on this specifically.

Luckily, the principles are quite simple:

  • Everything in your game has a position, which is in world coordinates.
  • You have a camera or viewport position, also in world coordinates, to determine which part of the world you're looking at.
  • To know where to draw something on the screen, you have to convert from world coordinates to screen coordinates.
  • Your screen view is relative to the camera, so to do this conversion, you simply subtract the camera position from an object's world position to get the object's screen position.

Try creating several objects, giving them positions in a world larger than the screen (eg. 4000x4000), and move the camera position around with the keys or joypad.

You will notice that this means the position of your camera corresponds to the world position visible at one corner of the screen. To have the camera pointing at the middle of the screen instead, you need to also subtract half the screen width and half the screen height into the translation operation that changes world positions into screen positions.

But I have 5 years of game development experience.

No offence, but what have you done for 5 years if you haven't ever had to move the viewpoint? It sounds like your experience isn't very typical for game development.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜