Jump to content

  • Log In with Google      Sign In   
  • Create Account

NotYourAverageUser

Member Since 08 Dec 2006
Offline Last Active Oct 06 2014 12:00 PM

Topics I've Started

First Android Game

11 April 2014 - 07:24 AM

Hey all,

 

I have released my first android app.  It is a unity project (also my first).   The main goal of this project was to just get some working knowledge of unity and the whole android publishing process.

 

And, well, I did it.  I have been toying with game programming for quite some time now.  I have built my own engine started a bunch of small projects but never took anything to completion.

 

With the help of Unity, I finally did. I learned a lot.  I plan to continue and make more games now that I have a framework of understanding.

 

It is called Peg Popper 3d.  It is that peg solitaire board game you've maybe seen at Cracker Barrel or similar.  The link is here.

https://play.google.com/store/apps/details?id=com.forwardthinking.peg

 

It isn't the best, but it works, it is fun and I made it.  I did the modeling and artwork for it as well, so don't hit me up too hard on that (too cheap to afford an artist).

 

Well that is all!!!

 

Thanks for listening and being there, you awesome community.


Event Handlers In C

07 August 2013 - 02:09 PM

I must admit that C is not my most fluent programming language.  I am trying to develop an event handling construct and just wanted to see if I was going down the proper path or if there are other more succinct options out there already.

 

Currently, I don't do anything special just print out a string when the event is raised.  It all seems to be working just fine; but again, I am not too comfortable with C so I'd like to know if there are things I am not doing the way I should be in C.

 

Please do point out any coding no-nos and the like as this is more an exercize to better my C skills.  It is not complete... for instance I still need to implement a remove handler function...just didn't want to put too much effort down this path if there are better ways to handle such.

#include <stdio.h>

#define MAX_NAME_LENGTH 10

/********************************************************************
	STRUCTURES AND ENUMS FOR
	EVENT HANDLING FUNCTIONS
********************************************************************/
typedef enum Events{
	TEST1,
	TEST2,
	TEST3,
	MAX_EVENTS
}e_Events;

typedef void (*callback) (void *);

typedef struct EventHandlers{
	callback cb;
	struct EventHandlers *next;
	char name[MAX_NAME_LENGTH];
} s_EventHandlers;

s_EventHandlers *listeners[MAX_EVENTS];

/********************************************************************
	FORWARD DECLARES FOR
	EVENT HANDLING FUNCTIONS
********************************************************************/
void InitListeners(s_EventHandlers *handlers[], int size);
void DestroyListeners(s_EventHandlers *handlers[], int size);
void RegisterEvent(e_Events event, callback cb, char *name);

/********************************************************************
	TEST EVENT HANDLERS FUNCTIONS
********************************************************************/
void Test1Handler1(void *data){
	printf("In Test1 Handler 1 %s\n", data);
}
void Test1Handler2(void *data){
	printf("In Test1 Handler 2 %s\n", data);
}
void Test2Handler1(void *data){
	printf("In Test2 Handler 1 %s\n", data);
}
void Test3Handler1(void *data){
	printf("In Test3 Handler 1 %s\n", data);
}
void Test3Handler2(void *data){
	printf("In Test3 Handler 2 %s\n", data);
}

int main(int argc, char **argv) 
{
	s_EventHandlers *handlers = NULL;
	char data[] = "this is the data";
	
	InitListeners(listeners,MAX_EVENTS);
	
	RegisterEvent(TEST1, Test1Handler1, "T1H1");
	RegisterEvent(TEST1, Test1Handler2, "T1H2");
	RegisterEvent(TEST2, Test2Handler1, "T2H1");
	RegisterEvent(TEST3, Test3Handler1, "T3H1");
	RegisterEvent(TEST3, Test3Handler2, "T3H2");
	
	handlers = listeners[TEST1];
	for(; handlers != NULL; handlers = handlers->next){
		handlers->cb(data);
	}
	
	handlers = listeners[TEST2];
	for(; handlers != NULL; handlers = handlers->next){
		handlers->cb(data);
	}
	
	handlers = listeners[TEST3];
	for(; handlers != NULL; handlers = handlers->next){
		handlers->cb(data);
	}
	
	DestroyListeners(listeners,MAX_EVENTS);
	
	return 0;
}

void RegisterEvent(e_Events event, callback cb, char *name){
	s_EventHandlers **handlers = &listeners[event];
	
	if (*handlers == NULL){
		*handlers = (s_EventHandlers*) malloc(sizeof s_EventHandlers);
		(*handlers)->cb = cb;
		
		strncpy((*handlers)->name,name,MAX_NAME_LENGTH);
		(*handlers)->name[MAX_NAME_LENGTH-1] = '\0';
		
		(*handlers)->next = NULL;
	} else { 
		while ((*handlers)->next != NULL){
			(*handlers)++;
		}
		(*handlers)->next = (s_EventHandlers*) malloc(sizeof s_EventHandlers);
		(*handlers)->next->cb = cb;
		
		strncpy((*handlers)->next->name,name,MAX_NAME_LENGTH);
		(*handlers)->next->name[MAX_NAME_LENGTH-1] = '\0';
		
		(*handlers)->next->next = NULL;
	}	
}

