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

Pages: 1-

Constructive advice? In MY /prog/??!

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?

Name: Anonymous 2011-02-27 3:39

>>1

fuck you faggot

Name: anon4help !!SMc+oRp3hlfrttZ 2011-02-27 3:41

nobody knows?

Name: Anonymous 2011-02-27 3:45

>>1
ZUN used only the purest Lisp dialect to write 東方.
I have two problems.
You're using C++, sure you do.

The first is, implementing yielding.
Capture the current continuation, return a struct with both the continuation and your return value, do what you have to do, restart the continuation.

My second problem, is how would I go about properly giving objects a behavior, an artificial inteligence?
Code the behaviour.
I'd want to pass multiple functions to it.
If by functions you mean actual functions, you've choose the wrong language.

so what would be the best way about solving this sort of thing?
Use a decent language.

Name: >>4 2011-02-27 3:51

And before you think I'm trolling you:

1. Scheme has continuations, and most implementations already have some kind of yield.
2. Lisp is known to be good for AI.
3. High order functions.
4. Since code=data, you can make it extensible by just reading the configuration and evaluate it.
5. C++ is not so much more OMGOPTIMIZED!!! FAST AS VIRGIN FUCK than SBCL.

Name: anon4help !!SMc+oRp3hlfrttZ 2011-02-27 3:53

>>4
He used C++ or C#. I know because he showed some of his programming in an interview, and stated he used Visual Studio for his games.

I'm not trying to be like ZUN, but I know that it's a powerful language. And I like working with object-oriented code like c++. And it's fast. Lisp is an interpreter.

My problem isn't with C++. I need a way to implement a script. It's done before, and I know that many games are written in it.
I'm trying to implement things like motion with events instead of spline motion because I find it exhaustingly tedios to have to work with complex math equations for a simple motion like getting an object to come in the screen, go left and right over a few frames, and then leave.

Name: Anonymous 2011-02-27 4:02

>>6
Lisp is an interpreter.
What the fuck, no, it's compiled and ``as fast as C''.

I'm trying to implement things like motion with events
You could pass messages between the threads.

I find it exhaustingly tedios to have to work with complex math equations
You can't have TOUHOU-QUALITY patterns without them.

Name: Anonymous 2011-02-27 4:09

