Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
cotton farm 0.0.1.0
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
/* ----------------------------------------------------------------------- ------------------------------------------------------------------- -------------------------- · COTTON FARM · ---------------------------- ------------------------------------------------------------------- ----------------------------------------------------------------------- A game by: - Green Onion Studios - 2017 ----------------------------------------------------------------------- ------------------------------------------------------------------- Curent Version:(Final/Beta/Alpha/Development Vesion): -[[0.0.1.0]]- Release date: 25/11/2017 VERSION NOTES: WORKS: YES Changes: 1) Fixed bug in tempo_clock 2) Improved Code Structure Future Changes: 1) Create intro 2) Screen format 3) Scoring System 4) florusishing stage 5) improve code structure Developer comments: Yeyyyy, alpha version boiii!!!!!!1!!1!!111!!! ----------------------------------------------------------------------- ------------------------------------------------------------------- */ //// 1: HEADER //// #include <iostream> // Basic Library #include <fstream> // Library that allows reading or writing in files #include <conio.h> // Library that allows reading key press #include <windows.h> // Library that allows sleep function #include <stdio.h> // Library that allows to change the background and text color using namespace std; // Setting up the cout<< and cin>> functions // WARNING! // IF YOU ARE READING THIS CODE, WE RECOMMEND TO START IN "INT MAIN", you can get back here when you have finished reading the "int main" //// 3: GROWING STAGE //// void growing_stage (float &growing_progress, int &w, int &f, int &h, int &time, int &w_grade, char &input, float &speed) { // HEADER : Here we declare and inicialise some variables that we will use later on int i = 0; // Variable used to print the indicator bars system ("cls"); // Celar Screen // DISPLAY: The code here affects what will be displayed on the screen cout << "__________________________________________________\n"; cout << "__________________________________________________\n"; cout << "--------------------------------------------------\n"; cout << " - COTTON FARM SIMULATOR -\n"; cout << " Growing Stage\n"; cout << "--------------------------------------------------\n"; cout << "__________________________________________________\n"; cout << "Time: " << time / 20 << "\n"; cout << "Score: " << "Comming Soon" << "\n"; cout << "Speed: " << speed << "%\n"; cout << "__________________________________________________\n"; cout << " ||-.-.-.--|--.-.-.-|| \n"; // GUIDANCE BAR: the goal is to get your variables as close to the center of thsi bar as possible. cout << " W = "; do { //This DO,WHILE condition will print a bar as long as needed, depending on the value of the variable cout << "-"; i ++; } while (i < w); cout << " \n"; i = 0; // We restart this variable, as we will use it later cout << " ||-.-.-.--|--.-.-.-|| \n"; cout << " F = "; do { cout << "-"; i ++; } while (i < f); cout << " \n"; i = 0; cout << " ||-.-.-.--|--.-.-.-|| \n"; cout << " H = "; do { cout << "-"; i ++; } while (i < h); // USER INPUT: This section of the code is the risponsable for changing variables according to the user's input if (kbhit()) { // This if condition will save the key pressed by the user in the variable "input". If the user doesn't press any key, it skips some lines, going to "A" input = getch(); } else { goto A; } switch (input) { // This SWITCH condition will read the input variable and change some variables according to it case 'w': w = w + 2; break; case 'f': f = f +2; break; case 'h': h = h-4; break; default: cout<< "\n INCORRECT KEY"; break; } A: // When the last if condition is false, the code skips some lines and starts reading here cout << "--------------------------------------------------\n"; cout << "__________________________________________________\n"; } // GROWING CLOCK: lauches and controls the growing stage //// 4: GROWING CLOCK //// void growing_clock (float &growing_progress, int &w, int &f, int &h, int &time, int &w_grade, char &input, float &speed) { // HEADER : Here we declare and inicialise some variables that we will use later on int tempo_clock; char input1; // TIME MANAGEMENT tempo_clock++; // Adds 1 to the variable tempo_clock if (tempo_clock > 4 ){ // This if condition keeps the variable tempo_clock between 1 and 4 NOTE: THIS NUMBER HAS TO CHANGE WHEN WE CHANGE THE SPEED, NOW IT SET FOR 4FPS, Which is btw wrong tempo_clock = 1; } time++; // Adds 1 to the variable time if (tempo_clock==1) // this series of if conditions define the automatic adjusing of the variables { w = w-1; h = h+1; } if (tempo_clock==2) { f = f-1; h = h+1; } if (tempo_clock==3) { h = h-1; } if (tempo_clock==4) { w = w-1; h = h+1; } Sleep (50); // This determines the FPS at wich the game operates (1000 = 1fps, 100 = 10 fps) //GRADE CALCULATOR if (w > 19){ w = 20; w_grade = 0; } if (w < 1){ w = 1; w_grade = 0; } growing_stage(growing_progress, w, f, h, time, w_grade, input, speed);//Launches Growing_Stage } else growing_progress = 100; } //// 2: MAIN FUNCTION //// int main(){ // HEADER : Here we declare and inicialise some variables that we will use later on float growing_progress = 0; // Variable used for switching Phases, it will be changed by the score in future versions, the phase will change when you get to a certain ammount of score, the goal is to do it in the lowest time possible int time = 0, w = 10, f = 10, h = 10, w_grade = 10; char input; float speed=100; // The user will be able to change this one before starting a new game // INTRO MESSAGE cout << "__________________________________________________\n"; cout << "__________________________________________________\n"; cout << "__________________________________________________\n"; cout << "__________________________________________________\n"; cout << "__________________Game Version:___________________\n"; cout << "____________________0.0.1.00______________________\n"; cout << "__________________________________________________\n"; cout << "__________________________________________________\n"; cout << "__________________________________________________\n"; Sleep (1500); // Wait 1.5 seconds system ("cls"); // Clear the screen system ( "color 02"); // Change the color cout << "__________________________________________________\n"; cout << "__________________________________________________\n"; cout << "--------------------------------------------------\n"; cout << " - GREEN ONION STUDIOS - \n"; cout << " present \n"; cout << "--------------------------------------------------\n"; cout << "__________________________________________________\n"; Sleep (4000); system ("cls"); cout << "__________________________________________________\n"; cout << "__________________________________________________\n"; cout << "--------------------------------------------------\n"; cout << " A GAME BY: \n"; cout << " Alessandro Granadino & Roman Delgado \n"; cout << "--------------------------------------------------\n"; cout << "__________________________________________________\n"; Sleep (4000); system ("cls"); cout << "__________________________________________________\n"; cout << "__________________________________________________\n"; cout << "--------------------------------------------------\n"; cout << " With the support of: \n"; cout << " \n"; cout << " PRIMER TEAM \n"; cout << " & \n"; cout << " LA PATRI INDUSTRIES \n"; cout << "--------------------------------------------------\n"; cout << "__________________________________________________\n"; Sleep (4000); system ("cls"); system ( "color 2f"); cout << "__________________________________________________\n"; cout << "__________________________________________________\n"; cout << "--------------------------------------------------\n"; cout << " - COTTON FARM SIMULATOR -\n"; cout << "--------------------------------------------------\n"; cout << "__________________________________________________\n"; cout << "Type any key and hit enter to start: "; cin >> input; system ("cls"); // MAIN MENU cout << "__________________________________________________\n"; cout << "__________________________________________________\n"; cout << "--------------------------------------------------\n"; cout << " - MAIN MENU -\n"; cout << "--------------------------------------------------\n"; cout << "__________________________________________________\n"; cout << "1: New Game\n"; cout << "2: Tutorial\n"; cout << "3: Highscores\n"; cout << "4: Exit\n"; cout << ">> "; cin >> input; // Reads an input provided by the user system ("cls"); // In an upcomming version, a switch will determine wich code is executed, depending on the user input cout << "NOTE: Only working option on this version is NEW GAME, creating a new game...\n"; Sleep (4000); system ("cls"); // This will keep lauching the growing clock, which controls the gwrowing stage until the score reaches a level, it will be done by time in an upcomming version do{ growing_clock (growing_progress, w, f, h, time, w_grade, input, speed); } while (growing_progress < 99); growing_progress =0; // In un upcomming version, it will launch the flourishing clock and the final money gained (and time and speed) that will be written down in a .txt file return 0; // It would exit the program once it reached this, we will loop it back to the main menu in an upcommig version }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
fork mode
|
history
|
discussion