C++ :: Game Control - Organizational System Giving Errors

Jun 24, 2014

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?

View 1 Replies


ADVERTISEMENT

C++ :: Code Blocks No Longer Giving Any Useful Errors

Jun 8, 2013

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)

Which is not particularly useful for debugging.

View 11 Replies View Related

C++ :: Implementation File Versus Header File - Eclipse Giving Errors

Feb 10, 2013

I have written my program and it works when I keep everything in the header files, and then have my main. I am now splitting them up into implementation files, but Eclipse keeps giving me errors. It gives me error at every opening brace of the constructor and functions. It says on all of them "Redefinition of (name of constructor or method), Previously declared here." What am I doing wrong, because it works in the header file?

#include "KeyValuePair.h"
template<typename Key,typename Value>
KeyValuePair<Key,Value>::KeyValuePair()

[Code] .....

View 3 Replies View Related

C++ :: Why Is Basic Battle System Failing (no Compile Errors)

Aug 4, 2014

Here's the source code from "battle.h" (which should probably be renamed to "animal.h")

Do you think I made my errors here or in one of the many other headers or cpp?

#include "Identity.h"
#include "stdafx.h"
#ifndef battle_h
#define battle_h
int numbers1 = rand() % 5;
int numbers2 = rand() % 7;
int numbers3 = rand() % 9;
int numbers4 = rand() % 11;

[code].....

View 8 Replies View Related

C++ :: Program And Simulate 2 Floor Lift Control System?

Apr 28, 2014

I need to program and simulate a 2 floor lift control system. How to do that ? I need to design its program only.

View 1 Replies View Related

C++ :: Video Game - How To Set Up Save System

May 20, 2013

I would like to create a video game. It would be text based. How could I set up a save system? Also, how would I load it?

View 3 Replies View Related

C++ :: Writing Plugin Framework / System For Game

Mar 23, 2014

So I'm trying to accomplish something that right seems to hard for it to be worth it. I'm trying to write a plugin framework/system for my game. I have read about it and everything that pops up says it's OS-specific and you have to load the plugins from either a .so file on linux or from a .dll file on Windows. So here lie my questions:

-Is there any universal way of accomplishing this?

-Every way I've seen assumes i know the names of the functions I'm calling which doesn't hold true if the plugin are written by a 3rd party. How would i turn the table on this matter?

View 1 Replies View Related

C++ :: Game With Entity Component System - Generalizing Repeated Functions

Dec 20, 2014

I'm working on a game with an entity-component system. I have a Manager class that is handling all of the components by feeding them into vectors set up for each type of component. Right now I have a lot of repeated code for each kind of component.

void add_pos_comp(shared_ptr<Position> pos_comp);
shared_ptr<Position> get_pos_comp(int id);
const vector<shared_ptr<Position>>& get_pos_comps();

void add_vel_comp(shared_ptr<Velocity> vel_comp);
shared_ptr<Velocity> get_vel_comp(int id);
const vector<shared_ptr<Velocity>>& get_vel_comps();

I've tried generalizing this with templates, but I've been confused by how I should organize the collection of vectors for each component. I had it setup so that they were all in an unordered_map, but how to get the templated functions to find the right map slot to use based simply on the template's parameters.

The full project is here for reference: [URL] ....

View 2 Replies View Related

C++ :: Simple Game Menu - Program That Simulates Handheld Gaming System

Sep 26, 2013

I have to write a program that simulates a handheld gaming system. a system can have power toggled so its either on or off. when the system is on, its volume level can be raised or lowerd. a system has minimum volume level of zero and a maximum volume level of 10. a system stores games.

// simple game menu
//simulates a handheld gaming system
using namespace std;
class Game {
public:
Game(int GameNumber = 3, int volume = 10);

[Code] .....

View 1 Replies View Related

C# :: Change Form Control Properties From User Control

May 24, 2014

I have researched quite extensively, experimented, and still cannot seem to change the properties of a control on an active winform from a user control.

So I have a user control which populates each dynamically added tab page in a tab control.

I have a textbox in the user control which I would like to type in, capture the text_change event, and change the text of the label in the winform.

View 14 Replies View Related

C# :: Bind DatePicker Control To DataGrid Control (column)?

Apr 25, 2014

How do I bind a DATE column in a DataGridView Control to a DatePicker control (using C#)? I already have the DataGridView control bound to a database stored procedure which takes a DATE value as a parameter and selects joining table based on the results.

View 7 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

C++ :: Giving Audio Input To A Program

Sep 27, 2013

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.

View 3 Replies View Related

C++ :: Array / Pointer Giving Error?

Jul 20, 2013

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

View 2 Replies View Related

C++ :: Add And Minus From Text File Not Giving Right Value

Feb 5, 2014

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;

[Code] .....

View 1 Replies View Related

C# :: Random Numbers Giving Same Number

Jul 30, 2014

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();

[Code] .....

View 2 Replies View Related

Visual C++ :: Giving Values To All The Members?

Oct 15, 2013

Write a C++ program to implement the following description:

1. Define a global structure and name it GStruct with the following members:
a. X as integer
b. Y as integer.

2. Define a local structure inside the main and name it LStruct with the following members:
a. X as integer
b. Y[3] as GStruct

3. Inside the main declare two variables V1 and V2 of type LStruct.

4. Give values to all of their members by using input statement (cin).

5. If V1 equal V2 print "They are equal" else print "Not Equal".

#include <iostream>
using namespace std;
struct GStruct {
int x;
int y;
};
int main() {

[Code] .....

View 1 Replies View Related

C++ :: Dividing Two Floats Not Giving The Required Quotient

Jan 9, 2014

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.

View 10 Replies View Related

C++ :: Using Same Socket For Second Send / Receive Giving No Result?

Jul 28, 2013

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.

View 4 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 :: Retrieve Information From A Website - Libcurl Not Giving Output

Apr 2, 2014

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.

View 1 Replies View Related

C++ :: Sum Of Diagonals Of Matrix - Program Giving Segmentation Error?

Jan 7, 2015

After entering the values of the matrix, it is giving me segmentation error. also "if possible", correct it

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

[Code]......

View 2 Replies View Related

C++ :: Merge Sort Implementation Giving Incorrect Output

Oct 25, 2014

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;

[code].....

View 5 Replies View Related

C++ :: Program To Find Quarks And Their Charge And Mass - Giving Error

Mar 3, 2013

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]={};

[Code] .....

View 1 Replies View Related

C++ :: Giving One Line Command That Prints Lots Of Lines - Ostream?

Nov 9, 2012

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;

Will print

hello
mike
how
are
you

How can i do it?

View 5 Replies View Related







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