Game world question

BlitzMax Forums/BlitzMax Beginners Area/Game world question

blackwater(Posted 2010) [#1]
Hi everyone! I'm brand new to BlitzMax, I did some forum searches on this topic but I'm still confused about a few things, hopefully I can explain this correctly.

Do the screen coordinates ever change? What I mean is does the viewport always have the coordinates 0.0 to whatever the screen is set at?

I guess what I'm getting at is how would I create a map that goes beyond the viewport? If I move the player object to the left, for example, and let's say a game object was at coordinates -100,-100 how would I display that?

Or does the viewport not change at all and I'll actually have to shift the game objects so they get displayed when the player is near them?

What I'm asking is, take the game Eschalon, how does the player object navigate around the game world?

Thanks in advance for any help.


Yahfree(Posted 2010) [#2]
It's all relative. You can do whatever you want with object coordinates. The screen coordinates simply represent the pixels on the screen.

A way to achieve the effect you're looking for, is to define a game world size, say 20,000px by 20,000px, and define a location, say 10,000px by 10,000px

You would change what you render to the screen based on the location, and when you move, you would move the location coordinates, not anything else.

Sorry if that was a bit abstract, but really programming is very abstract. You could define the viewport to be -200 to 4000 if you wanted to. Everything is relative. (did I already say that? :) )


TaskMaster(Posted 2010) [#3]
Look into the SetOrigin command. It changes the location of the top left corner.


Czar Flavius(Posted 2010) [#4]
You should be wary of changing the origin - you don't want to draw the entire map and simply offset it globally.

1. What is on the screen? When you update each game object, do a check. Is their position in the game world, minus the user's current position (scroll), above 0 and below the size of the screen? If so, add them to a visible_objects list.

2. Draw only what is in the visible_objects list, but minus from their position the current scroll coordinates. Afterwards, clear the visible_objects list.

Example, screensize 640x480, mapsize 10000x10000, current scroll position is such that (5000, 5000) is the top left corner of the screen. Badguy at position (5500, 5200) of the map. Minus the scroll, and you get (500, 200). Both of these are above 0 and below (640, 480). The badguy is visible! Draw him at (500, 200) "real" screen coordinates.

You don't need to change the origin to get this to work. For a very large map, your game will be much faster. With the same numbers, a badguy at (6000, 6000) would not be drawn.


Jesse(Posted 2010) [#5]
I don't know if this will help you. I made a really simple tile map engine a few years back and posted it in the code archives:
http://www.blitzmax.com/codearcs/codearcs.php?code=2235
it's not too complicated but it is in Object format of which I think it might be a bit too complicated for a beginner but sense I don't know much about how much you konw, I'll let you be the judge.
I used to have the complete demo in a zip for download but for reasons beyond my control it's no longer an option. sorry.


TomToad(Posted 2010) [#6]
I made a little tutorial on one method for scrolling large maps. Check it out here
http://www.blitzbasic.com/Community/posts.php?topic=91640


blackwater(Posted 2010) [#7]
Thanks guys, all of this information helped a lot. I wasn't sure if there were screen coordinates and a separate world coordinates but now I understand, or at least I think I do!