[QUOTE=Darwin226;22343159]I'm getting the "Attempted to read or write protected memory." error when trying to use Gl.glCreateShader( Gl.GL_FRAGMENT_SHADER ).
How can I fix it? I've tried Googling it but no luck.[/QUOTE]
I didn't see any obvious solutions, wanna post your code?
Sure. [URL="http://pastebin.com/BccFVZtC"]Here it is.[/URL]
I think I'm supposed to use it like this but not sure.
I can post the shader.fs too but since the program doesn't actually get to the part where it's supposed to load it, i don't think that's the problem.
Trying to get my GMod module to compile, but the linker wont stop giving me these errors:
[code]1>main.obj : error LNK2001: unresolved external symbol "int __cdecl Shutdown(struct lua_State *)" (?Shutdown@@YAHPAUlua_State@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "int __cdecl Init(struct lua_State *)" (?Init@@YAHPAUlua_State@@@Z)[/code]
[QUOTE=Darwin226;22343379]Sure. [URL="http://pastebin.com/BccFVZtC"]Here it is.[/URL]
I think I'm supposed to use it like this but not sure.
I can post the shader.fs too but since the program doesn't actually get to the part where it's supposed to load it, i don't think that's the problem.[/QUOTE]
I don't see anything incredibly obvious. Does it work without creating a shader? Like will it draw just regular polygons. I'm not positive how everything comes together in C#, but how are you getting Gl when you're going to create a shader? Typically I'd see it as a private variable, I don't know if you can reference it without a declaration first. v:v:v Just make sure that the variable isn't null, and that it's been initialized.
I don't really understand what you mean. Without the shader part everything works. It draws the rainbow triangle and everything.
[QUOTE=Dacheet;22312909]I have a lot of functions (about 20 or 30) and I want to have a universal command that, when input, couts a variable, and then goes back the the function you were in. How do I do that?
C++, by the way.[/QUOTE]
Here's the code
[code]
#include <stdio.h>
#include <tchar.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
string name;
string reply;
int coins;
char strnew[255];
// Death func
int death();
// The sections
//You waking up
int s1();
int s1torch();
int s1zombie();
int s1pit();
int s1as();
int s1shiny();
//After you get the TORCH
int s2();
int s2noshiny();
int s2back();
int s2wall();
int s2eatbrick();
int s2pushbrick();
int s2pullbrick();
int s2gate();
// Nelsonshire
int s3();
int s3pub();
int s3shop();
int s3inn();
// Deciders
int retID(string caseR);
int retID2(string caseR);
int retID3(string caseR);
int retID4(string caseR);
int retID5(string caseR);
int retID6(string caseR);
int retID7(string caseR);
// For s1()
int retID(string caseR)
{
if (caseR == "NORTH" || caseR == "north" || caseR == "North") {
return 1;}
if (caseR == "SOUTH" || caseR == "south" || caseR == "South") {
return 2; }
if (caseR == "WEST" || caseR == "west" || caseR == "WEST") {
return 3; }
}
int retID2(string caseR)
{
if (caseR == "TORCH" || caseR == "Torch" || caseR == "torch") {
return 1;}
if (caseR == "SOUTH" || caseR == "South" || caseR == "south") {
return 2; }
if (caseR == "WEST" || caseR == "West" || caseR == "west") {
return 3; }
if (caseR == "NORTH" || caseR == "North" || caseR == "north") {
return 4;
}
}
int retID3(string caseR)
{
if (caseR == "SOUTH" || caseR == "South" || caseR == "south") {
return 1; }
if (caseR == "WEST" || caseR == "West" || caseR == "west") {
return 2; }
if (caseR == "SHINY" || caseR == "Shiny" || caseR == "shiny") {
return 3; }
}
int retID4(string caseR)
{
if (caseR == "SOUTH" || caseR == "South" || caseR == "south") {
return 1; }
if (caseR == "WEST" || caseR == "West" || caseR == "west") {
return 2; }
if (caseR == "WALL" || caseR == "Wall" || caseR == "wall") {
return 3; }
}
int retID5(string caseR)
{
if (caseR == "VERB" || caseR == "Verb" || caseR == "verb") {
return 1; }
if (caseR == "EAT" || caseR == "Eat" || caseR == "eat" ) {
return 2; }
if (caseR == "PUSH" || caseR == "Push" || caseR == "push") {
return 3; }
if (caseR == "PULL" || caseR == "Pull" || caseR == "pull") {
return 4; }
}
int retID6(string caseR)
{
if (caseR == "EAST" || caseR == "East" || caseR == "east") {
return 1; }
if (caseR == "SOUTH" || caseR == "South" || caseR == "south" ) {
return 2; }
}
int retID7(string caseR)
{
if (caseR == "EAST" || caseR == "East" || caseR == "east") {
return 1; }
if (caseR == "SOUTH" || caseR == "South" || caseR == "south" ) {
return 2; }
}
// greeting
int main()
{
coins = 0;
cout << "Greetings! Welcome to the Turnip Role Playing Game! \n I am the Dungeon Master! Let's begin! \n What is your first name? \n";
cin >> name;
system("cls");
cout << "Okay, " << name << ", let's get down to buisness! \n PRESS ENTER TO CONTINUE";
system("pause >Nul");
s1();
}
// First part of the adventure
int s1()
{
system("cls");
cout << "You awake in a dark area. The drip of water fills echos throughout the dark corridor. Your choices to move are North, South, or West.\n <ANSWER IN ALL CAPS, ONE WORD> \n";
cin >> reply;
switch(retID(reply))
{
case 1:
s1torch();
break;
case 2:
s1zombie();
break;
case 3:
s1pit();
break;
default:
cout << "You can't do that!";
system("pause >Nul");
s1();
}
return 0;
}
// TORCH GET :D
int s1torch()
{
system("cls");
cout << "You stumble northward, only to trip on a long object. Upon further investigation, you find out that it is a TORCH. \n You can go NORTH, WEST, SOUTH, or TORCH.\n";
cin >> reply;
switch(retID2(reply))
{
case 1:
s2();
break;
case 2:
s1();
break;
case 3:
s1as();
break;
default:
cout << "You cannot do that!";
system("pause >Nul");
s1torch();
}
return 0;
}
//Second part of the adventure!
int s2()
{
system("cls");
cout << "You grab the torch and it magically lights up. You can see the stone walls and floors, signifying you're in a dungeon.\n You see a SHINY object out of the corner of your eye. \n Your options are WEST, SHINY or SOUTH. \n";
cin >> reply;
switch(retID3(reply))
{
case 1:
s2back();
break;
case 2:
s1pit();
break;
case 3:
s1shiny();
default:
cout << "You cannot do that!";
system("pause >Nul");
s2();
}
return 0;
}
int s1shiny()
{
system("cls");
cout << "You examine the source of the shine, to find ten gold coins! TEN COINS GET!";
coins = coins + 10;
system("pause >Nul");
s2noshiny();
}
int s2noshiny()
{
system("cls");
cout << "You grab the torch and it magically lights up. You can see the stone walls and floors, signifying you're in a dungeon. \n Your options are WEST, or SOUTH. \n";
cin >> reply;
switch(retID3(reply))
{
case 1:
s2back();
break;
case 2:
s1pit();
break;
default:
cout << "You cannot do that!";
system("pause >Nul");
s2noshiny();
}
return 0;
}
int s2back()
{
system("cls");
cout << "You return back to the room you originally started in. You see a strange indentation in the EAST WALL. \n Your options are SOUTH, WEST, or WALL. \n";
cin >> reply;
switch(retID4(reply))
{
case 1:
s1zombie();
break;
case 2:
s1pit();
break;
case 3:
s2wall();
break;
default:
cout << "You cannot do that!";
}
return 0;
}
int s2wall()
{
system("cls");
cout << "You investigate the strange indentation in the wall. To the left lies a loose BRICK. The BRICK is jutting out of the wall about two inches, enough to PULL or PUSH it. What do you do with BRICK? \n (Use just a verb: IE verb) \n";
cin >> reply;
switch(retID5(reply))
{
// Smart-Aleck response
case 1:
system("cls");
cout << "Silly " << name << "! That was an example. Now go back there and do it right!";
system("pause >Nul");
s2wall();
break;
case 2:
s2eatbrick();
break;
case 3:
s2pushbrick();
break;
case 4:
s2pullbrick();
break;
default:
system("cls");
cout << "You can't do that!";
system("pause >Nul");
s2wall();
}
return 0;
}
int s2pushbrick()
{
system("cls");
cout << "You push the brick in, and the room shakes. The indentation in the wall begins to lean towards you. \n You jump out of the way just in time for the bricks to crumble and fall onto the spot where you were just standing. \n You quint as the light from the outside filters through the dust. \n Crawling outside, you see a road, which leads EAST or SOUTH. To the EAST lies a town, and the SOUTH a gate. \n";
cin >> reply;
switch(retID6(reply))
{
case 1:
s3();
break;
case 2:
s2gate();
break;
default:
system("cls");
cout << "You cannot do that!";
system("pause >Nul");
s2pushbrick();
}
return 0;
}
// Not death, just a waste of a turn :-)
int s2gate()
{
system("cls");
cout << "You hear SOUTH towards the GATE. You are stopped by a guard. He tells you that you cannot pass through. Being the inquisitive young chap/chapette you are, you ask why, to which the guard responds, 'You need training. I mean, it's the wilderness out there! Go to Nelonshire and get training there. Until then I cannot help you.' \n Following his advice, you walk to the town of Nelsonshire.";
system("pause >Nul");
s3();
}
// Nelsonshire :D
int s3()
{
system("cls");
cout << "You enter the city gates of Nelsonshire. The sheer vastness of the city Nelsonshire. There is a PUB, a SHOP, and an INN.\n";
cin >> reply;
switch(retID7(reply))
{
case 1:
s3pub();
break;
case 2:
s3shop();
break;
case 3:
s3inn();
break;
default:
cout << "You cannot do that!";
system("pause >Nul");
s3();
}
return 0;
}
int s3pub()
{
system("cls");
}
int s3shop()
{
system("cls");
cout << "You enter the shop";
}
int s3inn()
{
}
// Death
int s1as()
{
cout << "You head west, leaving the torch behind. You begin to explore the area you are in. Suddenly you hear the sound of a sword unsheathing, and feel someone - or something's - presence. A katana rips through your abdomen, leaving our halved on the floor.";
system("pause >Nul");
death();
return 0;
}
int s1zombie()
{
system("cls");
cout << "You cautiously walk southbound. You hear a strange moaning from behind you. Before you have a chance to react, a ZOMBIE jumps on top of you. You can feel the flesh being ripped from your bones as you draw your last breath...";
system("pause >Nul");
death();
return 0;
}
int s1pit()
{
system("cls");
cout << "You walk towards the West. You begin to hear the crunch of leaves. \n Just as you begin to wonder why you hear the crunch of leaves in a dark area, you begin to fall. And fall... And fall. \n Your screams of both terror and joy (You did enjoy Ye Olde Rollercoasters as a child) are quashed by spikes at the bottom of the pit.";
system("pause >Nul");
death();
return 0;
}
//Comedic value!
int s2eatbrick()
{
system("cls");
cout << "You eat the brick. It tastes brick-like. You realize you made a stupid mistake (which is true) and fall on the floor dead. Wow, you're an idiot.";
system("pause >Nul");
death();
return 0;
}
int s2pullbrick()
{
system("cls");
cout << "You pull on the brick with all of your might. Since you skipped out on Ye Olde Architecture Class in school, you didn't realize it was a load bearing brick. \n The entire wall falls on you, instantly killing you";
system ("pause >Nul");
death();
return 0;
}
// Death Func
int death()
{
system("cls");
cout << "Congratulations! You have died. Press enter to return to the beginning!";
system("pause >Nul");
system("cls");
s1();
return 0;
}
/* CREDITS:
Lead programmer: ME
Troubleshooter: Firehawk
Beta Testers: ME , Michael "Meow" Gervais, Johnathan "Joshua Florist" Carpenter
*/
[/code]
You didn't explain very well.
Why don't you just cout it in the middle of some function?
But I want it to go back to whatever function you were in when you typed it.
[QUOTE=Dacheet;22374993]But I want it to go back to whatever function you were in when you typed it.[/QUOTE]
You realise this is the normal behaviour?
For example
[code]
void some_func() {
cout << "In a function" << endl;
}
int main() {
cout << "About to call function" << endl;
some_func();
cout << "That was fun!" << endl;
}
/*
Outputs:
About to call function
In a function
That was fun!
*/
[/code]
Also, how do I combine a whole bunch of strings into one variable in C++. I have a lot of return IDs (I think that's what they're called) and I want to condense them down to one variable for an if statement.
Use a string array:
[code]
const int MAXITEMS = 4;
string returnIDs[MAXITEMS] = {"This", "is", "an", "array"};
[/code]
Arrays start from 0 therefore, returnIDs[0] == "This", and returnIDs[1] == "is", and so on.
[QUOTE=TVC;22380512]Use a string array:
[code]
const int MAXITEMS = 4;
string returnIDs[MAXITEMS] = {"This", "is", "an", "array"};
[/code]
Arrays start from 0 therefore, returnIDs[0] == "This", and returnIDs[1] == "is", and so on.[/QUOTE]
I have a bunch of string variables and I want them all down into one array, so would I do that, but replace the strings with variables?
Yes, you should also try stuff like that before asking.
I tried that and this error about 7 times:
[code]
C:\Users\Owner\Documents\C++ Files\WIPs\Rp.c|168|error: conversion from `int ()(std::string)' to non-scalar type `std::basic_string<char, std::char_traits<char>, std::allocator<char> >' requested|
[/code]
And this one about 7 times:
[code]
C:\Users\Owner\Documents\C++ Files\WIPs\Rp.c|177|error: ISO C++ forbids comparison between pointer and integer|
[/code]
Here's the code (The problem is around int main() but I declare the array up higher:
[code]
#include <stdio.h>
#include <tchar.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
string name;
string reply;
int coins;
char strnew[255];
// Death func
int death();
// Money Func
int money();
// Inventory Func
// The sections
//You waking up
int s1();
int s1torch();
int s1zombie();
int s1pit();
int s1as();
int s1shiny();
//After you get the TORCH
int s2();
int s2noshiny();
int s2back();
int s2wall();
int s2eatbrick();
int s2pushbrick();
int s2pullbrick();
int s2gate();
// Nelsonshire
int s3();
int s3pub();
int s3shop();
int s3inn();
// Deciders
int retID(string caseR);
int retID2(string caseR);
int retID3(string caseR);
int retID4(string caseR);
int retID5(string caseR);
int retID6(string caseR);
int retID7(string caseR);
// For s1()
int retID(string caseR)
{
if (caseR == "NORTH" || caseR == "north" || caseR == "North") {
return 1;}
if (caseR == "SOUTH" || caseR == "south" || caseR == "South") {
return 2; }
if (caseR == "WEST" || caseR == "west" || caseR == "WEST") {
return 3; }
}
int retID2(string caseR)
{
if (caseR == "TORCH" || caseR == "Torch" || caseR == "torch") {
return 1;}
if (caseR == "SOUTH" || caseR == "South" || caseR == "south") {
return 2; }
if (caseR == "WEST" || caseR == "West" || caseR == "west") {
return 3; }
if (caseR == "NORTH" || caseR == "North" || caseR == "north") {
return 4;
}
}
int retID3(string caseR)
{
if (caseR == "SOUTH" || caseR == "South" || caseR == "south") {
return 1; }
if (caseR == "WEST" || caseR == "West" || caseR == "west") {
return 2; }
if (caseR == "SHINY" || caseR == "Shiny" || caseR == "shiny") {
return 3; }
}
int retID4(string caseR)
{
if (caseR == "SOUTH" || caseR == "South" || caseR == "south") {
return 1; }
if (caseR == "WEST" || caseR == "West" || caseR == "west") {
return 2; }
if (caseR == "WALL" || caseR == "Wall" || caseR == "wall") {
return 3; }
}
int retID5(string caseR)
{
if (caseR == "VERB" || caseR == "Verb" || caseR == "verb") {
return 1; }
if (caseR == "EAT" || caseR == "Eat" || caseR == "eat" ) {
return 2; }
if (caseR == "PUSH" || caseR == "Push" || caseR == "push") {
return 3; }
if (caseR == "PULL" || caseR == "Pull" || caseR == "pull") {
return 4; }
}
int retID6(string caseR)
{
if (caseR == "EAST" || caseR == "East" || caseR == "east") {
return 1; }
if (caseR == "SOUTH" || caseR == "South" || caseR == "south" ) {
return 2; }
}
int retID7(string caseR)
{
if (caseR == "EAST" || caseR == "East" || caseR == "east") {
return 1; }
if (caseR == "SOUTH" || caseR == "South" || caseR == "south" ) {
return 2; }
}
const int MAXITEMS = 7;
string returnIDs[MAXITEMS] = {retID, retID2, retID3, retID4, retID5, retID6, retID7 };
// greeting
int main()
{
if (MAXITEMS == "coins" || MAXITEMS == "COINS" || MAXITEMS == "Coins" || MAXITEMS == "money" || MAXITEMS == "MONEY" || MAXITEMS == "Money")
{
money();
}
coins = 0;
cout << "Greetings! Welcome to the Turnip Role Playing Game! \n I am the Dungeon Master! Let's begin! \n What is your first name? \n";
cin >> name;
system("cls");
cout << "Okay, " << name << ", let's get down to buisness! \n PRESS ENTER TO CONTINUE";
system("pause >Nul");
s1();
}
// First part of the adventure
int s1()
{
system("cls");
cout << "You awake in a dark area. The drip of water fills echos throughout the dark corridor. Your choices to move are North, South, or West.\n <ANSWER IN ALL CAPS, ONE WORD> \n";
cin >> reply;
switch(retID(reply))
{
case 1:
s1torch();
break;
case 2:
s1zombie();
break;
case 3:
s1pit();
break;
default:
cout << "You can't do that!";
system("pause >Nul");
s1();
}
return 0;
}
// TORCH GET :D
int s1torch()
{
system("cls");
cout << "You stumble northward, only to trip on a long object. Upon further investigation, you find out that it is a TORCH. \n You can go NORTH, WEST, SOUTH, or TORCH.\n";
cin >> reply;
switch(retID2(reply))
{
case 1:
s2();
break;
case 2:
s1();
break;
case 3:
s1as();
break;
default:
cout << "You cannot do that!";
system("pause >Nul");
s1torch();
}
return 0;
}
//Second part of the adventure!
int s2()
{
system("cls");
cout << "You grab the torch and it magically lights up. You can see the stone walls and floors, signifying you're in a dungeon.\n You see a SHINY object out of the corner of your eye. \n Your options are WEST, SHINY or SOUTH. \n";
cin >> reply;
switch(retID3(reply))
{
case 1:
s2back();
break;
case 2:
s1pit();
break;
case 3:
s1shiny();
default:
cout << "You cannot do that!";
system("pause >Nul");
s2();
}
return 0;
}
int s1shiny()
{
system("cls");
cout << "You examine the source of the shine, to find ten gold coins! TEN COINS GET!";
coins = coins + 10;
system("pause >Nul");
s2noshiny();
}
int s2noshiny()
{
system("cls");
cout << "You grab the torch and it magically lights up. You can see the stone walls and floors, signifying you're in a dungeon. \n Your options are WEST, or SOUTH. \n";
cin >> reply;
switch(retID3(reply))
{
case 1:
s2back();
break;
case 2:
s1pit();
break;
default:
cout << "You cannot do that!";
system("pause >Nul");
s2noshiny();
}
return 0;
}
int s2back()
{
system("cls");
cout << "You return back to the room you originally started in. You see a strange indentation in the EAST WALL. \n Your options are SOUTH, WEST, or WALL. \n";
cin >> reply;
switch(retID4(reply))
{
case 1:
s1zombie();
break;
case 2:
s1pit();
break;
case 3:
s2wall();
break;
default:
cout << "You cannot do that!";
}
return 0;
}
int s2wall()
{
system("cls");
cout << "You investigate the strange indentation in the wall. To the left lies a loose BRICK. The BRICK is jutting out of the wall about two inches, enough to PULL or PUSH it. What do you do with BRICK? \n (Use just a verb: IE verb) \n";
cin >> reply;
switch(retID5(reply))
{
// Smart-Aleck response
case 1:
system("cls");
cout << "Silly " << name << "! That was an example. Now go back there and do it right!";
system("pause >Nul");
s2wall();
break;
case 2:
s2eatbrick();
break;
case 3:
s2pushbrick();
break;
case 4:
s2pullbrick();
break;
default:
system("cls");
cout << "You can't do that!";
system("pause >Nul");
s2wall();
}
return 0;
}
int s2pushbrick()
{
system("cls");
cout << "You push the brick in, and the room shakes. The indentation in the wall begins to lean towards you. \n You jump out of the way just in time for the bricks to crumble and fall onto the spot where you were just standing. \n You quint as the light from the outside filters through the dust. \n Crawling outside, you see a road, which leads EAST or SOUTH. To the EAST lies a town, and the SOUTH a gate. \n";
cin >> reply;
switch(retID6(reply))
{
case 1:
s3();
break;
case 2:
s2gate();
break;
default:
system("cls");
cout << "You cannot do that!";
system("pause >Nul");
s2pushbrick();
}
return 0;
}
// Not death, just a waste of a turn :-)
int s2gate()
{
system("cls");
cout << "You hear SOUTH towards the GATE. You are stopped by a guard. He tells you that you cannot pass through. Being the inquisitive young chap/chapette you are, you ask why, to which the guard responds, 'You need training. I mean, it's the wilderness out there! Go to Nelonshire and get training there. Until then I cannot help you.' \n Following his advice, you walk to the town of Nelsonshire.";
system("pause >Nul");
s3();
}
// Nelsonshire :D
int s3()
{
system("cls");
cout << "You enter the city gates of Nelsonshire. The sheer vastness of the city Nelsonshire. There is a PUB, a SHOP, and an INN.\n";
cin >> reply;
switch(retID7(reply))
{
case 1:
s3pub();
break;
case 2:
s3shop();
break;
case 3:
s3inn();
break;
default:
cout << "You cannot do that!";
system("pause >Nul");
s3();
}
return 0;
}
int s3pub()
{
system("cls");
}
int s3shop()
{
system("cls");
cout << "You enter the shop";
}
int s3inn()
{
}
// Death
int s1as()
{
cout << "You head west, leaving the torch behind. You begin to explore the area you are in. Suddenly you hear the sound of a sword unsheathing, and feel someone - or something's - presence. A katana rips through your abdomen, leaving our halved on the floor.";
system("pause >Nul");
death();
return 0;
}
int s1zombie()
{
system("cls");
cout << "You cautiously walk southbound. You hear a strange moaning from behind you. Before you have a chance to react, a ZOMBIE jumps on top of you. You can feel the flesh being ripped from your bones as you draw your last breath...";
system("pause >Nul");
death();
return 0;
}
int s1pit()
{
system("cls");
cout << "You walk towards the West. You begin to hear the crunch of leaves. \n Just as you begin to wonder why you hear the crunch of leaves in a dark area, you begin to fall. And fall... And fall. \n Your screams of both terror and joy (You did enjoy Ye Olde Rollercoasters as a child) are quashed by spikes at the bottom of the pit.";
system("pause >Nul");
death();
return 0;
}
//Comedic value!
int s2eatbrick()
{
system("cls");
cout << "You eat the brick. It tastes brick-like. You realize you made a stupid mistake (which is true) and fall on the floor dead. Wow, you're an idiot.";
system("pause >Nul");
death();
return 0;
}
int s2pullbrick()
{
system("cls");
cout << "You pull on the brick with all of your might. Since you skipped out on Ye Olde Architecture Class in school, you didn't realize it was a load bearing brick. \n The entire wall falls on you, instantly killing you";
system ("pause >Nul");
death();
return 0;
}
// Death Func
int death()
{
system("cls");
cout << "Congratulations! You have died. Press enter to return to the beginning!";
system("pause >Nul");
system("cls");
s1();
return 0;
}
// Money Func
int money()
{
system("cls");
cout << "You currently have " << coins << " coins!";
}
/* CREDITS:
Lead programmer: ME
Troubleshooter: Firehawk
Beta Testers: ME , Michael "Meow" Gervais, Johnathan "Joshua Florist" Carpenter
*/
[/code]
Super quick question time!
How do I draw a rectangle with white outlines and black filling in XNA, C#?
[QUOTE=Dacheet;22396358]I tried that and this error about 7 times:
[code]
C:\Users\Owner\Documents\C++ Files\WIPs\Rp.c|168|error: conversion from `int ()(std::string)' to non-scalar type `std::basic_string<char, std::char_traits<char>, std::allocator<char> >' requested|
[/code]
And this one about 7 times:
[code]
C:\Users\Owner\Documents\C++ Files\WIPs\Rp.c|177|error: ISO C++ forbids comparison between pointer and integer|
[/code]
Here's the code (The problem is around int main() but I declare the array up higher:
[code]
#include <stdio.h>
#include <tchar.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
string name;
string reply;
int coins;
char strnew[255];
// Death func
int death();
// Money Func
int money();
// Inventory Func
// The sections
//You waking up
int s1();
int s1torch();
int s1zombie();
int s1pit();
int s1as();
int s1shiny();
//After you get the TORCH
int s2();
int s2noshiny();
int s2back();
int s2wall();
int s2eatbrick();
int s2pushbrick();
int s2pullbrick();
int s2gate();
// Nelsonshire
int s3();
int s3pub();
int s3shop();
int s3inn();
// Deciders
int retID(string caseR);
int retID2(string caseR);
int retID3(string caseR);
int retID4(string caseR);
int retID5(string caseR);
int retID6(string caseR);
int retID7(string caseR);
// For s1()
int retID(string caseR)
{
if (caseR == "NORTH" || caseR == "north" || caseR == "North") {
return 1;}
if (caseR == "SOUTH" || caseR == "south" || caseR == "South") {
return 2; }
if (caseR == "WEST" || caseR == "west" || caseR == "WEST") {
return 3; }
}
int retID2(string caseR)
{
if (caseR == "TORCH" || caseR == "Torch" || caseR == "torch") {
return 1;}
if (caseR == "SOUTH" || caseR == "South" || caseR == "south") {
return 2; }
if (caseR == "WEST" || caseR == "West" || caseR == "west") {
return 3; }
if (caseR == "NORTH" || caseR == "North" || caseR == "north") {
return 4;
}
}
int retID3(string caseR)
{
if (caseR == "SOUTH" || caseR == "South" || caseR == "south") {
return 1; }
if (caseR == "WEST" || caseR == "West" || caseR == "west") {
return 2; }
if (caseR == "SHINY" || caseR == "Shiny" || caseR == "shiny") {
return 3; }
}
int retID4(string caseR)
{
if (caseR == "SOUTH" || caseR == "South" || caseR == "south") {
return 1; }
if (caseR == "WEST" || caseR == "West" || caseR == "west") {
return 2; }
if (caseR == "WALL" || caseR == "Wall" || caseR == "wall") {
return 3; }
}
int retID5(string caseR)
{
if (caseR == "VERB" || caseR == "Verb" || caseR == "verb") {
return 1; }
if (caseR == "EAT" || caseR == "Eat" || caseR == "eat" ) {
return 2; }
if (caseR == "PUSH" || caseR == "Push" || caseR == "push") {
return 3; }
if (caseR == "PULL" || caseR == "Pull" || caseR == "pull") {
return 4; }
}
int retID6(string caseR)
{
if (caseR == "EAST" || caseR == "East" || caseR == "east") {
return 1; }
if (caseR == "SOUTH" || caseR == "South" || caseR == "south" ) {
return 2; }
}
int retID7(string caseR)
{
if (caseR == "EAST" || caseR == "East" || caseR == "east") {
return 1; }
if (caseR == "SOUTH" || caseR == "South" || caseR == "south" ) {
return 2; }
}
const int MAXITEMS = 7;
string returnIDs[MAXITEMS] = {retID, retID2, retID3, retID4, retID5, retID6, retID7 };
// greeting
int main()
{
if (MAXITEMS == "coins" || MAXITEMS == "COINS" || MAXITEMS == "Coins" || MAXITEMS == "money" || MAXITEMS == "MONEY" || MAXITEMS == "Money")
{
money();
}
coins = 0;
cout << "Greetings! Welcome to the Turnip Role Playing Game! \n I am the Dungeon Master! Let's begin! \n What is your first name? \n";
cin >> name;
system("cls");
cout << "Okay, " << name << ", let's get down to buisness! \n PRESS ENTER TO CONTINUE";
system("pause >Nul");
s1();
}
// First part of the adventure
int s1()
{
system("cls");
cout << "You awake in a dark area. The drip of water fills echos throughout the dark corridor. Your choices to move are North, South, or West.\n <ANSWER IN ALL CAPS, ONE WORD> \n";
cin >> reply;
switch(retID(reply))
{
case 1:
s1torch();
break;
case 2:
s1zombie();
break;
case 3:
s1pit();
break;
default:
cout << "You can't do that!";
system("pause >Nul");
s1();
}
return 0;
}
// TORCH GET :D
int s1torch()
{
system("cls");
cout << "You stumble northward, only to trip on a long object. Upon further investigation, you find out that it is a TORCH. \n You can go NORTH, WEST, SOUTH, or TORCH.\n";
cin >> reply;
switch(retID2(reply))
{
case 1:
s2();
break;
case 2:
s1();
break;
case 3:
s1as();
break;
default:
cout << "You cannot do that!";
system("pause >Nul");
s1torch();
}
return 0;
}
//Second part of the adventure!
int s2()
{
system("cls");
cout << "You grab the torch and it magically lights up. You can see the stone walls and floors, signifying you're in a dungeon.\n You see a SHINY object out of the corner of your eye. \n Your options are WEST, SHINY or SOUTH. \n";
cin >> reply;
switch(retID3(reply))
{
case 1:
s2back();
break;
case 2:
s1pit();
break;
case 3:
s1shiny();
default:
cout << "You cannot do that!";
system("pause >Nul");
s2();
}
return 0;
}
int s1shiny()
{
system("cls");
cout << "You examine the source of the shine, to find ten gold coins! TEN COINS GET!";
coins = coins + 10;
system("pause >Nul");
s2noshiny();
}
int s2noshiny()
{
system("cls");
cout << "You grab the torch and it magically lights up. You can see the stone walls and floors, signifying you're in a dungeon. \n Your options are WEST, or SOUTH. \n";
cin >> reply;
switch(retID3(reply))
{
case 1:
s2back();
break;
case 2:
s1pit();
break;
default:
cout << "You cannot do that!";
system("pause >Nul");
s2noshiny();
}
return 0;
}
int s2back()
{
system("cls");
cout << "You return back to the room you originally started in. You see a strange indentation in the EAST WALL. \n Your options are SOUTH, WEST, or WALL. \n";
cin >> reply;
switch(retID4(reply))
{
case 1:
s1zombie();
break;
case 2:
s1pit();
break;
case 3:
s2wall();
break;
default:
cout << "You cannot do that!";
}
return 0;
}
int s2wall()
{
system("cls");
cout << "You investigate the strange indentation in the wall. To the left lies a loose BRICK. The BRICK is jutting out of the wall about two inches, enough to PULL or PUSH it. What do you do with BRICK? \n (Use just a verb: IE verb) \n";
cin >> reply;
switch(retID5(reply))
{
// Smart-Aleck response
case 1:
system("cls");
cout << "Silly " << name << "! That was an example. Now go back there and do it right!";
system("pause >Nul");
s2wall();
break;
case 2:
s2eatbrick();
break;
case 3:
s2pushbrick();
break;
case 4:
s2pullbrick();
break;
default:
system("cls");
cout << "You can't do that!";
system("pause >Nul");
s2wall();
}
return 0;
}
int s2pushbrick()
{
system("cls");
cout << "You push the brick in, and the room shakes. The indentation in the wall begins to lean towards you. \n You jump out of the way just in time for the bricks to crumble and fall onto the spot where you were just standing. \n You quint as the light from the outside filters through the dust. \n Crawling outside, you see a road, which leads EAST or SOUTH. To the EAST lies a town, and the SOUTH a gate. \n";
cin >> reply;
switch(retID6(reply))
{
case 1:
s3();
break;
case 2:
s2gate();
break;
default:
system("cls");
cout << "You cannot do that!";
system("pause >Nul");
s2pushbrick();
}
return 0;
}
// Not death, just a waste of a turn :-)
int s2gate()
{
system("cls");
cout << "You hear SOUTH towards the GATE. You are stopped by a guard. He tells you that you cannot pass through. Being the inquisitive young chap/chapette you are, you ask why, to which the guard responds, 'You need training. I mean, it's the wilderness out there! Go to Nelonshire and get training there. Until then I cannot help you.' \n Following his advice, you walk to the town of Nelsonshire.";
system("pause >Nul");
s3();
}
// Nelsonshire :D
int s3()
{
system("cls");
cout << "You enter the city gates of Nelsonshire. The sheer vastness of the city Nelsonshire. There is a PUB, a SHOP, and an INN.\n";
cin >> reply;
switch(retID7(reply))
{
case 1:
s3pub();
break;
case 2:
s3shop();
break;
case 3:
s3inn();
break;
default:
cout << "You cannot do that!";
system("pause >Nul");
s3();
}
return 0;
}
int s3pub()
{
system("cls");
}
int s3shop()
{
system("cls");
cout << "You enter the shop";
}
int s3inn()
{
}
// Death
int s1as()
{
cout << "You head west, leaving the torch behind. You begin to explore the area you are in. Suddenly you hear the sound of a sword unsheathing, and feel someone - or something's - presence. A katana rips through your abdomen, leaving our halved on the floor.";
system("pause >Nul");
death();
return 0;
}
int s1zombie()
{
system("cls");
cout << "You cautiously walk southbound. You hear a strange moaning from behind you. Before you have a chance to react, a ZOMBIE jumps on top of you. You can feel the flesh being ripped from your bones as you draw your last breath...";
system("pause >Nul");
death();
return 0;
}
int s1pit()
{
system("cls");
cout << "You walk towards the West. You begin to hear the crunch of leaves. \n Just as you begin to wonder why you hear the crunch of leaves in a dark area, you begin to fall. And fall... And fall. \n Your screams of both terror and joy (You did enjoy Ye Olde Rollercoasters as a child) are quashed by spikes at the bottom of the pit.";
system("pause >Nul");
death();
return 0;
}
//Comedic value!
int s2eatbrick()
{
system("cls");
cout << "You eat the brick. It tastes brick-like. You realize you made a stupid mistake (which is true) and fall on the floor dead. Wow, you're an idiot.";
system("pause >Nul");
death();
return 0;
}
int s2pullbrick()
{
system("cls");
cout << "You pull on the brick with all of your might. Since you skipped out on Ye Olde Architecture Class in school, you didn't realize it was a load bearing brick. \n The entire wall falls on you, instantly killing you";
system ("pause >Nul");
death();
return 0;
}
// Death Func
int death()
{
system("cls");
cout << "Congratulations! You have died. Press enter to return to the beginning!";
system("pause >Nul");
system("cls");
s1();
return 0;
}
// Money Func
int money()
{
system("cls");
cout << "You currently have " << coins << " coins!";
}
/* CREDITS:
Lead programmer: ME
Troubleshooter: Firehawk
Beta Testers: ME , Michael "Meow" Gervais, Johnathan "Joshua Florist" Carpenter
*/
[/code][/QUOTE]
Well, this is a completely illegal statement.
[code]if (MAXITEMS == "coins" || MAXITEMS == "COINS" || MAXITEMS == "Coins" || MAXITEMS == "money" || MAXITEMS == "MONEY" || MAXITEMS == "Money")[/code]
You're comparing a number to various strings. What are you trying to do??
If I have two bytes, and I wanted to represent a single longer number with them, working completely in decimal how might I go about this?
[QUOTE=shill le 2nd;22401063]Well, this is a completely illegal statement.
[code]if (MAXITEMS == "coins" || MAXITEMS == "COINS" || MAXITEMS == "Coins" || MAXITEMS == "money" || MAXITEMS == "MONEY" || MAXITEMS == "Money")[/code]
You're comparing a number to various strings. What are you trying to do??[/QUOTE]
No, I'm trying to compare a string to various strings.
[QUOTE=Jawalt;22401316]If I have two bytes, and I wanted to represent a single longer number with them, working completely in decimal how might I go about this?[/QUOTE]
What do you mean a single longer number?
[QUOTE=Darwin226;22401800]What do you mean a single longer number?[/QUOTE]
Like how a 4 bytes represents an integer. I need to know how to manually do that kind of thing.
Nvm
Pretty sure the standard is 1 byte, all the references I can find say 1 byte.
Oh, I meant short, not char. [URL="http://msdn.microsoft.com/en-us/library/7tb7bdw6(VS.71).aspx"]Short[/URL].
[QUOTE=Jawalt;22401316]If I have two bytes, and I wanted to represent a single longer number with them, working completely in decimal how might I go about this?[/QUOTE]
Well if it's two bytes then you may aswell put it into a short because it will fit. If for whatever reason you wanted it in an int, i think you can still do that.
Actually, i'm not sure the best way to do it. I know you can put a char into a short or int without a cast but not sure how you would do 2.
[editline]12:30AM[/editline]
I've been told you can do it like
[cpp]
char a;
char b;
...
short int s = a << 8 & b;
[/cpp]
Which is handy to know.
[QUOTE=layla;22402543]Well if it's two bytes then you may aswell put it into a short because it will fit. If for whatever reason you wanted it in an int, i think you can still do that.
Actually, i'm not sure the best way to do it. I know you can put a char into a short or int without a cast but not sure how you would do 2.[/QUOTE]
I'm not working in C++ though is the thing, I'm working in a language interpreted by C++ with 1kb of memory, a big array made up of bytes. In the interpreted language I'd want to know how to do things to represent a larger number. The language is Turing complete bar the memory limit.
[QUOTE=Jawalt;22402726]I'm not working in C++ though is the thing, I'm working in a language interpreted by C++ with 1kb of memory, a big array made up of bytes. In the interpreted language I'd want to know how to do things to represent a larger number. The language is Turing complete bar the memory limit.[/QUOTE]
Ah, well sorry, i just assumed :P
[QUOTE=shill le 2nd;22401063]Well, this is a completely illegal statement.
[code]if (MAXITEMS == "coins" || MAXITEMS == "COINS" || MAXITEMS == "Coins" || MAXITEMS == "money" || MAXITEMS == "MONEY" || MAXITEMS == "Money")[/code]
You're comparing a number to various strings. What are you trying to do??[/QUOTE]
No, I'm trying to compare a string to various strings.
[QUOTE=layla;22402741]And if you happen to be using zlib
short i;
gzread(file, &i, sizeof(i));
should do the job aswell
[editline]12:35AM[/editline]
Ah, well sorry, i just assumed :P[/QUOTE]
Nah it's cool, thanks for trying to help though. The only way I can think of doing it is to just do (in psuedocode)
[code]
mem[0] = 255 //Max a memory area can hold.
mem[1] = 30 //Amount to add
mem[2] = 240 // The area to be added to.
if mem[0] - mem[2] < mem[1] then
mem[10] = mem[0] - mem[2]
mem[2] += mem[10]
mem[3] += mem[1] - mem[10]
end
[/code]
Didn't spend too long on that but you get the point. That's incredibly inefficient though :(
I don't know if you can do this but you can multiply one by 256, then add the other one.
[code]
So if the first byte is 120 and the second one is 240:
120*256 + 240 = 30960
Or in binary:
120 - 0111 1000
240 - 1111 0000
120 * 256 = 30720 - 0111 1000 0000 0000
30720 + 240 = 30960 - 0111 1000 1111 0000 //which is the fist one and second one put together [/code]
[QUOTE=Darwin226;22403095]I don't know if you can do this but you can multiply one by 256, then add the other one.
[code]
So if the first byte is 120 and the second one is 240:
120*256 + 240 = 30960
Or in binary:
120 - 0111 1000
240 - 1111 0000
120 * 256 = 30720 - 0111 1000 0000 0000
30720 + 240 = 30960 - 0111 1000 1111 0000 //which is the fist one and second one put together [/code][/QUOTE]
I think that's getting pretty close now. If I could use that to represent the number and then for printing and such put the output of that into separate memory areas. But how to get the 120*256 when you can only hold 255 as your tops number is the problem.
Sorry, you need to Log In to post a reply to this thread.