Hey guys, so i have this project due on the 13th of Dec. I have been trying to work on it but im at a roadblock pretty early on and im just at a loss as to what to do, so i would appreciate a ton if you guys an provide some help :)
I am to make a program that is a game and is a pirate ship game. The ships are to start randomly in a 10x10 playing board (made with an array) and are to have four attributes [Movement (how many spaces a hip can move in one turn),Armor (how much damage it can take before being killed), Weapon (how strong the weapon is), and Range (how far can it shoot)].
What i need help on now is i think moving (before i get the attributes done), i would like to make it so the user enters where he wants to move (W for up, D for right, and A for left, NOT DOWN. Eventually this would be affected by the movement attribute so the user only has a certain amount of moves per turn.
But yeah, im at a loss guys and my teacher is very bad at helping me because he is way too vague and my classmates are all having trouble too. This project is a huge chunk of my grade so im pretty stressed out about it :(
Here's what i have so far:
#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
const int ROW = 10;
const int COL = 10;
int player;
int computer;
void printBoard (int[][COL]);
int main(int argc, char *argv[])
{
int gameboard[ROW][COL];
srand(time(0));
player = rand()%99+1;
computer = rand()%99+1;
printBoard(gameboard);
system("PAUSE");
return EXIT_SUCCESS;
}
void printBoard (int [] [COL])
{
for (int rows = 0; rows < ROW; rows++)
{
for (int collumns = 0; collumns < COL; collumns++)
{
if ((player / 10) == rows && (player % 10) == collumns)
{
cout << " P";
}
if ((computer / 10) == rows && (computer % 10) == collumns)
{
cout << " C";
}
//else if statement here to check computer
else
{
cout << " *";
}
}
cout << endl;
}
}
Here are my teachers instructions:
Each Frigate can move left, right, straight or not at all. It can't move diagonally or backwards. It can only move in the direction it is facing (N, S, E, W). Each frigate can fire only to the right or to the left of the direction it is facing. (E.g. if facing North, the ship can shoot east or west only)
Each turn the user gets to put in a sequence of actions equal to the number of actions their ship has available. All the actions are entered one after another for the user, and then the computer calculates its turn (up to the number of actions it has). Each ship then takes an action starting at the top of its list of actions, one action at a time. Order (or who goes first each for each segment of the turn) is determined randomly. When a ship fires, it can hit the other ship if the number of squares (starting with the square in front of the ship) counting to the square the opponents ship is in, is less than or equal to the range of their weapon. It does damage to the opposing ships armor equal to the count of the range of the weapon. If during any turn, any ship’s armor is equal to or less than zero, it is disabled and can no longer move forward, it may only turn in place.
P.S. Oh also, sorry about earlier, i think i posted two threads by accident, sorry bout that.