slider puzzle

Started by Ghostlady, Sun 23/05/2010 15:44:35

Previous topic - Next topic

Ghostlady

I pulled a script from a previous game for a slider puzzle.  It doesn't seem to work for my new game.  Is there an easier way to do this than by checking "exactly where" (pixel) the moving square is?  The pieces are sized at 100 x 100.

Here is the script.

int button_pressed=0;
Object *ob;

function room_RepExec()
{
   
 int correct;
 int i=1;
 while (i <=  8)  {      // or number of slide-pieces (this # is 8, for some reason, a smiley shows up when I post)
   Hotspot *hot = Hotspot.GetAtScreenXY(object.X+25,  object.Y-25);  //Middle of tile
   if (hot.ID == i) correct ++;
   else correct = 0;
   i ++; }

if (correct == 8)      { // or number of slide-pieces
 Wait(20);
 object[9].Visible = true;
 Wait(40);
 object[9].Move(185, 195, 5, eNoBlock, eAnywhere);
 Wait(80);
 Display ("you did it");  
 player.ChangeRoom(131);
}
     
 if (mouse.IsButtonDown(eMouseLeft)) {
   if (button_pressed==0) {
     button_pressed = 1;
     ob = Object.GetAtScreenXY(mouse.x, mouse.y);
   }
 }
 else {
   button_pressed=0;
   if (ob != null) {
     ob.Baseline = 0;
     if (Object.GetAtScreenXY(ob.X + 50, ob.Y-1) == null && GetWalkableAreaAt(ob.X+50, ob.Y-1) != 0) {
       ob.Move(ob.X+50, ob.Y, 3, eBlock);
     }
     else if (Object.GetAtScreenXY(ob.X - 50, ob.Y-1) == null  && GetWalkableAreaAt(ob.X-50, ob.Y-1) != 0) {
       ob.Move(ob.X-50, ob.Y, 3, eBlock);
     }
     else if (Object.GetAtScreenXY(ob.X, ob.Y-51) == null  && GetWalkableAreaAt(ob.X, ob.Y-51) != 0) {
       ob.Move(ob.X, ob.Y-50, 3, eBlock);
     }
     else if (Object.GetAtScreenXY(ob.X, ob.Y+49) == null  && GetWalkableAreaAt(ob.X, ob.Y+49) != 0) {
       ob.Move(ob.X, ob.Y+50, 3, eBlock);
     }
     ob = null;
   }
 }
}
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

SMF spam blocked by CleanTalk