am I doing this right?

BlitzMax Forums/BlitzMax Beginners Area/am I doing this right?

hi angel daniel thanks for your response. you said

What you COULD do is say, if the player wants to fly to the right, then you start subtracting values from the X coordinate of the origin


I originally posed this code
setorigin (graphicswidth()/2 - x , graphicsheight()/2 - y )


am I right in saying that this code is doing what you said? as its doing a subtracting calculation with x changing as you move the ship.


Presumably you are only drawing enemies that are within the visible part of the game world, though?/quote]

Actually I have drawn some enemies like x= 2000, y = 2000 and fly to meet them.

I have my ship,x displayed and my ship,y so i can see when I am nearing the 2000,2000 and also to help navigate :)

and when I get there the enemy ship is there waiting. Did you expect it wouldn't work? As in you didn't believe what I was doing could work? Or were you just asking.

Isnt the part you suggested with the gameworldOriginX and Y the same as with your first suggestion;
subtracting a value from the x coordinate of the origin and adding to the x coord of the playership?


[quote]if the player wants to fly to the right, then you start subtracting values from the X coordinate of the origin, while at the same time adding values to the X coordinate of the player ship - but not to the enemy ships


Also correct me if I am wrong now but isn't the above paragraph quote actually what I am doing? because-

I am subtracting a value from the x coordinate and y coordinate of setorigin with the code
setorigin (graphicswidth()/2 -x )
same for the Y coord of the setorigin.

AND i didnt mention before, of course I am adding to the x and y value of the ship based on how the player moves. And the x and y in that above code is the ship.x and ship.y, and this also means that the value being taken away from the x and y origin is the same as that being added to the ship. so the ship remains in the middle. Just like you explained

so the origin only moves when you move as in input(up,down,left right keys), which is how it should be right?

what I have done to limit the game world or create the box that the game world now is, is multiply world_width = screen_width * 2000.
which is fairly big.


let me know if I am right, in that what you wrote to do , is what I am actually doing, just didnt add in the part about the ship.

also then if you want to set something back to normal like for drawing interface graphics, you would have to put a setorigin 0,0 command back in the loop in that area before drawing them otherwise the origin would be being calculated with the other setorigin call, and this would be un wanted.