Mirixy17 / MindPower

1 stars 0 forks source link

Skrati ovaj kod #13

Open lukarolak opened 4 years ago

lukarolak commented 4 years ago
// Tetris.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <Windows.h>
#include <chrono>
#include <thread>
int main()
{
    std::cout << "************" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "************" << std::endl;

    {
        std::chrono::seconds dura(1);
        std::this_thread::sleep_for(dura);
        system("cls");
    }

    std::cout << "************" << std::endl;
    std::cout << "*     *    *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "************" << std::endl;

    {
        std::chrono::seconds dura(1);
        std::this_thread::sleep_for(dura);
        system("cls");
    }

    std::cout << "************" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*     *    *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "************" << std::endl;

    {
        std::chrono::seconds dura(1);
        std::this_thread::sleep_for(dura);
        system("cls");
    };

    std::cout << "************" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*     *    *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "************" << std::endl;

    {
        std::chrono::seconds dura(1);
        std::this_thread::sleep_for(dura);
        system("cls");
    }

    std::cout << "************" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*     *    *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "************" << std::endl;

    {
        std::chrono::seconds dura(1);
        std::this_thread::sleep_for(dura);
        system("cls");
    }

    std::cout << "************" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*          *" << std::endl;
    std::cout << "*     *    *" << std::endl;
    std::cout << "************" << std::endl;
}
Mirixy17 commented 4 years ago
  1. jednostavna verzija:
#include <iostream>
#include <Windows.h>
#include <chrono>
#include <thread>

void Ciscenje()
{
    std::chrono::seconds dura(1);
    std::this_thread::sleep_for(dura);
    system("cls");
}

void Igraliste(std::string rijec)
{
    std::cout << rijec << "\n";
}

int main()
{
    Ciscenje();

    Igraliste("************\n*    *     *\n*          *\n*          *\n*          *\n*          *\n************");

    Ciscenje();

    Igraliste("************\n*          *\n*    *     *\n*          *\n*          *\n*          *\n************");

    Ciscenje();

    Igraliste("************\n*          *\n*          *\n*    *     *\n*          *\n*          *\n************");

    Ciscenje();

    Igraliste("************\n*          *\n*          *\n*          *\n*    *     *\n*          *\n************");

    Ciscenje();

    Igraliste("************\n*          *\n*          *\n*          *\n*          *\n*    *     *\n************");
}
Mirixy17 commented 4 years ago

include

include

include

include

void Brisanje()

{ std::chrono::seconds dura(1); std::this_thread::sleep_for(dura); system("cls"); }

int main() { const std::string granica = "****"; const std::string praznina = " ";

std::string polje;

polje.append(granica);

polje.append("\n");

polje.append(praznina);

polje.append("\n");

polje.append(praznina);

polje.append("\n");

polje.append(praznina);

polje.append("\n");

polje.append(praznina);

polje.append("\n");

polje.append(granica);

std::cout << polje;

}

lukarolak commented 3 years ago
#include <iostream>
#include <Windows.h>
#include <chrono>
#include <thread>
#include <vector>

const int broj_stupaca = 4;
const int broj_redova = 4;

void IspisiTetris(std::vector<std::vector<char>> Tetris)
{
    for (int stupac = 0; stupac < broj_stupaca; stupac++)
    {
        for (int red = 0; red < broj_redova; red++)
        {
            std::cout << Tetris[stupac][red];
        }
        std::cout << '\n';
    }
}

void PauzaIOcistiEkran()
{
    std::chrono::seconds dura(1);
    std::this_thread::sleep_for(dura);
    system("cls");
}

int main()
{
    std::vector<std::vector<char>> tetris;

    tetris.resize(broj_stupaca);
    for (int stupac = 0; stupac < broj_stupaca; stupac++)
    {
        tetris[stupac].resize(broj_redova);
    }

    for (int stupac = 0; stupac < broj_stupaca; stupac++)
    {
        for (int red = 0; red < broj_redova; red++)
        {
            tetris[stupac][red] = ' ';
        }
    }

    tetris[0][0] = '*';
    tetris[1][0] = '*';
    tetris[1][1] = '*';
    tetris[2][2] = '*';

    while (true)
    {
        IspisiTetris(tetris);
        PauzaIOcistiEkran();

        for (int stupac = broj_stupaca - 2; stupac >= 0; stupac--)
        {
            for (int red = broj_redova-1; red >= 0; red--)
            {
                if (tetris[stupac][red] == '*')
                {
                    if (tetris[stupac + 1][red] == ' ')
                    {
                        tetris[stupac][red] = ' ';
                        tetris[stupac + 1][red] = '*';
                    }
                    else if(red <= broj_redova - 2)
                    {
                        tetris[stupac][red] = ' ';
                        tetris[stupac][red+1] = '*';
                    }
                }
            }
        }
    }
}
Mirixy17 commented 3 years ago

//#include <iostream>
//#include <Windows.h>
//#include <chrono>
//#include <thread>
//
//void Igra()
//{
//    std::chrono::seconds dura(1);
//    std::this_thread::sleep_for(dura);
//    system("cls");
//}
//
//void Igraliste(std::string rijec)
//{
//    std::cout << rijec << "\n";
//}
//
//int main()
//{
//
//    const std::string granica = "************";
//
//    const std::string praznina = "*          *";
//
//    const std::string zvjezdica = "*    *     *";
//
//    std::string polje;
//
//    polje.append(granica);
//
//    polje.append("\n");
//
//    polje.append(praznina);
//
//    polje.append("\n");
//
//    polje.append(zvjezdica);
//
//    polje.append("\n");
//
//    polje.append(zvjezdica);
//
//    polje.append("\n");
//
//    polje.append(zvjezdica);
//
//    polje.append("\n");
//
//    polje.append(zvjezdica);
//
//    polje.append("\n");
//
//    polje.append(zvjezdica);
//
//    polje.append("\n");
//
//    polje.append(granica);
//
//    polje.append("\n");
//
//    polje.append(granica);
//
//    Igraliste(polje);
//
//}