PROGRAMMERS, read this post!
So check this out. Right before spring break my programming professor slams us with a pretty tough assignment. We've got pointers, loops, AND graphics going on in this project. It's a text adventure. It's really quite simple, because the prof gave us most of the code. Here's what he gave us.
#include <stdio.h>
/****************************************************************************
* ps3.c
*
* Computer Science 121
* Your Name
*
* Super Text Adventure
*
* User starts in one of 4 rooms and hunts down a treasure.
***************************************************************************/
/*
* render: Draws the map. Places an X and T where the character and
* treasure reside, respectively.
*
* Parameters:
* room - A room number where the player is. Valid room numbers are 1-4.
*
*/
void render(int room)
{
if ((room < 1) || (room > 4))
{
printf("Cannot draw map, invalid room number: %d\n", room);
return;
}
printf("---------\n");
if (room == 1)
printf("| X | |\n");
else if (room == 2)
printf("| | X |\n");
else
printf("| | |\n");
printf("---------\n");
if (room == 3)
printf("| X | T |\n");
else if (room == 4)
printf("| | X |\n");
else
printf("| | T |\n");
printf("---------\n");
printf("You are in room %d.\n", room);
printf("\n");
}
/*
* move: Returns the room number the player resides in after moving
* north, west, south, or east. This function ensures that the player can
* never leave the map. If player attempts to move outside of
* room 1, 2, 3, or 4 an appropriate message is displayed, and the room
* the player originally resided in is returned.
*
* Parameters:
* command - An integer representing up [8], left [4], down [2], or right [6].
* player_room - The room number where the player is. Valid room numbers are 1-4.
*
* When this function is finished, the room number where the player resides after applying the given command
* will be stored in the value pointed to by player_room.
*/
void move(int command, int *player_room)
{
/* implement this function*/
return 0;
}
/* Game logic goes here */
int main()
{
int player_room = 1;
printf("== Super Text Adventure ==\n");
render(player_room);
}
Now I knew something was funny looking at this code. And the whole time he's like "Don't change the render function!" Bullshit, you cocksucker. Because of the random printf argument in the render function, nothing would come out the way he wanted us to make it.
Every time you'd enter an incorrect number, it was supposed to prompt you with an error message and then reprint the map, like this (though you don't see the error message in question):
Because of this motherfucker's bullshit code, I ended up wracking my brain trying to debug the code I wrote, because I trusted this dumbass. This is like the 10th time this dude has slipped up. Before, he's walked us through writing programs for topic examples that I tried compiling and they were either filled with syntax errors or crashed. This professor fucking SUCKS.
I'd post my code, but this post is long enough already. Will post if asked.