Log In  

Cart [#lookat-0#] | Code | 2019-09-15 | License: CC4-BY-NC-SA | Embed

Made this little cart as I was working through coding a look-at type function. Wanted to post it in case it's helpful for someone.

This type of functionality is useful for all sorts of things. Maybe you just want one character to look at another or a gun barrel to follow the cursor etc.

P#67698 2019-09-15 14:45 ( Edited 2019-09-15 14:47)

:: dw817

Strangely last night I was thinking of the Apple ][ game called "RobotWar."

What's especially interesting about this game outside you have the ability to write code for your robot to battle other robots is its unique ability to SEE other robots.

And I don't just mean diagonally or from a cross +, no, you could rotate the head of your robot and if you were within range of both your sensors and angle, you could indeed see your opponent and react thusly.

Just me guessing the easiest way to do this would be for the computer to determine the angle to the other target and then get an ABS() for the angle of the "head" of the first target (player) and get a number from 15 or less so even if its not in perfect sight, it can vary a bit.

Also to check distance. Too far and the robot cannot see the opponent.

What would especially be interesting, PL, would be to add walls, both horizontal and vertical, and be able to be blocked by attempting to look through this solid object.

P#67700 2019-09-15 15:42

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-11-19 08:52 | 0.015s | 4194k | Q:23