Advice on general approaches or feasibility and discussions about game design
Post a reply

Re: [WIP] A generic platformer w/ object-oriented game engin

Sat Jan 10, 2015 11:49 pm

Myndale wrote:You actually have a number of options here. The best plan is probably to design your architecture so that you never have to do any per-frame allocations (e.g. by maintaining a bank of objects) but if that's not an option then one workaround is to declare your own form of the placement new operator like this:


I'll probably do a bank of objects. Different objects will have a different byte size in memory (because they might use different variables), so I'll either have to normalize the sizes, or maybe use unions or structs? For example, give the base enemy class an extra 32 byte struct, and have each inheriting class override that struct with any combination of variables they need that come in under 32 bytes. That way all enemies have the same size and I can allocate an array for a max number of them at compile time.

(...you can cast/override unions or structs like that, right?)

EDIT: There seem to be a few solutions here that will help me out.

Re: [WIP] A generic platformer w/ object-oriented game engin

Sun Jan 11, 2015 1:11 pm

Great job Jamish!

Considering that in almost every game made so far, the vast vast vast majority of bitmaps are 8px/1 byte wide, maybe there should be a more optimized drawBitmap function that draws only 8px wide bitmaps, with maybe HFLIP and VFLIP, but without rotation. That would remove a few operations used to find the size of the bitmap and shift through it and a few branches in the logic to change the direction/rotation of drawing. As usual I have no idea how much faster that could be on Arduino, but I'm throwing the idea out there for you more experienced guys to comment on it.

Re: [WIP] A generic platformer w/ object-oriented game engin

Sun Jan 11, 2015 6:50 pm

I created a new topic in Software Development dedicated to graphical functions optimization, because we are getting pretty out of topic here :P
Post a reply