English 中文(简体)
C. 生成/更新六角电网
原标题:generating/creating hexagon grid in C
  • 时间:2011-05-12 02:46:36
  •  标签:
  • c

因此,一米试图使C的六角电网成为一种游戏。 我确实是建立在从哪里开始的基础之上的。 ANyone有任何想法。

EDIT:我需要大约15至20座六角 grip,像游戏板一样。 a. 从事游戏。 不详

问题回答

绝对。 尽管六角形形形形色色,但为了今后使用,仍然可以载于你通常的多层面阵列中(我假定你想要把事情放在你的六角)。 简而言之,它简明扼要。 Agles = (6 - 2) * 180 = 4 180 = 720。 一个角为720 / 6 = 120度。 先计算左角角Y的位置,等于(六角Side - hexagonWidth * hexagonWidth)。 我确信,你可以浏览hexagonWidth? 奥凯,现在与最后一位相比,X位立场是零。 你们需要把Y级的位置打上其面前的六角的高度的一半,或者根据<代码>row * col是哪怕是很奇怪的。 由于你知道六角的宽度,你有相反的坐标。 页: 1

在我继续发言之前,这是否应该 in? 还是真实的图表?

因此,让这真是直截了当的,会把游戏放在ole上? 早就应该建立你的数据结构,最明显的是 no。

The nodes

每座六角都有六个边缘。

typedef struct Node {
  void *object; /* Pointer to object */
  Node *node_array; /* Pointer to node_array with  node_count  nodes */
  int node_count; /* size of node_array */
} Node;

How to initialize and connect the node structure

mag:

 /
|  |
 /

它有以下优势:诺特赫特、埃米亚、南埃亚、南马威西、西里德和挪威。 接下来观察如何安排会议(10、11和12人在海克斯岛有代表,以便能够在一个空间中运行):

//  0 1 2 3
// 4 5 6 7 8
//  9 A B C

http://code>0。 通过<条码>SOUTHEAST链接和4 通过<代码>SOUTHWEST链接。 还注意到两行在奇数和甚至数项要素之间是如何交替的。 请打电话<代码>0、1、2、3}row[0]{4、5、6、7、8}<row***/strong>。 并请将此称为5x3。 创建这种阵列的最容易的方法是malloc(sizeof(Node) * width*

Connecting the nodes

First of all let me point out that every even row (0, 2, 4, ...) will have width-1 elements. But there s more, each element (x, y) on this row will link to the following element in your array:

  • (x+1, y-1) - NORTHEAST
  • (x+1, y) - EAST
  • (x+1, y+1) - SOUTHEAST
  • (x, y+1) - SOUTHWEST
  • (x-1, y) - WEST
  • (x, y-1) - NORTHWEST

Elements on the other rows, such as {4, 5, 6, 7, 8} will have width elements, where element (x, y) links to the following:

  • (x, y-1) - NORTHEAST
  • (x+1, y) - EAST
  • (x, y+1) - SOUTHEAST
  • (x-1, y+1) - SOUTHWEST
  • (x-1, y) - WEST
  • (x-1, y-1) - NORTHWEST

When trying to link (x1,y1) with (x2, y2), ensure that 0 <= x < width and 0 <= y < height.

Remember ...

你的阵列包含一个<>未使用的元素,分两行(各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行(各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行各行。 您也不妨向他们提供某种类型的label<>>>>>或index,以便你能够把参与者交给他们。 您could称其为(x,y)乳制品,或按其指数表示,全都归于你。 奶粉(x, y)对于你来说非常容易,因为这将直接标明其储存的阵列。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签