Bah

Published October 02, 2004
Advertisement
Work has eaten my time this past week. I found some old code from a past (failed, shock horror) game project. It was in C and I thought I could thieve/reuse most of it as a base for Space Invaders (after porting it to C# of course [smile]).

I had a look through and I remembered doing something pretty interesting that helped me with a problem that I don't think is mentioned much: Switching what is rendered and what inputs are taken in a game. For example: your main game menu looks entirely different to the 'main' part of your game and it takes different inputs. How do you manage these different situations?

What I had done is implement a RenderMode table which linked a number of callbacks to the bits in an __int64. This allowed me to toggle drawing things to the screen by simply bitwise XOR-ing the relevant bit in the current RenderMode. I could then bitwise AND each RenderMode in the lookup table with the current RenderMode and if it came out true I would call the relevant callback which would draw something to the screen.

This then extended to my input functions where I would associate each key (mouse or keyboard) with a callback and a RenderMode- ensuring that some keys could be painlessly reused for a menu or in the game proper.

I'm currently porting this code over to C# (using ulong so I get the possibility of 128 unique RenderModes) hopefully it will be as much of a success as it was in C.

I'll post the C code if anyone wants, I can't be bothered to upload it if it ain't gonna be used [grin]
Previous Entry Plans...
Next Entry My first entry
0 likes 3 comments

Comments

zdlr
Hmm, I seem to have imagined that ulong is 128 bit in C#.

I'm sure I was looking at something on MSDN that's 128 bit in C#.

Anyway, I only used 8 bit places before and that's because I was using a rendermode for everything I was drawing, to test it out. In reality, I think 64 might be enough for most games.

---

It was the decimal value type. That's 128 bit. Knew I'd seen it somewhere.
October 02, 2004 10:47 AM
TANSTAAFL
They call that a "State Machine"
October 04, 2004 09:01 AM
zdlr
Shows how good my uni course is then, huh.
October 05, 2004 05:05 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Finally made it!

900 views

BSP Rendering!

1113 views

My first entry

982 views

Bah

1356 views

Plans...

1050 views
Advertisement