简体   繁体   English

绘制/渲染网格iOS的最佳方法-生活游戏

[英]Best way to draw/render grid iOS - Game of Life

I am taking a stab at John Conway's game of life [wiki] & [demo] . 我正在刺杀约翰·康威(John Conway)的生活游戏[wiki][demo] I have developed a small program in C to calculate the next state - using a 1D array (but with 2D array logic). 用C开发了一个小程序来计算下一个状态-使用一维数组(但具有二维数组逻辑)。

I am hoping to make a small iOS app out of this (to Objective-C!), and am wondering the best and fastest way to render a grid like seen in the video. 我希望以此为基础开发一个小型iOS应用程序(向Objective-C!),我想知道以最佳方式和最快的方式呈现视频中所示的网格。 Note, it would have to render every fraction of a second and would use an array of 1 's and 0 's to determine a "block's" respective colour. 注意,它必须渲染每一秒的分数,并使用10的数组来确定“块”的相应颜色。

Edit: I'm probably looking at around 10 frames/sec, but a very large grid. 编辑:我可能正在查看约10帧/秒,但非常大的网格。 It'd be rendering out hundreds of thousands of squares. 它将渲染出数十万个正方形。 Of course, if this isn't physically possible with iPhone/iPad technology then I'll reduce the grid size. 当然,如果使用iPhone / iPad技术实际上无法做到这一点,那么我将减小网格尺寸。 It is variable without issue, just looks more 'epic' on a grand scale. 它是可变的,没有问题,只是在更大范围内看起来更加“史诗”。

Any suggestions will help out, never touched anything of this manner before. 任何建议都会有所帮助,以前从来没有碰过这种方式。

The best way depends on your criteria. 最好的方法取决于您的标准。 Fastest would probably be to use OpenGL. 最快的可能是使用OpenGL。 You might even be able to write a shader to do the entire simulation. 您甚至可以编写着色器来进行整个模拟。 However, OpenGL is hard. 但是,OpenGL很难。 Really hard. 真的很难

I suspect that using Core Graphics and implementing code in a view's drawRect method that renders the array of cells onto the screen would be fast enough. 我怀疑使用Core Graphics并在将单元格数组呈现到屏幕上的视图的drawRect方法中实现代码会足够快。 It depends on how many cells you have and how many frames/second you want to draw. 这取决于您拥有多少个像元以及要绘制多少帧/秒。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM