I'm a 15-year-old and I'm making a text adventure game for my computer class. I've learned the most basic commands (printf, scanf, loops) and as I go it just gets more and more confusing. My game is pretty much going to be like Zork. I'm programming it in C and I'm using Dev-Cpp.
Here's what I have so far:
How do I fix this code? Also, I'm sure there are other commands I need to know to make this thing work. When the character goes east I'll add 1 to the x value, -1 for west, etcetera. For items, I'll just have an integer, 1 means you have the item, 0 means you don't. I just need help with the user input for things like "get pants," "use sword," and other things like that.Code:#include <stdio.h> #include <stdlib.h> int main() { int x, y, a; x=5; y=5; printf("[%d,%d]You are standing on the north side of a lake. Your pants are floating in the water.\n", x, y); scanf("%s %s", &a); if (a="get pants"); /* I need to fix this line */ { printf("You put on the wet pants. They feel slimy.\n"); } else { printf("Are you sure you want to walk around with no pants on?\n"); } sleep (5000); }



LinkBack URL
About LinkBacks



CornedBee