• entries
657
2,699
• views
900,547

where's the humanoid?

1,321 views

In order for the Robots to move or shoot, they need to know where the Humanoid is in relation to themselves. If we're only looking at 4 directions it fairly straightforward - horizontal vs vertical is determined by seeing if the difference between Robot X and Humanoid X bigger or smaller than the difference between Robot Y and Humanoid Y. Once horizontal/vertical is decided then if the difference is negative the direction is left or up, while if it's positive it's right or down.

For Frantic it's a tad more complex as we want to use 8 directions. I pulled out some graph paper and sketched this out - nowhere near as purty as Nathan would do, I'm sure

The robot is at the origin, with an onscreen location of (10,10). The letters A-L are different test positions the Humanoid could be at (their coordinates are listed down the right). The blue lines, labeled L1-L4, define the boundaries for determining which of the 8 directions the Humanoid is in. The numbers 0-7 are direction identifiers used by the program.

I then did some calculations using Open Office and came up with these formulas with these results:

```L1 = (rX - hX) * 2 - (rY - hY)
L2 = (rX - hX)     - (rY - hY) * 2
L3 = (rX - hX) * 2 + (rY - hY)
L4 = (rX - hX)     + (rY - hY) * 2
```

In reviewing the spreadsheet results I could see that I could figure out which of the 8 directions the humanoid was located by checking the sign of L1, L4 and then either L2 or L3. See function DirectionToHumanoid() in the source file main.c if you're interested in how that works.

To test the routines I set it up so that 3 of the robots would "point" to the Humanoid using the 3 robot shots. (the robots are sprites 3, 9 and 15 - that's what the numbers on the left of the graph paper are!)

Next thing to do is revise the DirectionToHumanoid() function to also return "Target Lock" - i.e.: if the humanoid is stationary, he'd get hit if the robot fired a shot. Looking at the robots with direction indicators in the screen capture, the top one does not have target lock, the middle one does, and the bottom one may or may not as it's too close to eyeball. Once that's done I'll be able to add the routines to make the robots shoot and move!

ROM

Source

How about (randomly) incorporating the player's current movement direction? Especially if the robot is further away.

I'd thought about that as a way to compensate for the lack of on-screen shots, but decided to do homing missiles instead. Homing missiles have a different shape than normal shots, you can see them in the screenshot above - the robots are using homing missiles to point at the humanoid.

Homing missiles can change their direction in flight, but only 1 time after being fired. The robots will shot normal missiles while the tanks will shoot homing missiles. I'll set it up so when the game starts you'll mostly get robots, with an increasing chance of tanks as you work your way thru the game.

I haven't decided yet if the tanks will only show up in the Frenzy style game, or if they'll also appear in the Berzerk style. The main differences are:

• Berzerk
• only robots
• 8 moveable wall segments
• walls are lethal to both humanoid and robots
• Evil Otto is invincible
• no special rooms

• Frenzy
• robots and tanks
• 15 moveable wall segments, 2 wall styles -shots either destroy the wall or are bounced off it.
• walls are not lethal
• Evil Otto can be killed (though he respawns and moves faster)
• special rooms appear periodically: Big Otto, Power Plant, Central Computer, and Robot Factory

Instead of allowing to change direction once, maybe it is easier (and better looking) to limit the direction change. So that the missile cannot turn 90° in one step, but has to fly a curve instead.

So up to 2 direction changes of 45° each. That could work.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.