How to point a sprite in a specified direction in micro:bit? - bbc-microbit

I'm working on a basic game for micro:bit just as a way to learn the technology, and I was hoping that one of the sprites would move in the direction of the compass.
Is there a way to do this?

Use the "set" block to set the direction of the sprite to "compass heading (ยบ)", then "move" the sprite a number of steps (in that direction). It might also be good to add "if on edge, bounce" block.
Thank you #neillb!

Related

In 3d, how to pick the most suitable point?

I have a 3d scene (with pointclouds and some other objects). I implemented algorithm to pick the closest point to the mouse for a pointclouds. But my problem is : I have several objects in my scene, so when I try to pick an object (or a point inside a pointcloud), I go through all the objects on my scene, I look for the more suitable point for each of them (accordingly to distance to the raycast or angle (which is better)). At this stage, I don't know how to find the point of which object is the most suitable in all situations.
Explanation : I want to find a point very close to the raycast but also quite close to my camera to pick visible objects (points) only.
So I need to find a way to mix : closest point to the raycast and closest point to the camera. Do you have some ideas or widespread solution in 3d ? Thanks for your help.

rhombus framed buttons objective c?

basically I am trying to edit not only the appearance of the button(thats the easy part) but the frame that detects the touch to be a rhombus rather then a square
html example:http://irwinproject.com
I've tried CGAfflineTransform however it doesn't allow me to make non rectangular objects. is there a way to skew
Im just wondering if this is possible because, if not could someone point me in a direction the only viable answer I've found is resorting to something along the lines of a spriteKit;
I found this however this implementation leaves dead spots on buttons where they overlap
custom UIButton with skewed area in iPhone
is there a way to message people on here there was a gentleman who said he figured out how to transform but never posted his solution.
In order to modify the touch area of an oddly shaped button you could use a solution similar to OBShapedButton. I have used this particular project in the past myself for adjacent hexagon buttons and it worked perfectly. That said, you may have to modify it a bit to work with drawn shapes instead of images.

How to detect if an UIBezierPath intersects itself?

I have an user drawn UIBezierPath and I want to know if it intersects itself.
Can anyone point me in a good direction for detecting this?
Thanks!
How do you build your path? Is it just an accumulation of straight line segments? If so you could keep a list of those (parallel to your UIBezierPath, that you use for rendering), and then perform line intersection tests. It'll be O(N^2), though, in the naive implementation.

touched Image and recovering the touched point's coordinate

I'm working on an iPad application and that's my problem:
I elaborated an algorithm to know if a point is inside a polygon, in an image. So I need when touching the Image, to know the coordinates of the touched point and then do an action using those coordinates (an NSLog to make the example easy), the problem is that I can't use an IBAction on an UIImageView, and so can't recover the point's coordinates. Thanks for any help
I think at first you have to make polygon which fit to your image. And then you can use touchesBegan:withEvent: to get the coordinate of touch point and judge whether the point is inside of polygon or not.
Here is similar question like yours.
How to get particular touch Area?
I think this is a little difficult work, so maybe you would better use cocos2d library which have collision judgement function.
http://box2d.org/forum/viewtopic.php?f=9&t=7487
But also I think iOS is well constructed for handling touch, so this is beneficial effort for you.

finding the coordinates of an NSImageView

Im not too used to cocoa yet, so please bear with me
I am writing a game for mac in Objective-C on cocoa, and I have one problem:
I have two NSImageViews, and i need to set it up so that if I move one, the other one follows it ON THE Y AXIS ONLY. How do I find out the coordinates of the first image so that i can apply the x value to the second one?
Any help is greatly appreciated
I'm not sure if this works with NSImageView, but it works with UIImageView.
yourImage.frame.origin.x;
I hope that helps