void InitListeners(s_EventHandlers *handlers[], int size){
	int i;
	for (i = 0; i < MAX_EVENTS; i++){
		handlers[i] = NULL;
	}
}

void DestroyListeners(s_EventHandlers *handlers[], int size){
	int i;
	s_EventHandlers *deleteMe, *next;
	for (i = 0; i < MAX_EVENTS; i++){
		deleteMe = handlers[i];
		
		while (deleteMe){
			next = deleteMe->next;
			free(deleteMe);
			deleteMe = next;
		}
	}
}

COM Smart Pointers

13 August 2007 - 03:04 PM

Are there any good COM smart pointer implementations. I am using C++, and VS8 Express. I am trying to use CComPtr in <Atlbase.h> to no avail. These are the compiler errors.
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcomcli.h(300) : error C2299: 'ATL::CComPtr<T>::operator =' : behavior change: an explicit specialization cannot be a copy constructor or copy assignment operator
        C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcomcli.h(304) : see reference to class template instantiation 'ATL::CComPtr<T>' being compiled
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcomcli.h(300) : error C2299: 'ATL::CComPtr<T>::operator =' : behavior change: an explicit specialization cannot be a copy constructor or copy assignment operator
        with
        [
            T=IUnknown
        ]
        C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcomcli.h(508) : see reference to class template instantiation 'ATL::CComPtr<T>' being compiled
        with
        [
            T=IUnknown
        ]
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcomcli.h(300) : error C2299: 'ATL::CComPtr<T>::operator =' : behavior change: an explicit specialization cannot be a copy constructor or copy assignment operator
        with
        [
            T=IPersistStream
        ]
        C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcomcli.h(2215) : see reference to class template instantiation 'ATL::CComPtr<T>' being compiled
        with
        [
            T=IPersistStream
        ]
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlbase.h(861) : error C2299: 'ATL::CAutoPtr<T>::CAutoPtr' : behavior change: an explicit specialization cannot be a copy constructor or copy assignment operator
        C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlbase.h(927) : see reference to class template instantiation 'ATL::CAutoPtr<T>' being compiled
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlbase.h(884) : error C2299: 'ATL::CAutoPtr<T>::operator =' : behavior change: an explicit specialization cannot be a copy constructor or copy assignment operator
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlbase.h(4522) : error C3203: 'CComAutoThreadModule' : unspecialized class template can't be used as a template argument for template parameter 'T', expected a real type
        C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlbase.h(4534) : see reference to class template instantiation 'ATL::CComAutoThreadModule<ThreadAllocator,dwWait>' being compiled
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcomcli.h(300) : error C2299: 'ATL::CComPtr<T>::operator =' : behavior change: an explicit specialization cannot be a copy constructor or copy assignment operator
        with
        [
            T=ITypeLib
        ]
        C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlbase.h(5982) : see reference to class template instantiation 'ATL::CComPtr<T>' being compiled
        with
        [
            T=ITypeLib
        ]
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcomcli.h(300) : error C2299: 'ATL::CComPtr<T>::operator =' : behavior change: an explicit specialization cannot be a copy constructor or copy assignment operator
        with
        [
            T=ICatRegister
        ]
        C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlbase.h(6100) : see reference to class template instantiation 'ATL::CComPtr<T>' being compiled
        with
        [
            T=ICatRegister
        ]
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcomcli.h(300) : error C2299: 'ATL::CComPtr<T>::operator =' : behavior change: an explicit specialization cannot be a copy constructor or copy assignment operator
        with
        [
            T=LPD3DXMESH
        ]
        c:\documents and settings\running\my documents\visual studio projects\yardville\source\../include/Renderdata.h(17) : see reference to class template instantiation 'ATL::CComPtr<T>' being compiled
        with
        [
            T=LPD3DXMESH
        ]



any ideas??!?? Not me... ------------------------------------------------------ So I started working on my own, but I would rather work with something more tested. Also, I am running into issues with the implementation; I cannot AddRef () to a COM object that I haven't yet acquired. So do I add an Acquire() method that will set a flag, such that while this flag is set, I need to call AddRef() next time I access the COM object before I reset the flag, however if the Com_ptr is destroyed before the item is released I will not call Release()?
template<class T>
class com_ptr
{
public:
	com_ptr(T* raw):ptr(raw),bRefNeeded(false)
	{
		if (ptr)
			ptr->AddRef();
	}

	com_ptr(const com_ptr<T> &rhs):ptr(rhs.ptr)
	{
		if (ptr)
			ptr->AddRef;
	}

