Gra w życie – Podejście drugie

Podejście drugie do projektu gry życie czyli tak naprawdę kontynuacja tego wpisu http://darkgl.pl/2015/05/21/gra-w-zycie/

Projekt nie dokończony

Część kodu

#define WIN32_LEAN_AND_MEAN

#include <iostream></iostream>

#include <windows.h></windows.h>

#include <cstdio>
#include <ctime>
#include <cstdlib></cstdlib></ctime></cstdio>

#include "LifeScene.h"

#include <conio.h></conio.h>

int main(int argc, char** argv) {

LifeScene currentScene;

int intervalTime = 0;

int renderSizeX = 0 ,
renderSizeY;

bool randomInput = true;

std::cout &lt;&lt; "Input interval ( ms ) : ";
	std::cin &gt;&gt; intervalTime;

std::cout &lt;&lt; "Input render size x : ";
	std::cin &gt;&gt; renderSizeX;

std::cout &lt;&lt; "Input render size y : ";
	std::cin &gt;&gt; renderSizeY;

std::cout &lt;&lt; "Random input ? ";
	std::cin &gt;&gt; randomInput;

currentScene.setGridSize( renderSizeX , renderSizeY );
currentScene.setPosition( renderSizeX / 2 , renderSizeY / 2 );

if( randomInput ){
srand (time(NULL));

for( int positionX = ( renderSizeX / 2 ) - ( renderSizeX / 2 ) ; positionX &lt;= renderSizeX ; positionX++ ){
			for( int positionY = ( renderSizeY / 2 ) - ( renderSizeY / 2 ) ; positionY &lt;= renderSizeY ; positionY++ ){
				if( rand() % 2 ){
					currentScene.setAliveCell( positionX , positionY );
				}
			}
		}
	}

gameoflife

Life Game.zip Download

Dodaj komentarz

Witryna wykorzystuje Akismet, aby ograniczyć spam. Dowiedz się więcej jak przetwarzane są dane komentarzy.