SgtMe 46 Veteran Poster Featured Poster

A good way to learn stuff is to make decent programs that do helpful things. Not ones that p*ss people off.

Fbody commented: Amen! +4
SgtMe 46 Veteran Poster Featured Poster

449

SgtMe 46 Veteran Poster Featured Poster

Please post your code. Don't forget to push the code button before you paste each file.

SgtMe 46 Veteran Poster Featured Poster

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)?

SgtMe 46 Veteran Poster Featured Poster

445

SgtMe 46 Veteran Poster Featured Poster

A -> Win (-ning the competition against team B) ;)

SgtMe 46 Veteran Poster Featured Poster

Thats ok :)
Glad you got it sorted.

SgtMe 46 Veteran Poster Featured Poster

repairs -> broken

SgtMe 46 Veteran Poster Featured Poster

427

SgtMe 46 Veteran Poster Featured Poster

423

SgtMe 46 Veteran Poster Featured Poster

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 :)

SgtMe 46 Veteran Poster Featured Poster

queue -> wait

SgtMe 46 Veteran Poster Featured Poster

415

SgtMe 46 Veteran Poster Featured Poster

411

SgtMe 46 Veteran Poster Featured Poster

Well have a look, make a few demo programs to get the feel, then incorporate them into your main program.

SgtMe 46 Veteran Poster Featured Poster

407

SgtMe 46 Veteran Poster Featured Poster

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");
}
SgtMe 46 Veteran Poster Featured Poster

403

SgtMe 46 Veteran Poster Featured Poster

Found this page. Not sure if it's helpful or not.
http://www.daniweb.com/forums/thread96561.html

SgtMe 46 Veteran Poster Featured Poster
SgtMe 46 Veteran Poster Featured Poster

good -> bad

SgtMe 46 Veteran Poster Featured Poster

403

SgtMe 46 Veteran Poster Featured Poster

What problem are you currently having?

SgtMe 46 Veteran Poster Featured Poster

Have you tried enclosing the whole thing (after the equals) in "float(...);"? Sometimes that works...

SgtMe 46 Veteran Poster Featured Poster

407

SgtMe 46 Veteran Poster Featured Poster

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 :@

SgtMe 46 Veteran Poster Featured Poster

naughty -> nice

SgtMe 46 Veteran Poster Featured Poster

^ doesn't like my favourite drink ;)
< loves pepsi :D
V hopefully also loves pepsi :)

SgtMe 46 Veteran Poster Featured Poster

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.

SgtMe 46 Veteran Poster Featured Poster

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 :)

SgtMe 46 Veteran Poster Featured Poster

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!)

SgtMe 46 Veteran Poster Featured Poster

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?

SgtMe 46 Veteran Poster Featured Poster

potato -> skin

SgtMe 46 Veteran Poster Featured Poster

Sorry double post by accident.

SgtMe 46 Veteran Poster Featured Poster

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.

SgtMe 46 Veteran Poster Featured Poster
SgtMe 46 Veteran Poster Featured Poster

poker -> chips

SgtMe 46 Veteran Poster Featured Poster

407

SgtMe 46 Veteran Poster Featured Poster

401
Ich muss ins Bett gehen. Night all :)

SgtMe 46 Veteran Poster Featured Poster

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 :)

SgtMe 46 Veteran Poster Featured Poster

397

SgtMe 46 Veteran Poster Featured Poster

393

SgtMe 46 Veteran Poster Featured Poster

card -> paper

SgtMe 46 Veteran Poster Featured Poster

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.

SgtMe 46 Veteran Poster Featured Poster

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 :)

SgtMe 46 Veteran Poster Featured Poster

391

SgtMe 46 Veteran Poster Featured Poster

meeting -> greeting

SgtMe 46 Veteran Poster Featured Poster

387

SgtMe 46 Veteran Poster Featured Poster

secret -> telling (just came into my head, I'm actually rather good at keeping secrets).

SgtMe 46 Veteran Poster Featured Poster

383