C/C++ :: Updating Window In Game Loop?

May 25, 2014

So I am working on making a game. The first thing I did was make a window class. This correctly makes the window and displays it.

Now, I run my game loop and it just freezes the window and shows the Application has stopped working message box. I believe this is because the Window is not actually being updated.

My game loop however, looks like this.

bool run = true;
while(run) {
Window::Render();
if (Window::IsCloseRequested())

[Code].....

View 4 Replies


ADVERTISEMENT

C :: Cannot Get Out Of Loop - Stuck With Updating Variables

Jul 18, 2013

Code:
#include<stdlib.h>#include<stdio.h>
#include<unistd.h>
#include<math.h>
int main(void)
{
double N, NG, LG, epsilon, root; // setting all variables to type double

[Code] .....

The goal is to create a program to calculate the square root of a number provided by the user to an error tolerance 0.005

Looking around i fond the Code: fabs(NG - LG) < epsilon); section that was very similar to what i was using, but if this is better im down for that.

My issue, from what i can see, is the updating of the values of LG. if the test for error tolerance fails then LG needs to take on the value of the results of NG.

Now I am not 100% that is the point of failure due to the fact the script does calculate the root properly, but it never exits the program once it reaches the tolerance level.

Code: imac:ENG-3211 user$ ./hw_4_1

Please enter the number you wish to find the square root: 4

4.00 2.500
4.00 2.050
4.00 2.001
4.00 2.000
4.00 2.000
4.00 2.000
4.00 2.000
4.00 2.000
4.00 2.000

And it continues forever until i manually break the program even though the answer was found, in this example, on the 4th loop.

View 8 Replies View Related

C++ :: How To Make CMD Window Pop Up When Open A Game

Dec 20, 2014

I wanna know how to do so a cmd window when you open a game.

Example: when I start cheese attack (just a name I like) then a cmd window come up, how do I do that?

View 1 Replies View Related

C/C++ :: Make Basic Snake Game Using Command Window And Screen Refreshes?

Apr 15, 2015

I am trying to make a basic Snake game using the command window and screen refreshes. So far I have a board, snake, food, and no walls. Basically I have it so the snake moves like the traditional snake in the game, when it eats the food once it grows. However when it eats the food a second time the game crashes. I think I have narrowed the issue down to the grow array that I have (below) but I am not sure if the issue could be a result of something else.

Grow Array

cord growArray (cord *p_values, int *size)
{
*size = *size + 1;
cord *p_new_values = new cord[ *size ];

[Code]....

View 7 Replies View Related

C/C++ :: Factor Game Using Loop

Feb 12, 2015

So I'm doing this problem where the user will input a number that will be factored until the number is 1, 2 people will play this game and they will take turns entering a number that the initial number(named gameN) will be divided by until it is 1. Whoever get it to 1 wins. My problem is I'm not really sure how to do this, I'm pretty new to programming so besides some if statements and a loop, the problem shouldn't require too much to write. Some rules for the game are, the number entered to factor the gameN cant be less than 2, and has to divide evenly into gameN, which I have signifies with modulus. Here is where I'm at so far.

#include <stdio.h>
int main(){
int gameN;
int p1f;
int p2f;
printf("What number should the game be played with?");
scanf("%d", &gameN);

[Code] ....

View 2 Replies View Related

C++ :: Game Loop Design - Restart Round?

Sep 30, 2013

I have a simple game loop.

while(true) {
//round initialization stuff
while(true) {
//capture input, make pieces move,
}
}

I am faced with the decision of what is the best way of restarting the game. The problem is, the condition for restarting a game is very, very deep inside the game's logic. So returning returning... is not an option, or at least, it ain't gonna be pretty.

So one of my considerations is to use a goto label, like so:

while(true) {
//round initialization stuff
while(true) {
//capture input, make pieces move,
} restart_round:
}

This seems to be the cleanest solution, since it allows me to fully reset the 'state' of the round, by first having all the destructors(pertaining to the round's objects) called, and then the constructors and other initialisation stuff.

Are there any subtleties that I am missing regarding this solution?

View 10 Replies View Related

C++ :: Guessing Game - How To Successfully Loop Back To The Beginning

Feb 5, 2015

So I'm making my first program w/ C++ and its a game guessing game. I've learned how to use booleans, chars, strings, if/else, loops, and input. Anything past that I dont know. I've gotten my game to work properly except for the fact that when you guess incorrectly, the program closes. I want the program to go to the beginning of the program again so the user can restart. So far i've gotten the loop to beginning thing to work but not well. It'll only repeat twice before closing again and it'll say the user got the wrong answer even if it was correct. Here's my code

#include <iostream>
#include <string>
#include <random>
#include<ctime>
using namespace std;

int game(){
string playerName;
int guess;

[Code] ....

View 1 Replies View Related

C++ :: Number Guessing Game - Play Again Loop Broken

Sep 11, 2013

OK, so the program is working minus the play again loop. I even tried a goto statement for it but no luck. Basically what its doing is after the game runs its course it asks if you would like to play again? If you hit Y it starts over but if you it N it starts over. I want it to out put thank you for playing and close after user hits a button.

// C// Guess My Number
// The classic number guessing game

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

[Code] ....

View 1 Replies View Related

C++ :: Tile Mapping Program - Loop Through All Tiles In Game Setting X And Y Coordinates

Jun 6, 2013

void create_map(){

int x = 0;
int y = 0;
while (y >= 15) {
game_map[x][y].pos_x = x * tile_size;
game_map[x][y].pos_y = y * tile_size;

Objective of the code: to loop through all tiles in the game, setting their X and Y coordinates.

It just doesn't do anything at all. No error message.

View 12 Replies View Related

C++ :: For Loop In Hangman Game - Read A Word From Text File Randomly And Matches It With Definition

Jun 26, 2014

Ok here I have a program that reads a word from a text file randomly and matches it with the definition. The user has to guess what the word is according to the definition.

I'm having trouble with my for loop, I'm not getting any errors. But I just know something is off.

Here's my code:

#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>

using namespace std;
int main(){
int number;
int count = 0;
int numOfGuess = 0;

[Code] ...

This is words.txt:

apple#the usually round, red or yellow, edible fruit of a small tree
boat#a vessel for transport by water
horse#a solid-hoofed plant-eating domesticated mammal with a flowing mane and tail, used for riding
television#a system for transmitting visual images and sound that are reproduced on screens
soup#a liquid dish, typically made by boiling meat, fish, or vegetables, etc.
bottle#a container, typically made of glass or plastic and with a narrow neck
barber#a person who cuts hair
toast#sliced bread browned on both sides by exposure to radiant heat
radar#a system for detecting the presence, direction, distance, and speed of aircraft, ships, and other objects
red#of a color at the end of the spectrum next to orange and opposite violet

View 1 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# :: SQL Update Not Updating But Can Add - No Errors

Feb 1, 2015

I am currently just trying to update a record in a SQL database.I can add a record and delete a record just fine but when I go to update I get no errors but it just doesn't update.

Here is what I have and done coding for hours trial and error

private void btnAddProd_Click(object sender, RoutedEventArgs e)
{//validate method // product = new Product(txtProductName.Text, Convert.ToDecimal(txtProductCost.Text), txtProductType.Text);
product = new Product();
MakeProduct(product);
if(modify) {
Product theOneAndOnly = new Product();

[Code] ....

View 1 Replies View Related

C/C++ :: Updating Values In Dat File

Nov 9, 2014

The file name is "movie.dat" and currently i was able to save data into the file in this order:

[movie_code] [movie_dur] [movie_title] [movie_rating] [movie_dir] [movie_genre] [movie_status]

[12345] [120] [Movie] [PG13] [Director] [Comedy] [Active]

I want to search for the "movie_code" and change the [movie_status] from Active to Inactive.

So lets say for example i have a movie code 12345 saved in my movie file. I want to change the value from "Active" to "Inactive"for argument sake.

This is the code i was trying to do it with:

FILE *movie_fp;
movie_fp = fopen("movie.dat", "r+b");
int m_code;
MOVIE movie_data;
printf("*** Welcome to the movie updater! ***
");
if(movie_fp != NULL){

[Code] ...

View 2 Replies View Related

Visual C++ :: Updating To New Windows SDK?

Apr 27, 2013

I've just integrated the Windows SDK V7.0A into my VS2005 application, and I'm getting the dreaded "Application configuration error" when I try to run it on an XP machine.

It runs fine on the development machine, and some customer machines (Win7 and Win8), but will not run on XP due to missing/incorrect version dlls.

I've rebuilt all my libraries, but still no joy.

So, my first question is - If I upgrade the Windows SDK to V7.0A, do I also need to use MFC 10 and msvcrt10, or can I stick with MFC 8?

The next question is, how do I find out which dlls are missing, and which libraries or other dlls are requesting the missing versions?

View 11 Replies View Related

C++ :: Object Data Not Updating Correctly

Dec 14, 2013

I am writing a program that manages a group of tool bins. This group is handled as an object that is an array of two element structures called InvBin. I initialize the bins with data from a file which contains the descriptions and initial quantities. I also have functions to add or subtract items from a bin and a function to display a report of the description and quantity of all of the bins.

The add and remove functions work correctly based on the cout statement in the functions, however when I display the report, it displays the initial quantity instead of the new quantity. In addition, when I use the add and remove functions again on the same bin, they use the initial quantity.

These are the add and remove functions and the report function from the main program.

Code:
//Adds an item to a bin
void addItem(HANDLE screen, BinManager tools, int &count) {
int binNum;
int addNum;
system("cls");

[Code].....

View 2 Replies View Related

C++ :: Updating Global Pointer In Tree

Jul 16, 2013

I am having trouble updating my global pointer in the following code,

Code:
#include <iostream>
using namespace std;

struct RB{
RB()=default;
RB(int clr):color(clr) { }
int color;

[Code] ....

The problem is, at line where I compar y==Tnil, It is evaluating to false at the first insert. But It should be true. again, after ending the function, T again becomes equal Tnil, as a result , none of the is being inserted.

View 2 Replies View Related

C :: Updating Specific Data In The File

Mar 17, 2013

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#define MAX 200

[Code] ....

Inside of my studentinfo.txt file

Code:
Jnh Has 2353325 23 56 72 34 67 22 46 42 5 23 56 23
Daniel Laurent 6744590 10 20 30 40 50 60 70 80 90 100 40 50

This code is working totally fine. Right now, I'm trying to update a specific data from the student info. Let's say I'm trying to update my student number of Daniel. So, in this case, I want to replace 6744590 to some other student number. I think I have to use fseek() or rewind() and use fputs() but, I don't know how I should decide where to look.

View 8 Replies View Related

C++ ::  Updating Array In Grading Program

Sep 14, 2014

The program will grade a series of exams and then print a grade report for students in a course.

Input: An instructor has a class of students each of whom takes a multiple-choice exam with 10 questions. For each student in the class, there is one line in the input file. The line contains the answers that student gave for the exam. The input file named "grade_data.txt" will have the following format:

line 1: the key for the exam (e.g.)
bccbbadbca

lines 2-n:
a set of answers. You know you are done when you get to a line with no data.

Note: You will not know in advance how many exams you have to grade and you don't need to store the exam answers in your program.

Processing: The program is to read the input file and grade each exam and print out the score for that exam. You will also keep track of how many students earned each score (0-10) and print a report after the grading.

Output: Here is an example of how the output might appear. You will write the report to an output file named "grade_report.txt"

Student 1 - 8
Student 2 - 10
Student 3 - 1
etc.

Final Report
------------
10 - 4
9 - 2
8 - 3
.
.
1 - 3
0 - 0

high score - 10
low score - 1
mean score - 6.25

What I am having trouble with is the second part of the program. I have already figured out each grade for each student. The part I am having trouble with is updating the array every time that it gives me a student score so that I know how many people made a 10, how many made a 9, etc.

View 1 Replies View Related

C# :: Datagrid Not Updating Styling After Refresh

May 21, 2014

I have a datagrid, which has a column called Status. In the database, the field is a text field that can have the values up, down, or danger.

I needed to display the status as a "light" as per client request, so I have a StatusToImageConverter class that receives the status, and returns the proper image to display in the datagrid column. Works fine.

Now the issue I am having... I have a combo box above the datagrid for the user to filter the results if desired. The filtering works fine, but the newly displayed devices do not have their status light. In the Status column, nothing appears after the user filters. I think it may have to do with the fact that I am not re-initializing the datagrid, but just refreshing it? That's just my educated guess.

XAML:
In the UserControl Resources:

<local:StatusToImageConverter x:Key="ImageConverter" />
In the DataGrid Control:
<DataGridTemplateColumn Header="Status" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>

[Code].....

View 5 Replies View Related

C Sharp :: Updating Database From Datagridview

Jul 12, 2013

I just wanna update my database with one click only.

I do for update my database from datagridview1 but it shows a error like this :

Unhandled exception has occurred in your application . If you click Continue, the application will ignore this error and attempt to continue. If you click Quit,the application will close immediately.

Update requires a valid UpdateCommand when passed DataRow collection with modified rows

Attached Files : WindowsFormsApplication4.zip (127.2 KB)

View 2 Replies View Related

Visual C++ :: Dynamically Updating Image (PNG)

Dec 26, 2013

I am working on a Windows application using Visual Studio 2012. One of the screens have a text entry field for the user. Instead of using a standard text field control, am placing a image which looks exactly like a text field. Now what i want to do is, capture the key stroke and update this image with the characters entered by user.

The initial image shown to the user is "Blank_Text_Entry.png" and this is added to the resource as IDB_BLANK_TEXT_ENTRY.

This is a rectangular white image with dimensions 153 x 27, with a size of 250 bytes.

My goal is to be able to update this image dynamically based on key strokes by user and display it.

View 5 Replies View Related

Visual C++ :: Updating Image On A Button

Aug 2, 2013

I have created an application that has bunch of buttons on top and i want to change the image when I click on the button. But unfortunately I can't get it to work.

Here is the code:

if (serialPort1.IsOpen) {
tsbCommPortOpenClose.ToolTipText = "Open serial port";
closeCommPortToolStripMenuItem.Text = "Open serial port";
tsbCommPortOpenClose.Image = Image.FromFile("Red.bmp");
serialPort1.Close();
[Code] ....

The second one which changes the image to "image2" works fine. Here is the definition of image2:

namespace Regress;
...
private Bitmap image2;
System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
StreammyStream = myAssembly.GetManifestResourceStream("Regress.Sharing.gif");
image2 = new Bitmap(myStream);

When I do the same with the other image that I want to use, it won't work! I opened the project properties and added the image into the resources too, and it still doesn't work. It fails and says the file was not there. I've put a copy of the file in the root directory and one in "Resources" folder but it still doesn't work.

View 3 Replies View Related

C++ :: Updating String From Aaaa To Dddd

Jan 29, 2012

I am writing some code that takes a string of n letters, so a, or aa or aaa or aaaa...a and transforms these into d or dd or ddd or dddd...d by essentially counting. e.g aaaa -> aaab -> aaac -> aaad -> aaba and so on. Also technically the user inputs what the ending is whether it be d or e,f,g; however, for practical reasons counting up to dddd should work. My main issue is I am having trouble getting the letters correct. I get up to aadd and then once I go to abaa I have trouble getting the second to last a to switch correctly.

Code:
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
vector<string> pleasework;
string apple = "aaaaaa";
int end = apple.size()-1;

[Code] ....

View 3 Replies View Related

C :: Updating Record In Random Access File

Nov 5, 2014

I have been searching through the forums and found a couple snippets of code and from that i came up with this. What i want to do is search for the specific movie code and then update the movie status from inactive to active (for argument sake).

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

typedef struct SYSTEM_MOVIE{
int movie_code;
int movie_dur;
char movie_title[25];

[Code] ....

View 1 Replies View Related

C++ :: QLabels And High Speed Updating Causes Crash

Jun 26, 2014

On a project I'm working on, I need to update many QLabels very quickly. Each label needs to be updated at about 20 to 50 hertz and there can be over 50 labels at any given time. The problem I'm having is after running the program for about a minute, the labels freeze and the whole program crashes about 10 seconds later. If I comment out the setText() and setNum() calls and reroute the outputs to the console, it runs fine and never crashes. Why does calling SetText() and setNum() so quickly cause the program to crash and how can I prevent this?

View 5 Replies View Related







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