Name: anon4help !!SMc+oRp3hlfrttZ 2011-02-27 3:36
Hey /prog/. I'm making a game engine.
I'm using C++ as my main language, maybe with a bit of LUA.
My goal is to make a simple verticle shooter, but with complex bullet patterns and smart enemies as entities.
If any of you played Touhou, you've got a pretty good idea.
I'm using DirectX as my main graphics and sound implementation, and everything was pretty easy so far.
But the problem lies with the actual management of making the game itself. I have two problems.
The first is, implementing yielding. I tried a Shmup maker with C-like syntax called 'Danmakufu', and it had some pretty clever design, but not enough power. Anyway, it had a cool little feature called "yield", in which it suspends a 'task' created by you, the scripter. See, the objects are already pre-made withing structs, and all I had to do was simply define how they behaved in a structure. A mainLoop for each object is run every frame, and a seperate thread called "Initialize" is run once throughout the per lifetime of the object(s). Most of the time, I'd put tasks up in Initialize, and put in yields to synchronize things like motions and bullet fire the entire script. What yield does, is delay everything within that thread, below that yield, for one frame. It looks like it works by giving up the thread's timeslice for the rest of that frame, and exists the thread. Now, using a return function in windows essentially does the same thing, except when you use the return function, the thread's scope is destroyed and we cannot re-enter it from where we left off like yield does in Danmakufu.
And that's where I have my problem.
My second problem, is how would I go about properly giving objects a behavior, an artificial inteligence? Since my entities are objects, they inherit things like XY coordinates on the screen, textures, vertices, direction, all that stuff. But setting all of those is as easy as passing a few arguments in parameters. EntityObject[indexnum].xpos=40 would easily set the X value to 40 for the object with the vale of indexnum. Passing behaviors isn't as easy, because I'd want to pass multiple functions to it. The most efficient way I can think of solving it is by passing a pointer to a text document in which has all the functions written out already. EntityObject.pointertoTextforBehav="behavior.txt", in which behavior.txt would have things written in it like {EntitySetX(50); yield(50);-wait 50 frames ShootCurtainFire();-done after the waiting
so what would be the best way about solving this sort of thing?
I'm using C++ as my main language, maybe with a bit of LUA.
My goal is to make a simple verticle shooter, but with complex bullet patterns and smart enemies as entities.
If any of you played Touhou, you've got a pretty good idea.
I'm using DirectX as my main graphics and sound implementation, and everything was pretty easy so far.
But the problem lies with the actual management of making the game itself. I have two problems.
The first is, implementing yielding. I tried a Shmup maker with C-like syntax called 'Danmakufu', and it had some pretty clever design, but not enough power. Anyway, it had a cool little feature called "yield", in which it suspends a 'task' created by you, the scripter. See, the objects are already pre-made withing structs, and all I had to do was simply define how they behaved in a structure. A mainLoop for each object is run every frame, and a seperate thread called "Initialize" is run once throughout the per lifetime of the object(s). Most of the time, I'd put tasks up in Initialize, and put in yields to synchronize things like motions and bullet fire the entire script. What yield does, is delay everything within that thread, below that yield, for one frame. It looks like it works by giving up the thread's timeslice for the rest of that frame, and exists the thread. Now, using a return function in windows essentially does the same thing, except when you use the return function, the thread's scope is destroyed and we cannot re-enter it from where we left off like yield does in Danmakufu.
And that's where I have my problem.
My second problem, is how would I go about properly giving objects a behavior, an artificial inteligence? Since my entities are objects, they inherit things like XY coordinates on the screen, textures, vertices, direction, all that stuff. But setting all of those is as easy as passing a few arguments in parameters. EntityObject[indexnum].xpos=40 would easily set the X value to 40 for the object with the vale of indexnum. Passing behaviors isn't as easy, because I'd want to pass multiple functions to it. The most efficient way I can think of solving it is by passing a pointer to a text document in which has all the functions written out already. EntityObject.pointertoTextforBehav="behavior.txt", in which behavior.txt would have things written in it like {EntitySetX(50); yield(50);-wait 50 frames ShootCurtainFire();-done after the waiting
so what would be the best way about solving this sort of thing?