Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    7
  • comments
    13
  • views
    4560

Bah

Sign in to follow this  
zdlr

554 views

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]
Sign in to follow this  


3 Comments


Recommended Comments

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.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!