A good way to learn stuff is to make decent programs that do helpful things. Not ones that p*ss people off.
A good way to learn stuff is to make decent programs that do helpful things. Not ones that p*ss people off.
449
Please post your code. Don't forget to push the code button before you paste each file.
Looks like a fake virus. What's even the point? Is it that fun scaring the sh*t out of someone you don't know? Do you think it's enjoyable for them? Would you like (if you though it was real)?
445
A -> Win (-ning the competition against team B) ;)
Thats ok :)
Glad you got it sorted.
repairs -> broken
427
423
Sorry "woooee" but I'm taking his side. I never ever ever ever ever give out free homework help. However, I will give links to sites and tiny snippets of code to get them started. "M3M69" is relatively new here, so go easy on them :)
queue -> wait
415
411
Well have a look, make a few demo programs to get the feel, then incorporate them into your main program.
407
Here's a demo code:
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
//variables
//length of array
const int len=5;
//array of numbers. Obvs. 24 is highest
int arr[len]={3, -1, 24, 10, 16};
//index of current highest
int HighestSoFar=0;
//loop until we have tested each array value
int i=0;
while (i<len)
{
//if the current array value is higher than
//the current highest, overwrite the current
//highest variable ("HighestSoFar")
if (arr[i]>arr[HighestSoFar]){HighestSoFar=i;}
i++;
}
cout<<"HIGHEST INDEX "<<HighestSoFar<<endl;
cout<<"HIGHEST VALUE "<<arr[HighestSoFar]<<endl;
system("Pause");
}
403
good -> bad
403
What problem are you currently having?
Have you tried enclosing the whole thing (after the equals) in "float(...);"? Sometimes that works...
407
Well you would need a lot of "if" statements. Have a variable for each ship (use array) called "Direction". This could be an int array or string array (eg. 1 or "N" is north). When the user presses a key, use if statements to check which way they are facing and move accordingly.
EDIT:
I see you are running two threads. Please keep all your problems in this thread. Thanks.
I must go to school now (damn thing doesn't shut unless there's 1209109238 feet of snow :@
naughty -> nice
^ doesn't like my favourite drink ;)
< loves pepsi :D
V hopefully also loves pepsi :)
If we break down the logic in that line, it is correct.
sqrt(
pow(mypointx-pointpx, 2)
+
pow(mypoint-pointpy, 2)
)
;
Have a look on google and see if you can find anything on converting scientific to decimal.
So you'll obvs. have your array "Board[3][3]". And values will be "0" or "1".
You want a loop that will reprint the game board. Use 'system("cls");' on Windows to clear the console. Then reprint the board.
Each loop, the user should be asked to press a key ("W", "A", "S" or "D"). If they put in another key, don't do anything, but don't report it either. Have a variable which stores the location of the "1". Obvs., if the player presses "W", take one off the "y" value of the coord.
Have a loop that goes through your array. If it hits "1" print "1", else print "0" (or vice versa). Don't forget that when you move, change the current position to "0", THEN change the next position (the one you are moving to) to "1".
Hope this helps :) If so, please upvote. Thanks :)
These won't fix your issue, but they will clean up your code a bit.
In main.cpp:
-Change lines 8-10 to:
float mypointx, mypointy, Answer;
-After line 22 add:
system("pause");
In XYPoint.h:
-Change lines 13-17 to:
float mypointx, mypointy, pointpx, pointpy, mydistance;
In XYPoint.cpp:
-Remove lines 6-10 (Variables already zero. For one run, you won't need to set them. Keep though if looping program).
-------------------------------
Not sure why you are getting the answer in scientific notation.
When you are testing your program, make the (actual) distance between points "0", as to say that both sets of coordinates are the same. If it does not turn out zero, something is wrong.
When that is working, you will need to test the logic of your program with a 3-4-5 triangle. From your fixed point (eg [0, 0]), you will go out 3 on the x, and up 4 on the y, giving you [3, 4]. The hypotenuse (the distance) of which will be "5".
http://www.tpub.com/math1/20f.htm
Hope this helps :) (If so, then please upvote!)
Please press the code button before you paste your code. Please explain your problem better. What does your program do to the data before it writes it into other files?
potato -> skin
Sorry double post by accident.
Please explain how you would like your movement:
1. W ALWAYS moves the ship up
2. W moves in the direction facing
It looks kinda like you want the first one. Let's say you have a ship at [5, 5] and you want to move it up one space. Though the ship is facing up, you press W to go up. The ship's position is now [5, 4]. You just take one off the y value. Obviously, you have to update your board, but that up there is a simple explanation. Then repeat for A and D.
poker -> chips
407
401
Ich muss ins Bett gehen. Night all :)
Eeeeek...sounds nasty. I think education globally is going to waste. I keep hearing on this site of people who are stuck on homework, not because they can't do it, but because they have a poor tutor, or the tutor is too vague or whatever. The fact that there are lots of functions doesn't really help.
My brain is trying to figure out a way of doing it without classes. For movement, I would suggest that you in your 10x10 grid, you have blank spaces as '0' and ships as 's'. Then, when you come to print, you would find all the ships in the array, get their direction, and print, say, [^] [>] [v] [<] to show the direction.
With regards to armour and range and the like, I would have an array called, eg., ArmourStats of length 'n=ships'. Therefore, ArmourStats[0] would be the value of the armour of ship one, ArmourStats[1] of ship two and so forth. Repeat for the other mass-variable storage mabobs.
You could reduce the amount of functions quite easily. Have ONE function for move, which takes a variable of where the ship you want to move is, and where to. Then you can just recycle this. Obviously, repeat with the other functions. The more of this you do, the more your tutor will/should be impressed.
Good luck again :)
397
393
card -> paper
So classes are banned? Awwwww shucks...if it wasn't banned you could sure learn that easily...
I guess you'll just have to use lots of functions and variables then. Go through the logic of your program, get a piece of paper, and work out what variables and functions you need. Organize the basic structure, then start to code in the finer details.
Tell your tutor that they should have taught you classes before getting you to make a game.
Have a look at classes. Make a class for your frigate/each type of ship. Then it should have functions such as one for movement, firing etc. You'll need to be careful about what variables you need and passing them backwards and forwards between your main program and the classes.
http://www.cplusplus.com/doc/tutorial/classes/
The movement idea of your program should be considerable maths-based (ie. calculating whether a move is legal, how far should they move etc.). It appears that the logic is not too difficult, but there is a lot of it.
Good luck :)
391
meeting -> greeting
387
secret -> telling (just came into my head, I'm actually rather good at keeping secrets).
383