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

Pages: 1-4041-8081-

Code snippet from Japanese shoot-em-up game

Name: Anonymous 2010-08-16 19:00

void t13()
{
    z1=jiki[9]*4;
    if(hant(jiki[0]+ENHnt[z1]*100-6000,jiki[1]+ENHnt[z1+1]*100-6000,ENHnt[z1+2]+120,ENHnt[z1+3]+120,ex-200,ey-200,4,4))
    {
        SIN(nel(mid(1,0,0)-ey,ex-mid(0,0,0)),(abs(exx)+abs(eyy))/8+300);
        exx=exx+sinx;
        eyy=eyy+siny;
    }
    if(ex+exx<    0){ex=    0;exx= abs(exx);}
    if(ex+exx>40000){ex=40000;exx=-abs(exx);}
    if(ey+eyy<    0){ey=    0;eyy= abs(eyy);}
    if(ey+eyy>48000){ey=48000;eyy=-abs(eyy);}

    ec++;
    alt{
    case e7==0:
        {
            if(ec==1)
            {
                ep[0]=nLimit(6+lev,16);
                ep[1]=nLimit(3+lev/2,8);
                ep[2]=LLim(4+150/(lev+5)-lev/10,1);
                ep[3]=ep[0]+ep[2];
            }
            exx=(exx+sgn(mid(0,0,0)-ex)*3)+rndpm(20);
            eyy=(eyy+sgn(mid(1,0,0)-ey)*3)+rndpm(20);
            if((ec>60)&&(ec<480+480%ep[3]))
            {
                if(ec%ep[3]==0)
                {
                    ep[4]=(mid(0,0,0)+ex)/2;
                    ep[5]=(mid(1,0,0)+ey)/2;
                }
                if(ec%ep[3]<ep[0])ebhas1(eblim(ep[1]),0,nLimit(1+(lev+4)/6,4),ex,ey,nel(ey-ep[5],ep[4]-ex),0,ebsp,ebsp/4);
            }
            if(ec>560+480%ep[3])
            {
                for(i=0;i<256;i++)ep[i]=0;
                ec=0;e7++;ejmuteki=1;
            }
        }
    case e7==1:
        {
            exx=(exx+sgn(mid(0,0,0)-ex)*2)+rndpm(55);
            eyy=(eyy+sgn(mid(1,0,0)-ey)*2)+rndpm(55);
            if(ec<600)
            {
                if(ec%(12-nLimit(lev/3,9))==0)ebhas1(eblim(1),0,7,ex,ey,nel(ey-mid(1,0,0),mid(0,0,0)-ex),0,0,0);
                if(ec%((30-nLimit(lev*2,25))*2)==0)
                {
                    z1=nLimit(2+lev,12)+lev/8;
                    for(i=0;i<z1;i++)ebhas1(eblim(2),0,11,ex,ey,nel(ey-mid(1,0,0),mid(0,0,0)-ex),1640-i*60,ebsp*(1+z1-i)/5,0);
                }
            }
            if(ec>700){e7++;ec=0;}
        }
    case e7==2:
        {
            if(ec<600)
            {
                exx=exx*99/100;
                eyy=eyy*99/100;
            }
            else
            {
                exx=(exx-sgn(mid(0,0,0)-ex)*6)+rndpm(65);
                eyy=(eyy-sgn(mid(1,0,0)-ey)*6)+rndpm(65);
            }
            if(ec==1)
            {
                ejmuteki=0;
                z1=1+(lev>6);
                for(i=EBSP;i!=-1;i=eb[i*B+19])if(eb[i*B+4]!=0)if(eb[i*B+15]==7){ebhas1(eblim(z1),1,16,eb[i*B],eb[i*B+1],eb[i*B+7],3600/z1,100,0);eb[i*B]=-128000;}
            }
            if(((exx==0)&&(eyy==0)&&(ec<400))||((ec>599)&&(ec<801)))ebhas1(eblim(1+nLimit(lev/4,4)),1,15,ex,ey,rnd(3600),0,200,-40);
            if((eblim(EB)==EB)&&(((ec>400)&&(ec<600))||(ec>800))){e7=0;lev++;ec=0;}
        }
    }
}


Well, shit.

Name: 1 2010-08-16 19:03

Have some more. http://pastebin.com/wM4mTpUp

if(i== 1)if(cnf[2]>0)
I just don't know.

Name: Anonymous 2010-08-16 19:28

jump(en,mv,mv,mv,mv,mv,mv,mv,nm,mv,mv,
                        mv,mv,mv,nm,mv,mv,nm,nm,nm,nm,
                        nm,nm,nm,mv,mv,mv,mv,nm,nm,nm,
                        nm,nm,nm,mv,nm,mv,mv,mv,nm,nm,
                        nm,nm,nm,nm,nm,nm,nm,nm,nm,nm,
                        nm,nm,nm,nm,nm,nm,nm,nm,nm,nm,
                        nm,nm,nm,nm,nm,nm,nm,nm,nm,nm);


