tetr.js development thread

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

Previous topic - Next topic

Kitaru

#30
Quote from: simonlcEDIT: I just found out what is causing the line clear bug. It's due to javascript's very stupid sort method.

If you sort [21, 19, 20] you will get [19, 20, 21] as expected. If you sort [10, 9, 11] you get [10, 11, 9]. Even though 10 is bigger than 9, it only looks at the first digit first, so 1 is smaller than 9 and that's why 9 is at the end. So this is why the line clear code only messes up in that spot. I should have this fixed soon.
From http://www.w3schools.com/jsref/jsref_sort.asp:
[!--quoteo--][div class=\\\'quotetop\\\']QUOTE[/div][div class=\\\'quotemain\\\'][!--quotec--]The sort order can be either alphabetic or numeric, and either ascending or descending.

Default sort order is alphabetic and ascending.

Note: When numbers are sorted alphabetically, "40" comes before "5".

To perform a numeric sort, you must pass a function as an argument when calling the sort method.

...

Example

Sort numbers (numerically and ascending):
var points = [40,100,1,5,25,10];
points.sort(function(a,b){return a-b});

The result of points will be:
1,5,10,25,40,100[/quote]So, I think it's less that Javascript's default sort is inherently bad and more that one wouldn't necessarily expect that behavior given the datatype. You just need to override the default comparator to get the behavior you're looking for.
<a href=http://backloggery.com/kitaru><img src="http://backloggery.com/kitaru/sig.gif" border='0' alt="My Backloggery" /></a>

simonlc

Quote from: FelipeMayrink
How about some other block skins to choose from? That would be a nice feature...

Also, not really a big fan of the white background. Maybe I'm just too used to Nullpomino, but still...
Yeah I thought about this too, I'll likely make a light dark toggle soon.

Quote from: UJS3
I agree on both counts  

I don't know how block skins are implemented in HTML5, but if it's like nullpo (simple image files) then perhaps we can help by submitting skins. I prefer bare bones, solid color.
At the moment they are just vector data, which is so they can scale. Doing a solid color option would be quite trivial, and will also be doing this. I was going to save this for later but might as well ask now: If anyone wants to submit free or give me the rights to use some art for the minos, I can remake them in scalable form and include them. If you already have them in svg or vector form, even better. One thing I wont have is cultris style blocks (also in nullpo), which I have no idea how to make.

Quote from: Kitaru
So, I think it's less that Javascript's default sort is inherently bad and more that one wouldn't necessarily expect that behavior given the datatype. You just need to override the default comparator to get the behavior you're looking for.
Coming from python, I'm definitely spoiled. I've been reading lots about javascript lately, and while there's many bad parts, there's also some really nice things, which I wish I had learned earlier. I've been working on improving the code to reflect these new ideas and techniques I learned.

Maybe for april fools I can flip the canvas to make it really hard to play.

simonlc

Quick WIP preview of the dark theme. I'm also re working the layout so you can change the size of the game and go fullscreen.

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

FelipeMayrink

#33
Quote from: simonlc
Quick WIP preview of the dark theme. I'm also re working the layout so you can change the size of the game and go fullscreen.

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


Sweet Mother of God, yes!

UJS3

Nice, I really like the large indicator for number of lines left as well  

simonlc

Glad you guys like it.

I need some advice as to how I should implement gravity in the settings. Right now you can choose from 0-20G and auto, but obviously we should be able to select everything in between 0 and 1. Would having the option to select 1/64 to 63/64 be sufficient? What about 0.1-0.9G? Personally I think the latter would be fine, but I'm not sure whether players have special preferences or not.

I've built a settings menu from the ground up, so now I can easily add new settings, and it'll generate all the HTML dynamically, this should speed up adding new features.

I have to test all the settings, and fix a few things. Then add the finishing touches to the menu design. After that we should see a new release.

FelipeMayrink

Quote from: simonlc
Glad you guys like it.

I need some advice as to how I should implement gravity in the settings. Right now you can choose from 0-20G and auto, but obviously we should be able to select everything in between 0 and 1. Would having the option to select 1/64 to 63/64 be sufficient? What about 0.1-0.9G? Personally I think the latter would be fine, but I'm not sure whether players have special preferences or not.

I've built a settings menu from the ground up, so now I can easily add new settings, and it'll generate all the HTML dynamically, this should speed up adding new features.

I have to test all the settings, and fix a few things. Then add the finishing touches to the menu design. After that we should see a new release.

I don't think people are so specific in their gravity settings, so the ladder should be more than enough.

It's nice to know new things are going to be added more easily. I really can't wait for new releases of this, to the point that I get excited whenever I see that you made a new post in this topic.  I am really monitoring this.

Any estimations to when the new release is coming out?

simonlc

Quote from: FelipeMayrink
I don't think people are so specific in their gravity settings, so the ladder should be more than enough.

It's nice to know new things are going to be added more easily. I really can't wait for new releases of this, to the point that I get excited whenever I see that you made a new post in this topic.  I am really monitoring this.

Any estimations to when the new release is coming out?



Well there's a lot of unfinished features, so if nothing goes wrong finishing them, I expect it to be out by Sunday.

simonlc

Well I decided to push this release out now, even though there's a few things missing. Please let me know how these new features are for you.

What's new?
  • The settings menu, click or hold the arrows to change options.
  • DAS and ARR settings, let me know if you want a wider range for these.
  • Dark theme, though the look of both is still early WIP.
  • Gravity setting, decided to just go with the full x/64G and 0-20G.
  • Lock Delay setting.
  • Auto sizing, and also you can pick a fixed size if it'll fit in your screen. I might expand on this and allow more customization.
  • Option to use flat colored blocks. Settings to remove the 'grid' lines might come in the future.
  • Setting to turn off the ghost or use a colored ghost.
  • Line counter on the left.
Apart from that there's a few bug fixes, and improvements to the controls menu.

What's not in yet:
  • Sound and volume do nothing.
  • Neither does hide cursor.
  • Instant updating of features, sometimes it needs a little kick like a page refresh or browser resize. This will probably be fixed soon.
  • Local high scores are coming next, pretty much the same style as nullpo unless there is some requests.
  • Lots of improvements that I want to make that really wont be noticable to anyone.
  • Better menu system, with a scroll bar for small screens.
  • Better overall design and look.
  • Resetting settings and controls to default.
  • Ability to pause, and automatic pause when the page isn't visible. Pausing was in the old version but it didn't pause the timers.
There's lots of future options, like adding sounds (I need sounds first), adding custom block skins, and things like that. I made some color functions that I'm really not happy with for controlling things like the falling piece brightness and colored ghost piece, but the function is really bad and called literally 3 times for every single block you see. Only the falling piece is drawn at 60fps, but even that bothers me. I'm likely going to ditch those and think of something else. I'm thinking of adding even more functions and just caching the colors at the start of the game, but even then I'm not sold. I'm also really starting to hate the look of the design. The menus never really got any design, and even though I like the minimalism of everything it's just not giving me the right mood. I think I'm going to take time to work on that next more than anything, and probably mess around with playing sounds in JS. The state of sound in JS is pretty messy, so it's going to take some work to just get a system for playing sounds well across all browsers. There's also the Web Audio API that is only supported by some browsers but I'm itching to play with it.

TL;DR: I'm going to work on the design and improve some features that I quickly implemented and am not happy with their state.

UJS3

#39
Yes! You, sir, are a gentleman and a scholar.

Another feature request: configurable soft drop speed. Ranging from sonic drop to something a beginner would be happy with.

Bug report: failed movement seems to reset the lock delay. Soft drop a piece and hold a direction key until it hits the wall. If you keep holding it down, the piece never locks and the next piece doesn't spawn until you let it go.

Edit: here's a weird one. Hold down direction key as before and change to a different browser tab. Release the key and tab back to the game. It still recognizes the movement even though it has been released. I can move in the other direction, but it'll move back to the wall afterwards. I'm using chromium under linux mint, btw.

Edit2: Had some bad problems with the settings menu. Can't remember the circumstances exactly, but I believe I was holding down the right arrow for changing the DAS setting, and after letting go it just kept cycling. Clicking on another setting causes that value to cycle. If you have epilepsy problems, don't change the light/dark theme while it's doing this.

simonlc

#40
Quote from: UJS3
Yes! You, sir, are a gentleman and a scholar.

Another feature request: configurable soft drop speed. Ranging from sonic drop to something a beginner would be happy with.

Bug report: failed movement seems to reset the lock delay. Soft drop a piece and hold a direction key until it hits the wall. If you keep holding it down, the piece never locks and the next piece doesn't spawn until you let it go.

Edit: here's a weird one. Hold down direction key as before and change to a different browser tab. Release the key and tab back to the game. It still recognizes the movement even though it has been released. I can move in the other direction, but it'll move back to the wall afterwards. I'm using chromium under linux mint, btw.

Edit2: Had some bad problems with the settings menu. Can't remember the circumstances exactly, but I believe I was holding down the right arrow for changing the DAS setting, and after letting go it just kept cycling. Clicking on another setting causes that value to cycle. If you have epilepsy problems, don't change the light/dark theme while it's doing this.
Wow nice finds.

I'm going to try and fix those now, I've replicated all of them. I'm not sure I will be able to fix the tab one, as that seems more like a browser implementation problem, but I have some ideas. I went ahead and added the soft drop speed, as it was as simple as copying the gravity code.

Edit: Fixed the mouse bug in the settings menu.
Edit 2: Fixed the bug when holding a direction key causing the piece not to lock.

UJS3

#41
A few more thoughts

Looks like the lock delay is fixed, nice. I don't see a soft drop setting, not sure if it was supposed to be visible yet. Hitting the soft drop key hangs the game though...

The gravity settings don't always work. I change it from 0 to 2 and it seems too fast. Switching to 40/64 doesn't change anything.

Finally (and this may be intentional), when I go to http://simon.lc/tetr.js/ and hit retry, the game mode says "undefined". This is true of course, but it seems to start a marathon game. May as well choose a default and call it that.

Edit: As for the tab thing, it shouldn't really come up in a real game, so I'm not worried about it, just thought it was interesting  

FelipeMayrink

#42
This is awesome.

simonlc

#43
Quote from: UJS3
A few more thoughts

Looks like the lock delay is fixed, nice. I don't see a soft drop setting, not sure if it was supposed to be visible yet. Hitting the soft drop key hangs the game though...

The gravity settings don't always work. I change it from 0 to 2 and it seems too fast. Switching to 40/64 doesn't change anything.

Finally (and this may be intentional), when I go to http://simon.lc/tetr.js/ and hit retry, the game mode says "undefined". This is true of course, but it seems to start a marathon game. May as well choose a default and call it that.

Edit: As for the tab thing, it shouldn't really come up in a real game, so I'm not worried about it, just thought it was interesting  
Yeah the soft drop thing was my bad, I told myself "if I do it this way it wont work" so I start doing it right, then for some reason I go back and say "no I should do it this way, I'm so clever" and did it the way that wouldn't work. It should work now.

The undefined thing is just me being lazy, that should be fixed when I'm finished the new design.

As for the gravity I really don't know what to say. It seems to work correctly for me.

Quote from: FelipeMayrink
This is awesome.


UJS3

Quote from: simonlc
As for the gravity I really don't know what to say. It seems to work correctly for me.

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.