Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / World Co-ordinates & Screen Co-ordinates ???

Author
Message
Rudders
12
Years of Service
User Offline
Joined: 20th Jan 2012
Location: Oxfordshire UK
Posted: 15th Feb 2012 11:49
Hello All,

Would someone please expalin World Co-ordinates & Screen Co-ordinates..

I get the SetViewOffset(x,y) command which will move the screen view of the World... But what World?

How is the World size determined or set?

Somewhat confused!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Feb 2012 17:24
Hi Rudders, I started a set of tutorials in the TGC newsletter called AppGameKit Bitesize. I suggest you take a look at the first one which explains this fairly well (I hope!).

AGK Bitesize 1: The AppGameKit World

Rudders
12
Years of Service
User Offline
Joined: 20th Jan 2012
Location: Oxfordshire UK
Posted: 17th Feb 2012 09:11
Hi baxslash and thanks for the tutorial, very helpful especially the Depth aspect.

However! And I am feeling a bit thick here... I still do not really understand the World (both AppGameKit and the real one!)

Your tutorial implies that any coordinates outside the screen is in the world, is this correct?

Is the coordinate -1,0 a world coordinate as it is outside the screen.

Your starfield code checks to see if a star sprite is outside of the screen and therefore in the work and if it is you reset its position in the screen...

If my assumptions are correct then, you can change the view of the screen by moving it from its origin 0,0 to bring into view any area outside of the screen (the world) to display sprites that were positioned off screen..

Is it that simplistic?

Thanks for your help ... and patience!

Rudders
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 17th Feb 2012 09:53
Think of it like this:
The "World" is viewed through the "Screen" just like something filmed by a camera. You can position things in the world and change which part of the world you look at using "setViewOffset".

You can find out whether a world co-ordinate is within the screen using the "worldToScreen" commands. If a world co-ordinate passed through these commands returns as negative or higher than the screen size then it is not on the screen.

Similarly you can fix sprites to the screen like the graphics on news programs on TV using "fixSpriteToScreen".

Quote: "If my assumptions are correct then, you can change the view of the screen by moving it from its origin 0,0 to bring into view any area outside of the screen (the world) to display sprites that were positioned off screen..

Is it that simplistic?
"

Yes, pretty much!

Experiment. Let me know if you have any more questions. You can post them here if you like.

Also I will be posting further tutorials here: Free resources from ADG

Rudders
12
Years of Service
User Offline
Joined: 20th Jan 2012
Location: Oxfordshire UK
Posted: 17th Feb 2012 12:39
Great, crystal clear now. Thanks again for your superb help.

Login to post a reply

Server time is: 2024-05-03 14:58:27
Your offset time is: 2024-05-03 14:58:27