Creative Commons License Foxbond's Repo

/** (c) 2012 Michał (Foxbond) Chraniuk */
#include <pthread.h>
#include <iostream>
#include <time.h>
#include <conio.h>


using namespace std;


void* paletkaD(void* just) {
    while (true) {
       u=_getch();
		if(u==106){v=v-1;}
	if(u==108){v=v+1;}
        if (u == 27) { gameDestroy(); }
        if (destroyGame){ pthread_exit(just); }
    }
    return NULL;
}

void* paletkaG(void* just){
	 while (true) {
	j=_getch();
	if(j==97){c=c-1;}
	if(j==100){c=c+1;}
	 if (j == 27) { gameDestroy(); }
        if (destroyGame){ pthread_exit(just); }
	 }
	return NULL;
}

void* pilka(void* just){
	if (b==4&&n==c){
	b=b*-1;}
	if (b==22&&n==v){
	b=b*-1;}
	if (b==4&&n==z){
	b=b*-1;
	if (s==-1){s=0;}
	else
	s=1;}
	if (b==4&&n==x){
	b=b*-1;
	if (s==1){s=0;}
	else
	s=-1;}
	if(n==2&&s==-1){s=s*-1;}
	if(n==14&&s==1){s=s*-1;}
	return NULL;
}


int main(int argc, char* argv[]) {
	
	//to co na poczatku (przed rozp. gry)
	
    pthread_t thread1, thread2, thread3;
    int tret1, tret2, tret3, just;
	tret3 = pthread_create(&thread3, NULL, paletkaG,
            (void*) &just);
    tret2 = pthread_create(&thread2, NULL, paletkaD,
            (void*) &just);
    tret1 = pthread_create(&thread1, NULL, pilka,
            (void*) &just);

	
    pthread_join(thread1, NULL);
    pthread_join(thread2, NULL);
	pthread_join(thread3, NULL);
    
    
    return 0;
}

> Back