Keeping track of an object

Started by Ghostlady, Sat 11/02/2006 23:21:23

Previous topic - Next topic

Ghostlady

I am creating a puzzle that has 11 objects on two shelves.Ã,  Five objects on the top shelf and six objects on the bottom shelf.Ã,  When clicking on two of the objects, they will change places.Ã,  I know which two objects have been clicked.Ã,  The problem I am having is knowing where those objects are.Ã,  I have tried something like this:

Code: ags

if (Object.GetAtScreenXY(51,91) == oImage1) {
Ã,  Ã,  Ã, object[0].Move(51, 91, 5, eNoBlock, eAnywhere); }
else {
Ã,  Ã,  Ã,  if (Object.GetAtScreenXY(117,90) == oImage1) {
 Ã,  Ã,  Ã,  Ã,  Ã,  object[0].Move(117, 90, 5, eNoBlock, eAnywhere); }


but it is not working.Ã,  The coordinates are from what is displayed as the "objects position" when adding an object on the screen.Ã,  Ã, Are these coordinates different than the screen coordinates and if so, how would I adjust?
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

Ashen

#1
Is it a scrolling room? If so, then: Yes, those coordinates may be different to screen coords, and you'd adjust like this:
Code: ags

if (Object.GetAtScreenXY(51-GetViewportX(),91-GetViewportY()) == oImage1) {
     object[0].Move(51, 91, 5, eNoBlock, eAnywhere); }
else if (Object.GetAtScreenXY(117-GetViewportX(),90-GetViewportY()) == oImage1) {
          object[0].Move(117, 90, 5, eNoBlock, eAnywhere); }


You might also have a problem if you're using 640x4*0 (and possibly 800x600) resolution (see this BFAQ entry).

Finally - what if you check the object's current coords directly, instead of using GetAtScreenXY(), i.e.:
Code: ags

if (oImage1.X == 51 && oImage1.Y == 91) {
  /Blah



(Or possibly some combination of the last two.)
I know what you're thinking ... Don't think that.

Ghostlady

Bravo Ashen,

This worked:

Code: ags
if (oImage1.X == 51 && oImage1.Y == 91) {


I was really pulling hair with this one.

BTW, it is not a scrolling room and it is using the 640 x 480 size.

My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

SMF spam blocked by CleanTalk