Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


ViperG

Member Since 07 Nov 2004
Offline Last Active Jan 15 2012 07:26 PM

Topics I've Started

Holding the mouse down

28 August 2011 - 07:25 PM

So I was curious what other people do about this.

I currently have my game loop fixed at 50 cycles a second, and fps runs at max.

The problem I just ran into is when I am detecting mouse1 and mouse2 to detect a mouse click vs being held down is that if the game logic runs 2x before it hits my menu code (part of the draw code)

It detects that im holding the mouse down, and once it gets to the game menus I doesn;t recieve the click even because it's considered a mouse holding event instead.

This only happens when my FPS drops below 50, then the game logic can possibly run 2x times before it renders/menu draw code.

I use a state machine to determine what menus are visable and what not, and the menus handle their own close buttons. But I can't click on the button because it thinks im already clicked it since it thinks im holding the mouse down. (game logic ran 2x, detects im holding the mouse still on 2nd loop = mouse is held down).

hope that make sense. I have a few ways to fix the problem but was just curious on what other designs/input/menu methods people have used.

saving and loading a structure - serialization

19 January 2011 - 04:31 PM

So my game has lots of structures, all of which i will need to save at one point for save games and user created content with the in game ship builder. After doing some thinking on how to do this in the easiest possible way with the least amount of maintenance and code, i came up with this method, please give me your opinions, this is a prototype wip and it's rather simple and currently isn't finished but i wanted feedback on it.


template<typename t3>
void ioprocess(t3& data, string iotext)
{
	if (method==SAVE)
	{
		if (iotext.size() > 0)
			FOI << iotext << data << endl;
		else
			FOI << data << endl;
	}
	else
		{
			string itext="";
			FIO >> itext;
			if (itext==iotext)
				FIO >> data;
			else ; //throw a error message...
		}
}


and a sample game struct:


struct shipdata
{
	bool bumpmap;
	string descrip;
	int tid, schid, lid, shid, mass, armor, hull, vents, ventcolor, dtid, dsmall, dbig, bumptid, collision, explosion, ai, price;
	float xsize, ysize, armortype, thrust, shscale, shieldangle, trscale, txsize, tysize, scale;
	string owner, sclass, sid, name;
	vector<datacomp> Components;
    
	void shipdata::processio()
	{
		ioprocess(sid, "$sid= ");
		ioprocess(name, "name= ");
		ioprocess(descrip, "description= ")
		...
		...
		...
	}
}


Right now FIO and FOI are going to be global input/output ifstream/ofstream. or i can pass it as a referenced parameter but in this situation 2 globals are easier.

so for example if I have 100 instances of ship data, i can just call shipdata.processio(); for each instance, and it will save the entire structure into whatever file I have specified, and the same command can be used to read just by toggling which method i want to use, save or load.

and if I add members or remove members of the struct, I simply add a ioprocess call for that variable and saving and loading are done for me.
and this method can be put on all my structures or classes if I want to save any of their members or load them.


so my question is this a good way to serialize a structure? good? bad?

Please Critique my first I/O simple serialization attempt

18 January 2011 - 10:37 PM

So my game has lots of structures, all of which i will need to save at one point for save games and user created content with the in game ship builder. After doing some thinking on how to do this in the easiest possible way with the least amount of maintenance and code, i came up with this method, please give me your opinions, this is a prototype wip and it's rather simple and currently isn't finished but i wanted feedback on it.


template<typename t3>
void ioprocess(t3& data, string iotext)
{
	if (method==SAVE)
	{
		if (iotext.size() > 0)
			FOI << iotext << data << endl;
		else
			FOI << data << endl;
	}
	else
		{
			string itext="";
			FIO >> itext;
			if (itext==iotext)
				FIO >> data;
			else ; //throw a error message...
		}
}


and a sample game struct:


struct shipdata
{
	bool bumpmap;
	string descrip;
	int tid, schid, lid, shid, mass, armor, hull, vents, ventcolor, dtid, dsmall, dbig, bumptid, collision, explosion, ai, price;
	float xsize, ysize, armortype, thrust, shscale, shieldangle, trscale, txsize, tysize, scale;
	string owner, sclass, sid, name;
	vector<datacomp> Components;
	
	void shipdata::processio()
	{
		ioprocess(sid, "$sid= ");
		ioprocess(name, "name= ");
		ioprocess(descrip, "description= ")
		...
		...
		...
	}
}


Right now FIO and FOI are going to be global input/output ifstream/ofstream. or i can pass it as a referenced parameter but in this situation 2 globals are easier.

so for example if I have 100 instances of ship data, i can just call shipdata.processio(); for each instance, and it will save the entire structure into whatever file I have specified, and the same command can be used to read just by toggling which method i want to use, save or load.

and if I add members or remove members of the struct, I simply add a ioprocess call for that variable and saving and loading are done for me.
and this method can be put on all my structures or classes if I want to save any of their members or load them.

Intel 945G and Texture_Rectangles

21 September 2010 - 06:16 PM

So it looks like any of the Intel 945 chipsets (945G/945GM/... maybe 955 also) do not support NPOT textures and don't support ext_texture_rectangle.

My game can definitely run on this chipset and even get 60+ fps but I have to run my game in POT textures to make it fast. I want to be able to support NPOT to make it easier for the modding community to be able to mod my game. I could just make it a rule where they have to use POT textures.

Or I can do a texture atlas.

So my question is should i switch to texture atlas or switch to ext_text_rect or just keep to power of 2 textures.

And on these chipsets 2048x2048 is max texture size, so I would probably have to make 5-10 atlases...? possibly more.

Saving Classes/Structs/Objects C/C++

13 September 2010 - 01:28 PM

Well I am getting to the part where I need File I/O.. Almost everything is structured as a struct or a class, and I need to save this data to files and read in later etc.

The two methods that only exist seem to be:

1) Serialization
2) Save each member one at a time.

Option 1 seems to be the most popular for example Boost::serialization, however i'm having linking problems trying to get the .lib file for serialization to work.

2) save each member in a text format, or possibly binary.

I was curious on what other people do and if there are any tricks or advanced topics to make this easier. I probably have about 10-20 objects I need to save to different files, and it looks like I am going to have to type alot of tedious code to be able to save my data as a text file.

PARTNERS