	com_ptr& operator=(const com_ptr& rhs)
	{
		if ( this->ptr == rhs.ptr)
			return *this;

		if (ptr)
			ptr->Release();

		ptr = rhs.ptr; 
                if (ptr)
                        ptr->AddRef();
	}

   ~com_ptr()
   {
	   if (ptr && !bRefNeeded)
		   ptr->Release();
   }

   T* Acquire()
   {
           bRefNeeded = true; // or something of the sort !!!!!
	   return ptr;
   }

   T* Get()
   {
           if (ptr && bRefNeeded)
           {
                 ptr->AddRef();
                 bRefNeeded = false;
           } 

	   return ptr;
   }

   T& operator*() const
   {
      if (ptr && bRefNeeded)
           {
                 ptr->AddRef();
                 bRefNeeded = false;
           } 

      return *ptr;
   }

   T* operator->() const
   {
      if (ptr && bRefNeeded)
           {
                 ptr->AddRef();
                 bRefNeeded = false;
           } 
      return ptr;
   }
private:
   T* ptr;
   bool bRefNeeded;
};



[Edited by - DeafManNoEars on August 13, 2007 9:24:13 PM]

Looking for Advice On Design

13 August 2007 - 09:09 AM

Looking for Opinions and how you handle such stuff in your own applications. 1) Do you prefer to have objects taking care of themselves...(i.e. a RenderableObject that will hold a pointer to the render device and draw itself)? 2) Or would you prefer registering a RenderableObject with the render device and have the device take care of the rendering? This is what I was thinking, please tell me how much this sucks, as I have no formal training and limited experience. Actually I have a lot of expereince but have never really exposed my source code or designs to people for critiquing. I want to have a GameObject that owns a pointer to a RenderableObject and a PhysicsObject. RenderableObject and PhysicsObject are abstract classes with one or two functions (Render( float fET, DWORD data ) for the former and Update(float fET) for the latter). I was going to derive, say, a MeshObject from RenderAbleObject. So I derive a Player from GameObject. I instantiate this Player and register it with the RenderDevice and the PhysicsDevice. The render device will keep a list of all materials and textures used as well as what items are currently in view and call GameObject->IRenderableObject->Render(...) on the appropriate objects while the PhysicsDevice calls GameObject->IPhysicsObject->Update(...). My concerns with this, is that I don't think I really like casting the RenderableObject pointer in the GameObject/Player into a mesh for the player and then back to a RenderableObject for the renderdevice. I also don't know if I should just pass a temporary pointer to the RenderDevice to the RenderableObject to aid in the rendering and loading functions, or if the Renderable object should just own a pointer to the device. The RenderDevice and PhysicsDevice take care of all memory management on all registered components. It is the GameObjects duty to release all none physics and rendering related data. My GameObject maintains a flag indicating whether it has been registered or not and can clean up on it's own if it hadn't been registered. 3) Is there a way I can force an object to be registered? (Should I have a factory function in my RenderDevice that will create the appropriate object, and pass back a pointer to an IRenderAbleObject); 4) Is it OK that I don't force registration and just keep track of whether an object has been registered or not? -Seems improper to me. 5)Can somebody point me to some documentation that can describe the pattern I am looking for, tell me a better idea, or explain what is flawed in my design? 6)How can I make GameObject a cleaner composition of derived RenderableObjects and PhysicsObjects. I guess I am really just looking to hear how others take care of these things. I can always think of many different design solutions that work but I don't have any good form of Metrics to weed out the poor, breakable designs and select the more appropriate ones. Thank you for your time. Seth edit: Gave 3) its own paragraph :) [Edited by - DeafManNoEars on August 13, 2007 3:51:44 PM]

CARDSOFT on USB

20 March 2007 - 05:40 AM

There are miriads of intelligent people on this site, that is why I am choosing to ask this here. I will begin by describing what I want to do and then what I have already tried and how poorly they have failed. I am attempting to get access to a PCMCIA card that I have in my laptop via DOS. I have no floppy drive. I have a USB key. I have made my USB key bootable to the dos environment with a win98 bootdisk image. I have even gotten the cardsoft card and socket services to install on the key through the dos shell. Problem is... after I install it and reboot, the computer never loads past the win98 splash screen. So then I tried to make my usb bootable via a dos6.22 bootdisk image using the HP USB format utility, however, this is not working as expected. It will format the drive but then not copy over the files from the virtaul floppy drive that I have the image mounted to. Even if I manually copy the files over after the US Bdisk is formatted I am left with a non-bootable disk. Yes my BIOS supports booting from USB, I have been able to boot from the USB disk, and I have been able to load the cardsoft utilities onto the disk... Has anybody acomplished what I am trying to do, and if yes can you offer a helping hand. Please. If anymore information is required just ask. I have a Dell Inspiron 6000.

PARTNERS