GAME MAIN DETAILS

1. Description of Processing in Game Main

Game Main has been created as a call-back function (om_game_main() function). Call-back functions can be registered with Nusystem's nuGfxFuncSet function, and registered functions will be executed on each vertical trace. At present, primarily the following kinds of processing have been incorporated into Game Main.

    (1) Camera action control (om_camera.c)
    (2) Player character operation control (om_mychar.c)
    (3) Player character animation control (om_mychar.c)
    (4) Corn flake control (om_cornfrake.c)
    (5) Goal plate control (om_goal.c)
    (6) Collision check with map (maze) (om_bg_entry.c)
    (7) Collision check between player character and corn flake (om_mychar.c)
    (8) Control at stage clear and game over (om_game_over.c)
    (9) Map (maze) and corn flake culling (om_bg_entry.c)
    (10) Scene buidling (om_camera.c)
    (11) Character drawing (om_eval_draw.c)
    (12) Map (maze) drawing (om_bg_entry.c)

2. Map (Maze) Structure

This section explains how the map (maze) is created in numirror.

There are probably a variety of ways to create a map, depending on the programmer. Please note that there really is no right way to create this numirror map. The way the map was created in this sample is just one of the many available ways to do map creation.

(1) Creating the map

The numirror map comprises 5 areas, 25 zones, and 100 grids. Please refer to Figure 1.

wpe1.gif (32897 bytes)

(Fig. 1)

Map Size

The size of the map is 3000 from the origin (0,0) to each positive and negative domain. In other words, it is a 6000 x 6000 map.

Grid Size

Each grid is a 600 x 600 square.

Zone Size

Since each zone is made up of 2 x 2 grids, each zone is a 1200 x 1200 square.

Area Size

Since each area is made up of 10 x grids, each area is a 6000 x 1200 rectangle.

(2) Collision check between map and player character

Collision checks between the map and the player character are performed in the following sequence, utilizing the map formation described in (1).

Calculate Map Coordinates of Player Character

First, the coordinates of the player character on the map are calculated.

In (Fig. 1), the vertical axis is the Z coordinates and the horizontal axis is the X coordinates.

The zone coordinates at which the player character is currently situated are calculated based on the player character's current world coordinates.

(Calculation Formulae)

X Zone Coordinate = ((Size of map X coordinate/2) + X coordinate of player character)/1200
Z Zone Coordinate = ((Size of map Z coordinate/2) + Z coordinate of player character)/1200

Collision Check with All Walls in Zone

A collision check for all the walls in a zone is performed by searching said zone data from the resulting XZ zone coordinate values.

The zone data are defined in the following header files.

  om_bg_zoneA.h  (Defines all data for all zones affiliated with area A)
  om_bg_zoneB.h  (Defines all data for all zones affiliated with area B)
  om_bg_zoneC.h  (Defines all data for all zones affiliated with area C)
  om_bg_zoneD.h  (Defines all data for all zones affiliated with area D)
  om_bg_zoneE.h  (Defines all data for all zones affiliated with area E)

3. Collision Check with Corn Flake

The method of performing a collision check between the player character and corn flakes placed in the maze will be explained in this section. Please refer to Figure 2.

A collision check is performed viewing the collision areas for the player character and the corn flake as shown in Figure 2.

(1) Calculate the differences between the player character, the corn flake and a center point.

First, calculate the differences between the player character and a center point, and the corn flake and a center point (dx and dz in Figure 2).

(2) Calculate the distance between two points

Calculate the distance between the two points using the Pythagorean theorum, based on the values from (1).

Length of red diagonal line = (dx * dx) + (dz * dz)

(3) Collision Check

Perform the collision check using the following formula.

Length of red diagonal line < (r1 + r2) * (r1 + r2)

wpe2.gif (5343 bytes)

(Fig. 2)

4. Map Culling

"numirror" performs software culling of the map. As with collisions, only one of the several methods for installing this culling may be used. Please note that there is no right method.

Hardware culling is also possible with N64. Persons interested in hardware culling may refer to Chapter 11 "Programming RSP Graphics" in the N64 Programming Manual.

The methods of software culling installed by numirror are explained below.

(1) Area Culling

This culls the areas except for the area in which the player character is currently located (the "star" in Figure 3) and the areas above and below that. In this case, since the player character is currently in area B, area A, area B, and area C are drawn, while area D and area E are not drawn.

(2) Zone Culling

After area culling, next zone culling is performed. Even they are in the drawn area, the zones farthest from the player are culled.

The zones, except for the zone in which the player character is currently located (the "star" in Figure 3), - Zone B3 - and the zones above and below it - Zones A3, C3 - and the zones to the left and right of it are culled.

In other words, the zones which are drawn are the zones surrounded by the red frame in Figure 3, and the zones which are culled - Zones A1, A5, B1, B5, C1, C5 - are not drawn.

"star" shows the player character current position

wpe2.gif (28047 bytes)

(Fig. 3)

When the player character's current position is as shown below, only the zones surrounded by the red frame will be drawn.

wpe3.gif (27921 bytes)

(Fig. 4)