huh

Name: Anonymous 2010-08-16 19:29

my ancestors are rolling in their graves right now

Name: Anonymous 2010-08-16 19:34

VALID PERL CODE

Name: Anonymous 2010-08-16 20:09

void cnfsave()
I knew it. This kind of store-the-state-in-an-array code is usually begotten because someone wants to be clever and simplify saving/loading.
And always with magic numbers, because that's how it was done in BASIC, where they first learned the technique.

Name: Anonymous 2010-08-16 20:15

That is some of the shittiest code I've ever seen.

Name: Anonymous 2010-08-16 20:17

>>7
Read FV's blog.

Name: Anonymous 2010-08-16 20:20

>>8
Who is FV?

Name: Anonymous 2010-08-16 21:36

What game is this from?

After all, rather than being a /prog/ elitist, I would like to test the actual functionality.

Name: Anonymous 2010-08-16 21:44

>>9
FrozenVoid.

Name: Anonymous 2010-08-16 21:57

>>10
Touhou?

Name: Anonymous 2010-08-17 2:09

This stuff is painful to read.

Name: Anonymous 2010-08-17 2:54

>>8
Please post his blog's address.

Name: Anonymous 2010-08-17 3:12

>>14
Please learn how to use /prog/scrape and/or Google.

Name: Anonymous 2010-08-17 3:16

>>15
Please fuck off, Xarn. I won't install FIOC just to use your shit.

Name: Anonymous 2010-08-17 3:24

>>16
Back to /pr/, please.

Name: Anonymous 2010-08-17 4:05

So this is why porn games from Japan are usually s l o w a s f  u c k.

Name: Anonymous 2010-08-17 7:01

>>10,12

Nope. YGS2000. The game works really well, google it. Just don't look in the "script" folder.

Name: Anonymous 2010-08-18 2:43

Official /prog/ Challenge!
Make a Japanese shoot-em-up game.

Name: Anonymous 2010-08-18 2:56

>>20
Don't you have to be Japanese for that?

Name: >>21 2010-08-18 2:57

And if you're Japanese, won't you be forced to use Ruby?

Name: Anonymous 2010-08-18 4:12

I had a Japanese professor for a couple CS classes and noticed he like 2-5 letter variable wherever possible, often giving things that should have been "blockOn" names like blkn

Name: Anonymous 2010-08-18 5:18

It conserves valuable screen estate.

Name: Anonymous 2010-08-18 11:53

>>23
Even poorly named variables are better than shitCase.

Name: Anonymous 2010-08-18 12:18

>>23,25
block_on
CODE TAGS ARE USED FOR CODE SNIPPETS

Name: Anonymous 2010-08-18 12:52

This code looks like collision or interaction with an object in screen.

...Just a guess...

Name: Anonymous 2010-08-18 12:56

I had a Nipponese sensei for a couple of conpyuta sciensu classes and noticed he like the dibagga wherever possible, often giving things that should have been "traceOn" names like yelling TRACE ON!!! and jamming his p○n○s into my vag○○○ to replenish my magic

Name: Anonymous 2010-08-18 14:57

>>25
Why not go Hungarian and get the worst of both worlds?

Name: Anonymous 2010-08-18 15:32

>>29
s/Hungarian/Systems Hungarian/

Name: Anonymous 2010-08-18 18:57

>>26
THE BLOCK ON

Name: Anonymous 2010-08-18 22:14

Is that C? What the fuck is going on with those case statements?

Name: Anonymous 2010-08-18 23:12

>>32
You can use curly braces to delimit blocks even outside of the usual places. Most people don't, though.

Name: Anonymous 2010-08-19 1:34

>>21
No, you just have to make it in Japan.

Name: Anonymous 2010-08-19 3:48

>>35
Is that even relevant to this thread, or just your way of saying ``I have read SICP to learn how to write spam bots''?

Name: Anonymous 2010-08-19 3:52

>>1
At first glance, I thought this was C, but what the hell is an alt statement?  And why do all the case statements look like:
case e7==something: where "e7" is not defined anywhere?

Name: Anonymous 2010-08-19 3:57

>>37
Macros and globals respectively. It's only a snippet.

Name: Anonymous 2010-08-19 4:23

>>33
I'm not talking about the braces dumbass. I'm talking about case e7==0:. That is completely fucked. Without macros, that's a boolean, and there are only two values of it. Cases cannot be repeated and have to be compile-time constants.

The only way this can compile as C is if e7 is some crazy-ass macro. The case statements also have no breaks, so unless case is also overridden, or e7 contains a break and opens a new case, then all these case statements fall through.

