Advertisement
BeamNG_IRC

Untitled

Jun 10th, 2014
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. #include "functions.h"
  2. #include "windows.h"
  3. #include <iostream>
  4. #include <fstream>
  5. using namespace std;
  6. virtual void functions::Shoot(int x, int y) { // rebound/bounce
  7.     int sleep = 100;
  8.     int l = 0;
  9.     int repeat = 0;
  10.     x += 1;
  11.     while (y < 24) { // bounce down
  12.         system("cls");
  13.         x += 1;
  14.         y += 1;
  15.         cout << "information:" << endl << "x: " << x << " y: " << y;
  16.         WriteTo(x, y);
  17.         cout << "()";
  18.         repeat += 1;
  19.         Sleep(sleep);
  20.     }
  21.     while (l < repeat) { // bounce back up
  22.         l += 1;
  23.         system("cls");
  24.         x += 1;
  25.         y -= 1;
  26.         cout << "information:" << endl << "x: " << x << " y: " << y;
  27.         WriteTo(x, y);
  28.         cout << "()";
  29.         Sleep(sleep);
  30.     }
  31.     system("cls");
  32.     cout << "information:" << endl << "x: " << x << " y: " << y;
  33.     WriteTo(x, y);
  34.     cout << "()";
  35. }
  36. virtual void functions::WriteTo(int x, int y) {
  37.     static HANDLE hStdout = NULL;
  38.      COORD coord;
  39.      coord.X = x;
  40.      coord.Y = y;
  41.      if(!hStdout) {
  42.        hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  43.      }
  44.      SetConsoleCursorPosition(hStdout,coord); // sets console cursor position for writing
  45.      ofstream log;
  46.      log.open("c:/users/snowflake/desktop/log.txt", ios::app); // only valid on my pc, I guess I can make it work for everyone
  47.      log << "x: " << x << " y: " << y << endl;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement