[Game] Tetris Windows 7+

Post your working scripts, libraries and tools
User avatar
maestrith
Posts: 817
Joined: 16 Oct 2013, 13:52

[Game] Tetris Windows 7+

06 Sep 2017, 11:59

Controls:
-Left - Left
-Right - Right
-Up - Rotate Tetrimino
-Down -Drop Faster
-S - Drop to Bottom
-Q - Hold

Requires Windows 7+ and IE 11+
AutoHotkey_2017-09-06_12-56-22.png
(32.06 KiB) Downloaded 251 times
Source can be downloaded Here
0.000.3
Changed: Suggested by iPhilip
-ColorHLSToRGB: This is used to get colors that work well against a black background
Last edited by maestrith on 31 May 2020, 06:57, edited 2 times in total.
John H Wilson III 05/29/51 - 03/01/2020. You will be missed.AHK Studio OSDGUI Creator
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32
User avatar
RUNIE
Posts: 292
Joined: 03 May 2014, 14:50
GitHub: Run1e

Re: Tetris Windows 7+

06 Sep 2017, 13:03

Prettiest and most functional version of tetris written in AHK I think there is! Ghost piece is awesome.
User avatar
maestrith
Posts: 817
Joined: 16 Oct 2013, 13:52

Re: Tetris Windows 7+

06 Sep 2017, 13:06

RUNIE wrote:Prettiest and most functional version of tetris written in AHK I think there is! Ghost piece is awesome.
Thanks :)
John H Wilson III 05/29/51 - 03/01/2020. You will be missed.AHK Studio OSDGUI Creator
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32
User avatar
SKAN
Posts: 632
Joined: 29 Sep 2013, 16:58

Re: Tetris Windows 7+

06 Sep 2017, 14:04

Awesome! :bravo:

My score was like 4300 when my game ended and it simply began afresh... I couldn't see my final score.
User avatar
maestrith
Posts: 817
Joined: 16 Oct 2013, 13:52

Re: Tetris Windows 7+

06 Sep 2017, 14:08

SKAN wrote:Awesome! :bravo:

My score was like 4300 when my game ended and it simply began afresh... I couldn't see my final score.
I'll add in a msgbox or something for a score.
John H Wilson III 05/29/51 - 03/01/2020. You will be missed.AHK Studio OSDGUI Creator
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32
User avatar
maestrith
Posts: 817
Joined: 16 Oct 2013, 13:52

Re: Tetris Windows 7+

06 Sep 2017, 14:16

0.000.2
Added: Suggested by SKAN
-Final Score MsgBox
John H Wilson III 05/29/51 - 03/01/2020. You will be missed.AHK Studio OSDGUI Creator
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Tetris Windows 7+

06 Sep 2017, 14:43

This is really good. Yes the ghost piece is very nice (see where the piece is going to end up in advance), as is s to immediately place the piece.

I thought I might mention two nice old Windows games:

[This one is a relatively simple one, enemy planes, and your plane, fly around a 2D map, with blocks placed in many places. You can fire and they can fire.]
Alien Force : Robert Epps : Free Download & Streaming : Internet Archive
https://archive.org/details/win3_alienforce

[More complicated, but great game.]
Kye (video game) - Wikipedia
https://en.wikipedia.org/wiki/Kye_(video_game)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
SpeedMaster
Posts: 389
Joined: 12 Nov 2016, 16:09

Re: Tetris Windows 7+

06 Sep 2017, 14:45

Beautiful. :o
Thanks for sharing ! :bravo:

Suggestion:
Please can you insert this tag [Game] as a prefix in your title ?
this will make the search easier ;)
User avatar
maestrith
Posts: 817
Joined: 16 Oct 2013, 13:52

Re: Tetris Windows 7+

06 Sep 2017, 15:15

SpeedMaster wrote:Beautiful. :o
Thanks for sharing ! :bravo:

Suggestion:
Please can you insert this tag [Game] as a prefix in your title ?
this will make the search easier ;)
:) Thanks and No Problem :)
John H Wilson III 05/29/51 - 03/01/2020. You will be missed.AHK Studio OSDGUI Creator
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32
User avatar
kczx3
Posts: 1107
Joined: 06 Oct 2015, 21:39

Re: [Game] Tetris Windows 7+

10 Sep 2017, 20:18

12,900
Lines: 117
User avatar
maestrith
Posts: 817
Joined: 16 Oct 2013, 13:52

Re: [Game] Tetris Windows 7+

10 Sep 2017, 20:22

kczx3 wrote:12,900
Lines: 117
:thumbup:
John H Wilson III 05/29/51 - 03/01/2020. You will be missed.AHK Studio OSDGUI Creator
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32
joefiesta
Posts: 377
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: [Game] Tetris Windows 7+

27 May 2020, 19:16

interesting. but, many of the pieces are near impossible to see. they are too dark against the black background.
User avatar
maestrith
Posts: 817
Joined: 16 Oct 2013, 13:52

Re: [Game] Tetris Windows 7+

27 May 2020, 19:20

joefiesta wrote:
27 May 2020, 19:16
interesting. but, many of the pieces are near impossible to see. they are too dark against the black background.
Yea, I just did random colors...
John H Wilson III 05/29/51 - 03/01/2020. You will be missed.AHK Studio OSDGUI Creator
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32
iPhilip
Posts: 459
Joined: 02 Oct 2013, 12:21

Re: [Game] Tetris Windows 7+

28 May 2020, 11:49

maestrith wrote:
27 May 2020, 19:20
joefiesta wrote:
27 May 2020, 19:16
interesting. but, many of the pieces are near impossible to see. they are too dark against the black background.
Yea, I just did random colors...
Hi maestrith,

You might want to experiment with this approach to getting colors that work against a black background. I have found it useful in my code:

Code: Select all

ColorARGB := "0xFF" ColorHLSToRGB(i > 240 ? mod(i, 240) : i, 120, 240)  ; i is an integer, e.g. A_Index

; Reference: https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-colorhlstorgb - ColorHLSToRGB function

ColorHLSToRGB(Hue, Luminance, Saturation) {
   BGR := DllCall("shlwapi.dll\ColorHLSToRGB", "UShort", Hue, "UShort", Luminance, "UShort", Saturation, "UInt")
   Return Format("{:06X}", ((BGR & 0xFF) << 16) | (BGR & 0xFF00) | ((BGR >> 16) & 0xFF))
}
Cheers,

- iPhilip
Windows 10 Pro (64 bit) - AutoHotkey v1.1+ (Unicode 32-bit)
joefiesta
Posts: 377
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: [Game] Tetris Windows 7+

30 May 2020, 14:55

@iPhilip - what does your code have to do with Tetris? And, what does it do? The variables you define aren't used in the Tetris script.
iPhilip
Posts: 459
Joined: 02 Oct 2013, 12:21

Re: [Game] Tetris Windows 7+

30 May 2020, 15:19

joefiesta wrote:
30 May 2020, 14:55
@iPhilip - what does your code have to do with Tetris? And, what does it do? The variables you define aren't used in the Tetris script.
Hi @joefiesta,

Thank you for your questions. I imagine you are confused by my message. Actually I was responding to a thread initiated by your comment
joefiesta wrote:
27 May 2020, 19:16
... but, many of the pieces are near impossible to see. they are too dark against the black background.
by offering a way to get colors that are more visible against a black background. I left it to @maestrith to decide whether to integrate the code into the Tetris script. Here is some code you can run to see the effect:

Code: Select all

#NoEnv

Gui, Color, Black
Gui, Add, Progress, x100 y100 w100 h100 cBlue BackgroundBlack vMyProgress, 100
Gui, Show, w300 h300, Colors

Loop
{
   Random, Index, 0, 240
   Color := ColorHLSToRGB(Index, 120, 240)
   ; Random, Color, 222222, 999999  ; Uncomment to see current color scheme in Tetris
   GuiControl, % "+c" Color, MyProgress
   Sleep 1000
}

; Reference: https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-colorhlstorgb - ColorHLSToRGB function

ColorHLSToRGB(Hue, Luminance, Saturation) {
   BGR := DllCall("shlwapi.dll\ColorHLSToRGB", "UShort", Hue, "UShort", Luminance, "UShort", Saturation, "UInt")
   Return Format("{:06X}", ((BGR & 0xFF) << 16) | (BGR & 0xFF00) | ((BGR >> 16) & 0xFF))
}

