PDA

View Full Version : Object Stop at X,Y Point


aquataze
05-28-2006, 10:17 PM
I need to know how to make an object atop and not move any fatrther at a certain point even if it is told to move.
This is for a board game and when a question is answeres incorrect the image moves back but if the first image is incorrect it still moves back past the board. So I neeed some code that will stop it from moving past a certain point. Fast help appreciated!
Thank You!

aquataze
05-28-2006, 10:50 PM
Sorry that's supposed to say


I need to know how to make an object STOP and not move any fatrther at a certain point even if it is told to move.
This is for a board game and when a question is answers incorrect the image moves back but if the first image is incorrect it still moves back past the board. So I neeed some code that will stop it from moving past a certain point. Fast help appreciated!
Thank You!

Intrigued
05-28-2006, 11:00 PM
Okay, one way you can do this at design time even is to move your image to each place on the board that the image could possible be. Then, save each of those X and Y coordinates into a variable. How I did this was to move the image around on the Page at design time again, and then I made a note of what the Properties (left side of the IDE for AMS) stated (numbers) and then that is what you can use to make sure the images (objects, game pieces, etc.) match exactly where you want them to be at run-time! Finally, just calculate off of those fixed "land spots" and then either subtract or add to the positions to keep the game pieces inside of gameboard limits. Anyway, several ways to do this I suppose.

Now, if you want to allow for dynamic change of the window size and objects (the board).. you need a different approach.

:yes

Intrigued
05-28-2006, 11:26 PM
Here's something very basic, but it should help you out:

http://www.amsuser.com/ams/examples/ObjectExactMove-AMS6-Intrigued.apz

(sample project)

aquataze
05-29-2006, 04:19 PM
How can I put the size of the board instead of it using the windows size
local tblScreenSize = Page.GetSize();
g_nScreenWidth = tblScreenSize.Width;
g_nScreenHeight = tblScreenSize.Height;

Becuase the gameboard is only part of the screen

aquataze
05-29-2006, 04:42 PM
Or if you could edit this code to not allow an image to move left of its original position.


if (question_index > 0) then

if (answer_list[question_index] == "A") then
text = "You're right. Good job!";
Paragraph.SetText("Question",text);
numcorrect = numcorrect + 1 BadGuy.MoveRight();
else

text = "Incorrect. The correct answer is "..answer_list[question_index].."!";
Paragraph.SetText("Question",text) BadGuy.MoveLeft();
end


HideAnswerButtons();


SetupNextQuestion();
end

aquataze
05-29-2006, 06:23 PM
Nevermind I thigured it out thank you

Intrigued
05-29-2006, 08:14 PM
Congrats. and no problem!

aquataze
05-30-2006, 02:46 PM
Now I just need to thigure out how to jump to a page when an image reaches a specific point.

TJS
05-30-2006, 03:05 PM
Following Intrigued's suggestion, if you use a set of global variables to track the coordinates of the player's progress (one set for current and a second for target) you can add your Page.Jump() action when the current==target.

In the example I posted I used three sets of variables:
1) Current coordinates
2) Step coordinates (makes the player's piece step from square to square)
3) Target coordinates (the last step in the player's turn)

http://www.indigorose.com/forums/showthread.php?t=16282