Skip to content

Instantly share code, notes, and snippets.

@babycourageous
Created April 26, 2020 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save babycourageous/ccd9fb96ec460168fcb836f07c4a0171 to your computer and use it in GitHub Desktop.
Save babycourageous/ccd9fb96ec460168fcb836f07c4a0171 to your computer and use it in GitHub Desktop.
Tetris kicks from official Tetris SRS wiki translated to JavaScript Object
const kicks = {
'JLSTZ': [
{
rotation: 0,
direction: -1,
tests:[
{
dx: 0,
dy: 0
},
{
dx:1,
dy:0
},
{
dx:1,
dy:-1
},
{
dx:0,
dy:2
},
{
dx:1,
dy:2
},
]
},
{
rotation: 0,
direction: 1,
tests:[
{
dx:0, dy:0
},
{
dx:-1, dy:0
},
{
dx:-1, dy:-1
},
{
dx:0, dy:2
},
{
dx:-1, dy:2
},
]
},
{
rotation: 1,
direction: -1,
tests:[
{
dx:0, dy:0,
},
{
dx:1, dy:0,
},
{
dx:1, dy:1,
},
{
dx:0, dy:-2,
},
{
dx:1, dy:-2,
},
]
},
{
rotation: 1,
direction: 1,
tests:[
{
dx:0, dy:0,
},
{
dx:1, dy:0,
},
{
dx:1, dy:1,
},
{
dx:0, dy:-2,
},
{
dx:1, dy:-2,
},
]
},
{
rotation: 2,
direction: -1,
tests:[
{
dx:0, dy: 0,
},
{
dx:-1, dy: 0,
},
{
dx:-1, dy: -1,
},
{
dx:0 , dy:2,
},
{
dx:-1 , dy:2,
},
]
},
{
rotation: 2,
direction: 1,
tests:[
{
dx: 0, dy:0,
},
{
dx: 1, dy:0,
},
{
dx: 1, dy:-1,
},
{
dx: 0, dy:2,
},
{
dx: 1, dy:2,
},
]
},
{
rotation: 3,
direction: -1,
tests:[
{
dx:0, dy: 0,
},
{
dx:-1, dy: 0,
},
{
dx:-1 , dy:1,
},
{
dx:0, dy: -2,
},
{
dx:-1, dy: -2,
},
]
},
{
rotation: 3,
direction: 1,
tests:[
{
dx: 0, dy:0,
},
{
dx: -1, dy:0,
},
{
dx: -1, dy:1,
},
{
dx: 0, dy:-2,
},
{
dx: -1, dy:-2,
},
]
}
],
'I': [
{
rotation: 0,
direction: -1,
tests:[
{
dx: 0, dy: 0,
},
{
dx: -1, dy: 0,
},
{
dx: 2, dy: 0,
},
{
dx: -1, dy: -2,
},
{
dx: 2, dy: 1,
},
]
},
{
rotation: 0,
direction: 1,
tests:[
{
dx: 0, dy: 0,
},
{
dx: -2, dy: 0,
},
{
dx: 1, dy: 0,
},
{
dx: -2, dy: 1,
},
{
dx: 1, dy: -2,
},
]
},
{
rotation: 1,
direction: -1,
tests:[
{
dx: 0, dy: 0,
},
{
dx: 2, dy: 0,
},
{
dx: -1, dy: 0,
},
{
dx: 2, dy: -1,
},
{
dx: -1, dy: 2,
},
]
},
{
rotation: 1,
direction: 1,
tests:[
{
dx: 0, dy: 0,
},
{
dx: -1, dy: 0,
},
{
dx: 2, dy: 0,
},
{
dx: -1, dy: -2,
},
{
dx: 2, dy: 1,
},
]
},
{
rotation: 2,
direction: -1,
tests:[
{
dx: 0, dy: 0,
},
{
dx: 1, dy: 0,
},
{
dx: -2, dy: 0,
},
{
dx: 1, dy: 2,
},
{
dx: -2, dy: -1,
},
]
},
{
rotation: 2,
direction: 1,
tests:[
{
dx: 0, dy: 0,
},
{
dx: 2, dy: 0,
},
{
dx: -1, dy: 0,
},
{
dx: 2, dy: -1,
},
{
dx: -1, dy: 2,
},
]
},
{
rotation: 3,
direction: 1,
tests:[
{
dx: 0, dy: 0,
},
{
dx: -2, dy: 0,
},
{
dx: 1, dy: 0,
},
{
dx: -2, dy: 1,
},
{
dx: 1, dy: -2,
},
]
},
{
rotation: 3,
direction: 1,
tests:[
{
dx: 0, dy: 0,
},
{
dx: 1, dy: 0,
},
{
dx: -2, dy: 0,
},
{
dx: 1, dy: 2,
},
{
dx: -2, dy: -1,
},
]
}
]
}
@lts20050703
Copy link

lts20050703 commented Jan 17, 2023

image

https://gist.github.com/babycourageous/ccd9fb96ec460168fcb836f07c4a0171#file-kicks-js-L306

LINE 306 should be direction: -1

Already made a tetris clone in vanilla javascript typescript, thank you for your tetris in svelte guide, it had help me a lot in understanding how to use stores and just svelte in general!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment