Click here to Skip to main content
15,892,005 members
Articles / Mobile Apps

Bunnyaruga: GAPI, Hekkus, Basics of Deployment

Rate me:
Please Sign up or sign in to vote.
3.63/5 (15 votes)
25 Apr 2004CPOL14 min read 54.1K   247   20  
This article shows an example of a game that uses the GAPI and Hekkus libraries. It also shows a nice and free way of deploying your games/applications without requiring the .NET Framework installed on the end user machines.
using System;
using System.Runtime.InteropServices;

namespace HekkusNet
{
	/// <summary>
	/// Summary description for HekkusSound.
	/// </summary>
	public class HekkusSound : IDisposable
	{
		private IntPtr unmanagedObject;
		public IntPtr HekkusObject
		{
			get { return unmanagedObject; }
		}

		public HekkusSound()
		{
			IntPtr hInst = Hekkus.GetHInstance();
//		public static extern IntPtr Sound_Create (IntPtr hInst);
			unmanagedObject = Hekkus.Sound_Create(hInst);
		}

		public void Dispose()
		{
//		public static extern UInt32 Hekkus.Sound_Destroy (IntPtr pSound);
			Hekkus.Sound_Destroy(unmanagedObject);
		}

		public bool Open(int freqmix, bool stereo)
		{
//		public static extern bool Hekkus.Sound_open (IntPtr pSound, UInt32 freqmix, bool stereo);	
			return Hekkus.Sound_open (unmanagedObject, (UInt32)freqmix, stereo);
		}

		public bool Open(int freqmix, int maxmodchannels, int maxsfxchannels, bool stereo)
		{
			//		public static extern bool Hekkus.Sound_open (IntPtr pSound, UInt32 freqmix, bool stereo);	
			return Hekkus.Sound_openEx (unmanagedObject, (UInt32)freqmix, (UInt32)maxmodchannels, (UInt32)maxsfxchannels, stereo);
		}

		public void Close()
		{
//		public static extern bool Hekkus.Sound_close (IntPtr pSound);
			Hekkus.Sound_close (unmanagedObject);
		}

		public void Suspend()
		{
			//		public static extern bool Hekkus.Sound_suspend (IntPtr pSound);
			Hekkus.Sound_suspend(unmanagedObject);
		}

		public void Resume()
		{
			//		public static extern bool Hekkus.Sound_resume (IntPtr pSound);
			Hekkus.Sound_resume(unmanagedObject);
		}

		public int GetMaxChannelMod()
		{
//		public static extern UInt32 Hekkus.Sound_maxChannelMod (IntPtr pSound);
			return (int)Hekkus.Sound_maxChannelMod (unmanagedObject);
		}

		public int GetMaxChannelSfx()
		{
			//		public static extern UInt32 Hekkus.Sound_maxChannelSFX(IntPtr pSound);
			return (int)Hekkus.Sound_maxChannelSFX(unmanagedObject);
		}

		public int GetPlayingChannelMod()
		{
			//		public static extern UInt32 Hekkus.Sound_playingChannelMod (IntPtr pSound);
			return (int)Hekkus.Sound_playingChannelMod (unmanagedObject);
		}

		public int GetPlayingChannelSfx()
		{
			//		public static extern UInt32 Hekkus.Sound_playingChannelSFX(IntPtr pSound);
			return (int)Hekkus.Sound_playingChannelSFX(unmanagedObject);
		}

		public int PlaySfx(HekkusSoundFX sound)
		{
//		public static extern UInt32 Hekkus.Sound_playSFX (IntPtr pSound, IntPtr sndfx);
			return (int)Hekkus.Sound_playSFX(unmanagedObject, sound.HekkusObject);
		}

		public void StopSFX(int chl)
		{
			//		public static extern void Hekkus.Sound_stopSFX (IntPtr pSound, UInt32 chl);
			Hekkus.Sound_stopSFX (unmanagedObject, (UInt32)chl);
		}

		public void PauseSFX()
		{
			//		public static extern bool Hekkus.Sound_pauseSFX (IntPtr pSound);
			Hekkus.Sound_pauseSFX(unmanagedObject);
		}

		public void ResumeSFX()
		{
			//		public static extern bool Hekkus.Sound_resumeSFX (IntPtr pSound);
			Hekkus.Sound_resumeSFX(unmanagedObject);
		}
	
		public int PlayMod(HekkusModule module)
		{
			//		public static extern UInt32 Hekkus.Sound_playMod (IntPtr pSound, IntPtr sndfx);
			return (int)Hekkus.Sound_playMod(unmanagedObject, module.HekkusObject);
		}

		public void StopMod()
		{
			//		public static extern void Hekkus.Sound_stopMod (IntPtr pSound, UInt32 chl);
			Hekkus.Sound_stopMod (unmanagedObject);
		}

		public void PauseMod()
		{
			//		public static extern bool Hekkus.Sound_pauseMod (IntPtr pSound);
			Hekkus.Sound_pauseMod(unmanagedObject);
		}

		public void ResumeMod()
		{
			//		public static extern bool Hekkus.Sound_resumeMod (IntPtr pSound);
			Hekkus.Sound_resumeMod(unmanagedObject);
		}

		public int VolumeSFX
		{
			get { return GetVolumeSFX(); }
			set{ SetVolumeSFX(value); }
		}

		public void SetVolumeSFX(int volume)
		{
//		public static extern void Hekkus.Sound_SetVolumeSFX (IntPtr pSound, UInt32 v);
			Hekkus.Sound_SetVolumeSFX(unmanagedObject, (UInt32)volume);
		}

		public int GetVolumeSFX()
		{
//		public static extern UInt32 Hekkus.Sound_GetVolumeSFX (IntPtr pSound);
			return (int)Hekkus.Sound_GetVolumeSFX (unmanagedObject);
		}

		public int VolumeMod
		{
			get { return GetVolumeMod(); }
			set{ SetVolumeMod(value); }
		}
		public void SetVolumeMod(int volume)
		{
			//		public static extern void Hekkus.Sound_SetVolumeMod (IntPtr pSound, UInt32 v);
			Hekkus.Sound_SetVolumeMod(unmanagedObject, (UInt32)volume);
		}

		public int GetVolumeMod()
		{
			//		public static extern UInt32 Hekkus.Sound_GetVolumeMod (IntPtr pSound);
			return (int)Hekkus.Sound_GetVolumeMod (unmanagedObject);
		}

	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions