I am a student and our prefessor has given us an assignment to creat a game in C++, the game is about a player tha moves in a space trying to reach homeland. i have created the 2 dimenson space. i have put the homeland and the palyer. the player moves by inputing number from 1 t 9. my problem is how to delete a blackhole if the players reaches one and the other probelem is that whan i debug it it doesn't execute, this is my program., and how to calculate the curent position of the player and homeland everu time the player makes a step and this can be done by c2 = a2 + b2.
// Detyra.cpp : Defines the entry point for the console application.
#include "StdAfx.h"
#include <iostream> // Imput/Output
#include <cstdlib> // Using rand numbers
#include <time.h> // using curent computer time to randomize numbers
using namespace std; //
int main ()
{
#define YDIM = 20;
#define XDIM = 30;
int Universe[20][30];
int i;
int j;
for ( i = 0; i < 30; i++) //
{
for (j = 0; j < 20; j++)
Universe[j][i] = 0;
}
const int YLOW = 0;
const int YHIGH = 20;
const int XLOW = 0;
const int XHIGH = 30;
int xh; // declare variable x for the homeplanet.
int yh; // declare variable y for the homeplanet.
{
time_t seconds; // using functions srand and rand to choose a randome place for the planet.
time(&seconds);
srand((unsigned int)seconds);
int xb = 0; //declare variable x for the blackhole.
int yb = 0; //declare variable y for the blackhole.
int total = 0; // declare variable total end initialize to count the total steps.
/* Using the loop to place randomly 60 balckholes
and make sure that no one of them not to corespondent in the same place
with the planet or the player */
the assignment asks me to place 60 black holes rundomly chosed in the universe and each of the black holes should be represented as a "2" so i have set them as o from the beginning. if the player falls in a black hole the player must be returned to his previous position and the black hole should be eliminated form the game.
When you say eliminated from the game, do you mean it becomes free space into which the player may now pass freely? If so, set the value at the black hole to 0.