Archive for the 'Gamedev' CategoryPage 2 of 3

VM design, fundamental choices

While thinking and playing with a few ideas, I realised that my parameter stack isn’t going to be very big. Because I was only planning on having push and pops (no direct access) there isn’t a way to use much more than is required to complete an expression (eg a = a + b - c). So this means I will be using local variables a lot more. The parameters passed to a function were going to be popped off and put into local variables so they can be used.

All this got me thinking that I could use a register based machine instead. I’ve heard that they are faster, and possibly a bit easier to program in the compiler. Either a register based vm, or a stack based one that can address offsets from the stack - so I can use it for temp variables and leave the parameters on it.

Another question that popped up concerns the variable stack. I was planning to be able to increase and decrease the section of the variable stack that the current funciton is using. This is good because a function will only use up as much variable stack space as needed when it calls other functions.

My first impression is to have it stack based with the ability to access offsets, and keep the dynamic sized local variable stack.

Another thing to think about is that I want to implement static-closure code block things - the ability to come back to sections of code within a function from other funcitons higher up on the stack. These bits of code can access and modify the local variables that are in the original function as well as have their own variables. Nested static-closures as well. I was planning on having independant local variable stacks in each ‘frame’. The closure uses the parameter stack normally (it’s a function in it’s own right) but uses the original function’s variable stack for it’s variables.

Game Design blogs

A few game blogs that I read.

Tea Leaves
Only a Game
Curmudgeon Gamer
Grumpy Gamer

Ragdolls

W00t, got angle springs (=ragdolls) working… now I need one of the coders in the group to do the collisions, and the other guy to load and save to xml.

Many thanks goes out to Matteo for giving me some of his code to look at… it let me know I was on the right track.

Edit: now I just need to include damping - they ‘jiggle’ all over the place at the moment.

Mouse Click State Machine

Gah! I wish I could use my language to program this engine… I really need to get it finished. I could be using delegate states to do the state machine to handle mouse stuff… now I have to use a frig’n switch statement.

#’s are method calls to the game delegate… it gets to choose what to do

The state machine:

ready:

mouseDown -> clickDown
mouseUp -> ready

clickDown:

mouseDown -> clickDown
mouseUp -> doubleClickReady
movement -> dragMove # dragStart

doubleClickReady:

mouseDown -> doubleClickDown
mouseUp -> doubleClickReady
timeout -> ready # singleClick

doubleClickDown:

mouseDown -> doubleClick
mouseUp -> ready # doubleClick
movement -> doubleDragMove # doubleDragStart

dragMove:

# dragMove
mouseDown -> dragMove
mouseUp -> ready # dragUp

doubleDragMove:

# doubleDragMove
mouseDown -> doubleDragMove
mouseUp -> ready # doubleDragUp

Writing a Basic Game Engine

I’m currently programming an opengl and physics system to be used to program at least one game for the uni course I’m doing. I’m using glfw and my own physics engine.

I’ve got springs and line constraints working, I’m going to put in angular constraints and ‘capsule’ collision volumes and perhaps spheres as well.

The game is going to be simple - the course I’m doing it for alone has 3 other assignments. I’m thinking something like Ragdoll Masters or a ‘people aquarium’ with dirt, trees, houses that you can shake and do other stuff with. Lemmings also comes to mind. Something simple and cool. The people in my group seem to want to do a side-scroller…

Anyway, uni is in full swing… assignments out of my ears.