Jump to content







Photo

where's the humanoid?

Posted by SpiceWare, in Frantic 20 August 2011 · 98 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 ;-)
Attached Image

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
Attached Image

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!)
Attached Image


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
Attached File  frantic_harmony20110820.bin (32K)
downloads: 21

Source
Attached File  Frantic20110820.zip (505.01K)
downloads: 12




How about (randomly) incorporating the player's current movement direction? Especially if the robot is further away.
  • Report
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
  • Report
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.
  • Report
So up to 2 direction changes of 45° each. That could work.
  • Report

May 2012

S M T W T F S
  12345
6789101112
13141516171819
2021 22 23242526
2728293031  

Recent Entries

Recent Comments

0 user(s) viewing

0 members, 0 guests, 0 anonymous users

Search My Blog

Latest Visitors