Two questions in one thread!

BlitzPlus Forums/BlitzPlus Programming/Two questions in one thread!

schilcote(Posted 2009) [#1]
I have two problems I need help with, and they have to do with two of the three things I have not yet mastered in blitz: graphics and Types. (The third are DLLs, if you were wondering.)

Okay, first question.
Is there a way to sort of do the opposite of the Viewport() command? What I mean by this is the viewport sort of shrinks the drawing area on the screen. What I need to do is shrink the screen onto the drawing area, if that makes any sense.

I am writing a sort of galaxy management system for 2D space sim/RPGs (think Spore). Right now I am writing the function to draw the map zoomed in to a level. So, if the screen is zoomed in, the player will only see the upper left corner of the galaxy, which is fine untill you want to go to a planet on the right or lower left side. I need to make the screen draw relative to the player's location, but I don't really have any ideas on how to do this. I can zoom the screen in with simple multiplication (just multiply everythings x,y coordinates and sizes by the zoom level) but I can't make the screen center on the player.

The second is a more sort of hypothetical question. Is it possible for types to be inside types? This question might sound silly to pepole who are experienced with types, but I might not really understand what types are supposed to be. I was thinking how you can do "galaxy.star" with types, and I thought, could you do "galaxy.star.planet"? Sort of use the type as a type collection inside its own type collection. I sort of think I could have the program go through galaxy.star=Each star and then have planets "inside" the star, sort of do galaxy.star.planet=Each planet sort of thing.

Some of my text might be confusing (it confuses me a little bit actually), so ask if you want me to clarify something.


Matty(Posted 2009) [#2]
To zoom in one a point you are almost on the right track with multiplying the x/y coordinates by the zoom factor:

Subtract the 'player x/y' from the coordinates first then multiply as follows:

(Zoom Level * (CoordinateX - PlayerX)) + (ViewPortWidth /2)
(Zoom Level * (CoordinateY - PlayerY))  + (ViewPortHeight /2)



schilcote(Posted 2009) [#3]
I had a flash of inspiration a while ago and managed to figure it out on my own. I thought like this, "Since relativity says that you can't tell whether you're moving or everything else is, I wonder if instead of moving the camera over top of the bit of galaxy I want to look at, I could instead move the bit of galaxy under the camera?" So I wrote the following code:

starx=starx*zoom
stary=stary*zoom
radius=radius*zoom

starx=starx+x
stary=stary+y


It worked first try!

I don't really understand the code you gave me, but my code seems to work, so I'll just stick with that.