GuiClose:
GuiEscape:
   ExitApp
Again, it was just a suggestion to help address the problem you identified. If it's not useful, feel free to disregard.

Cheers,

- iPhilip
Windows 10 Pro (64 bit) - AutoHotkey v1.1+ (Unicode 32-bit)
joefiesta
Posts: 377
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: [Game] Tetris Windows 7+

01 Jun 2020, 07:55

@iPhilip - Thanks. I didn't mean to be disrespectful. I thought you meant I could drop your code into Tetris. I'm sure I can figure out what you're doing and can figure out revising tetris on my own even though it is very complicated, what with so many objects and such I know little about. But, considering this forum entry got almost no interest, I suspect nobody even uses the script. So, I doubt the author has much concern at this point. He was probably just working on his game writing skills.
User avatar
maestrith
Posts: 817
Joined: 16 Oct 2013, 13:52

Re: [Game] Tetris Windows 7+

01 Jun 2020, 07:58

joefiesta wrote:
01 Jun 2020, 07:55
@iPhilip - Thanks. I didn't mean to be disrespectful. I thought you meant I could drop your code into Tetris. I'm sure I can figure out what you're doing and can figure out revising tetris on my own even though it is very complicated, what with so many objects and such I know little about. But, considering this forum entry got almost no interest, I suspect nobody even uses the script. So, I doubt the author has much concern at this point. He was probably just working on his game writing skills.
I added it to the main script already.
John H Wilson III 05/29/51 - 03/01/2020. You will be missed.AHK Studio OSDGUI Creator
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32
joefiesta
Posts: 377
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: [Game] Tetris Windows 7+

01 Jun 2020, 08:27

@maestrith - Thanks. A humungous improvement. Rather primary colors, but, they are perfect considering the simplicity of the game.

If I dare say, I would like to suggest some other changes. It's been decades since I played tetris on an ancient nintendo box. I don't remember the ghost square, but I like it, even though it makes playing easier.

1. The ghost piece would be nicer if it were more visible (solidly colored), say a somewhat dark shade of gray.
2. Levels would be nice. As one clears oh I don't know perhaps 25 lines, the speed of the pieces falling could increase a little, and the scoring could increase a little. I vaguing remember, too, that with Tetris as it got more difficult the shapes selected were less random--that is to say duplicate shapes tended to occur in sequence more often (which adds to the difficulty). But, I could be wrong about such a memory.
3. I would like the BLUE line surrounding the playing field to be brighter (more visible).
4. The help instructions on the side are rather difficult to read also. They could be a lighter shade of pink.

But, my compliments on a beautiful piece of coding. I guess it's time I learned about the advanced object (terminology??) techiniques you employ. But, what do you want from a retired mainframe programmer.

thanks again for the color fix.
iPhilip
Posts: 459
Joined: 02 Oct 2013, 12:21

Re: [Game] Tetris Windows 7+

03 Jun 2020, 11:46

joefiesta wrote:
01 Jun 2020, 07:55
@iPhilip - Thanks. I didn't mean to be disrespectful. I thought you meant I could drop your code into Tetris. I'm sure I can figure out what you're doing and can figure out revising tetris on my own even though it is very complicated, what with so many objects and such I know little about. But, considering this forum entry got almost no interest, I suspect nobody even uses the script. So, I doubt the author has much concern at this point. He was probably just working on his game writing skills.
Hi @joefiesta,

Thank you for your note. I appreciate you reaching out to me. I totally empathize with you on the challenge of modifying other people's code. I mean, it's hard enough going back to my own code and figuring out why I did what I did - even with documentation and comments! :lol:

I am glad that @maestrith was able to integrate the function into the game. As you noted above, it's a significant improvement. :) When I played the new game, I noticed that the randomization of the colors was adding a degree of difficulty for me as my mind was trying to associate colors with shapes in order to anticipate the appropriate rotation or move. Who knew that color could add a degree of difficulty to a game! ;)

Cheers,

- iPhilip
Windows 10 Pro (64 bit) - AutoHotkey v1.1+ (Unicode 32-bit)

Return to “Scripts and Functions”

Who is online

Users browsing this forum: hoppfrosch and 20 guests