Ilija's question board

Mar 13, 2013 at 8:59am
I made this topic for all my questions so that I don't flood the forum.I will also post my solved things as source code.
here is my new question
I want to make a ball move anywhere on the map but I can only make it move forward can anyone write a step back,left and right so that i can make it move everywhere here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
int a
//all up movement begining
;cout<<"\nI\nI\nI\nI\nI\nI\nI\nI\nI\nI o\n"
;cin>>a        
;if(a==1){
cout<<"\nI\nI\nI\nI\nI\nI\nI\nI\nIo\nI \n"
;cin>>a
;if(a==1){
cout<<"\nI\nI\nI\nI\nI\nI\nI\nIo\nI\nI \n"
;cin>>a
;if(a==1){
cout<<"\nI\nI\nI\nI\nI\nI\nIo\nI\nI\nI \n"
;cin>>a
;if(a==1){
cout<<"\nI\nI\nI\nI\nI\nIo\nI\nI\nI\nI \n"
;cin>>a
;if(a==1){
cout<<"\nI\nI\nI\nI\nIo\nI\nI\nI\nI\nI \n"
;cin>>a
;if(a==1){
cout<<"\nI\nI\nI\nIo\nI\nI\nI\nI\nI\nI \n"
;cin>>a
;if(a==1){
cout<<"\nI\nI\nIo\nI\nI\nI\nI\nI\nI\nI \n"
;cin>>a
;if(a==1){
cout<<"\nI\nIo\nI\nI\nI\nI\nI\nI\nI\nI \n"
;cin>>a
;if(a==1){
cout<<"\nIo\nI\nI\nI\nI\nI\nI\nI\nI\nI \n"
;}
;}
;}
;}
;}
;}
;}
;}
;}

//all up movement end
    system("PAUSE");
    return EXIT_SUCCESS;
}

###########################SOLVED########################################
A little rpg battle

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
int a,enemypower,b,c
;c=100
;enemypower=5
;b=100
;while(b>0){
;cout<<"enemy health "<<b<<"\n"
;cout<<"your health "<<b<<"\n"
;cout<<"your stamina:"<<b<<"\n"
;cout<<"pick a move:hit;strike or fire punch\n"
;cin>>a
;if(a==3){
b=b-20
;c=c-enemypower*3
;cout<<"enemy health "<<b
;cout<<"your health"<<c
;}
;if(a==2){
b=b-15
;c=c-enemypower*2
;cout<<"enemy health "<<b
;cout<<"your health"<<c
;}
;if(a==1){
b=b-10
;cout<<"enemy health "<<b

; system("PAUSE");
}
}
}


Last edited on Mar 14, 2013 at 11:38am
Mar 13, 2013 at 10:26am
You never change your variables. DO like that:
1
2
3
if(a==2){
b = b-15;
cout<<"enemy health "<<b;
And you should make separate variables for your health, enemy health and stamina.

And what with your coding style? My eyes hurt.
Last edited on Mar 13, 2013 at 10:26am
Mar 13, 2013 at 10:28am
b - n is the result of the operation, but it doesn't modify the value of b. To modify b do b -= n.
Mar 13, 2013 at 8:40pm
@miinipaa my coding style is your typical messy 11yr old style
i still get the problem that on the second turn the code doesnt memorize the last turns b.example i chose 3 it says enemy health 80 then i chose 2 and then it says enemy health 85 Help!
Mar 13, 2013 at 8:53pm
closed account (3qX21hU5)
Do you want your health and the enemy health to be the same?
1
2
3
;cout<<"enemy health "<<b<<"\n"
;cout<<"your health "<<b<<"\n"
;cout<<"your stamina:100"


Because your using b to hold both of them.

Also to make it perminate change these

1
2
;cout<<"enemy health "<<b-20
;cout<<"your stamina "<< b-25


and other like those to

1
2
;cout << "enemy health " << b-=20 // Notice the -=
;cout << "your stamina " <<  b-=25


Also PUT YOUR ; on the END OF YOUR STATEMENTS much easier to read for us and I'm not even going to try correcting them. ;p
Mar 13, 2013 at 8:58pm
it says no match for operator -=
Mar 13, 2013 at 9:16pm
thanx for all the help I found the solution here is the code the trick was not to use == but = LOL
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
int a,b,c
;b=100
;while(b>0){
;cout<<"enemy health "<<b<<"\n"
;cout<<"your health "<<b<<"\n"
;cout<<"your stamina:100"
;cout<<"pick a move:hit;strike or fire punch\n"
;cin>>a
;if(a==3){
b=b-20
;cout<<"enemy health "<<b
;}
;if(a==2){
b=b-15
;cout<<"enemy health "<<b
;}
;if(a==1){
b=b-10
;cout<<"enemy health "<<b

; system("PAUSE");
}
}
}
Mar 13, 2013 at 9:36pm
closed account (3qX21hU5)
That isn't the only problem the firat one is your semi colons you have many that aren't suppose to be there and they are all at the beginning. Yes it it legal but it is really bad formating. Also you are still using the same variable for your health and the enemies health.

Also please use codetags when posting code to the forums ( the <> under format. Highlight your code and click that button)
Mar 13, 2013 at 9:53pm
thanx will do i know but they will get used when i turn this into a game
Last edited on Mar 14, 2013 at 9:14am
Mar 14, 2013 at 9:21am
bump
Mar 14, 2013 at 10:56am
bump
Mar 14, 2013 at 12:10pm
closed account (3qX21hU5)
Why are you bumping it you when you haven't asked any questions....

Edit: Nevermind I see what you did. But please just make a new post instead of editing your original post every time you have a new question and bumping it. For one it gets people very confused, and two if any other users are trying to solve a question that is similar to yours they won't be able to view your old questions and the answers you have gotten.

So please make new threads for all your new questions thank you.
Last edited on Mar 14, 2013 at 12:24pm
Mar 14, 2013 at 12:34pm
It may be a bit early to say this, but here goes:

Do we have a brand new troll?
Mar 14, 2013 at 2:43pm
Probably not a troll. I think it's just one of the new breed of young people who live in social-network land. Write a bit of code... Post it online for feedback... rinse & repeat.

Looks like this guy is learing something though and that's always a good thing. Except how to use CODE TAGS! 8^P Elija, before you post, select the parts that are code and then click the <> button to the right. It will format your code for easy viewing.

Also, listen to Zereo and start NEW threads for NEW topics. Otherwise you will break the internet and everyone will be mad at you! You don't need to "flood the forum". Just read your manuals and research on-line when you need answers. When that doesn't work, it's time to ask on a forum like this. Happy coding!
Mar 14, 2013 at 7:11pm
I am learning and sure I will post new topics I plan to have a future with c++ and yeah if you consider I am young but thad does not matter i already learned english as my second language
Topic archived. No new replies allowed.