>>38
You're going to need to give us the macros for alt and e7, and possibly case as well if it's overridden by a macro.

Name: Anonymous 2010-08-19 4:39

>>39
I'm not talking about the braces dumbass. I'm talking about case e7==0:. That is completely fucked. Without macros, that's a boolean, and there are only two values of it.
Maybe you should actually look up how C works.

Cases cannot be repeated and have to be compile-time constants.


Maybe you should also look up how labels work in general.

Anyway.
Did Satoshi Nishimura write this code? Sure looks like his.

Name: Anonymous 2010-08-19 5:20

>>40
Regarding your second quote:

C99 6.8.4.2p3: The expression of each case label shall be an integer constant expression and no two of the case constant expressions in the same switch statement shall have the same value after conversion. [...]

Name: Anonymous 2010-08-19 5:45

>>41
C99

Name: Anonymous 2010-08-19 6:27

>>42
C90 6.6.4.2 (3.6.4.2 in ANSI's C89): The controlling expression of a switch statement shall have integral type.  The expression of each case label shall be an integral constant expression.  No two of the case constant expressions in the same switch statement shall have the same value after conversion. [...]

Name: Anonymous 2010-08-19 7:45

>>1
This really doesn't look that bad. e probably means entity; ex/ey are current position, exx/eyy are the delta in the current tick. This is obvious from the top, right before the alt block, it makes sure the resulting movement will be bounded by reflecting off the world bounds. Before that looks like some gravity/repulsion code, maybe poor-man's collision detection. It is attracted or repulsed from another entity (possibly jiki or ENHnt).

Notice how at the end of each 'case' block, there's an if statement which will increment e7, and in the last case it sets e7 to zero. At first I thought this looks a whole lot like Duff's device, but judging from more of the code you posted, those case statements definitely don't fall through. I can't imagine any compiler macro for case that could make that compile. The include statements don't look correct either. Are you sure this is really C? Are you sure your C compiler hasn't been modified?

As far as the contents of the different cases in >>1, they look like different behaviors that the entity moves through sequentially and periodically. The behaviors all seem to randomly jitter the delta, except in the last case it may decay the speed exponentially instead of jittering (i.e. glide to a stop.) I don't know what the eb or ep arrays are.

It would help to have translations for "hant", "jiki", "ebhas", "ejmuteki", and a couple other identifiers. (The 'e's may be a prefix here.) Anyone speak Japanese?

Name: Anonymous 2010-08-19 8:07

Anyone speak Japanese?

This made me laugh, but the answer makes me cry.

Name: Anonymous 2010-08-19 8:20

hant is probably hantei, hitbox
jiki is probably jiki, own unit
ebhas no idea
ejmuteki, ej(?) muteki=invincible/invuln
Fire away!

Name: Anonymous 2010-08-19 8:58

>>46
So the top part is indeed a collision check with "own unit", probably player, and the entity bounces off at an angle.

ec looks like an animation counter. It gets reset to zero on each behavior/state change and increments each tick. ejmuteki switches on in e7==1 and back off at the start of e7==2, so that means the entity is invincible during the 1 behavior.

In the e7==0 behavior, the amount of time the entity spends in it seems to depend on the difficulty level. Without knowing what ebhas1 means I can't really tell what it does, but it governs all of their movements in all behaviors; it seems to have the side effect of actually moving the entity.

Name: Anonymous 2010-08-19 9:43

The Japanese as a society have the mental discipline required to remember what every symbol does without requiring overly long name. Furthermore, Japanese programmers are instilled the spirit of the samurai by their sensei: after years of practice, reading this sort of code becomes just as effortless as reading it, for they have mastered the art of Japanese minimalism. Any comment would just impede their reading.

Name: Anonymous 2010-08-19 9:47

reading this sort of code becomes just as effortless as reading it
I don't think this is too difficult.

Name: Anonymous 2010-08-19 10:24

>>48
//include"script/outsource.txt"    //あとで消せよ~

Name: Anonymous 2010-08-19 13:10

>>48
I replied with >>13 and, while I am not going back on that remark, it's not like it's immediately obvious what is going on.  You can tell in short sequences what is happening with parts of the code; but, I wouldn't have been able to construct something about the whole unless I knew Japanese - >>46 - or had longer variable names to work with.

Name: Anonymous 2010-08-19 13:13

>>43
What's your point? There are more standards out there than ANSI's.
Unless I'm very much mistaken, this is GNU C.

Name: Anonymous 2010-08-19 14:39

>>52
"C" means either C90 or C99. You're also mistaken, GNU C does not allow non-constant nor duplicate case values.

Name: Anonymous 2010-08-19 14:55

C99 is all you need.

Name: Anonymous 2010-08-19 15:24

>>53
"C" means either C90 or C99.
No, ``ANSI C'' means either C89 or C99. ``ISO C'' means either C90 or C99. Just ``C'' can refer to any dialect, and was around two decades before C89 came along.

Name: Anonymous 2010-08-19 16:03

>>54
haha fuck you xarn

Name: Anonymous 2010-08-19 19:51

>>56
Xarn programs in FIOC, not C99.

Name: Anonymous 2010-08-19 20:04

>>57
I think you're forgetting something.

Name: Anonymous 2010-08-19 20:12

>>57
§§faggot quotes'' and being a nitpicking anushole uniquely define a Xarn.

Name: Anonymous 2010-08-19 23:27

>>59
The only person nitpicking (or trying to) here is >>53, and he didn't use what you call ``faggot quotes''.

Name: Anonymous 2010-08-20 3:07

>>56,57
Xarn uses C89.

Name: Anonymous 2010-08-20 4:54

Structure and Interpretation of Japanese Shoot 'em Ups

Name: Anonymous 2010-08-20 6:33

Are those case statements intented to be fall-through, since there are no breaks anywhere?

Name: Anonymous 2010-08-20 7:57

So that's what happened to that Sussdollar bank game that clever Jap was writing for prog.

Name: Anonymous 2010-08-20 7:58

>>64
Hey, I remember that! I was on his team.

Name: Anonymous 2010-08-20 10:21

I couldn't join the team because I wasn't a Stanford guy ;_;

Name: Anonymous 2010-08-20 15:36

>>1
Are you going to fucking tell us how alt and case work or not?

Name: Anonymous 2010-08-20 15:41

I'd complain about the abuse of globals but the whole thing is written like a monstrous state machine... in which case distinguishing between locals and globals is pointless.

Name: Anonymous 2010-08-20 15:43

>>67
That's the least of your worries. Start with K&R and don't stop until you can spot the bigger questions raised by that code.

Name: Anonymous 2010-08-20 16:14

>>68
abuse of globals
Nonsense.  Globals are the pinnacle of clean design.

Name: Fart Commander 2010-08-20 17:08

This kind of programming is like an all-in gamble...  The guy writing it basically says "fuck everything, I can make this work in one shot and no one will ever need to actually look at the code later."

Going "all-in" on hello_world.c is probably OK.  Going "all-in" on a Japanese Shoot-em-UP is probably not a good idea.  Or maybe this guy is just the ultimate badass.

Name: Anonymous 2010-08-20 17:32

Name: Anonymous 2010-08-20 18:35

>>71
When I'm working on uncommented code there are a few things that I am thinking about the original creator. "Badass" is not one of them.

Name: Anonymous 2010-08-20 19:24

We're dealing with some NEETs making their games in weeks-long hacking sessions barely interrupted by biological functions. This sort of code makes sense in that context.

Name: Anonymous 2010-08-20 19:33

I found this code very readable. Maybe you should stop being a bunch of pussies.

Name: Anonymous 2010-08-20 19:34

>>74
I write all of my code in those circumstances, and I can assure you it's not nearly as bad as this.

Name: Anonymous 2010-08-20 21:35

>>76
Indeed. This is the only proper way to program.

Name: Anonymous 2010-08-20 22:59

>>77
Agreed. Pizza is recommended.

Name: Anonymous 2010-08-21 1:36

>>39

#include <stdio.h>
#define a 5
main ()
{
  switch(1)
  {
    case a==3:
    {
      printf("%s\n","foo");
    }
    case a==5:
    {
      printf("%s\n","bar");
    }
  }
}

Name: Anonymous 2010-08-21 9:49

>>79
#include <stdio.h>
#define a 5
main ()
{
  switch(1)
  {
    case a==3:
    {
      printf("%s\n","foo");
    }
    case a==4:
    {
      printf("%s\n","uh oh two case statements that have the same value!");
    }
    case a==5:
    {
      printf("%s\n","bar");
    }
  }
}

Name: Anonymous 2010-10-26 23:05

Name: Anonymous 2011-02-03 2:13

Name: Anonymous 2011-09-25 14:10

pantsu

Name: Anonymous 2011-09-25 14:26

Name: Anonymous 2011-09-25 15:39

>>87
Am afraid
http://code.google.com/p/kene-touhou-mohofu/source/browse/trunk/src/game_core/boss/boss_card.c
Look at this fine-tuned (we don't use hardcoded around here) boss handling code and who needs unicode for their source code when they could just use SJIS?

Name: Anonymous 2011-09-25 16:29

>>88
line 173: multiprex_rate_vector();

I hope they weren't trying to spell multiplex.

Name: Anonymous 2011-09-25 21:42

>>89
u mena murtiprex

Name: 2012-01-25 7:19


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