Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <SFML/Graphics.hpp>
- #include <ctime>
- using namespace std;
- sf::RenderWindow window(sf::VideoMode(500, 400), "COT++", sf::Style::Titlebar);
- sf::VertexArray points(sf::Points, 3000);
- sf::Event event;
- fstream f;
- unsigned int Pointers[10000000], pointer = 0, funcSelector = 0, lengthBuffer;
- char filePath[30] = "c:/users/79994/desktop/a.exe";
- bool mouseLeft, touchDown, fileCreated = 0;
- void readFile() {
- f.seekg (0, f.end);
- lengthBuffer = f.tellg();
- f.seekg (0, f.beg);
- char *fileBuffer = new char[lengthBuffer];
- f.open(filePath, ios::in | ios::app | ios::binary);
- f.read(fileBuffer, lengthBuffer);
- f.close();
- return fileBuffer[];
- }
- void writeFile(){
- if (fileBuffer[0] > 0 & fileCreated == 0) {
- filePath[23] += 1;
- f.open(filePath, ios::out | ios::app | ios::binary);
- f.write(fileBuffer, lengthBuffer);
- filePath[23] -= 1;
- fileCreated = 1;
- }
- f.close();
- }
- void removeFile() {
- filePath[23] += 1;
- remove(filePath);
- filePath[23] -= 1;
- fileCreated = 0;
- }
- /*void drawArray() {
- pointer = 0;
- if (sizeof(fileBuffer) > 0) {
- while (pointer < sizeof(fileBuffer)) {
- //Draw Array...
- pointer += 1;
- }
- }
- }*/
- void Search() {
- char buffer[sizeof(fileBuffer)];
- memcpy(buffer, fileBuffer, sizeof(fileBuffer));//copying array to array
- unsigned int NewPointer = 0, requiredNumber;
- //define requiredNumber
- while (pointer < sizeof(fileBuffer)) {
- Pointers[NewPointer] = Pointers[pointer];
- buffer[NewPointer] = buffer[pointer];
- if (fileBuffer[pointer] == requiredNumber) {
- NewPointer += 1;
- }
- pointer += 1;
- }
- }
- void touch(){
- touchDown = sf::Touch::isDown(0);
- sf::Vector2i touch = sf::Touch::getPosition(0, window);
- if(touch.x < 100 & touch.y < 100){
- funcSelector = 1;
- }
- }
- void mouse() {
- mouseLeft = sf::Mouse::isButtonPressed(sf::Mouse::Left);
- sf::Vector2i mouse = sf::Mouse::getPosition(window);
- if (mouseLeft & mouse.y < 100) {
- funcSelector = 1 + mouse.x/100;
- }
- }
- int main()
- {
- float start, x = 0.f, y = 1.f, pos = 0.f;
- unsigned int n = 0;
- start = clock();
- while(x < 500.f){
- points[n].position = sf::Vector2f(x + pos, y + pos);
- points[n].color = sf::Color::Green;
- x += 1.f;
- n += 1;
- if(x == 500.f & y < 100.f){
- x = 0.f;
- y += 100.f;
- }
- }
- x = 100.f, y = 1.f;
- while(x < 600.f){
- points[n].position = sf::Vector2f(x + pos, y + pos);
- points[n].color = sf::Color::Green;
- y += 1.f;
- n += 1;
- if(y > 101.f){
- x += 100.f;
- y = 1.f;
- }
- }
- while (window.isOpen())
- {
- mouse();
- if ((clock() - start) > 10) {
- while (window.pollEvent(event)) {
- }
- switch(funcSelector){
- case 5: window.close();
- break;
- case 1: readFile();
- break;
- case 2: writeFile();
- break;
- case 3: removeFile();
- break;
- case 4: Search();
- break;
- }
- start = clock();
- window.clear();
- window.draw(points);
- window.display();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement