问题描述
大家好,我很抱歉我不知道应该在哪里发布这个特别的东西...... :(反正,
Hello all, I'm sorry I have no idea where I should of posted this particular thing... :( anyways,
我正在尝试制作一个简单的跟踪程序而且我不知道应该从哪里开始。我之前使用过它而且它是mega在很多方面很有帮助。
I am trying to make a simple tracking program and I am at a loss of where I should begin. I've used this before and it was mega helpful in a lot of ways.
到目前为止我所做的是形式,但从那时起我感到很茫然基本上它是一个带有N,S,E和W按钮以及坐标l的程序abel显示当前坐标,它从{X = 0,Y = 0}开始,然后它们也是Go 1按钮和Go 10按钮
所以它的功能如下:
What I have so far is the form made but from that point I'm at a loss. Basically it is a program with N, S, E, and W button and a Coordinate label that displays the current coordinate it starts at {X=0, Y=0} then their is also a Go 1 button and a Go 10 button so how it functions is like first:
我点击让我们说E(东)按钮>
I click the lets say the E (East) Button >
然后我点击Go 10按钮>
Then I click the Go 10 button >
标签将更改为{X = 10,Y = 0}。
The label will change to {X=10, Y=0}.
所述示例的延续将是:
A continuation of said example would be:
然后我点击S(南)>
I then click S (South) >
后跟Go 1>
Followed by Go 1 >
然后标签为{X = 10,Y = -1} ......
The label would then be {X=10, Y=-1}...
希望这是有道理的,但这正是我目前正在努力实现的目标。
Hopefully that makes sense but that's what I am currently trying to achieve.
推荐答案
例如,如果你点击"W"面朝西,你可以更新你的方向向量,如下所示:
For example, if you click 'W' to face west you might update your direction vector like this:
directionX = -1;
directionY = 0;
directionX = -1;
directionY = 0;
将此技术适当地应用于其他基数方向处理程序。
Apply this technique appropriately for the other cardinal direction handlers.
Go 1会这样做:
positionX + = directionX;
positionY + = directionY;
positionX += directionX;
positionY += directionY;
和Go 10会这样做:
and Go 10 would do:
positionX + = directionX * 10;
positionY + = directionY * 10;
positionX += directionX * 10;
positionY += directionY * 10;
您可以决定North是+ Y还是-Y。
You can decide whether North is +Y or -Y.
如果North是posit依维尔,然后"面向北方"。会做:
If North is positive Y, then "face north" would do:
directionX = 0;
directionY = 1;
directionX = 0;
directionY = 1;
这篇关于机器人追踪计划?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!