I have programmed a game where you guess a number (1-6) and if the number is equal to the random number then give the player score + 10. But if I have selected for example 4 players then if the game will give player 1 a score it gives player 2 a score instead? What can be causing this error?
Code:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int cube;
int number[4];
I am writing a game that is 2 to 4 players. i am wondering how to ask how many players, and make the score stay with each player. it is a rip off of zombie dice, this is what i have so far the playerScore array is to hold the score for each player and the turn array is hold hold the values that they rolled that turn, i also dont know how to clear out the turn array when it goes to the next player.
#include <iostream> #include <cstdlib> #include <cmath> #include <ctime> using namespace std; int main() { int playerScore[4];
#include <stdio.h> float total, avg, max, min; float judge[4]; int index; int array[4]; int main() { total = 0.0; max = array[0]; min = array[0];
[Code] ....
I dont understand how to make the array when it prints out only print out the final average and the final maximum score with the final minimum score but what its doing at the moment is just giving an average for each individual score taken...
Minimum and maximum scores are displaying 0.0
And it displays these things 4 times in a row i just want it to be displayed once.
I want to give audio-input to a FFT code (KissFFT) written in C, on a real-time basis. While I can give a simple test signal (like sine wave) by writing the sine function as input, I am not sure how I should convert an audio-signal (e.g.: song) into a form that can be taken as input by the KissFFT C code.
The program should ask the user how many students were surveyed and dynamically allocate an array of that size. The program should then allow the user to enter the number of movies each student has seen.
#include <iostream> #include <string> using namespace std;
[Code].....
The problem I'm having is that where I declare movies = [numStudents]; the semicolon after the numStudents array is giving me this error - "error: expected a '{' introducing a lambda body".
I'm creating a bank system. So I know to make a deposit to the balance, which add ups what is the balance to i have add.
When i run the deposit function, its work well in some ways. If balance(text file) has the value 10, add i addSum 20, the balance will become 30, same as the text file will become 30. so its work well to add positive number.
double deposit(double balance){ double addSum = 0; system("CLS"); cout<< "Welcome to deposit."<<endl; cout<<"Enter a sum you wish to add to your account:";
[Code] .......
When I withdraw from 30 which is the balance, then i takeSum, for example i take away 30. The balance will become 30 - 30 = 0
When i make another withdraw from example -150, it will be -150.
Which shows correct.
But when i make a deposit from -150 and i addSum 130, the balance shows -500, and it should had been -20.
double withdraw(double balance) { double takeSum = 0; system("CLS"); cout<< "Welcome to withdraw."<<endl; cout<<"Enter a sum you wish to take away from your account:"; cout << balance << '
[Code] .....
What is causing this problem, also when function deposit and withdraw close, it goes to readBalance function, should go to menu.
double readBalance(double balance) { int option; system("CLS"); cout<<"Welcome to balance."<<endl; cout<<"Your balance is:"<<endl;
Not a major issue since I got this to work but for some reason both my random numbers are the same and not sure why ...
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class ComputerAssistedInstructions { private static Random rand1 = new Random(); private static Random rand2 = new Random();
This is what I got so far. It creates a vector in a direction I want to move, then just normalizes the vector. Simple as that. But I'm having 2 problems..
AI moves towards player only when Im at like the end of screen and the AI is on the other side, I must keep a certain distance for it to be able to move towards me. Basically, its not constantly moving towards the player. I also tried it with trig, using atan2 for angle and sin / cos for speed. Also didn't work, same result.
The other problem is when I want to add i.e 5 more AIs. For each new AI it creates, it makes a new update.. So, to kinda clear it up. If I'm in middle of the screen and an AI is spawned above me, it will move towards me. But when after that one, 2nd AI spawns beneath me, both 1st and 2nd AI move up. Basically, previous AIs take the update from last one that is created. For updating I'm using lists, objects and iters.
I'm having some problems figuring out 3 and 4 player games in an Uno game I'm working on. I'm not sure what specifically the problem is, however. I've tried everything I can think of; I'm at a loss for what to do next. Two player games work perfectly, which makes the nonfunctional 3 and 4 player games seem odd to me. Here is the code:
public void MoveOpponents() { if (nextPlayer == 0) { if (Main.dir == Direction.Clockwise) nextPlayer = 1; else nextPlayer = numPlayers - 1;
[Code] .....
The code for the human player is in Update(), but I won't show that because it's actually quite similar to the above code.
Right now what it's doing is jumping all over the place, making opponent 2 play before opponent 1, then I play, then opponent 1 plays. Then I play again. It's really messed up.
Im using the remquo function in the cmath library as follows:
int quotient; double a = remquo (10.3, 4.5, "ient);
This gives the correct remainder (a = 1.3) and quotient (quotient = 2).
Infact about 50% of the answers are right when I play around, however, trying something like:
int quotient; double a = remquo (2.25, 1.5, "ient);
yields an incorrect quotient of 2 and remainder of 0.
I do think this has something to do with float arithmetic. I recall tinkering with the float number 0.500 and that the CPU actually saves it as 0.50000000000000231. However if my suspicion of float arithmetic as the suspect is correct, I do not understand why a tenth decimal would make such a drastic difference as changing the quotient result.
I'm using Code:Blocks 12.11 on windows 7, with the built-in MinGW compiler. When I try and compile a program that has an error in it (misnamed variable, missing include, extra semi-colon somewhere, anything) instead of saying something about what went wrong it just has this:
Process terminated with status 1 (0 minutes, 0 seconds) 0 errors, 0 warnings (0 minutes, 0 seconds)
when I want to use the same socket connected to the host to send() and recv() for the second time, recv() will return 0 without anything in buffer. Basically I am doing:
1. connect to the website 2. send packets 3. receive packets 4. send packets again (I think this one is working since it's not giving me SOCKET_ERROR) 5. receive packets again (this one is returning 0 so as "connection closed")
source code: [URL] ....
as you can see, I have sock2, which when I use for second send/recv it's working fine, however I will do more communication, and having sockets for all of that and connecting them.
I am trying to retrieve information from a website [URL] .... and have written a C code as follows:
Code: #include <stdlib.h>#include <stdio.h> #include <string.h> #include <curl/curl.h> int main(int argc, char* argv[]) { /* Exit status to return */ int exitStatus = 0;
[Code] .....
The output of this program should be: From To 4504111 B0LPF3 4504111 P62993
The first print option [printf("%s", url)] gives the url output as [URL] .... which on being manually pasted in any web-browser gives the correct output but the program fails to give the output.
I'm making a game with the following class structure:
GameControl - The class that actually runs the game, with a while(!closed) // run the game loop.
State - A class that handles the state of the game, for example if the game is rendering the scene it would be in one state, and if it is rendering the menu, it would be in another.
ComponentManager - A class that manages all of the components of what is being done, for instance, the Scene class would contain a bunch of components handling the drawing of each tree, physics, the camera, etc. The manager will put them all together.
Component - A component of whatever is being done. A tree (and its rendering code) would be an example of a component of the scene. The camera would be another. The component does not necessarily have to be drawn, it could be handling something like physics (and would throw physics events to other components that need to move in a certain way).
The GameControl class has its loop, which would call the update function on the current State (there are classes that inherit State and override the update function of State).
In the update function of the base class "State", it would take all of the active ComponentManagers and update them. There are classes that inherit the base class ComponentManager and override its update function.
Each ComponentManager would update each of the Components that it owns.
This is the organizational structure that I came up with to make the game scalable and changeable . If, for instance, I wanted to add multiplayer at some point, I would add a class that inherits the State that controls the gameplay called "MultiplayerGameState". This would just add a new ComponentManager that inherits the ComponentManager that controls the player and all of the living things that are moving around. Then, the MultiplayerGameState class would recieve the multiplayer messages coming in and add other player Components for the other players.
My code is giving me various errors like "Forward definition of class State" and "Invalid use of incomplete type State". Unless I made some stupid error that I didn't catch, these are being caused by me including the classes in ways that some of the classes do not see the full definitions of the classes they need to see (because of the preprocessor directives preventing classes from being included multiple times.
Code: (Not implemented exactly as shown above, but I think the main difference is that the main class is not in GameControl, it's in OgreFramework.cpp)
The base classes: [URL] ... States: [URL] ... ComponentManagers: [URL] ... Components: [URL] ... The project: [URL] ...
My question is: is there a better way to implement my organizational system so that these errors don't occur?
I've implemented the merge sort algorithm and used the 'merge' part for counting the number of split-inversions in an array as part of an assignment for an online course. How ever, the out put array is not a sorted version of the input array and as a result the number of split inversions obtained is wrong. I think that there is some thing wrong in the way I am indexing arrays.
I've used ' cout ' to print the values of indexes to see exactly what values are being passed in during the recursions.
Code:
#include <iostream> using namespace std; int length=0,mid=0,inv=0; void mergesort(int arr[], int first, int last) { cout << "first: " << first << " " << "last: " << last; cout << endl;
Im using SDL2 but I'm encountering an unexpected error. I have implemented the same method to move as in my old Projects, but the Player appears to be stuck...
The Player is stuck for maybe half a second, and then everything works as it should, but every time I Change direction or i start moving the Player is stuck for a short Moment.
#ifndef _PLAYER_HPP_ #define _PLAYER_HPP_ #include <iostream> #include <string> #include "SDLGameObject.hpp" class CPlayer : public CSDLGameObject
I have been looking and i'm stuck on this. I wrote this program to find quarks and their charge and mass but i need it to give me 5 different ones. so i made an array but when i run it it gives me this
"Unhandled exception at 0x001631c6 in DiasQuarkP1V0.exe: 0xC0000005: Access violation reading location 0xd5bf0c38." and it shows the xstring library.
this is my main, is their anything wrong with my code?
#include "StdAfx.h" #include <stdio.h> #include <string> using namespace std; int main() { Quark solution[5]={};
I'm using cout to print lots of lines. But i want to put together them in one variable etc. Then , i want to print it. I think i can do it with ostream but I cant do it . Is there any example use of ostream.
I want to use it such that: x<< "hello" << endl; x<< "mike" << endl; x<< "how " << endl; x<< "are" << endl; x<< "you" << endl; cout << x;
Here is the code I have written so far. My problem is that when the second user enters its position the last user's position is wiped of the board. I want to know how I can hold that position and keep doing so until the game is finished. I thought that calling the previous function would do that (and you can see where I have put that into a comment) but it doesn't.
Code: #include <iostream> //includes header file using namespace std; //function prototypes void printLeftUpper(int i, int j); void printMiddleUpper(int i, int j);
I actually need to create a labyrinth and a player who needs to go thru the map collecting objects (like bags, water etc...). I planned to do the map with a bidimentional array (5x5) but I dont know how to put different objects on an index.. Ex: array[3][2] will have a Botte of water and an energy bar..
Someone told me to use structs but I dont really understand how this would work... I've tried so many times bit I cant do it...
I have a question about one function in my program. Write a function that will replace players in a team. New player gets in the game, and takes the place of one that leaves. Prototype of function is:
void replace(TEAM *p,PLAYER newplayer,int num)
where second parameter is new player, and the third is a jersey number of player who leaves the game. Two structures are defined as:
Is C# or any other programming language out there that can run like a program that has been installed on you PC? For example say i want my program to run Media player with a saved play list, run spotify, or run a search on the internet?