tetr.js development thread

Started by simonlc, March 17, 2013, 10:49:15 AM

Previous topic - Next topic

simonlc

Quote from: UJS3
Oops, you're right. Custom gravity is fine  

But shouldn't gravity get faster over time in marathon mode? I wrote this off as a gravity problem at first.

Yup that will be in there eventually, but right now the only difference is 150 lines vs 40 lines. I'm also probably going to add Ultra and survival. I'm still doing research on all three of these, since I'm not sure if I want them to be TF clones or not.

simonlc

WIP:

[!--ImageUrlBegin--][a href=\\\"http://i.imgur.com/X6erjyq.png\\\" target=\\\"_new\\\"][!--ImageUrlEBegin--][img width=\\\"400\\\" class=\\\"attach\\\" src=\\\"http://i.imgur.com/X6erjyq.png\\\" border=\\\'0\\\' alt=\\\"IPB Image\\\" /][!--ImageUrlEnd--][/a][!--ImageUrlEEnd--]

FelipeMayrink

Quote from: simonlc
WIP:

[!--ImageUrlBegin--][a href=\\\"http://i.imgur.com/X6erjyq.png\\\" target=\\\"_new\\\"][!--ImageUrlEBegin--][img width=\\\"400\\\" class=\\\"attach\\\" src=\\\"http://i.imgur.com/X6erjyq.png\\\" border=\\\'0\\\' alt=\\\"IPB Image\\\" /][!--ImageUrlEnd--][/a][!--ImageUrlEEnd--]

>backgrounds

meh...

UJS3

It's cool that you have it working, although I personally don't care very much about background (as long as it's not obnoxious flashing ads like TB). A few options to choose from might be a fun feature.

UJS3

So I had an idea that would combine replays and the finesse trainer. Play a normal game and export the replay, then load it into the finesse trainer and play through the game with the ghost piece guiding you. That way we could get e.g. a pro ST stacker or microblizz WR and play it ourselves. Maybe you'll learn something you don't get from just watching it?

I have no idea if this is feasible, have you decided on a format for the replays yet?

Barneey

Love it so far, would be it be possible to make the "Ready" and "Go" more visible? They fade away in the background.

simonlc

Quote from: UJS3
So I had an idea that would combine replays and the finesse trainer. Play a normal game and export the replay, then load it into the finesse trainer and play through the game with the ghost piece guiding you. That way we could get e.g. a pro ST stacker or microblizz WR and play it ourselves. Maybe you'll learn something you don't get from just watching it?

I have no idea if this is feasible, have you decided on a format for the replays yet?
That's a great idea. I've been wanting to either have NullpoMino replay format, or be able to convert them. Not long ago I quickly looked at it and had no idea how they worked, so for now there's still some research that needs to be done. I think your idea is great, and when the time comes to implement those features I will definitely add that mode in too.

Quote from: Barneey
Love it so far, would be it be possible to make the "Ready" and "Go" more visible? They fade away in the background.
Yup I'm working on that right now, making a completely new design. Before I restricted myself to looking like NullpoMino, but I've decided to just make it how ever I want.

UJS3

#52
Quote from: simonlc
I've been wanting to either have NullpoMino replay format, or be able to convert them. Not long ago I quickly looked at it and had no idea how they worked, so for now there's still some research that needs to be done.
It would be really nice to have nullpo compatibility. Belzebub here on HD did a nullpo mod which allowed to export fumens directly, he probably knows a lot about how replays are handled. Maybe esialb knows too, since he's working on a nullpo fork right now. You may not have to reinvent the wheel.

simonlc

Cool, I'll get in touch with them when the time comes.


Meanwhile, I'm working on adding new block types:


FelipeMayrink

Ok... this is more interesting...

simonlc

#55
Quote from: FelipeMayrink
Ok... this is more interesting...
You don't like them?

FelipeMayrink

#56
Quote from: simonlc
You don't like them?
What? I do like them.

That's why I said it's more interesting. I was comparing to the backgrounds WIP, which is not so interesting in my opinion because BACKGROUNDS SUCK HUGE BALLS!
And such...

Paradox

i like it so far, what do you plan the final version to be like?
[!--ImageUrlBegin--][a href=\\\"http://oi46.tinypic.com/2zqx63k.jpg\\\" target=\\\"_new\\\"][!--ImageUrlEBegin--][img width=\\\"400\\\" class=\\\"attach\\\" src=\\\"http://oi46.tinypic.com/2zqx63k.jpg\\\" border=\\\'0\\\' alt=\\\"IPB Image\\\" /][!--ImageUrlEnd--][/a][!--ImageUrlEEnd--]

Integration

#58
Quote from: simonlcI've been wanting to either have NullpoMino replay format, or be able to convert them. Not long ago I quickly looked at it and had no idea how they worked, so for now there's still some research that needs to be done.
Here some code from Controller.java:

public static final int BUTTON_BIT_UP = 1,
                        BUTTON_BIT_DOWN = 2,
                        BUTTON_BIT_LEFT = 4,
                        BUTTON_BIT_RIGHT = 8,
                        BUTTON_BIT_A = 16,
                        BUTTON_BIT_B = 32,
                        BUTTON_BIT_C = 64,
                        BUTTON_BIT_D = 128,
                        BUTTON_BIT_E = 256,
                        BUTTON_BIT_F = 512;

public int getButtonBit()
{
    int input = 0;
    if(buttonPress[BUTTON_UP]) input |= BUTTON_BIT_UP;
    if(buttonPress[BUTTON_DOWN]) input |= BUTTON_BIT_DOWN;
    if(buttonPress[BUTTON_LEFT]) input |= BUTTON_BIT_LEFT;
    if(buttonPress[BUTTON_RIGHT]) input |= BUTTON_BIT_RIGHT;
    if(buttonPress[BUTTON_A]) input |= BUTTON_BIT_A;
    if(buttonPress[BUTTON_B]) input |= BUTTON_BIT_B;
    if(buttonPress[BUTTON_C]) input |= BUTTON_BIT_C;
    if(buttonPress[BUTTON_D]) input |= BUTTON_BIT_D;
    if(buttonPress[BUTTON_E]) input |= BUTTON_BIT_E;
    if(buttonPress[BUTTON_F]) input |= BUTTON_BIT_F;
    // ...

public void setButtonBit(int input)
{
    clearButtonState();
    if((input & BUTTON_BIT_UP) != 0) buttonPress[BUTTON_UP] = true;
    if((input & BUTTON_BIT_DOWN) != 0) buttonPress[BUTTON_DOWN] = true;
    if((input & BUTTON_BIT_LEFT) != 0) buttonPress[BUTTON_LEFT] = true;
    if((input & BUTTON_BIT_RIGHT) != 0) buttonPress[BUTTON_RIGHT] = true;
    if((input & BUTTON_BIT_A) != 0) buttonPress[BUTTON_A] = true;
    if((input & BUTTON_BIT_B) != 0) buttonPress[BUTTON_B] = true;
    if((input & BUTTON_BIT_C) != 0) buttonPress[BUTTON_C] = true;
    if((input & BUTTON_BIT_D) != 0) buttonPress[BUTTON_D] = true;
    if((input & BUTTON_BIT_E) != 0) buttonPress[BUTTON_E] = true;
    if((input & BUTTON_BIT_F) != 0) buttonPress[BUTTON_F] = true;
    // ...

The input of a certain time is written to one variable. If you interprete that variable as a binary number, then
  • its last digit tells you, if your hard drop key is pressed
  • its 2nd last digit tells you, if your soft drop key is pressed
  • its 3rd last digit tells you, if your left movement key is pressed
  • its 4th last digit tells you, if your right movement key is pressed
  • its 5th last digit tells you, if your rotate counterclockwise key is pressed
  • ... and so on ...
If the current input is different from the last frame, its value and frame number is stored to an array, which is written to the replay file at the end of the game. In the replay file, you'll find lines like those:

0.r.108=4
0.r.114=20
0.r.119=21
0.r.122=5
0.r.125=4
0.r.132=5
0.r.134=1
0.r.138=9
0.r.140=8
0.r.144=24
0.r.148=28
0.r.151=21
0.r.152=17
0.r.153=1
0.r.159=0
0.r.166=1

Those keys are pressed in the corresponding frames:

108-113: left
114-118: left, rotate ccw
119-121: left, rotate ccw, drop
122-124: left, drop
125-131: left
132-133: left, drop
134-137: drop
138-139: right, drop
140-143: right
144-147: right, rotate ccw
148-150: left, right, rotate ccw
151-151: drop, left, rotate ccw
152-152: drop, rotate ccw
153-158: drop
159-155: no key pressed
156-???: drop

[fumen]110@7eLOki2qb2kBvqbvaBKsbSubytbynBDnbDhBAAA[/fumen]

simonlc

#59
Quote from: Paradox
i like it so far, what do you plan the final version to be like?

I don't think there ever will be a final version. But the development will probably slow down a lot after I included all the gametypes I want to play.

Quote from: Integration
Here some code from Controller.java:

Oh wow, that's a very good explanation, thanks.