C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 21st, 2008, 09:00 AM
Koueen Koueen is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 1 Koueen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 45 sec
Reputation Power: 0
"RPG" Style Game, using C++

I'm trying to make a game I have made the character creation part, but I can't get the movement to work, Here's my code:

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <iostream>
#include <cstdlib>
//mapinfo
int map [6][6] ={0,0,0,0,0,0,
0,9,9,9,9,0,
0,9,9,9,9,0,
0,9,9,9,9,2,
0,0,0,2,0,0,
};

int x,y;
int x1,y1;


char movement;

using namespace std;

int main(int argc, char *argv[])
{
//Starting area
x=2;
y=2;
//Moving
movement:
cin >> movement;
//Testing for direction
if (movement== 'w')
{
if (map [x] [(y-1)]== 9)
{
x;
y-1;
}
else if (map [x] [y-1]==1 )
{
x;
y-1;
}
else if (map [x] [y-1]==0 )
{
printf ("There's a wall there, watch it next time.\n");
}
else if (map [x] [y-1]==2)
{
printf ("This door is closed.\n");
}
else if (map [x] [y-1]==4)
{
printf ("You try to turn the handle, but it doesn't move.\n");

}
}
if (movement== 's')
{
if (map [x ] [(y+1)]== 9)
{
x;
y+1;
}
else if (map [x] [y+1]==1 )
{
x;
y+1;
}
else if (map [x] [y+1]==0 )
{
printf ("There's a wall there, watch it next time.\n");
}
else if (map [x] [y+1]==2)
{
printf ("This door is closed.\n");
}
else if (map [x] [y+1]==4)
{
printf ("You try to turn the handle, but it doesn't move.\n");

}
}
if (movement== 'a')
{
if (map [x-1] [(y)]== 9)
{
x-1;
y=1;
}
else if (map [x-1] [y]==1 )
{
x=2;
y=1;
}
else if (map [x-1] [y]==0 )
{
printf ("There's a wall there, watch it next time.\n");
}
else if (map [x-1] [y]==2)
{
printf ("This door is closed.\n");
}
else if (map [x-1] [y]==4)
{
printf ("You try to turn the handle, but it doesn't move.\n");

}
}
if (movement== 'd')
{
if (map [x+1] [(y)]== 9)
{
x=2;
y=1;
}
else if (map [x+1] [y]==1 )
{
x=2;
y=1;
}
else if (map [x+1] [y]==0 )
{
printf ("There's a wall there, watch it next time.\n");
}
else if (map [x+1] [y]==2)
{
printf ("This door is closed.\n");
}
else if (map [x+1] [y]==4)
{
printf ("You try to turn the handle, but it doesn't move.\n");

}
}
goto movement;
return EXIT_SUCCESS;
}

EDIT: 0s are impassable
9s are passable
1s are open doors
2s are closed doors
4s are broken doors

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > "RPG" Style Game, using C++


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap