Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

KAMRAN IMRANLI
KAMRAN IMRANLI
4,107 Points

The exact place of a platform

When we choose coordinates for a platform, how to understand that which part of the platform will be located on that coordinate? As far as I remember from high school mathematics, you can choose or give exact coordinates to only points. We cannot give only one X, and one Y coordinate to a triangle or a rectangle (the closest shape of our platforms).

Without knowing any context of the question, I think the coordinates of any shape are just referring to the corner of the shape (probably the top-left pixel, or bottom right).

1 Answer

The positioning for platforms specifies the location of the top left corner of the platform. You can get the dimensions of the platform by clicking the image in the file list on the left hand side. For example platform_1.png is 192 x 32 pixels. Then to test just do the math (800-192 = 608 and 600-32 = 568).

platforms.create(0,  0, 'platform');
platforms.create(608, 568, 'platform');

The first platform is at the top left of the screen. The second platform is at the bottom right.