$ sbcl
This is SBCL 1.0.40.0.debian, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>;.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* (defun op-is-a-fag () 'op-is-a-fag)
OP-IS-A-FAG
* (compile 'op-is-a-fag)
OP-IS-A-FAG
NIL
NIL
* (disassemble 'op-is-a-fag)
; disassembly for OP-IS-A-FAG
; 0AADBAE6:       8B15B8BAAD0A     MOV EDX, [#xAADBAB8]       ; 'OP-IS-A-FAG
                                                              ; no-arg-parsing entry point
;       EC:       8BE5             MOV ESP, EBP
;       EE:       F8               CLC
;       EF:       5D               POP EBP
;       F0:       C3               RET
;       F1:       CC0A             BREAK 10                   ; error trap
;       F3:       02               BYTE #X02
;       F4:       18               BYTE #X18                  ; INVALID-ARG-COUNT-ERROR
;       F5:       4F               BYTE #X4F                  ; ECX
NIL
*

Name: Anonymous 2011-02-27 4:24

>>6
Lisp is an interpreter.
I FOLD!11

Name: Anonymous 2011-02-27 4:25

>>8
> racket
 Welcome to Racket v5.1.
 > (enter! "decompiler.rkt")
 > (define (op-is-a-fag) 'op-is-a-fag)
 > (op-is-a-fag)
 'op-is-a-fag
 > (decompile op-is-a-fag)
 00000000  8943FC            mov [ebx-0x4],eax
 00000003  83C3FC            add ebx,byte -0x4
 00000006  B8008C80B6        mov eax,0xb6808c00
 0000000B  8B00              mov eax,[eax]
 0000000D  83C41C            add esp,byte +0x1c
 00000010  5F                pop edi
 00000011  5E                pop esi
 00000012  5B                pop ebx
 00000013  5D                pop ebp
 00000014  C3                ret


OMG not optimized :(

Name: Anonymous 2011-02-27 4:25

:GJS1M 67dcbdbce4a0b67c4b48e86a6ae29205a95e4b83024a9d947213d1231800e8d9
:47 25b0afade37864876418f0a9594caf8d
:1298795764 1298798744
>>5

<-- check my doubles

Name: anon4help !!SMc+oRp3hlfrttZ 2011-02-27 4:26

>>7

>You can't have TOUHOU-QUALITY patterns without them.

Actually, I can. If you've ever tried Danmakufu, it's unbelievably easy. And it's also so in any language.
All I'd have to do to spawn bullets in a circle around a given boss is make a function that spawns a bullet (which I've already done) and another to return a given object's data, like XY coordinates.

For example, in Danmakufu code:

FireBullets();

task FireBullets(){
let ang=0; let x=GetX(); let y=GetY(); let speed=1.5; let bullettype=whatever;

loop(infinite){
loop(30){
CreateShot01(x+10*cos(ang),y+10*sin(ang),speed,ang,bullettype);
ang+=360/30;
}
ang+=1;
loop(4){yield;}
}

}

///the above fires bullets in a circle around a given entity. The circle spirals, making the scene looks like its twirling

It's just as easy to do in C++, and the code is pretty obvious. replacing data type int/float for let, replacing task for void, and using for/while for loop() loop types. It's very easy.
The only problem is exiting the scope everytime yield is called so it goes back to the infinite game loop and updates the next object/bullet/whatever. My best guess is that it does this by multithreading and uses a framecounter and sleep() function that suspends the thread until next frame.

But there's still the problem of actually assigning the object this sort of behavior. I want to be able to write it in a text document of some sort and make it as easy as creating an Entity with a function like CreateEnemy("Behavior.txt");, in which this creates one object that inherits the stuff written there.


Well, it doesn't seam to do much good asking here, seeing you're trying to prevent me from writing in the language. I didn't come to ask what I should write code in. I asked how I can get structures to inherit "behaviors" and run them, in which they are updated every frame in an infinite loop.

Name: Anonymous 2011-02-27 4:32

TOO LISP; DIDN'T READ

Name: Anonymous 2011-02-27 4:33

>>12
I asked how I can get structures to inherit "behaviors" and run them,
A behaviour class with some ENTERPRISE boilerplate to serialize it.

Name: Anonymous 2011-02-27 4:33

>>14
And see >>7

Name: Anonymous 2011-02-27 5:37

Name: Anonymous 2011-03-22 23:17

>>6
>I find it exhaustingly tedios to have to work with complex math equations
you is gay

seriously, though, move your enemies the same way you move your player characters (give them state and controls)
then designing AI is just a matter of deciding what controls (left, right, up, down, accelerate, fire, etc.) to use in each game state

tl;dr separate the AI from the motion mechanics

Name: Anonymous 2011-03-23 10:01

>>17
Like Counter-Strike bots!! :)))))))))))))

Name: Anonymous 2011-10-03 11:16

lisp sucks

Name: Anonymous 2011-10-03 11:35

My best guess is that it does this by multithreading and uses a framecounter and sleep() function that suspends the thread until next frame.
You're on the right track. But you shouldn't use C++ for moving the entities. Native multithreading isn't meant for this sort of thing and will perform rather badly. You should use an interpreter or design one.
Both BulletML and Danmakufu are terribly bad. BulletML is enterprise and limited (unintended pun). Danmakufu's language is meh and the primitives are a steamy pile of poo.
ZUN's ECL is surprisingly good but very game-specific and documentation is almost non-existent.
Also, I'm making a similar shmup engine right now and I'm pretty sure it will be better than yours.

Name: Anonymous 2011-10-03 12:06

OP I was doing the exact same thing at one point,
using this coroutine library for c++:
http://www.akira.ruc.dk/~keld/research/COROUTINE/

The claims of "portable" are a huge fat lie. (They take pointers to automatic storage variables and memcpy the area between to "switch the stack" or something)

http://www.mediafire.com/?irs1kj7fjvor682
See the classes inheriting from Coroutine, the code looks like:

void CFairy1TickCoroutine::Routine()
{
...
  while(true)
  {
  ...
    Detach();
  }
}

Now look at how shit the code is, do you want to end up with this? Just give in and use a superior language please

Name: Anonymous 2011-10-03 12:08

check 'em

Name: Anonymous 2011-10-03 12:38

>>20
I'm making a similar shmup engine right now
Please keep us updated! >>1-san's project is obviously doomed to fail, but I would like to see how yours turns out.

I wrote a very, very basic framework for a shmup in C/SDL a few years ago, but it sucked.

Name: Anonymous 2011-10-03 13:22

>>1
Touhou

TOO HOU

DIDN'T READ

Name: Anonymous 2011-10-03 19:06

>DirectX
No freedom, no care

Name: 2012-01-25 7:17


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