Gra w życie

Prosta gra w życie napisana na studia w C++. Przykład online to http://pmav.eu/stuff/javascript-game-of-life-v3.1.1/

gra2

Kawałek kodu

#include <vector></vector>

class Game{
public:
Game(){}

Game( int width , int height ){
this -&gt; array.resize( height );

for( int iPositionHeight = 0 ; iPositionHeight &lt; height ; iPositionHeight++ ){
                        this -&gt; array[ iPositionHeight ].resize( width );
}

this -&gt; classWidth = width;
this -&gt; classHeight = height;
}

void createArray( int width , int height ){
this -&gt; array.resize( height );

for( int iPositionHeight = 0 ; iPositionHeight &lt; height ; iPositionHeight++ ){
                        this -&gt; array[ iPositionHeight ].resize( width );
}

this -&gt; classWidth = width;
this -&gt; classHeight = height;
}

void step(){
std::vector&lt; std::vector&lt; bool &gt; &gt; tmpArray;

tmpArray.resize( this -&gt; classHeight );

for( int iPositionHeight = 0 ; iPositionHeight &lt; this -&gt; classHeight ; iPositionHeight++ ){
tmpArray[ iPositionHeight ].resize( this -&gt; classWidth );
}

Gra2z.zip Download

Dodaj komentarz

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