C/C++ :: Stopping A Game When Winning Score Is Reached

Nov 11, 2014

I'm working on coding a game of pong that allows players to play until one reaches a score of 10. Once the winning score is reached I want to display a "Game Over" message stating which player won. The game works perfectly except for stopping when the winning score is reached.

Here is the code I have so far:

//pongTest.cpp
#include "stdafx.h"
#include <string>
#include <Windows.h>
#include <iostream>
#include <conio.h>
#include <sstream>
#include <math.h>
#include <glgl.h>
#include <glglu.h>
#include "GL/freeglut.h"

[Code] ....

Not sure if my gameOver() function just isn't written properly, I'm not calling it properly, or a mixture of both.

View 2 Replies


ADVERTISEMENT

C++ :: BlackJack Game - How To Keep Score

Nov 20, 2014

A buddy and I have been working together to try and create a blackjack game for a project we are doing, and while we have a couple of issues we are trying to get worked out, for some reason we are perplexed as to how we can keep score. Right now, it keeps score but it doesn't reset when it adds a card. So if you had 14 and you hit, and added 3; you would have 31 instead of 17.

// initialize players and hands
srand(static_cast<unsigned int>(time(0)));
GetPlayerInfo(players);
do {
int score = 0;
bool busted = (score > 21);
ShuffledDeck(deck);

[Code] .....

View 2 Replies View Related

C++ :: Program To Keep Score Of Bowling Game

Dec 9, 2013

I'm writing a program to keep score of a game of bowling. Whenever I run the program, it comes up with the correct starting point, but whenever i type in the first number and click enter, the program stops running and it gives a return value of something similar to 3221225477. Here is my code. I think the problem might be that I'm not using pointers..? but I could be way off..I'm new to programming.

#include <stdio.h>
int main() {
int frame[10][3] = {{0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0,0}};
int frameOutcome[10], frameTotal[10], currentFrame = 0, totalScore = 0;

[Code] ....

View 1 Replies View Related

C++ :: Pong Game Keeps Crashing On A Score - Floating Point Exception

Mar 24, 2013

I wrote a pong game and it keeps crashing, it only happens on a score and says floating point exception.

Code:

//The headers
#include"SDL/SDL.h"
#include"SDL/SDL_image.h"
#include"SDL/SDL_ttf.h"
#include<string>
#include<stdio.h>
#include<math.h>

[Code] ....

View 3 Replies View Related

C++ :: Video Game - Compare 3 Players Score And Output Highest

Oct 21, 2013

I was tasked with creating a program that asks for the scores of three gamers then takes these scores and outputs the highest. I THINK I have the other parts down but I don't know how to get the program to compare the scores and output the highest without having to write a long list of commands comparing playerone to playertwo, then player one to playerthree, then player two to playerone, etc.

#include <iostream>
using namespace std;
int main () {
int playerOne, playerTwo, playerThree;
cout << "Please enter score for Player One: ";
cin >> playerOne;

[Code] .....

View 10 Replies View Related

C :: Stop Write Operation If File Size Has Reached 1GB?

Dec 23, 2013

A process is writing data continuously to a file . I need to stop the write operation if the file size has reached 1GB. Is there any way to check file size when it is opened for the write operation.

I could do the same using scripts. Can this be done using C Programming ?

View 5 Replies View Related

C++ :: How To Automatically Go To Next Textbox If Input Char Reached Its Limit

Sep 6, 2013

#include<windows.h>
#include<conio.h>
void gotoxy(int x,int y);
void gets_ex(char*, int max_chars);
int main(int argc, char *argv[]) {
char urname[16], surname[16], fullname[32];
start:
system("COLOR 1c");

[Code]...

View 8 Replies View Related

C :: Read Specific Amount Of Data From File Until Terminating Set Is Reached

Jul 23, 2014

I wrote a code to read a specific amount of data from file until terminating set is reached. however the code does what its supposed to correctly until it reaches the 5th loop it justs stops responding. I've checked the reading file and all elements are correct in the file.

Code:
int main(void){
FILE *file1;
FILE *file2;
FILE *file3;

struct t test1;
struct t test2;

[Code] ....

Screenshot of program crashing:

Screenshot of reading file:

View 11 Replies View Related

C/C++ :: Array To Only Print Out Final Average And Final Maximum Score With Final Minimum Score

Aug 27, 2014

#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.

View 1 Replies View Related

C :: Scanf With Stopping Condition

Mar 22, 2013

I wanted to input some numbers with scanf function, i can enter some numbers and if I input -1 to the scanf, the input must end. And the scanf function has limited input, the max that I can input is 40 numbers.example if enter 1 2 4 6 5 4 -1 the scanf function will ended and the result will be appear.I wanted to know how the scanf function is like that would be best for this problem, Code: scanf("%d", &n); the result if I input those number will be like

|
||
||||
||||||
|||||
||||

View 3 Replies View Related

C++ :: Stopping Threads Without Using Local Var?

Aug 31, 2014

Here's my code,

#include <iostream>
#include <unistd.h>
#include <thread>
using namespace std;
void Blink();

[Code] .....

The problem is i don't want to use local vars , is ther anyway do end the loop safely(removing all the vars used in function and etc) without using a local var ?

View 3 Replies View Related

C++ :: Stopping Codes With A Key Press

Feb 25, 2013

I have a program that I made, which does a list of stuff, then checks if a key is pressed, and if it's pressed, stop the looping.

The problem is, it checks if the key is pressed once a loop, which means that if the list has delays, you have to hold the button down for a while (depending on the list).

Here's an example:
Move mouse;
Pause program for 2 seconds;
Move mouse;
Pause program for 2 seconds;
Check if key is pressed;

What ways can I fix this problem?

View 1 Replies View Related

C++ :: Stopping Infinite Loop?

Feb 20, 2013

The code below gives me the maximum odd number and the minimum even number of a list of numbers that the user type. However, for the loop to stop the user needs to type 1000. Is there a better way (without having to have a "stopping" number, just in case I need this number to be somewhere on the list) to get the same results?

Code:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;
int main() {
int x, maxi, mini;

[code]...

View 2 Replies View Related

C/C++ :: Read Numbers From Cin Then Sum Up And Stopping When 0 Entered

Jun 6, 2014

Write a program that reads numbers from cin and then sums them, stopping when 0 has been entered. Add the following to your program:

-A counter within the while loop that keeps track of the number of inputs entered.
-A comment that determines if the total value is less than 100 or greater than 100, as in the sample output
-Switch statements to determine the total number of inputs

Sample output:

Enter numbers, one per line. Enter 0 to end:
7
8
6
5
5
9
8
0

The total was 48.
The total number of inputs read is 8.
The total is less than 100.

The code that I've got so far lets me keep track of the inputs entered, and displays the total of the values, but I'm not sure how to do the part where it determines if the value is greater or less than 100.

#include <iostream>
using namespace std;
int main() {
int val, total=0;
int i=0;
cout << "Enter numbers, one per line. Enter 0 to end:
";

[Code] .....

View 2 Replies View Related

C/C++ :: Stopping Case For Asterisk Pattern?

Dec 1, 2014

So, I'm going to write a recursive function for a asterisk pattern but I'm stuck figuring out how to create a stopping case for it, better yet, I'm unable to describe the pattern completely.

*
**
-*
****
--*
--**
---*
********
-----*
-----**
------*
-----****
-------*
-------**
--------*

( - represent white spaces )

What I've been thinking:

* Every odd row has 1 * with 1 incremented white space

* Every "pair" of asterisks equals 8 total (EX. 8 one pair *'s, 4 two pair *'s, 2 four pair *'s)

Unfortunately, that's all I got. how I can represent this as I function. Once I figure out what my stopping case should be, I think I can do the coding on my own.

View 1 Replies View Related

C Sharp :: Stopping And Resuming Threads?

Jul 9, 2012

how do I stop and restart a Thread in C# once it reaches a certain location on a form then restart the thread once it goes outside of the location boundries?

I am trying to stop an animation thread (a bullet) once it reaches a block on a panel.

View 1 Replies View Related

C :: Shows Lines Of Running In Output With Gdb Without Stopping

Feb 24, 2013

I run the program with gdb , i searched but find nothing about how i could run gdb , that shows what line of code is running constantly (i rather it also shows value of the variable on each line if it's possible ) without stopping (i mean i don't want to enter "step" every time , i just need to run the program with debugger and shows line of the code is running (without need to enter step each time by myself)is it possible? if yes , what command is needed to start gdb for this purpose?

P.S: for this purpose if i have to set breakpint i will. but even i rather not set breakpoint , i rather gdb while running the program shows what line is now executing (rather with the value of variabels).

View 4 Replies View Related

C/C++ :: Polymorphism Is Stopping Short Of Desired Class

Mar 2, 2014

I've been working on this project which inserts data for different types of books lately, and I'm trying to utilize inheritance and polymorphism. The issue I've been having is after I create an object with my MediaFactory, I go to insert data into that type of object, but it won't reach the correct child class. The parent class in this case is MediaData. The class I'm trying to reach is Childrens, and the class that falls in between is called Book. The function I'm calling to insert the information is setData(ifstream&). This function simply places the information from a txt file into an object with the insertion operator.

Right now the program runs into the setData function of Book instead of Childrens. I need Childrens so I can enter all the required attributes (title,author,year). The call to this function is in MediaManager through the function called buildMedia, and my test is running into the case if (type == 'Y'). From there a pointer of type MediaData is created and pointed to a new object returned of type Childrens. I'm using my debugger in Xcode which does show that the correct object type (Childrens) was created.

I've tried a couple things so far. First I created another function called getData. From there I passed in *media and infile (txt input file) into that function, which then passed it right into setData with a pointer to the object and infile in the parameter. That didn't work, so I also tried going back into Childrens and removing MediaData from all my virtual functions and replacing it with Book. I got the same result when that happened; It morphed into Book class instead.

I have a portion of my UML as a reference. Childrens is a Book; Book is a MediaData. I also included all code for MediaManager, MediaHash, MediaFactory, MediaData, Book, and Childrens.

I did not include the operator overloads in the .cpp files to eliminate some redundancy.

//-----------------------------------------------------------------------------
// MediaManager.h
// Manager class for MediaData type objects
//-----------------------------------------------------------------------------

#ifndef MediaManager_H
#define MediaManager_H
#include "MediaHash.h"
#include "MediaFactory.h"
#include "MediaData.h"
using namespace std;
class MediaManager {

[Code] ....

View 3 Replies View Related

C++ :: Game Design Practice For Accessing Container Of Game Objects

Dec 21, 2014

I'm working on my first video game. So far I have a few classes in the game starting with the Game class which includes a list of GameObjects (another class). There are several classes that inherit from GameObjects used to implement things like bullets, explosions, various enemy types, etc.

The game essentially iterates through the list of GameObjects to update/render them. I would like to provide access to the Game's list of GameObjects inside another class (like the Bullet class) so I can put new objects on the list. For example, when a bullet hits, I want to add an explosion to the Game's GameObject list it can be updated/rendered.

How this should be setup? I was considering adding a pointer to the Game or GameObject list to the GameObject class (and methods to access it), but I was wondering if there is a better way to set this up?

View 4 Replies View Related

C++ :: Program For Calculating Total Price Of Game Station And Game

Sep 13, 2014

I would like to make a program for calculating the total price of a game station, and a game. I made a program like this for just the price of a game in class, but I want to make one that does the game system as well.

View 7 Replies View Related

C++ :: How To Store A Score

Mar 28, 2013

I want to do something like when you have completed the first question then the program will give you +3 in coins then you have completed next question then I want the program to add 3 more so it says you have a value of coins 6. But I do not know exactly how to do this the code I begun to write was this:

Code:
#include <iostream>
using namespace std;
int main()

[Code] ...

This code works for 1 question but I want it to work like add 3 for every question the user guesses correct. Like if user enters the correct answer 3 times then he/she has a value of coins 9.

View 2 Replies View Related

C/C++ :: Adding To Score Every Second

May 18, 2014

Currently in development of a cookie clicker clone (for fun)

I am stuck at the idea of the "Cookies Per Second" thing.

Is there a way to implement a per second adder thing that doesnt actually effect the game play (eg even though the player may not be pressing C every second a cookie (or more) will be added, or if they can press C more than once a second, every second a cookie will be added... If you get what I mean).

Code is below if you would like to look />

MAIN.cpp
#include <iostream>
#include <conio.h>
#include <Windows.h>
#include "Shop.h"
#include "Varis mate.h"

[Code] .....

View 3 Replies View Related

C :: How To Get The Average Score For Each Student

Nov 10, 2013

I have to get the average score for each student. And modify my avgmarks function and write the marks to a output txt file.

Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

int bubble(int*,int);
void filewrite();
void avgmarks();
void fileprint();
void filesort();
void rollin();

[Code] .....

View 1 Replies View Related

C# :: Nickname Won't Appear On High Score

Mar 28, 2015

I've made a game and a dialogbox to show up asking to enter a nickname.

The problem is After entering the nickname, it won't show on the highscore list below (textbox)

Where can the problem be? Below is my code:

private void btnPlay_Click(object sender, EventArgs e) {
if (txtName.Text != "") {
Settings.Name = txtName.Text.ToString();

[Code] .....

View 5 Replies View Related

C# :: Cricket Score Card?

Mar 24, 2010

I have to develop an application named smart client score board in c#

Main requirements for this application are that application should display the live scores, detailed score board, running commentary (in text), players and team profiles, statistics of matches, results and fixtures for cricket.

sort out websites which support rss feeds for full score card.

View 6 Replies View Related

C++ :: Giving Score To Correct Player

Jul 22, 2013

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];

[Code] .....

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved