Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Game question

Name: Anonymous 2014-06-16 20:00

I am creating a game (engine) with SDL 2 using C and I am planing to have a scheme dialect to extend it in the future
here is my question, let's say I have N textures that I want to be rendered, should I have them in a list and render them every time something happens to the event loop? The other programmer I am working about is against the idea of having every texture in a list and believes that we should have them normaly in the code like variables, what to do?
another question is how to access other objects by some functions, for example I want every time someone presses the UP button to change the player position but in that case I should a: have the player variable as global or b: pass it in that function, should I have another list or something (like a db) for every object or something?
I have no idea on how to work with game stuff

Name: Anonymous 2014-06-16 21:07

>>5
I can't quite tell how those functions are meant to be used, but I'll elaborate:

if you have few enough or small enough assets that you can keep all of them loaded for a given level/area then it's easiest to load/unload them all for each level/area. you can put the whole level into an arena and deallocate the arena on unload. added bonus: reduced memory fragmentation.

if not, you probably want a master list of all assets in the area, with some function that will update the pointers on load, and some way of marking them as invalid on unload. you will also want a good way to determine in advance what needs to be loaded so it can be retrieved from disk by the time its needed. it's usually pretty easy in 2d scrollers, but less often necessary.

I think sdl2 probably has the same behaviour. it's not a drawback per se. they exploit it to optimize sdl. the good news is you don't have to worry about calculating what needs redraw, just draw every frame afresh. this keeps the drawing code regular, since every frame is drawn in the same way.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List