C/C++ :: Making A Timer Stay Accurate

May 9, 2014

So I've been trying to write a good update loop,

if (SDL_GetTicks() - startTime >= 1000) {
fps = loops;
startTime = SDL_GetTicks();
loops = 0;

[Code] ....

It's based off of deWitter's 4th game loop. [URL]....

However, there's one major flaw. If the update() function takes a long time to execute, the timer slows down, a "second" doesn't last 1000 milliseconds, and the fps counter spits out numbers like 100 and 120 when the limit should be 60. Is there a way to make a timer that always runs with constant speed no matter how long the update function takes?

View 2 Replies


ADVERTISEMENT

Visual C++ :: Number Of Players - Making Score Stay With Each Player

Oct 21, 2013

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

[Code] ....

View 3 Replies View Related

C++ :: Making A Countdown Timer?

May 17, 2013

I'm creating a game in which i.need player to.answer.my question within 10 seconds...

So I need a code for this timer... I don't want code to be paused by sleep or delay functions.. But I need that it waits.for 10 seconds.. and if user types answer in between.. it.reads it

And if player.doesn't answers it within 10 sec.. it displays a message

View 2 Replies View Related

C/C++ :: Shared Memory Project Not Getting Accurate Count For Processes

Jan 30, 2014

I'm working on a project that is supposed to create 3 processes. Process 1 should count from 1 to 100,000. Process 2 from 1 to 200,000. Process 3 from 1 to 300,000. I've written the basic code of it but my processes aren't printing out very accurate numbers.

Here's my code:

/*ass1*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdlib.h>
#include <unistd.h>
/* change the key number */
#define SHMKEY ((key_t) 8450)
typedef struct

[code]....

View 4 Replies View Related

C++ :: Program To Stay Open Until Press Enter Even After Whole Output

Oct 10, 2013

My program closes after the out even though i've used cin.get():

I want the program to stay open at least until you press enter, even after the whole output.

Code:
#include <iostream>#include <string>
int main()
{
std::cout << "Please enter your name";
std::string name;
std::cin>> name;
// build the message that we intend to write

[Code] .....

View 4 Replies View Related

C++ :: Rotates A Vector 90 Degrees - Values Won't Stay Negative

Jan 21, 2015

I have a function that rotates a vector 90 degrees. Only problem is, i never get negative values. For some strange reason, no matter what i do, the value of x is positive. And even if the x is negative. Once i put it into direction (struct with 2 values x and y) it turns again to positive. Im using VSC++2013 ultimate. At first direction was SDL_Point, so i thought it was SDL problem, but now it seems its something else.

if (c == '-') {
int x = direction.y;
x *= -1;
int y = direction.x;
direction = { x, y };
}

View 8 Replies View Related

C++ :: Program To Compute And Display Charges For Patient Hospital Stay

Dec 6, 2013

Write a program that computes and displays the charges for a patient's hospital stay. First, the program should ask if the patient was admitted as an in-patient or an out-patient. If the patient was an in-patient the following data should be entered:

-Number of Days spent in a Hospital
-The daily rate
-Charges for the hospital services(lab test, etc)
-Hospital medication charges

If the the patient was an out-patient the following data should be entered:

-Charges for Hospital services(lab test, etc)
-Hospital medication charges

The program should use two functions to calculate the total charges. One of the functions should accept arguments for the in patient data, while the other function accepts arguments for out-patient data. Both functions should return the total charges.

I dont know why but the result always gives me 0??? This is what I have.

#include<iostream>
using namespace std;
double in_patient(int Numdays, double dailyRate, double Charge_hospServices, double HospMed_Charge);
double out_patient(double Outcharge_Service, double OuthospMed_Charge);
int main() {

double dailyRate, Charge_hospServices,HospMed_Charge,Outcharge_Service,OuthospMed_Charge;

[Code] .....

View 4 Replies View Related

C++ :: How To Create A Timer

Jan 24, 2014

#include<iostream.h>
#include<time.h>
#include<conio.h>

[Code].....

View 3 Replies View Related

C/C++ :: How To Reset A Timer

Apr 12, 2012

Im trying to make a reaction game. I have a grafic that comes up, and the timer starts and when i hit the grafic the timer stops. But my problem is that the Timer doesn't reset.

View 2 Replies View Related

C :: Using Timer Module In PIC Microcontroller

Feb 28, 2013

how to produce a period signal that lasts 0.100 ms that is 35% red and 65% green using a bi-colour LED and the timer module?

while(ReadTimer0() < (unsigned int)165)

Its using this: OpenTimer0(TIMER_INT_OFF & T0_SOURCE_INT & T0_16BIT & T0_PS_1_32);

So does that mean that the period signal is 165 * 32 * 4/32 = 660 = 66%? I really just need to know how to calculate the period signal to produce 35% red and 65% green..

View 1 Replies View Related

C++ :: How To Set A Timer And Processing Continues

Apr 28, 2013

I need to set a timer but still have the program processing info. I have looked into using sleep but when using this all processing stops to my knowledge. I tried to use the settimer method but was having some issues since I am not using a dialog based interface.

View 1 Replies View Related

C# :: Timer Or Watcher For Variable?

Apr 4, 2015

I have some value in process memory (not my process). I have address of this value and want to execute function or smth else on changing this value. I think to use timers but I think they are too slow - low resolution(I read smth from 10 to 50 ms) and uses CPU too much. Can you offer me some other solution with not very much cpu usage but with checking variable value nearly 1 to 5 ms.

View 3 Replies View Related

C/C++ :: How To Create A Timer That Allows Input

May 14, 2013

I am trying to create a five second timer that allows a value to be entered in that span of time. However, if a value is not entered within the five seconds, the timer ends and a value will no longer be able to be entered. I am trying to create a math test that has a five second time limit for equations to be answered.

View 4 Replies View Related

C++ :: Timer With Non-return Calculations

Dec 25, 2013

My game runs in a while loop, as you can see in the code below. I need a timer, which won't stop this loop or freeze it, but it will wait, until timer is over and executes code without interfering with the while or for loop.

Code:

Code:
#include <iostream>
#include <iomanip>
#include <windows.h>
#include <ctime>
using namespace std;
char *map[25][25];

[Code] ....

View 1 Replies View Related

C :: How To Add Timer To Mini Quiz Game

Jun 1, 2014

I want to add a timer to my mini quiz game and show how much time it took for the user to finish it .I want to learn how to do that in C language

NOTE: My program only has a splash screen Allegro

The files are attached :

A bitmap [URL] .....

(I couldn't attach because of the size is above 200 kb. Please save as a BMP file )
A text file
A CPP file

View 9 Replies View Related

C :: Simple Alarm Timer Hat Went Off Every 12 Hours

Nov 2, 2013

In an assignment where they were asked to write a simple alarm that went off every 12 hours. This seemed mildly interesting so I gave it a go. The alarm actually goes off every minute (to have it go off every hour, or every 12, or some other interval more cogs, shafts and pinions would need to be added to the mechanism).

Code:
/* A simple "stopwatch" that prints an alarm message every minute.
*
* 2-Nov-2013
*
*/
#include <stdio.h>
#include <stdbool.h>
#include <time.h>

[Code] .....

View 8 Replies View Related

C :: Circuit Diagram - Programming A Timer

Jan 29, 2014

I have attached a circuit diagram below, which has been tested. Currently you have to manually push the switch to change the brightness of the bulbs. I want to program a chip to automate this.

Over 90 days the chip will output a high signal in replace of the switch every set period of time (say once every 1.5days). I can use any chip but the smaller the better!

View 1 Replies View Related

C :: Create A Hangman Game With Timer

Mar 21, 2013

I want to create a Hangman game with timer.. If the user cannot guess the word with in 1:30 min the game will stop and the word will be printed.

View 5 Replies View Related

C :: Adding Countdown Timer To Program

Dec 14, 2013

I want to add a countdown timer to my program so after specific time it go back to the main menu my program is something like vending machine....

View 1 Replies View Related

C++ :: Timer - Input While Continually Running

Feb 2, 2013

I am making a timer but I want to have an input while it is running. Here is my code.

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
using namespace std;

class timer {

[Code] .....

The bolded part is my attempt at trying to put in an input while the timer is running without having the other timer functions stop.

View 10 Replies View Related

C++ ::  How To Create Timer Effect In Turbo

Aug 31, 2014

I usually use codeblocks until my professor gave me a project in which it was mandatory to use turbo c++ so how can I create the timer effect in turbo???

E.g. if i want to print 1 2 3 4.... in a gap of 2 seconds how will I do it in turbo c++?

View 12 Replies View Related

C# :: How To Add A Timer Or Loop To Produce RSSI Value

Oct 24, 2014

I have a code which basically produces the RSSI value in a command prompt window once i run it but i want to add a function to it which would let the RSSI reproduce itself (once every 5 seconds or something) once its run without having to physically compile it every time.

using System;
using System.Collections.Generic;
using System.ComponentModel;

[Code].....

View 14 Replies View Related

C/C++ :: Timer Will Start From Its Previous Value Instead Of Its Initial Value?

May 8, 2014

I am making a product and in which i use a timer. I want when the product is being start the timer will run and when the product is off the timer will stop. If i again start the product the timer will start from its previous value.

I have problem that the timer start from its initial when i start my product.

View 7 Replies View Related

C/C++ :: Editing DLL File That Has Some Kind Of Timer

Oct 19, 2014

I have a .dll file that is used by some kind of launcher. Now the .dll file has some kind of timer on it and after that set of time it wont let me use it, how i can edit that out of a .dll?

View 4 Replies View Related

C++ :: How To Create Count Down Timer For 1 Hour 30 Minutes

Apr 7, 2014

I want to add a count down timer to my testing software 1hr and 30min

Its a 32bit console application, I want the countdown timer outputted above each question on the right side, timer only needs to output the time left at the top of each question so a live outputted timer is not important.

Questions are not random generated.

Also how to output "out of time" if the timer reaches 0 and for the test to end, I think branching is involved not too sure.

I already have, std::srand( std::time(0) ) ; at the start of the test to randomly generate the answer order.

View 10 Replies View Related

C# :: Using Timer To Refresh Interface - Keep Getting Error Message

Feb 3, 2015

I've been using a timer to refresh the listview on my application, but after half a second, I get the error message at first try/catch method in RefreshPlot() in PlotComponent.cs:

Quote An exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in Marketplace.exe but was not handled in user code

Additional information: There is already an open DataReader associated with this Connection which must be closed first.

View 4 Replies View Related







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