Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

cozzie

Member Since 13 Oct 2004
Offline Last Active Yesterday, 04:41 PM
-----

Topics I've Started

passing FMOD::sound by reference

Yesterday, 02:10 PM

Hi,

 

I've started to implement FMOD in my game (instead of directsound).

Now I'm struggling with passing a FMOD::Sound as a reference, to my loadsound function.

 

The problem is that the sound isn't loaded at all.

When I replace the pSound parameter 'sound' by a global FMOD::Sound (not passed as parameter), it works fine.

 

What am I overseeing?

 

bool Fmod_LoadSound(char *filename, FMOD::Sound *pSound)
{
	fmodResult = fmodSystem->createSound(filename, FMOD_DEFAULT, 0, &pSound);
	if(!Fmod_ErrorCheck(fmodResult)) return false;

	pSound->setMode(FMOD_LOOP_OFF);
	return true;
}

/**												**
 ** Play a sound through fmod ********************
 **												**/

void Fmod_PlaySound(FMOD::Sound *pSound)
{
	fmodSystem->playSound(FMOD_CHANNEL_FREE, pSound, false, &fmodChannel);
}

In the file where I declare and load the sound:

 

FMOD::Sound	*sound_shoot		= NULL;

	if(!Fmod_LoadSound("data/sound/_shoot.wav", sound_shoot)) return false; 

 

The only thing I found till now is that createSound needs a pointer to a pointer (**FMOD::Sound).

Any help is really appreciated.


How to 'ship' your game assets

12 May 2013 - 01:29 PM

Hi,
Like many of us I'm working on the next top gaming title. But before that, just doing some small games.
When I finished my first game I ran into something quite basic but never thought off.

My game folder concists of:
- an executable
- a data folder with sub folders for textures and sounds (bmp, png, tga, wav, mp3, ogg)
- some ascii files with highscores and own file format 3d scene information
- some X files (binary) with 3d meshes

What I want to prevent is to have all these assets and files 'open to public' within a grasp.
How would/ do you do this?

A few first thoughts:
- compress them all to a ZIP file, rename extension to i.e .abc
at runtime unpack the contents to a temporary folder (with some ZIP/ compression API).
Remove the files when application quits (how to handle non sunny quitting?)
- use some sort of DIY encryption and rename the file extensions
- ....

It's no problem if it's not waterproof though.
Really like to know your ideas and suggestions on this.

Framerate inconsistent..

11 May 2013 - 04:40 AM

Hi,

I'm currently programming a simple asteroids like game.

What I can't figure out is why I'm having fluctuations in the framerate/ motion of the game elements.

 

These are the symptons I have:

- something on the same PC I get different 'motion speeds'

- on several PC's the speed is way to high (release build), and when I set 'compatibility mode' of the executable to WinXP SP3 it's better

- my game AI/ game logics are all 'statíc' (not FPS related)

- I try to achieve FPS indedendent movement by doing the things below:

 

// at initial startup

	start = GetTickCount();

// in the game loop

		// keep the game running at a steady frame rate
		if(GetTickCount() - start >= 30)
		{
			start = GetTickCount();

			// do everything
		}



 

Any help is really appreciated.

(maybe I have to do something with the framerate in relation to moving game elements?)


random numbers in for loop (rand())

22 April 2013 - 03:12 PM

Hi all,

 

I'm struggling with generating a random number to an integer array, using a for loop.

In understand why the returned number is always the same because the loop is ready with all its iterations within a second.


How could I achieve random numbers within the for loop? (without using a sleep/ delay function)

 

Thanks in advance.

 

	for(int i=0;i<3;i++)
	{
		asteroids[i].x	= rand() % gamewidth + 1;
	}

 


sprite rotation around center?

06 April 2013 - 06:43 AM

Hi,

I'm working through the Game programming book of Jonathan S. Harbour. Currently getting into d3dx sprites.

 

My question is, how can I rotate and scale a sprite around it's own center?

Rotation works fine until I combine it with scaling.

 

Here's the (relevant) code I have, any help is appreciated.

 

void Sprite_Transform_Draw(LPDIRECT3DTEXTURE9 image,
						   int x,
						   int y,
						   int width,
						   int height,
						   int frame,
						   int columns,
						   float rotation,
						   float scaling,
						   D3DCOLOR color)
{

	// create a scale vector
	D3DXVECTOR2 scale(scaling, scaling);

	// create a translate vector
	D3DXVECTOR2 trans((float)x, (float)y);

	// set center by dividing scaled width and height by 2
	D3DXVECTOR2 spritecenter((float)(width * scaling)/2, (float)(height * scaling)/2);

	// create 2D transformation matrix
	D3DXMATRIX mat;
	D3DXMatrixTransformation2D(&mat, NULL, 0.0f, &scale, &spritecenter, rotation, &trans);

//	D3DXMatrixTransformation2D(&mat, &spritecenter, 0.0f, &scale, &spritecenter, rotation, &trans); TESTED, NOT OK

	// tell sprite object to use the transformation matrix
	spriteobj->SetTransform(&mat);

	// calculate frame location in source image
	int fx = (frame % columns) * width;
	int fy = (frame / columns) * height;
	RECT srcrect = { fx, fy, fx + width, fy + height };

	// draw the sprite image
	spriteobj->Draw(image, &srcrect, NULL, NULL, color);
}

The second parameter of 3dx transformation function is the sprite center for rotation, I tried both NULL as well as the scaling center of the sprite.


PARTNERS